code: def calc_k_cores(graph_file, directed=True):
      # directed is used to create either a Graph or DiGraph so the returned
      # cugraph can be compared to nx graph of same type.
      dataset_path = graph_file.get_path()
      NM = utils.read_csv_for_nx(dataset_path)
      G = graph_file.get_graph(
          create_using=cugraph.Graph(directed=directed),
          ignore_weights=True,
      )
      if directed:
          Gnx = nx.from_pandas_edgelist(
              NM, source="0", target="1", create_using=nx.DiGraph()
          )
      else:
          Gnx = nx.from_pandas_edgelist(
              NM, source="0", target="1", create_using=nx.Graph()
          )
      ck = cugraph.k_core(G)
      nk = nx.k_core(Gnx)
      return ck, nk
  
file_path: cugraph/python/cugraph/cugraph/tests/core/test_k_core.py
imports: import gc
  import pytest
  import networkx
  import cugraph
  from cugraph.testing import utils, UNDIRECTED_DATASETS
label_desc: Use image node_id 2 for calling a global function with example usage: calc_k_cores(graph_file, directed) and returns: ck,  nk