No it won’t; the original IDs are available in the name
vertex attribute:
>>> print(graph_up.vs["name"])
[20, 22, 21, 23, 308, 309, 313, 314, 315, 316]
The vertex IDs in igraph are always in the range [0; num_vertices-1]
; this is due to how the underlying C library behaves. However, the name vertex attribute can be filled with the “real” IDs. Furthermore, if you use only strings in the name
vertex attribute, then you can use these strings to refer to the vertices directly:
# Preprocessing your input array and converting IDs to strings
up_array = [[20, 22], [21, 22], [23, 22], [308, 21, 22], [309, 22], [313, 22], [314, 22], [315, 23, 22], [316, 21, 22]]
up_array = [item for item in up_array if len(item) == 2]
up_array = [(str(u), str(v)) for u, v in up_array]
# Creating the graph
graph_up = ig.Graph.TupleList(up_array, directed=True)
# Getting the degree of the node with `name` == 309
>>> print(graph_up.degree("309"))
1
# Getting all the names of the vertices
>>> print(graph_up.vs["name"])
['20', '22', '21', '23', '309', '313', '314']
# Creating a reverse mapping from names to IDs
>>> id_map = {v: k for k, v in enumerate(graph_up.vs["name"])}
>>> id_map
{'20': 0, '22': 1, '21': 2, '23': 3, '309': 4, '313': 5, '314': 6}