1 | initial version |
Something like this will do the job:
def find(n):
for g in graphs(n, size=n):
if not g.is_connected():
continue
f = g.characteristic_polynomial()
h = f.reverse()
h /= h.leading_coefficient()
if f == h:
g.show()
find(8)
It finds 3 such graphs of size 8.
2 | No.2 Revision |
Something like this will do the job:
def find(n):
find_graphs(n):
for g in graphs(n, size=n):
if not g.is_connected():
continue
graphs.nauty_geng(options=f'-c {n} {n}:{n}'):
f = g.characteristic_polynomial()
h = f.reverse()
h /= h.leading_coefficient()
if f == h:
g.show()
find(8)
find_graphs(8)
It finds 3 such graphs of size 8.