Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm not sure if this is a Mathematica problem, math problem or a CS problem, so if this is off-topic please transfer it.

In the package Combinatorica there is a function ListGraphs[n,m] which returns all nonisomorphic undirected graphs with n vertices and m edges. What algorithm does it use? All I can think of is to enumerate all graphs with n vertices and m edges brute-force, and check isomorphism for each graph. But I don't think that's effective. Is there a better algorism for this task? Thanks!

share|improve this question
2  
The Combinatorica package is described in detail in this book: Computational Discrete Mathematics: Combinatorics and Graph Theory with Mathematica . –  Yves Klett Jun 23 at 7:00
    
@YvesKlett Thanks for the recommendation! I checked but it's not in our library, so I might as well wait for an answer –  Alex Su Jun 23 at 7:08

1 Answer 1

up vote 6 down vote accepted

You can find the code for the function in the file Combinatorica.m:

nb = NotebookOpen[ToFileName[{$InstallationDirectory, "AddOns", "Packages", 
            "Combinatorica"}, "Combinatorica.m"]];
NotebookFind[nb, "ListGraphs[n_Integer?Positive, m_Integer]"]

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.