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

查看:49
本文介绍了使用 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.

我的问题非常简单,但我还没有在 SO 上找到特定于 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 对象直接传递给绘图函数;它将自动绘制底层图形并自动为集群选择颜色.可以像往常一样在 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天全站免登陆