[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Speed comparison of R and C
From: |
Gábor Csárdi |
Subject: |
Re: [igraph] Speed comparison of R and C |
Date: |
Sat, 12 Feb 2011 10:16:09 +0100 |
On Sat, Feb 12, 2011 at 4:03 AM, cheng-chun Tu <address@hidden> wrote:
> 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.
Objects are only copied when you modify them. In neighbors() the graph
is not modified, so there is no copying. In set.vertex.attribute() the
graph is modified and will be copied.
Gabor
> Regards,
> William
> Stony Brook University
>
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
--
Gabor Csardi <address@hidden> UNIL DGM
- Re: [igraph] Speed comparison of R and C, (continued)
- Re: [igraph] Speed comparison of R and C, Tamas Nepusz, 2011/02/08
- Re: [igraph] Speed comparison of R and C, William Tu, 2011/02/08
- Re: [igraph] Speed comparison of R and C, William Tu, 2011/02/08
- Re: [igraph] Speed comparison of R and C, Tamás Nepusz, 2011/02/08
- Re: [igraph] Speed comparison of R and C, Gábor Csárdi, 2011/02/08
- RE: [igraph] Speed comparison of R and C, jeremy.raw, 2011/02/09
- [igraph] Bipartitle community detection, Liang Wang, 2011/02/09
- Re: [igraph] Bipartitle community detection, Tamás Nepusz, 2011/02/10
RE: [igraph] Speed comparison of R and C, cheng-chun Tu, 2011/02/11
- Re: [igraph] Speed comparison of R and C,
Gábor Csárdi <=