https://hal.archives-ouvertes.fr/hal-02177739
Raw File
Tip revision: b8541bfa2c0f272b08ebd8d19251eb263a8daae4 authored by Software Heritage on 01 January 2009, 00:00:00 UTC
hal: Deposit 318 in collection hal
Tip revision: b8541bf
TestCommunityDetector0.R
###############################################################################
## Tests the sensitivity of community detection algorithms to weights.
##
## @author Vincent Labatut
## @version 3
###############################################################################

### considering the weights in this network should really change the detected communities
network <- graph(edges=c(0,1,1,2,2,3,3,0,3,4,4,5,5,6,6,7,7,4), directed=FALSE)
E(network)$weight <- c(1,1,1,1,10,1,1,1,1)
plot(network, layout=layout.fruchterman.reingold(network))

# algos
#result <- edge.betweenness.community(graph=network, edge.betweenness=FALSE, merges=TRUE, bridges=FALSE, labels=FALSE)
#result <- fastgreedy.community(graph=as.undirected(network,mode="collapse"), merges=TRUE, modularity=TRUE)
result <- walktrap.community(graph=network, steps=2, merges=TRUE, modularity=TRUE, labels=TRUE)
for(i in 1:nrow(result$merge))
	print(community.to.membership(graph=network, merges=result$merges, steps=i, membership=TRUE, csize=FALSE)$membership)

#result <- leading.eigenvector.community(graph=as.undirected(network,mode="collapse"))

#result <- label.propagation.community (graph=network)
#print(result)

#result <- spinglass.community(graph=connectNetwork(network))
#print(result$membership)
back to top