I am attempting to generate all non-isomorphic directed graphs with 6 vertices using command ListGraphs[6, Directed].But it does not work efficiently and takes a month producing nothing.

Can anyone suggest an alternative way to accomplish this goal?

Thank you in advance.

  • 1
    $\begingroup$ Did you actually wait for this for a full month? You know that you can download lists of these? Even GraphData has them up to size 7. If you want to generate them, then first create all symmetric adjacency matrices. You can use Range[2^15] and IntegerDigits in base-2 to get the 0s and 1s then fill them into a symmetric matrix (this requires some more complex code). Finally, use DeleteDuplicatesBy[..., CanonicalGraph] to filter isomorhic duplicates. $\endgroup$
    – Szabolcs
    Commented Apr 3, 2017 at 5:24
  • $\begingroup$ Sorry, I missed the fact that they are directed. That means that GraphData doesn't have it, but you can still find graph tables online. The method above with CanonicalGraph will likely be too slow too. $\endgroup$
    – Szabolcs
    Commented Apr 3, 2017 at 5:36
  • $\begingroup$ Thank you very much for your suggestions. Can you please point out a specific link via which I can find graph tables? I did some search online but couldn't find one. $\endgroup$
    – Mike
    Commented Apr 3, 2017 at 5:59
  • $\begingroup$ You are right, this seems to be quite elusive. I'll search some more later. Until then I recommend you start looking here: hog.grinvin.org/MetaDirectory.action It is easy to find such lists for undirected graphs, and also software (see geng included with nauty), but not for directed graphs. $\endgroup$
    – Szabolcs
    Commented Apr 3, 2017 at 8:58
  • $\begingroup$ Or perhaps you can ask on math.stackexchange.com or even mathoverflow of such a list (of software to generate it) exists. If you do, please ping me as I am interested in the response too. $\endgroup$
    – Szabolcs
    Commented Apr 3, 2017 at 9:04

1 Answer 1


I recommend you use "gtools" from the nauty suite, specifically geng and directg. IGraph/M makes it possible (and easy) to import graphs generated by these tools.

Please see https://mathematica.stackexchange.com/a/214436/12

Do note that there are 1,540,944 directed graphs on 6 vertices. Importing them will take a while. On my machine, it took 137 seconds, which is much better than a month.

IGImport["!geng 6 | directg", "Nauty"] // Length // AbsoluteTiming
(* {136.801, 1540944} *)

Of these 137 seconds, only about 2.5 was spent in generating the graphs by gtools. The rest of the time was spent in importing them to Mathematica.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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