user3403882
user3403882

Reputation:

How to access name of a specific vertex in graph (python-igraph)

I am writing a code in poython and created a graph using python-igraph. Now I want to access vertices names (or maybe other attributes). I know for index it is like this:

vs[i].index

But I am not sure about the name. When I use the vs[i] itself, it prints the following:

igraph.Vertex(<igraph.Graph object at 0x00000000040946D8>, 2, {'name': '3'})

So, obviously there is name but apparently I don't know how to access it.

Any help will be much appreciated.

Upvotes: 3

Views: 5760

Answers (1)

ahajib
ahajib

Reputation: 13520

It can be accessed like the following:

graph.vs[i]["name"]

It will return the name (or basically the label) of the specific node.

Upvotes: 3

Related Questions