jayelm jayelm - 1 year ago 152
Python Question

Plotting communities with python igraph

I have a graph

in python-igraph. I can get a
community structure with the following:

community = g.community_multilevel()

gives me a list of the group membership of all the vertices in the graph.

My question is really simple but I haven't found a python-specific answer on SO. How can I plot the graph with visualization of its community structure? Preferably to PDF, so something like

layout = g.layout("kk")
plot(g, "graph.pdf", layout=layout) # Community detection?

Thanks a lot.

Answer Source

You can pass your VertexClustering object directly to the plot function; it will automatically plot the underlying graph instead and select colors automatically for the clusters. The desired layout can be specified in the layout=... keyword argument as usual.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download