cugraph.experimental.PropertyGraph.renumber_vertices_by_type#

PropertyGraph.renumber_vertices_by_type(prev_id_column=None)[source]#

Renumber vertex IDs to be contiguous by type.

Parameters:
prev_id_columnstr, optional

Column name to save the vertex ID before renumbering.

Returns:
a DataFrame with the start and stop IDs for each vertex type.
Stop is inclusive.

Examples

>>> import cugraph
>>> import cudf
>>> import cudf
>>> from cugraph.experimental import PropertyGraph
>>> df = cudf.DataFrame(columns=["src", "dst", "some_property"],
...                     data=[(99, 22, "a"),
...                           (98, 34, "b"),
...                           (97, 56, "c"),
...                           (96, 88, "d"),
...                          ])
>>> pG = PropertyGraph()
>>> pG.add_edge_data(df, type_name="etype", vertex_col_names=("src", "dst"))
>>> vert_df1 = cudf.DataFrame({"vert_id": [99, 22, 98, 34],
...                            "v_prop": [1 ,2 ,3, 4]})
>>> pG.add_vertex_data(vert_df1, type_name="vtype1", vertex_col_name="vert_id")
>>> vert_df2 = cudf.DataFrame({"vert_id": [97, 56, 96, 88],
...                            "v_prop": [ 5, 6, 7, 8]})
>>> pG.add_vertex_data(vert_df2, type_name="vtype2", vertex_col_name="vert_id")
>>> pG.renumber_vertices_by_type()
        start  stop
vtype1      0     3
vtype2      4     7