# Visualizing a huge weighted graph

Consider a weighted graph 'net':

length = 500000;
vtx[] := Table[i <-> RandomInteger[{0, i - 1}], {i, 1, length}];
w = RandomInteger[{1, 100}, Length[vtx[]]]
net = Graph[vtx[], EdgeWeight -> w, GraphLayout -> {"SpringEmbedding", "EdgeWeighted" -> True}];
Export["net.png", net, "PNG"];


Unfortunately, Mathematica is unable to visualize such a network and save it to a file. Is there any way to do this?

• Mathematica can generate such a graph just fine. What you seem to want is to visualize it. Look up the options of the graph layout method you are using and choose settings which result in the layout algorithms stopping sooner. May 19, 2019 at 8:26
• You'll find tips here: mathematica.stackexchange.com/a/187205/12 May 19, 2019 at 8:27
• Thanks to @Szabolcs. But I really want the graph to keep the edge length corresponding to the weights. If I use the "EdgeWeighted" -> True, Mathematica does not generate such a large network, unfortunately. It is doing well with smaller ones. And this is not a matter of RAM. May 19, 2019 at 19:59
• Thanks. But I still can not generate a graph such as this: drive.google.com/drive/folders/… May 27, 2019 at 7:14
• The first two columns are nodes and the third column is the edge weight (eg 898748 <-> 908885 weight is 28). To load data: w = Import["Weighted_graph.dat"]; w1 = w[[All, {1, 2}]]; w2 = Map[(#[] <-> #[]) &, w1]; weights= w[[All, 3]]; The idea is to generate a graph (to a file eg *.png), keeping the edge length equal to the weight values. May 27, 2019 at 7:23