NetworkX

Previous topic

networkx.convert.to_networkx_graph

Next topic

networkx.convert.relabel_nodes

networkx.convert.convert_node_labels_to_integers

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

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+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 (default) discard old labels if False, create a dict self.node_labels that maps new labels to old labels