Hi Tamas, sorry for bothering you on this all again. after the steps you explain to me ,I use the graph.strength() to get the number of edges pointed out for each community, But I was wondering is it any way to assign the id of each vertex in the contracted graph exactly the membership number of the community in the original graph. as when we calculate the weighted degree of vertex 1 of the contracted graph, we will actually have the number of edges which pointed out of the community with the the membership number of 1 in the original graph.
thank you in advance, Fatemeh On Thu, Nov 27, 2014 at 1:36 PM, Tamás Nepusz <[email protected]> wrote: > Hi, > > 1. assign an edge weight of 1 to each edge > 2. Use contract.vertices with the membership vector of your community > structure to contract each community to a single vertex. Then simplify the > graph and tell igraph to sum the edge weights when it merges multiple edges > into a single one during simplification. > > 3. The edge weights in the contracted graph will tell you rhe number of > edges between the communities in the original graph. > > T. > > On 25 Nov 2014, at 21:22, Fatemeh a <[email protected]> wrote: > > 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 > > > _______________________________________________ > igraph-help mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/igraph-help > > -- regards F..A
_______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
