cases = []
for m in cartesian_product_iterator([[1,2] for _ in range(0,9)]):
G = Graph([[1,2,3,4,5,6], [[2*i+1,2*(j+1)] for i in range(0,3) for j in range(0,3) if m[i*3+j]==2]])
new = True
for H,_ in cases:
if G.is_isomorphic(H):
new = False
break
if new:
cases.append([G, matrix([m[0:3],m[3:6],m[6:]])])
len(cases)
26
for G, m in cases:
if len(G.edges())<=4:
print m
show(G)
print '------------'
[1 1 1] [1 1 1] [1 1 1]
------------ [1 1 1] [1 1 1] [1 1 2]
------------ [1 1 1] [1 1 1] [1 2 2]
------------ [1 1 1] [1 1 1] [2 2 2]
------------ [1 1 1] [1 1 2] [1 2 1]
------------ [1 1 1] [1 1 2] [1 2 2]
------------ [1 1 1] [1 1 2] [2 2 1]
------------ [1 1 1] [1 1 2] [2 2 2]
------------ [1 1 1] [1 2 2] [1 2 2]
------------ [1 1 1] [1 2 2] [2 1 2]
------------ [1 1 2] [1 1 2] [2 2 1]
------------ [1 1 2] [1 2 1] [2 1 1]
------------ [1 1 2] [1 2 1] [2 1 2]
------------
def rc_number(r):
if 1 in r and 2 in r:
return 2
elif 1 in r:
return 1
else:
return 4
def deg2type(r,c):
if r==2 and c==2:
return 'G'
elif r==1 and c==2:
return 'E'
elif r==2 and c==1:
return 'O'
elif r==1 and c==1:
return 'PR'
for _, m in cases:
# print m
# types = matrix
types = [[deg2type(rc_number(m.row(i))/m[i][j], rc_number(m.column(j))/m[i][j]
) for j in range(0,3)] for i in range(0,3)]
consistent = True
for r in types:
if not sorted(r) in [
sorted(['G','G','G']),
sorted(['G','G','O']),
sorted(['G','G','E']),
sorted(['G','G','PR']),
sorted(['PR','PR','E']),
sorted(['O','O','O']),
sorted(['O','O','PR']),
sorted(['O','O','G'])
]:
consistent = False
break
for c in zip(*types):
if not sorted(c) in [
sorted(['G','G','G']),
sorted(['G','G','O']),
sorted(['G','G','E']),
sorted(['G','G','PR']),
sorted(['PR','PR','O']),
sorted(['E','E','E']),
sorted(['E','E','PR']),
sorted(['E','E','G'])
]:
consistent = False
break
if consistent:
for t in types:
print t
print ''
['PR', 'PR', 'E'] ['PR', 'PR', 'E'] ['O', 'O', 'PR'] ['G', 'G', 'E'] ['G', 'G', 'E'] ['O', 'O', 'G'] ['G', 'G', 'PR'] ['G', 'PR', 'G'] ['PR', 'G', 'G'] ['G', 'G', 'G'] ['G', 'G', 'G'] ['G', 'G', 'G']