2
votes

I am fetching all the values from my graph into a list called nodes:

nodes = g.V().valueMap(True).toList()

For each node, I would like to get the id but I don't know how. E.g. I have a field called 'name'. To get name of the first vertex I would do something like this:

nodes[0][‘name’]

But I can't get the id of the first node using the same way. I don't know why. Maybe since it is automatically assigned and not a user created field, there is a different way of fetching it?

1

1 Answers

4
votes

You need to import id enum.

from gremlin_python.process.traversal import T

nodes = g.V().valueMap(True).toList()

nodes[0][T.id]