[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] elementary community_fastgreedy()

From: Tamas Nepusz
Subject: Re: [igraph] elementary community_fastgreedy()
Date: Thu, 07 Jul 2011 10:37:15 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110516 Lightning/1.0b2 Thunderbird/3.1.10

> simply plot(cl)
> and gives the error
> Traceback (most recent call last):
>   File "<pyshell#27>", line 1, in <module>
>     plot(cl)
>   File "C:\Python26\lib\site-packages\igraph\drawing.py", line 762, in plot
>     result = Plot(target, bbox)
>   File "C:\Python26\lib\site-packages\igraph\drawing.py", line 222, in 
> __init__
>     self._surface_was_created=not isinstance(target, cairo.Surface)
>   File "C:\Python26\lib\site-packages\igraph\drawing.py", line 51, in
> __getattr__
>     raise TypeError, "plotting not available"
> TypeError: plotting not available
You need the Cairo library and its Python bindings in order to be able to
use plotting in igraph. More details are to be found here:


> also i want to ask how can i learn which node belong to which cluster and
> cluster count  from dentogram object ? 
The dendrogram does not assign vertices into disjoint clusters; it is a
hierarchical decomposition. You have to "cut" the dendrogram at a given
level in order to obtain clusters. If you run community_fastgreedy(), you
obtain a dendrogram which is cut at the level which maximizes the modularity
by default, so you can use its "membership" property to obtain a list that
maps vertex IDs to cluster IDs:

>>> g = Graph.Famous("zachary")
>>> cl = g.community_fastgreedy()
>>> cl.membership

If you want to plot the graph and color the vertices by their cluster
indices, you can use something like this (works for up to 5 clusters):

colors = ["red", "green", "blue", "yellow", "magenta"]
plot(g, vertex_color=[colors[i] for i in cl.membership])


reply via email to

[Prev in Thread] Current Thread [Next in Thread]