I'm trying to enumerate the labeled graphs on $n$ vertices having at most $e$ edges. I thought GraphData /@ GraphData[n] and then filtering by edge count would do the trick (albeit slowlt) but this seems to only return some named graphs and it also only has one graph per isomorphism class, which is not what I want.

  • 1
    $\begingroup$ You can compute the max edge number mmax = Binomial[n,2] for n vertices, and select all m-element subsets of Range[mmax]. Then create arrays where these positions are set to 1, the rest to 0. Finally use the values in the arrays to fill the upper triangular part of an adjacency matrix. TakeList will be helpful for partitioning the array, PadLeft for turning it into a matrix. Finally, symmetrix the matrix and convert to a graph with AdjacencyGraph. I'm sorry, I don't have time to write ready to use code for this. $\endgroup$
    – Szabolcs
    Feb 28, 2022 at 20:16


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.