code: def convert_from_nx(
      nxG,
      weight=None,
      do_renumber=True,
      store_transposed=False,
      vertex_type="int32",
  ):
      """
      Convert a NetworkX Graph into a cuGraph Graph.
      This might not be the most effecient way since the
      process first extracts the data from Nx into a Pandas array.
  
      Parameters
      ----------
       nxG : NetworkX Graph
          The NetworkX Graph top be converted.
  
      weight : str or None
          the weight column name.  If the graph is weighted this
          identifies which column in the Nx data to extract
  
      do_renumber : boolean, default is True
          Should the data be renumbered
  
      store_transposed : boolean, defaukt is False
          should the cuGraph Graph store the transpose of the graph
  
      vertex_type : str, default is "int32"
          Vertex type
  
      Returns
      -------
      G : cuGraph Graph
  
      """
  
      if isinstance(nxG, nx.classes.digraph.DiGraph):
          G = cugraph.Graph(directed=True)
      elif isinstance(nxG, nx.classes.graph.Graph):
          G = cugraph.Graph()
      else:
          raise TypeError(
              f"nxG must be either a NetworkX Graph or DiGraph, got {type(nxG)}"
          )
  
      is_weighted = nx.is_weighted(nxG, weight=weight)
  
      if is_weighted is False:
          _gdf = convert_unweighted_to_gdf(nxG, vertex_type)
          G.from_cudf_edgelist(
              _gdf,
              source="src",
              destination="dst",
              edge_attr=None,
              renumber=do_renumber,
              store_transposed=store_transposed,
          )
      else:
          if weight is None:
              _gdf = convert_weighted_unnamed_to_gdf(nxG, vertex_type)
              G.from_cudf_edgelist(
                  _gdf,
                  source="source",
                  destination="target",
                  edge_attr="weight",
                  renumber=do_renumber,
                  store_transposed=store_transposed,
              )
          else:
              _gdf = convert_weighted_named_to_gdf(
                  nxG, weight, vertex_type
              )
              G.from_cudf_edgelist(
                  _gdf,
                  source="src",
                  destination="dst",
                  edge_attr="weight",
                  renumber=do_renumber,
                  store_transposed=store_transposed,
              )
  
      return G
  
file_path: cugraph/python/cugraph/cugraph/utilities/nx_factory.py
imports: import cugraph
  from .utils import import_optional
  import cudf
  from cudf import from_pandas
  from cudf.api.types import is_integer_dtype
label_desc: Use image node_id 4 for calling a global function with example usage: convert_from_nx(nxG, weight, do_renumber, store_transposed, vertex_type) and returns: G