I need to access the eigenvector centrality values for all the vertices in a graph. I am using graph-tool to do that.
I tried to calculate it just like closeness centrality but since in graph tool closeness returns just the Vertex Property map whereas eigenvector returns both the largest eigenvalue of the (weighted) adjacency matrix and the vertex property map, it's not working the same way.
node_closeness = []
for vertex in G.vertices():
a = closeness(G)[vertex]
node_closeness.append(a)
This code worked for closeness but same for eigenvector:
node_eigenvector = []
for vertex in G.vertices():
a = eigenvector(G)[vertex]
node_eigenvector.append(a)
does not work.
So, it gives me this error:
a = eigenvector(G)[vertex]
TypeError: tuple indices must be integers, not Vertex
But I think it is because eigenvector returns eigenvalue and Vertex property map both. Does anyone know how to fix this?