If you want a single graph, there is a one-liner:
g = max(graphs.nauty_geng("-c 7 9:9"), key=lambda g: abs(g.adjacency_matrix().determinant()))
Along these lines, we can make two passes over the graphs to get all graphs with the maximum determinant:
max_det = max(abs(g.adjacency_matrix().determinant()) for g in graphs.nauty_geng("-c 7 9:9"))
G = filter(lambda g: abs(g.adjacency_matrix().determinant())==max_det, graphs.nauty_geng("-c 7 9:9"))
Finally, if only one pass is preferred, it can be done like this:
G = []
max_det = -oo
for g in graphs.nauty_geng("-c 7 9:9"):
A = abs(g.adjacency_matrix().determinant())
if A > max_det:
max_det = A
G = [g]
elif A == max_det:
G.append(g)
What is your question given the code? Btw, you can specify the graphs size directly in nauty's parameters:
for g in graphs.nauty_geng("-c 7 9:9"):
My question is to find the graph(s) on 7 vertices having 9 edges whose adjacency matrix determinant (absolute) is maximum among all other graphs on 7 vertices having 9 edges.