麻烦Igraph库

时间:2017-04-26 13:26:23

标签: python-3.x igraph

我正在igraph中使用python 3

g.vs["name"] = ["Alice", "Bob", "Claire", "Dennis", "Esther", "Frank", "George"]

anwser应该是

 g.vs["name"]
 ["Alice", "Bob", "Claire", "Dennis", "Esther", "Frank", "George"]

但我得到的答案是:

g.vs["name"]
[]

怎么了?

1 个答案:

答案 0 :(得分:1)

尽管出现了igraph.Graph.vs,但igraph.VertexSeq不是字典(您的作业可能会有效),但类型为igraph.Graph.vs[some_attribute]。与字典不同,import igraph g = igraph.Graph() g.add_vertices(["Alice", "Bob", "Claire", "Dennis", "Esther", "Frank", "George"]) print g.vs['name'] # ["Alice", "Bob", "Claire", "Dennis", "Esther", "Frank", "George"] 仅允许您获取数据,而不是设置数据。添加具有指定名称的节点。执行以下操作:

foreach(var item in myList.Select(x => x.Key).Distinct())
{
    //Your Logic
}