code: def test_from_to_numpy(graph_file):
      # Read in the graph
      M = utils.read_csv_for_nx(graph_file, read_weights_in_sp=True)
  
      # create NetworkX and cugraph Directed Graph
      nxG = nx.from_pandas_edgelist(
          M,
          source="0",
          target="1",
          edge_attr="weight",
          create_using=nx.DiGraph,
      )
  
      cuG = cugraph.from_pandas_edgelist(
          M,
          source="0",
          destination="1",
          edge_attr="weight",
          create_using=cugraph.Graph(directed=True),
      )
  
      # convert graphs to numpy array
      nparray_nx = nx.to_numpy_array(
          nxG, nodelist=cuG.nodes().values_host
      )
      nparray_cu = cugraph.to_numpy_array(cuG)
      npmatrix_nx = nx.to_numpy_array(
          nxG, nodelist=cuG.nodes().values_host
      )
      npmatrix_cu = cugraph.to_numpy_array(cuG)
  
      # Compare arrays and matrices
      assert np.array_equal(nparray_nx, nparray_cu)
      assert np.array_equal(
          np.asarray(npmatrix_nx), np.asarray(npmatrix_cu)
      )
  
      # Create graphs from numpy array
      new_nxG = nx.from_numpy_array(nparray_nx, create_using=nx.DiGraph)
      new_cuG = cugraph.from_numpy_array(
          nparray_cu, create_using=cugraph.Graph(directed=True)
      )
  
      # Assert graphs are same
      exp_pdf = nx.to_pandas_edgelist(new_nxG)
      res_pdf = cugraph.to_pandas_edgelist(new_cuG)
  
      exp_pdf = exp_pdf.rename(
          columns={
              "source": "src",
              "target": "dst",
              "weight": "weights",
          }
      )
  
      exp_pdf = exp_pdf.sort_values(by=["src", "dst"]).reset_index(
          drop=True
      )
      res_pdf = res_pdf.sort_values(by=["src", "dst"]).reset_index(
          drop=True
      )
      res_pdf = res_pdf[["src", "dst", "weights"]]
  
      assert exp_pdf.equals(res_pdf)
  
      # Create graphs from numpy matrix
      new_nxG = nx.from_numpy_array(
          npmatrix_nx, create_using=nx.DiGraph
      )
      new_cuG = cugraph.from_numpy_array(
          npmatrix_cu, create_using=cugraph.Graph(directed=True)
      )
  
      # Assert graphs are same
      exp_pdf = nx.to_pandas_edgelist(new_nxG)
      res_pdf = cugraph.to_pandas_edgelist(new_cuG)
  
      exp_pdf = exp_pdf.rename(
          columns={
              "source": "src",
              "target": "dst",
              "weight": "weights",
          }
      )
  
      exp_pdf = exp_pdf.sort_values(by=["src", "dst"]).reset_index(
          drop=True
      )
      res_pdf = res_pdf.sort_values(by=["src", "dst"]).reset_index(
          drop=True
      )
      res_pdf = res_pdf[["src", "dst", "weights"]]
  
      assert exp_pdf.equals(res_pdf)
  
file_path: cugraph/python/cugraph/cugraph/tests/structure/test_convert_matrix.py
imports: import gc
  import pytest
  import numpy
  import networkx
  import cugraph
  from cugraph.testing import utils
label_desc: Use image node_id 3 for calling a global function with example usage: test_from_to_numpy(graph_file) without return types