[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [igraph] Speed comparison of R and C

From: cheng-chun Tu
Subject: RE: [igraph] Speed comparison of R and C
Date: Fri, 11 Feb 2011 22:03:41 -0500

Hi Jeremy, 

Thanks a lot for your advice and the sample code! So basically you suggest that 
to have better performance, we should manipulate the attributes as a vector 
rather than graph object. And, this needs a index to identify the edge 
corresponding to the location at the vector. 

After carefully examining my R code, I did the following:
1. Avoid copying when functions are called: For every function call, carefully 
check the possible size of every parameter when graph becomes large. If there 
is any, make the parameter global variable. (R seems not support call by 
reference or macro?)
2. For every part of code accessing edge/node attributes, maintain an index and 
access then as vectors.

However, I found in some cases I could not avoid copying. For example the 
build-in functions. For example my algorithm has recursively called 
"neighbors(graph, id)". The graph will be copied so many times and affects the 
performance. I search the r-mailing list trying to find call by reference or 
macro definition but it seems there is no easy solutions.

Stony Brook University

reply via email to

[Prev in Thread] Current Thread [Next in Thread]