Shared.get_node_id

Shared.get_node_id(nodes, vectorize: bool = False)[source]

Map labels in nodes to node indices.

Parameters
nodesstr or array_like

Node labels to map to node indices.

vectorizebool, default=False

Whether to vectorize over nodes (must be ndarray). Better performance for larger arrays.

Returns
int, list or ndarray

Node indices.

int : If nodes is str.

ndarray : If nodes is ndarray and vectorize is True.

list of int : else.