[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[igraph] slow rewire performance after subsetting a graph
From: |
Murat Tasan |
Subject: |
[igraph] slow rewire performance after subsetting a graph |
Date: |
Thu, 20 Dec 2012 22:14:41 -0500 |
hi all - i've noticed some drastic performance changes in the rewire method after i added some clean-up steps prior to rewiring a graph.this was done using the R package (v0.6, with 1-indexing):
G is a random graph where i artificially add a collection of zero-degree vertices, which i'll remove later to demonstrate the speed issue.
> G <- graph.data.frame(data.frame(v1 = sample(100, 100, replace = TRUE), v2 = sample(100, 100, replace = TRUE)), vertices = data.frame(1:200))
> H <- delete.vertices(G, which(degree(G) == 0))
the second line removes any zero-degree vertices from the graph object.
the edges (and any connected vertices) remain the same between G and H.
> G
IGRAPH DN-- 200 100 --
+ attr: name (v/c)
> H
IGRAPH DN-- 86 100 --
+ attr: name (v/c)
now some basic re-wiring.
> system.time(rewire(G, niter = 5e5))
user system elapsed
1.070 0.000 1.078
> system.time(rewire(H, niter = 5e5))
user system elapsed
4.930 0.000 4.929
i'm guessing "H" is kept in memory as a view on a backing "G", leading to the slow-down as boundary checks have to be made and calls forwarded to the underlying object.
for some large (real data) graphs i'm working with, the slow-down is magnified by a lot and becomes a substantial problem.
if my "view" guess is right, is there any way in R to force "H" to be treated as a completely new object (i.e. a clone-like call)?
cheers, and thanks for any insight here,
-m
- [igraph] slow rewire performance after subsetting a graph,
Murat Tasan <=