NetworkX

Previous topic

relabel_nodes

Next topic

relabel_nodes

convert_node_labels_to_integers

convert_node_labels_to_integers(G, first_label=0, ordering='default', discard_old_labels=True)[source]

Return a copy of G node labels replaced with integers.

Parameters :

G : graph

A NetworkX graph

first_label : int, optional (default=0)

An integer specifying the offset in numbering nodes. The n new integer labels are numbered first_label, ..., n-1+first_label.

ordering : string

“default” : inherit node ordering from G.nodes() “sorted” : inherit node ordering from sorted(G.nodes()) “increasing degree” : nodes are sorted by increasing degree “decreasing degree” : nodes are sorted by decreasing degree

discard_old_labels : bool, optional (default=True)

If True discard old labels. If False, create a node attribute ‘old_label’ to hold the old labels.