code: def _compare_bfs(cugraph_df, golden_distances, source):
      # This call should only contain 3 columns:
      # 'vertex', 'distance', 'predecessor'
      # It also confirms wether or not 'sp_counter' has been created by the call
      # 'sp_counter' triggers atomic operations in BFS, thus we want to make
      # sure that it was not the case
      # NOTE: 'predecessor' is always returned while the C++ function allows to
      # pass a nullptr
      assert len(cugraph_df.columns) == 3, (
          "The result of the BFS has an invalid " "number of columns"
      )
      cu_distances = {
          vertex: dist
          for vertex, dist in zip(
              cugraph_df["vertex"].to_numpy(),
              cugraph_df["distance"].to_numpy(),
          )
      }
      cu_predecessors = {
          vertex: dist
          for vertex, dist in zip(
              cugraph_df["vertex"].to_numpy(),
              cugraph_df["predecessor"].to_numpy(),
          )
      }
  
      # FIXME: The following only verifies vertices that were reached
      #       by cugraph's BFS.
      # We assume that the distances are given back as integers in BFS
      # max_val = np.iinfo(df['distance'].dtype).max
      # Unreached vertices have a distance of max_val
      missing_vertex_error = 0
      distance_mismatch_error = 0
      invalid_predecessor_error = 0
      for vertex in golden_distances:
          if vertex in cu_distances:
              result = cu_distances[vertex]
              expected = golden_distances[vertex]
              if result != expected:
                  print(
                      "[ERR] Mismatch on distances: "
                      "vid = {}, cugraph = {}, golden = {}".format(
                          vertex, result, expected
                      )
                  )
                  distance_mismatch_error += 1
              if vertex not in cu_predecessors:
                  missing_vertex_error += 1
              else:
                  pred = cu_predecessors[vertex]
                  if vertex != source and pred not in golden_distances:
                      invalid_predecessor_error += 1
                  else:
                      # The graph is unweighted thus, predecessors are 1 away
                      if vertex != source and (
                          (
                              golden_distances[pred] + 1
                              != cu_distances[vertex]
                          )
                      ):
                          print(
                              "[ERR] Invalid on predecessors: "
                              "vid = {}, cugraph = {}".format(
                                  vertex, pred
                              )
                          )
                          invalid_predecessor_error += 1
          else:
              missing_vertex_error += 1
      assert missing_vertex_error == 0, "There are missing vertices"
      assert distance_mismatch_error == 0, "There are invalid distances"
      assert (
          invalid_predecessor_error == 0
      ), "There are invalid predecessors"
  
imports: import gc
  import pytest
  import cupy
  import numpy
  from scipy.sparse import coo_matrix
  from scipy.sparse import csr_matrix
  from scipy.sparse import csc_matrix
  import cudf
  import cugraph
  from cupyx.scipy.sparse import coo_matrix
  from cupyx.scipy.sparse import csr_matrix
  from cupyx.scipy.sparse import csc_matrix
  from pylibcugraph.testing.utils import gen_fixture_params_product
  from cugraph.testing import utils, get_resultset, load_resultset, DEFAULT_DATASETS, SMALL_DATASETS
label_desc: Use image node_id 5 for calling a global function with example usage: _compare_bfs(cugraph_df, golden_distances, source) without return types