warning message in community detection with cluster_edge_betweenness algorithm

I’m using the cluster_edge_betweenness function to community detection because it fit with my weighted directed multiple net.
I run the code bellow:

com<-cluster_edge_betweenness(net, directed = TRUE, weights =E(net)$weight, edge.betweenness = TRUE, merges = TRUE, bridges = TRUE, modularity = TRUE, membership = TRUE)
But i get the following warning message:
2: In cluster_edge_betweenness(net, directed = TRUE, weights = E(net)$weight, :
At community.c:467 :Modularity calculation with weighted edge betweenness community detection might not make sense – modularity treats edge weights as similarities while edge betwenness treats them as distances.

I don´t understand if I shoud still using this algorithm for directed weighted nets. What should I do in this case?

Any help is appreciated!

This function can be used with weighted networks, but be aware of the interpretation of weights: weights are used as “edge lengths” during betweenness calculation. In other words, a high weight indicates a weak connection. The modularity score returned in the weighted case will not be meaningful because the modularity calculation considers high weights to mean strong connections.

For weighted directed networks, you might consider Infomap.

1 Like

Like you suggest, I´m using the cluster_infomap now for detecting communities.
I´m asking here wich one is the default value for “nb.trials” ?


According to the documentation, it is 10.

1 Like

Then, continuing with my doubts of infomap…
For my weighted directed and multiple network I run the code:
imc ← cluster_infomap(net.peso.enlace, e.weights =E(net.peso.enlace)$weight,
v.weights = NULL, nb.trials = 10, modularity = F)

but any time that i run the same code (without modifying anything), gives diferent results, so one time infomap detect 3 communities, other time 7 communities, other 4 communities…
What´s is wrong?

The algorithm uses random numbers, thus different runs may give different outputs. Getting wildly different outputs may indicate that the community structure is not very clearly defined. Try to see which nodes are always grouped into the same communities.

Set a random seed before running the function to get deterministic output.

mmm I imagined that it could be something like that…

how can i do this?

Using R’s standard facilities.

Personally I don’t use R, so I also had to look up that it is set.seed.

1 Like

Question about your problem from 2+ years ago: were you successful in setting a seed value for Infomap and get reproducible clusterings? It does not work for me. Thanks.