code: def from_cugraph(
      self,
      G,
      node_attributes: Optional[List[str]] = None,
      edge_attributes: Optional[List[str]] = None,
      load_nodes: bool = True,
      load_edges: bool = True,
      merge_if_existing: bool = True,
  ) -> Plottable:
      """
  
      If bound IDs, use the same IDs in the returned graph.
  
      If non-empty nodes/edges, instead of returning G's topology, use existing topology and merge in G's attributes
  
      """
  
      import cudf, cugraph
  
      g = self
  
      ####
  
      src = self._source or SRC_CUGRAPH
      dst = self._destination or DST_CUGRAPH
      edges_gdf = G.view_edge_list()  # src, dst
  
      if g._nodes is not None and load_nodes:
          raise NotImplementedError(
              "cuGraph does not support nodes tables; set g.nodes(None) or from_cugraph(load_nodes=False)"
          )
  
      if src != "src":
          edges_gdf = edges_gdf.rename(columns={"src": src})
      if dst != "dst":
          edges_gdf = edges_gdf.rename(columns={"dst": dst})
  
      if (
          g._edges is not None
          and g._source is not None
          and g._destination is not None
          and merge_if_existing
      ):
          if isinstance(g._edges, cudf.DataFrame):
              g_indexed_df = g._edges
          elif isinstance(g._edges, pd.DataFrame):
              g_indexed_df = cudf.from_pandas(g._edges)
  
          else:
              was_dask = False
              try:
                  import dask_cudf
  
                  if isinstance(g._edges, dask_cudf.DataFrame):
                      was_dask = True
                      g_indexed_df = g._edges.compute()
              except ImportError:
                  1
  
              if not was_dask:
                  raise ValueError(
                      "Unsupported edge data type, expected pd/cudf.DataFrame, got: %s",
                      type(g._edges),
                  )
  
          # TODO handle case where where 3 attrs and third is _edge
          if len(g_indexed_df.columns) == 2 and (
              len(g_indexed_df) == len(edges_gdf)
          ):
              # opt: skip merge: no old columns
              1
          elif (
              (len(edges_gdf.columns) == 2)
              or len(edges_gdf.columns) == 0
          ) and (len(g._edges) == len(edges_gdf)):
              # opt: skip merge: no new columns
              edges_gdf = df_to_gdf(g._edges)
          else:
              if len(g_indexed_df) != len(edges_gdf):
                  logger.warning(
                      "edge tables do not match in length; switch merge_if_existing to False or load_edges to False or add missing edges"
                  )
              g_edges_trimmed = df_to_gdf(g_indexed_df)[
                  [
                      x
                      for x in g_indexed_df
                      if x not in edges_gdf or x in [src, dst]
                  ]
              ]
              if g._source != "src":
                  edges_gdf = edges_gdf.rename(columns={"src": src})
              if g._destination != "dst":
                  edges_gdf = edges_gdf.rename(columns={"dst": dst})
              edges_gdf = edges_gdf.merge(
                  g_edges_trimmed, how="left", on=[src, dst]
              )
  
      g = g.edges(edges_gdf, src, dst)
  
      return g
  
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 2 for calling a global function with example usage: from_cugraph(G, node_attributes, edge_attributes, load_nodes, load_edges, merge_if_existing) and returns: g