code: def test_to_from_pandas(graph_file):
      # Read in the graph
      M = utils.read_csv_for_nx(graph_file, read_weights_in_sp=True)
  
      # create a NetworkX DiGraph and convert to pandas adjacency
      nxG = nx.from_pandas_edgelist(
          M,
          source="0",
          target="1",
          edge_attr="weight",
          create_using=nx.DiGraph,
      )
      nx_pdf = nx.to_pandas_adjacency(nxG)
      nx_pdf = nx_pdf[sorted(nx_pdf.columns)]
      nx_pdf.sort_index(inplace=True)
  
      # create a cugraph Directed Graph and convert to pandas adjacency
      cuG = cugraph.from_pandas_edgelist(
          M,
          source="0",
          destination="1",
          edge_attr="weight",
          create_using=cugraph.Graph(directed=True),
      )
  
      cu_pdf = cugraph.to_pandas_adjacency(cuG)
      cu_pdf = cu_pdf[sorted(cu_pdf.columns)]
      cu_pdf.sort_index(inplace=True)
  
      # Compare pandas adjacency list
      assert nx_pdf.equals(cu_pdf)
  
      # Convert pandas adjacency list to graph
      new_nxG = nx.from_pandas_adjacency(
          nx_pdf, create_using=nx.DiGraph
      )
      new_cuG = cugraph.from_pandas_adjacency(
          cu_pdf, create_using=cugraph.Graph(directed=True)
      )
  
      # Compare pandas edgelist
      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 2 for calling a global function with example usage: test_to_from_pandas(graph_file) without return types