import sys
from sage.all import *
G = Graph([('a', 'b'),('b', 'c'), ('b', 'd')]);
H = Graph([(1, 2), (2, 3) ]);
print("\n\n Graph G \n")
G.show()
print("\n\n Graph H \n\n")
H.show()
Pg = Set (G.vertices() + G.edges(labels=False));
Ph = Set (H.vertices() + H.edges(labels=False));
X = FiniteSetMaps(Pg, Ph);
Z = Set(X)
HomS = Set([]);
for f in Z:
s = True
for j in G.vertices():
if f(j)in H.vertices():
s=s and True
else:
s=s and False
for i in G.edges(labels=False):
u=i[0];
v=i[1];
if f(u)==f(v) and f(u)==f(i):
s=s and True
elif f(i)in H.edges(labels=False):
z=f(i);
if (z[0]==f(u) and z[1]==f(v)) or (z[1]==f(u) and z[0]==f(v)):
s=s and True
else:
s=s and False
else: s=s and False
if s==True:
HomS = HomS + Set([f])
print("\n\n Hom(G, H) \n\n")
for j in HomS:
print j
HomSt = Set([])
for g in HomS:
s = True
for v in G.edges(labels=false):
if g(v) in H.vertices():
s = False
if s == True:
HomSt = HomSt + Set([g])
print("\n\n HomSt(G, H) \n\n")
for j in HomSt:
print j