[R] Performance of graph and igraph package

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat Feb 5 18:32:47 CET 2011



On 05.02.2011 06:21, William Tu wrote:
> Dear R users,
>
> I'm using graph library to create a mesh-like network topology and
> implement a load balance routing algorithm. The current implementation
> uses graph, RBGL, and Rgraphviz libraries. I have a few attributes on
> every edge to represent the network loading and capacity, and I
> frequently update these values. However, I found it works so slow and
> right now I'm consider rewriting it using C or Python.
>
> Then I found another library, which is "igraph". I made a performance
> comparison between "graph" and "igraph" as below. For both graph, I
> create two attributes for each edge and set/get the value of all edges
> and measure the total elapsed time.
> A. using graph package:
> 108 nodes, 832 edges: 17 sec
> 140 nodes, 4800 edges: 576 sec
>
> B. using igraph package:
> 100 nodes, 4950 edges: 4 sec
> 200 nodes, 19900 edges: 111 sec
>
> igraph is much much faster than graph! Is this reasonable? or I did
> something wrong?

Calculating graphs efficiently is not a trivial task and you can 
optimize for different szenarios. Unless you doubt about the accuracy of 
results, I would not be worried about a factor of 5 in different 
implementations.

Uwe Ligges



> ps. I'm using 2 core 3GHz CPU with 2G ram.
>
> Thanks in advance,
> William
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list