尝试仅显示图形的巨型群集。在对整个图形进行子图形化之后,标签会发生变化。使用python 3,igraph,jupyter笔记本。在下面的代码中,我们将不胜感激-全面研究了答案,但似乎没有人遇到这个问题。
g = Graph(directed=directed) # create graph
g.add_vertices(numNodes[currentIndex]+1) # add vertices
g.add_edges(edgeList)
g.vs['label']=range(0,numNodes[currentIndex]+1)
g.vs['name']=range(0,numNodes[currentIndex]+1)
for node in g.vs(): print(node)
plot(g)
输出:
edgeList: [(1, 6), (3, 13), (4, 5), (5, 6), (6, 5), (7, 5), (8, 5), (9, 17), (11, 12), (12, 11), (13, 3), (14, 5), (15, 5), (16, 11), (17, 11)]
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 0, {'label': 0, 'name': 0})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 1, {'label': 1, 'name': 1})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 2, {'label': 2, 'name': 2})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 3, {'label': 3, 'name': 3})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 4, {'label': 4, 'name': 4})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 5, {'label': 5, 'name': 5})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 6, {'label': 6, 'name': 6})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 7, {'label': 7, 'name': 7})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 8, {'label': 8, 'name': 8})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 9, {'label': 9, 'name': 9})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 10, {'label': 10, 'name': 10})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 11, {'label': 11, 'name': 11})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 12, {'label': 12, 'name': 12})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 13, {'label': 13, 'name': 13})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 14, {'label': 14, 'name': 14})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 15, {'label': 15, 'name': 15})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 16, {'label': 16, 'name': 16})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 17, {'label': 17, 'name': 17})
igraph.Vertex(<igraph.Graph object at 0x7f238f637408>, 18, {'label': 18, 'name': 18}
链接到图表-SO的新功能,所以我还不能嵌入img
clusters = g.clusters(mode="WEAK")
giant = clusters.giant()
for node in giant.vs(): print(node)
plot(giant)
输出:
igraph.Vertex(<igraph.Graph object at 0x7f238f6375e8>, 0, {'label': 1, 'name': 1})
igraph.Vertex(<igraph.Graph object at 0x7f238f6375e8>, 1, {'label': 4, 'name': 4})
igraph.Vertex(<igraph.Graph object at 0x7f238f6375e8>, 2, {'label': 5, 'name': 5})
igraph.Vertex(<igraph.Graph object at 0x7f238f6375e8>, 3, {'label': 6, 'name': 6})
igraph.Vertex(<igraph.Graph object at 0x7f238f6375e8>, 4, {'label': 7, 'name': 7})
igraph.Vertex(<igraph.Graph object at 0x7f238f6375e8>, 5, {'label': 8, 'name': 8})
igraph.Vertex(<igraph.Graph object at 0x7f238f6375e8>, 6, {'label': 14, 'name': 14})
igraph.Vertex(<igraph.Graph object at 0x7f238f6375e8>, 7, {'label': 15, 'name': 15})
巨型群集图像输出
注释:请注意标签在图中的变化方式,但是当我打印每个节点时却没有变化?这到底是怎么回事?任何帮助将不胜感激。