使用python igraph绘制社区 [英] Plotting communities with python igraph

查看:126
本文介绍了使用python igraph绘制社区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在python-igraph中有一个图 g 。我可以获得具有以下内容的 VertexCluster 社区结构:

I have a graph g in python-igraph. I can get a VertexCluster community structure with the following:

community = g.community_multilevel()

community.membership 给我列出了图中所有顶点的组成员身份的列表。

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

我的问题确实很简单,但是我还没有找到关于python的特定答案。如何绘制具有社区结构可视化的图形?最好是PDF格式,例如

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?

非常感谢。

推荐答案

您可以将VertexClustering对象直接传递给plot函数;它将自动绘制基础图形,并自动为群集选择颜色。可以照常在layout = ...关键字参数中指定所需的布局。

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.

这篇关于使用python igraph绘制社区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆