code: def compute_cugraph(
      self: Plottable,
      alg: str,
      out_col: Optional[str] = None,
      params: dict = {},
      kind: CuGraphKind = "Graph",
      directed=True,
      G: Optional[Any] = None,
  ) -> Plottable:
      """Run cugraph algorithm on graph. For algorithm parameters, see cuGraph docs.
  
      :param alg: algorithm name
      :type alg: str
  
      :param out_col: node table output column name, defaults to alg param
      :type out_col: Optional[str]
  
      :param params: algorithm parameters passed to cuGraph as kwargs
      :type params: dict
  
      :param kind: kind of cugraph to use
      :type kind: CuGraphKind
  
      :param directed: whether graph is directed
      :type directed: bool
  
      :param G: cugraph graph to use; if None, use self
      :type G: Optional[cugraph.Graph]
  
      :return: Plottable
      :rtype: Plottable
  
      **Example: Pagerank**
          ::
  
              g2 = g.compute_cugraph('pagerank')
              assert 'pagerank' in g2._nodes.columns
  
      **Example: Katz centrality with rename**
          ::
  
              g2 = g.compute_cugraph('katz_centrality', out_col='katz_centrality_renamed')
              assert 'katz_centrality_renamed' in g2._nodes.columns
  
      **Example: Pass params to cugraph**
          ::
  
              g2 = g.compute_cugraph('k_truss', params={'k': 2})
              assert 'k_truss' in g2._nodes.columns
  
      """
  
      import cugraph
  
      if G is None:
          G = to_cugraph(self, kind=kind, directed=directed)
  
      if alg in node_compute_algs_to_attr:
          out = getattr(cugraph, alg)(G, **params)
          if isinstance(out, tuple):
              out = out[0]
          g = self.materialize_nodes(engine=EngineAbstract.CUDF)
          if g._node != "vertex":
              out = out.rename(columns={"vertex": g._node})
          expected_cols = node_compute_algs_to_attr[alg]
          if not isinstance(expected_cols, list):
              expected_cols = [expected_cols]
          if out_col is None:
              out_col = alg
          out = out.rename(columns={expected_cols[0]: out_col})
          nodes_gdf = g._nodes[
              [
                  x
                  for x in g._nodes.columns
                  if x not in out.columns or x == g._node
              ]
          ].merge(out, how="left", on=g._node)
          return g.nodes(nodes_gdf)
      elif alg in edge_compute_algs_to_attr:
          out = getattr(cugraph, alg)(G, **params)
          if isinstance(out, tuple):
              out = out[0]
          if "source" in out.columns:
              out = out.rename(
                  columns={"source": "src", "destination": "dst"}
              )
          g = self
          if g._source != "src":
              out = out.rename(columns={"src": g._source})
          if g._destination != "dst":
              out = out.rename(columns={"dst": g._destination})
          expected_cols = edge_compute_algs_to_attr[alg]
          if not isinstance(expected_cols, list):
              expected_cols = [expected_cols]
          if out_col is not None:
              if len(expected_cols) > 1:
                  raise ValueError(
                      "Multiple columns returned, but out_col (singleton) was specified"
                  )
              out = out.rename(columns={expected_cols[0]: out_col})
          edges_gdf = g._edges[
              [
                  x
                  for x in g._edges
                  if x not in out.columns
                  or x in [g._source, g._destination]
              ]
          ].merge(out, how="left", on=[g._source, g._destination])
          return g.edges(edges_gdf)
      elif alg in graph_compute_algs:
          out = getattr(cugraph, alg)(G, **params)
          if isinstance(out, tuple):
              out = out[0]
          if out_col is not None:
              raise ValueError(
                  "Graph returned, but out_col was specified"
              )
          return from_cugraph(self, out, load_nodes=False)
  
      raise ValueError("Unsupported algorithm: %s", alg)
  
file_path: pygraphistry/graphistry/plugins/cugraph.py
imports: import pandas
  from typing import Any, Dict, List, Optional, Union
  from graphistry.constants import NODE
  from graphistry.Engine import EngineAbstract
  from graphistry.Plottable import Plottable
  from graphistry.plugins_types import CuGraphKind
  from graphistry.util import setup_logger
label_desc: Use image node_id 4 for calling a global function with example usage: compute_cugraph(alg, out_col, params, kind, directed, G) and returns: g, g, from_cugraph