hi all - i've noticed some drastic performance changes in the rewire method (and potentially other methods as well) 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)? i've also tried get.edgelist(...) coerced into a data frame then graph.data.frame(...) on that edgelist, but performance again was slower than with the original graph (with its extra disconnected vertices). cheers, and thanks for any insight here, -m
_______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
