Hi,

I would appreciate if some one could help me to speed up this piece of code
 :

what I am trying to do is to calculate the number of edges on the boundary
of community S but it is really slow.

numberofedge<-function(graph,community)
{
cs <- data.frame(combn(unique(membership(community)),2)) #----considering a
combination of communities two by two
cx <- sapply(cs, function(x) {   #calculating edges in between two
communities
    es<-E(graph)[V(graph)[membership(community)==x[1]] %--%
              V(graph)[membership(community)==x[2]]]
    length(es)})
y=cbind(t(cs),cx)
i=1
CS=array( data=0,dim = length(unique(membership(community))))
while (i<length(y[,1])+1){    # calculating the edges on the boundary for
each community
 CS[y[i,1]]=CS[y[i,1]]+y[i,3]
  CS[y[i,2]]=CS[y[i,2]]+y[i,3]
  i=i+1
}


-- 
regards
F..A
_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to