Ask Your Question

Revision history [back]

Generate the list of all graph isomorphism classes of a given size n

I am hoping to generate a list of all graph isomorphism classes of a given size. The current code that I have first generate all the graphs on 2n, and then take all the isomorphism class representatives of size n. But the first step of generating all graphs on 2n vertices can take a really long time and huge amount of memory (run 10 days on my university's research computing cloud) and crashes.

See the following for my code:

def iso_graphs(n):
    '''returns all isomorphism classes of simple graphs on n edges on 2*n vertices'''
    L = list(graphs(2 * n, loops=False, size=n))
    print("Do we ever reach this point?")
    L = [G.canonical_label().copy(immutable=True) for G in L if G.size() == n]
    return L

I wonder if what is a correct and efficient way of doing it.

Thanks!