Reputation: 385
I'm trying to use igraph
in python 3
:
g.vs["name"] = ["Alice", "Bob", "Claire", "Dennis", "Esther", "Frank", "George"]
the anwser should be
g.vs["name"]
["Alice", "Bob", "Claire", "Dennis", "Esther", "Frank", "George"]
but the answer I've got is :
g.vs["name"]
[]
Whats wrong?
Upvotes: 1
Views: 43
Reputation: 13041
Despite appearances, igraph.Graph.vs
is not a dictionary (where your assignment would be expected to work) but of type igraph.VertexSeq
. Unlike a dictionary, igraph.Graph.vs[some_attribute]
only allows you to get the data, not to set the data. To add nodes with the indicated names. do the following:
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"]
Upvotes: 1