I've created a graph using graph-tool library and added string labels to nodes using vertex_properties. However, when I'm reading the graph, getting the labels from the vertices became an issue, since I also want in-degree's and out-degree's of the vertices as well. The code is as follows:
g = gt.load_graph('saved_graph.graphml')
v_labels = g.vp["my_labels"]
for v in g.vertices():
print(v)
print(v.in_degree())
In the above code, v's are printed as integers from 0 to N, where N is the number of total vertices. Basically I'm asking is: if statistics, such as in_degree I'm printing, I get from v in the loop will correspond to the labeled node v_labels[v]. Is this how we're supposed to obtain the string label of each node and associate them with statistics?
I'm new to graph-tool, so I appreciate any pointers or explanations. I failed to find a proper explanation in graph-tool documentation or examples, and anywhere else as well.
As a follow-up question, if the vertex properties and indices are aligned, in case I was to remove some of these vertices, what happens to this ordering?