Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 igraph 的新手。我尝试了这个简单的代码,但它没有显示节点内的顶点 ID。
from igraph import * g = Graph() g.add_vertices(3) g.add_edges([(0,1), (1,2)]) plot(g, layout = g.layout("kk"))
谁能告诉我为什么不显示ID?
因为默认情况下 ID 不显示为标签;)如果要显示它们,您必须将label每个节点的属性设置为其标签或指定vertex_label=...为关键字参数plot:
label
vertex_label=...
plot
g.vs["label"] = range(g.vcount())
或者
plot(g, layout="kk", vertex_label=range(g.vcount())