convert_node_labels_to_integers#
- convert_node_labels_to_integers(G, first_label=0, ordering='default', label_attribute=None)[source]#
Returns a copy of the graph G with the nodes relabeled using consecutive integers.
- Parameters:
- Ggraph
A NetworkX graph
- first_labelint, optional (default=0)
An integer specifying the starting offset in numbering nodes. The new integer labels are numbered first_label, âĶ, n-1+first_label.
- orderingstring
â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
- label_attributestring, optional (default=None)
Name of node attribute to store old label. If None no attribute is created.
See also
Notes
Node and edge attribute data are copied to the new (relabeled) graph.
There is no guarantee that the relabeling of nodes to integers will give the same two integers for two (even identical graphs). Use the
orderingargument to try to preserve the order.
Additional backends implement this function
cugraph : GPU-accelerated backend.