[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] plotting large graph
From: |
Tamás Nepusz |
Subject: |
Re: [igraph] plotting large graph |
Date: |
Wed, 22 Jan 2014 16:20:03 +0100 |
> thanks,
> the question should be plotting graph of thousand or hundred thousands of
> nodes
The short answer is probably: don’t. Chances are that you end up with an
untangible mess of nodes and edges drawn on top of each other, no matter how
hard you try. Suppose that you have, say, 30.000 nodes, and you want to draw
the network on a screen consisting of 1600x1200 pixels. That means that you
have 64 pixels for each node, assuming that you fill the screen entirely, and
you haven’t even drawn the edges or the labels of the nodes.
The long answer is: you need two things, 1) to calculate a layout that tells
igraph where to put each node on the screen and 2) to actually draw the graph.
Step 1 is probably easier but you basically have only one option for graphs of
this size; use the DrL layout algorithm that is built into igraph, cross your
fingers and hope that it comes up with something useful. (You may need to tweak
its parameters, and you may have to experiment a lot). Step 2 should be simply
a matter of passing the graph and the layout to the plot() function, but
chances are that none of the native drawing backends are able to cope with the
amount of graphics you have to draw on the screen. I managed to plot a graph
with ~75K nodes once using igraph, and I used the DrL layout for that, but I
had to implement the actual drawing “manually” instead of relying on the
built-in plot functions because the built-in functions spend a lot of time
doing things that I did not need and that only slowed things down (e.g.,
collecting relevant vertex and edge attributes that define the visual
appearance of the nodes, drawing labels, arrowheads, calculating edge
curvatures etc). Even with a custom drawing routine, drawing that graph at a
reasonable size (20.000 x 15.000 pixels) took quite a few minutes.
> and determine node color depending on weight?
If you use the default plotting backend, it should only be a matter of
assigning values to the “color” vertex attribute based on the weights before
plotting.
T.