code: def compare(ddf1, ddf2, src_col_name, dst_col_name, val_col_name):
      #
      #  We will do comparison computations by using dataframe
      #  merge functions (essentially doing fast joins).
      #  Check to see if all pairs in the original data frame
      #  still exist in the new data frame.  If we join (merge)
      #  the data frames where (src1[i]=src2[i]) and (dst1[i]=dst2[i])
      #  then we should get exactly the same number of entries in
      #  the data frame if we did not lose any data.
      #
  
      ddf1 = ddf1.add_suffix("_x")
      ddf2 = ddf2.add_suffix("_y")
  
      if not isinstance(src_col_name, list) and not isinstance(
          dst_col_name, list
      ):
          src_col_name = [src_col_name]
          dst_col_name = [dst_col_name]
  
      # Column names for ddf1
      src_col_name1 = [f"{src}_x" for src in src_col_name]
      dst_col_name1 = [f"{dst}_x" for dst in dst_col_name]
      col_names1 = src_col_name1 + dst_col_name1
  
      # Column names for ddf2
      src_col_name2 = [f"{src}_y" for src in src_col_name]
      dst_col_name2 = [f"{dst}_y" for dst in dst_col_name]
      col_names2 = src_col_name2 + dst_col_name2
  
      if val_col_name is not None:
          val_col_name = [val_col_name]
          val_col_name1 = [f"{val}_x" for val in val_col_name]
          val_col_name2 = [f"{val}_y" for val in val_col_name]
          col_names1 += val_col_name1
          col_names2 += val_col_name2
      #
      #  Now check the symmetrized edges are present.  If the original
      #  data contains (u,v), we want to make sure that (v,u) is present
      #  in the new data frame.
      #
      #  We can accomplish this by doing the join (merge) where
      #  (src1[i] = dst2[i]) and (dst1[i] = src2[i]), and verifying
      #  that we get exactly the same number of entries in the data frame.
      #
      join = ddf1.merge(
          ddf2, left_on=[*col_names1], right_on=[*col_names2]
      )
  
      if len(ddf1) != len(join):
          # The code below is for debugging purposes only. It will print
          # edges in the original dataframe that are missing from the symmetrize
          # dataframe
          join2 = ddf1.merge(
              ddf2,
              how="left",
              left_on=[*col_names1],
              right_on=[*col_names2],
          )
          # FIXME: Didn't find a cudf alternative for the function below
          pd.set_option("display.max_rows", 500)
          print(
              "join2 = \n",
              join2.sort_values([*col_names1])
              .compute()
              .to_pandas()
              .query(f"{src_col_name[0]}_y.isnull()", engine="python"),
          )
  
      assert len(ddf1) == len(join)
  
      #
      #  Finally, let's check (in both directions) backwards.
      #  We want to make sure that no edges were created in
      #  the symmetrize logic that didn't already exist in one
      #  direction or the other.  This is a bit more complicated.
      #
      #  The complication here is that the original data could,
      #  for some edge (u,v) ALREADY contain the edge (v,u).  The
      #  symmetrized graph will not duplicate any edges, so the edge
      #  (u,v) will only be present once.  So we can't simply check
      #  counts of ddf2 joined with ddf1.
      #
      #  join1 will contain the join (merge) of ddf2 to ddf1 in the
      #        forward direction
      #  join2 will contain the join (merge) of ddf2 to ddf1 in the
      #        reverse direction
      #
      #  Finally, we'll do an outer join of join1 and join2, which
      #  will combine any (u,v)/(v,u) pairs that might exist into
      #  a joined row while keeping any (u,v) pairs that don't exist
      #  in both data frames as single rows.  This gives us a data frame
      #  with the same number of rows as the symmetrized data.
      #
  
      swap_columns = dst_col_name1 + src_col_name1
      if val_col_name is not None:
          swap_columns += val_col_name1
  
      join1 = ddf2.merge(
          ddf1, left_on=[*col_names2], right_on=[*col_names1]
      )
      join2 = ddf2.merge(
          ddf1, left_on=[*col_names2], right_on=[*swap_columns]
      )
  
      # Ensure join2["weight_*"] and join1["weight"] are of the same type.
      # Failing to do that can trigger ddf to return a warning if the two ddf
      # being merge are of dofferent types
      join2 = join2.astype(join1.dtypes.to_dict())
  
      joinM = join1.merge(join2, how="outer", on=[*ddf2.columns])
  
      assert len(ddf2) == len(joinM)
  
file_path: cugraph/python/cugraph/cugraph/tests/internals/test_symmetrize_mg.py
imports: import gc
  import pytest
  import pandas
  import dask_cudf
  import cugraph
  from cugraph.testing import utils
  from pylibcugraph.testing.utils import gen_fixture_params_product
label_desc: Use image node_id 3 for calling a global function with example usage: compare(ddf1, ddf2, src_col_name, dst_col_name, val_col_name) without return types