docstr: Given an input dataframe with its column names, this function returns the
  renumbered dataframe(if renumbering occured) along with a mapping from internal
  to external vertex IDs. the parameter 'preserve_order' ensures that the order
  of the edges is preserved during renumbering.
docstr_tok: ["Given","an","input","dataframe","with","its","column","names",",","this","function","returns","the","renumbered","dataframe","(","if","renumbering","occured",")","along","with","a","mapping","from","internal","to","external","vertex","IDs",".","the","parameter","'preserve_order","'","ensures","that","the","order","of","the","edges","is","preserved","during","renumbering","."]
code: def renumber_and_segment(
      df,
      src_col_names,
      dst_col_names,
      preserve_order=False,
      store_transposed=False,
      legacy_renum_only=False,
  ):
      """
      Given an input dataframe with its column names, this function returns the
      renumbered dataframe(if renumbering occured) along with a mapping from internal
      to external vertex IDs. the parameter 'preserve_order' ensures that the order
      of the edges is preserved during renumbering.
      """
      if legacy_renum_only:
          warning_msg = "The parameter 'legacy_renum_only' is deprecated and will be removed."
          warnings.warn(warning_msg, DeprecationWarning)
  
      renumbered = False
  
      # For columns with mismatch dtypes, set the renumbered
      # id_type to either 'int32' or 'int64'
      if isinstance(src_col_names, list):
          vertex_col_names = src_col_names.copy()
      else:
          vertex_col_names = [src_col_names]
      if isinstance(dst_col_names, list):
          vertex_col_names += dst_col_names
      else:
          vertex_col_names += [dst_col_names]
      if df[vertex_col_names].dtypes.nunique() > 1:
          # can't determine the edgelist input type
          unrenumbered_id_type = None
      else:
          unrenumbered_id_type = df.dtypes[0]
  
      if np.int64 in list(df.dtypes):
          renumber_id_type = np.int64
      else:
          # renumber the edgelist to 'int32'
          renumber_id_type = np.int32
  
      # Renumbering occurs only if:
      # 1) The column names are lists (multi-column vertices)
      if isinstance(src_col_names, list):
          renumbered = True
      # 2) There are non-integer vertices
      elif not (
          df[src_col_names].dtype == np.int32
          or df[src_col_names].dtype == np.int64
      ):
          renumbered = True
  
      renumber_map = NumberMap(
          renumber_id_type, unrenumbered_id_type, renumbered
      )
      renumber_map.input_src_col_names = src_col_names
      renumber_map.input_dst_col_names = dst_col_names
      if not isinstance(renumber_map.input_src_col_names, list):
          src_col_names = [src_col_names]
          dst_col_names = [dst_col_names]
  
      # Assign the new src and dst column names to be used in the renumbered
      # dataframe to return (renumbered_src_col_name and
      # renumbered_dst_col_name)
      renumber_map.set_renumbered_col_names(
          src_col_names, dst_col_names, df.columns
      )
  
      # FIXME: Remove 'src_col_names' and 'dst_col_names' from this initialization as
      # those will capture 'simpleGraph.srcCol' and 'simpleGraph.dstCol'.
      # In fact the input src and dst col names are already captured in
      # 'renumber_map.input_src_col_names' and 'renumber_map.input_dst_col_names'.
      if isinstance(df, cudf.DataFrame):
          renumber_map.implementation = NumberMap.SingleGPU(
              df,
              src_col_names,
              dst_col_names,
              renumber_map.renumber_id_type,
              store_transposed,
          )
      elif isinstance(df, dask_cudf.DataFrame):
          renumber_map.implementation = NumberMap.MultiGPU(
              df,
              src_col_names,
              dst_col_names,
              renumber_map.renumber_id_type,
              store_transposed,
          )
      else:
          raise TypeError(
              "df must be cudf.DataFrame or dask_cudf.DataFrame"
          )
  
      if renumbered:
          renumber_map.implementation.indirection_map(
              df, src_col_names, dst_col_names
          )
          if isinstance(df, dask_cudf.DataFrame):
              renumber_map.df_internal_to_external = (
                  renumber_map.implementation.ddf
              )
          else:
              renumber_map.df_internal_to_external = (
                  renumber_map.implementation.df
              )
  
          df = renumber_map.add_internal_vertex_id(
              df,
              renumber_map.renumbered_src_col_name,
              src_col_names,
              drop=True,
              preserve_order=preserve_order,
          )
          df = renumber_map.add_internal_vertex_id(
              df,
              renumber_map.renumbered_dst_col_name,
              dst_col_names,
              drop=True,
              preserve_order=preserve_order,
          )
  
      else:
          # Update the renumbered source and destination column name
          # with the original input's source and destination name
          renumber_map.renumbered_src_col_name = src_col_names[0]
          renumber_map.renumbered_dst_col_name = dst_col_names[0]
  
      return df, renumber_map
  
file_path: cugraph/python/cugraph/cugraph/structure/number_map.py
imports: from collections.abc import Iterable
  import dask_cudf
  import numpy
  import cudf
  import warnings
label_desc: Use image node_id 8 for calling the NumberMap obj's underlying member method code with example usage: obj.renumber_and_segment(df, src_col_names, dst_col_names, preserve_order, store_transposed, legacy_renum_only) and returns: df,  renumber_map