I recently installed Mathematica 12.2. I'm now getting this output when I want to generate a directed graph that has 2817 nodes and 30,670 edges. I used to generate the graph of these nodes without a problem but now I'm getting the output below and not a picture of the network.

g = Graph[edges, VertexLabels -> "Name", VertexLabels -> Automatic]

This is my output enter image description here

  • 1
    $\begingroup$ Some experimentation suggests that a plot will not be generated automatically by Graph if you have 10,000 or more vertices or edges. You could use GraphPlot@Graph[...] to force plotting. $\endgroup$ – MarcoB Jan 24 at 19:37
  • 1
    $\begingroup$ Play with larger values for the sub-options "EdgeCountThreshold" and "VertexCountThreshold" of the system option "GraphOptions" using SetSystemOptions? (See the defaults using SystemOptions["GraphOptions"]) $\endgroup$ – kglr Jan 24 at 21:15
  • $\begingroup$ SystemOptions["GraphOptions"] Out[4]= {GraphOptions->{CacheResults->True,EdgeCountThreshold->10000,RenderingOrder->VertexFirst,VertexCountThreshold->1000}} $\endgroup$ – PRG Jan 24 at 21:24
  • $\begingroup$ Looks like 10,000 edges and 1,000 vertexes are the threshold defaults. MacroB's forced plotting works well. $\endgroup$ – PRG Jan 24 at 21:25

Default values for the edge count and vertex count thresholds are 10000 and 1000, respectively:

 {"GraphOptions" -> {"CacheResults" -> True, 
  "EdgeCountThreshold" -> 10000, "RenderingOrder" -> "VertexFirst", 
  "VertexCountThreshold" -> 1000}} 

With default settings a graph with, say, 1100 vertices and 11000 edges is not rendered:

RandomGraph[{1100, 11000}]

enter image description here

Increasing these thresholds gives the desired result:

SetSystemOptions["GraphOptions" -> {"EdgeCountThreshold" -> 20000,     
    "VertexCountThreshold" -> 2000}];

RandomGraph[{1100, 11000}] 

enter image description here

  • $\begingroup$ If getting a Graphics object (as opposed to a Graph object) as output is acceptable, you can also use the workaround suggested by MarcoB in comments (wrap Graph with GraphPlot) without having to change system option settings. $\endgroup$ – kglr Jan 24 at 21:41
  • $\begingroup$ Many thanks to you both MarcoB and kglr for sharing your wisdom ... much appreciated and very helpful!! ... prg $\endgroup$ – PRG Jan 24 at 21:46

Your Answer

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

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