Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何访问图形中特定顶点的名称(python igraph)_Python_Igraph_Vertex - Fatal编程技术网

如何访问图形中特定顶点的名称(python igraph)

如何访问图形中特定顶点的名称(python igraph),python,igraph,vertex,Python,Igraph,Vertex,我正在用poython编写代码,并使用PythonIGraph创建了一个图形。现在我想访问顶点名称(或者其他属性)。我知道索引是这样的: vs[i].index 但是我不确定这个名字。当我使用vs[I]本身时,它会打印以下内容: igraph.Vertex(<igraph.Graph object at 0x00000000040946D8>, 2, {'name': '3'}) graph.vs[i]["name"] igraph.Vertex(,2,{'name':'3'}

我正在用poython编写代码,并使用PythonIGraph创建了一个图形。现在我想访问顶点名称(或者其他属性)。我知道索引是这样的:

vs[i].index
但是我不确定这个名字。当我使用vs[I]本身时,它会打印以下内容:

igraph.Vertex(<igraph.Graph object at 0x00000000040946D8>, 2, {'name': '3'})
graph.vs[i]["name"]
igraph.Vertex(,2,{'name':'3'})
所以,显然有名字,但显然我不知道如何访问它


任何帮助都将不胜感激。

可以通过以下方式访问:

igraph.Vertex(<igraph.Graph object at 0x00000000040946D8>, 2, {'name': '3'})
graph.vs[i]["name"]

它将返回特定节点的名称(或基本上是标签)。

graph.vs[i][“name”]
是一种替代形式,对于大型图可能更有效-
graph.vs[“name”][i]
首先检索所有顶点的名称,然后提取第i个元素,而
graph.vs[i][“name”]
只是“跳跃”到第i个顶点,然后提取名称。@Tamá知道如何根据顶点名称访问它吗?我的意思是我有一个顶点的名称,我想知道它在邻接矩阵中的索引是什么:)@ahajib通过名称->graph.vs['name'].index('3')查找索引