igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Performance issue regarding when calculating induced_subgra


From: Tamas Nepusz
Subject: Re: [igraph] Performance issue regarding when calculating induced_subgraph and authority_score within a loop
Date: Mon, 25 Apr 2016 12:32:10 +0200

Hi,

I'm suspecting that rbind() is the bottleneck in your for loop because
it always  creates a copy your existing matrix when adding a new row
to it; use lapply() instead:

auth_scr <- lapply(clust, function(x) {
authority_score(induced_subgraph(g, x))$vector })

T.


On Sat, Apr 23, 2016 at 10:55 AM, Roland Sztaho <address@hidden> wrote:
> Hello Guys,
>
> I would like to prepare some stats based on clusters made by
> cluster_label_prop() method. When I use authority_score() and
> induced_subgraph() within a loop, it shows weak performance and I am looking
> for a workaround to speed up the code. My network contains approx. 3.000.000
> edges and 250.000 clusters. I think calculation of these measure for the
> clusters without the loop could be a good point, however I didn't find a way
> in the docs for this.
>
> R version 3.2.5 (2016 04 14)
> igraph package version 1.0.1
> OS: windows 7 64bit
>
> Here is what I have so far:
>
> library("igraph")
> library("plyr")
> setwd("C:/Projects/R/igraph")
>
> g_in = read.csv("my_network.csv", sep=" ")
> g = graph.data.frame(g_in, directed=FALSE)
>
> clust = groups(cluster_label_prop(g, weights=E(g)$weight))
> clust_count <- length(clust)
> clustm <- as.matrix(ldply((clust), data.matrix))
> clustm1 <- clustm[clustm[, ".id"] == 1, 2]
>
> g_sub = induced_subgraph(g, clustm1)
> auth_scr = as.matrix(authority_score(g_sub)$vector)
> for (i in 2:clust_count) {
> g_sub = induced_subgraph(g, clustm[clustm[, ".id"] == i, 2])
> auth_scr = rbind(as.matrix(auth_scr),
> as.matrix(authority_score(g_sub)$vector))
> }
>
> Any suggestions would be great!
>
> Thanks,
> Roland
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>



reply via email to

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