Hi,

> I just started out with iGraph in the python interface, I have trouble 
> printing out the membership of the community_walktrap.
The walktrap method does not give you a membership vector, it gives you a 
dendrogram instead (since it is a hierarchical clustering method). You must 
"cut" the dendrogram somewhere in order to obtain a membership vector. The 
easiest way to do this is to cut the dendrogram at the point where the 
modularity is maximal, and luckily the VertexDendrogram class has a method for 
that:

dendrogram = g.community_walktrap()
cl = dendrogram.as_clustering()
print cl.membership

(Note that "membership" is a property and not a method, so you don't need () at 
the end).

> After this I want to add this membership as an attribute to the respective 
> vertex, like this:
> g.vs["community"] = 0 (but this of course for each vertex).
That's easy: g.vs["community"] = cl.membership

Best,
Tamas


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

Reply via email to