Niklas Braun
Niklas Braun

Reputation: 413

Find overlapping modularity in two graphs - iGraph in Python

I have two related graphs created in iGraph, A and G. I find community in structure in G using either infomap or label_propagation methods (because they are two that allow for weighted, directional links). From this, I can see the modularity of this community for the G graph. However, I need to see what modularity this will provide for the A graph. How can I do this?

Upvotes: 0

Views: 437

Answers (2)

Niklas Braun
Niklas Braun

Reputation: 413

So I figured it out. What you need to do is find a community structure, either pre-defined or using one of the methods provided for community detection, such as infomap or label_propagation. This gives you a vertex clustering, which you can use to place on another graph and from that use .q to find the modularity.

Upvotes: -1

Vincent Labatut
Vincent Labatut

Reputation: 1808

Did you try using the modularity function?

im <- infomap.community(graph=G)
qG <- modularity(im)
memb <- membership(im)
qA <- modularity(x=A, membership=memb, weights=E(A)$weight)
cat("qG=",qG," vs. qA=",qA,"\n",sep="")

Note: tested with igraph v0.7, I don't have a more recent version right now. The parameter/function names might slightly differ.

Upvotes: 2

Related Questions