code: def hypergraph(
      values,
      columns=None,
      dropna=True,
      direct=False,
      graph_class=Graph,
      categories=dict(),
      drop_edge_attrs=False,
      categorical_metadata=True,
      SKIP=None,
      EDGES=None,
      DELIM="::",
      SOURCE="src",
      TARGET="dst",
      WEIGHTS=None,
      NODEID="node_id",
      EVENTID="event_id",
      ATTRIBID="attrib_id",
      CATEGORY="category",
      NODETYPE="node_type",
      EDGETYPE="edge_type",
  ):
      """
      Creates a hypergraph out of the given dataframe, returning the graph
      components as dataframes. The transform reveals relationships between the
      rows and unique values. This transform is useful for lists of events,
      samples, relationships, and other structured high-dimensional data.
      The transform creates a node for every row, and turns a row's column
      entries into node attributes. If direct=False (default), every unique
      value within a column is also turned into a node. Edges are added to
      connect a row's nodes to each of its column nodes, or if direct=True, to
      one another. Nodes are given the attribute specified by NODETYPE
      that corresponds to the originating column name, or if a row EVENTID.
      Consider a list of events. Each row represents a distinct event, and each
      column some metadata about an event. If multiple events have common
      metadata, they will be transitively connected through those metadata
      values. Conversely, if an event has unique metadata, the unique metadata
      will turn into nodes that only have connections to the event node.
      For best results, set EVENTID to a row's unique ID, SKIP to all
      non-categorical columns (or columns to all categorical columns),
      and categories to group columns with the same kinds of values.
  
  
  
      Parameters
      ----------
  
      values : cudf.DataFrame
          The input Dataframe to transform into a hypergraph.
  
      columns : sequence, optional (default=None)
          An optional sequence of column names to process.
  
      dropna : bool, optional (default=True)
          If True, do not include "null" values in the graph.
  
      direct : bool, optional (default=False)
          If True, omit hypernodes and instead strongly connect nodes for each
          row with each other.
  
      graph_class : cugraph.Graph, optional (default=cugraph.Graph)
          Specify the type of Graph to create.
  
      categories : dict, optional (default=dict())
          Dictionary mapping column names to distinct categories. If the same
          value appears columns mapped to the same category, the transform will
          generate one node for it, instead of one for each column.
  
      drop_edge_attrs : bool, optional, (default=False)
          If True, exclude each row's attributes from its edges
  
      categorical_metadata : bool, optional (default=True)
          Whether to use cudf.CategoricalDtype for the ``CATEGORY``,
          ``NODETYPE``, and ``EDGETYPE`` columns. These columns are typically
          large string columns with with low cardinality, and using categorical
          dtypes can save a significant amount of memory.
  
      SKIP : sequence, optional
          A sequence of column names not to transform into nodes.
  
      EDGES : dict, optional
          When ``direct=True``, select column pairs instead of making all edges.
  
      DELIM : str, optional (default="::")
          The delimiter to use when joining column names, categories, and ids.
  
      SOURCE : str, optional (default="src")
          The name to use as the source column in the graph and edge DF.
  
      TARGET : str, optional (default="dst")
          The name to use as the target column in the graph and edge DF.
  
      WEIGHTS : str, optional (default=None)
          The column name from the input DF to map as the graph's edge weights.
  
      NODEID : str, optional (default="node_id")
          The name to use as the node id column in the graph and node DFs.
  
      EVENTID : str, optional (default="event_id")
          The name to use as the event id column in the graph and node DFs.
  
      ATTRIBID : str, optional (default="attrib_id")
          The name to use as the attribute id column in the graph and node DFs.
  
      CATEGORY : str, optional (default "category")
          The name to use as the category column in the graph and DFs.
  
      NODETYPE : str, optional (default="node_type")
          The name to use as the node type column in the graph and node DFs.
  
      EDGETYPE : str, optional (default="edge_type")
          The name to use as the edge type column in the graph and edge DF.
  
      Returns
      -------
      result : dict {"nodes", "edges", "graph", "events", "entities"}
  
          nodes : cudf.DataFrame
              A DataFrame of found entity and hyper node attributes.
          edges : cudf.DataFrame
              A DataFrame of edge attributes.
          graph : cugraph.Graph
              A Graph of the found entity nodes, hyper nodes, and edges.
          events : cudf.DataFrame
              If direct=True, a DataFrame of hyper node attributes, else empty.
          entities : cudf.DataFrame
              A DataFrame of the found entity node attributes.
  
      Examples
      --------
      >>> M = cudf.read_csv(datasets_path / 'karate.csv', delimiter=' ',
      ...                   names=['src', 'dst', 'weights'],
      ...                   dtype=['int32', 'int32', 'float32'], header=None)
      >>> nodes, edges, G, events, entities = cugraph.hypergraph(M)
  
      """
  
      columns = values.columns if columns is None else columns
      columns = sorted(
          list(
              columns
              if SKIP is None
              else [x for x in columns if x not in SKIP]
          )
      )
  
      events = values.copy(deep=False)
      events.reset_index(drop=True, inplace=True)
  
      if EVENTID not in events.columns:
          events[EVENTID] = cudf.core.index.RangeIndex(len(events))
  
      events[EVENTID] = _prepend_str(events[EVENTID], EVENTID + DELIM)
      events[NODETYPE] = (
          "event"
          if not categorical_metadata
          else _str_scalar_to_category(len(events), "event")
      )
  
      if not dropna:
          for key, col in events[columns].items():
              if cudf.api.types.is_string_dtype(col.dtype):
                  events[key].fillna("null", inplace=True)
  
      edges = None
      nodes = None
      entities = _create_entity_nodes(
          events,
          columns,
          dropna=dropna,
          categories=categories,
          categorical_metadata=categorical_metadata,
          DELIM=DELIM,
          NODEID=NODEID,
          CATEGORY=CATEGORY,
          NODETYPE=NODETYPE,
      )
  
      if direct:
          edges = _create_direct_edges(
              events,
              columns,
              dropna=dropna,
              edge_shape=EDGES,
              categories=categories,
              drop_edge_attrs=drop_edge_attrs,
              categorical_metadata=categorical_metadata,
              DELIM=DELIM,
              SOURCE=SOURCE,
              TARGET=TARGET,
              EVENTID=EVENTID,
              CATEGORY=CATEGORY,
              EDGETYPE=EDGETYPE,
              NODETYPE=NODETYPE,
          )
          nodes = entities
          events = cudf.DataFrame()
      else:
          SOURCE = ATTRIBID
          TARGET = EVENTID
          edges = _create_hyper_edges(
              events,
              columns,
              dropna=dropna,
              categories=categories,
              drop_edge_attrs=drop_edge_attrs,
              categorical_metadata=categorical_metadata,
              DELIM=DELIM,
              EVENTID=EVENTID,
              ATTRIBID=ATTRIBID,
              CATEGORY=CATEGORY,
              EDGETYPE=EDGETYPE,
              NODETYPE=NODETYPE,
          )
          # Concatenate regular nodes and hyper nodes
          events = _create_hyper_nodes(
              events,
              NODEID=NODEID,
              EVENTID=EVENTID,
              CATEGORY=CATEGORY,
              NODETYPE=NODETYPE,
              categorical_metadata=categorical_metadata,
          )
          nodes = cudf.concat([entities, events])
          nodes.reset_index(drop=True, inplace=True)
  
      if WEIGHTS is not None:
          if WEIGHTS not in edges:
              WEIGHTS = None
          else:
              edges[WEIGHTS].fillna(0, inplace=True)
  
      graph = graph_class()
      graph.from_cudf_edgelist(
          edges,
          # force using renumber_from_cudf
          source=[SOURCE],
          destination=[TARGET],
          edge_attr=WEIGHTS,
          renumber=True,
      )
  
      return {
          "nodes": nodes,
          "edges": edges,
          "graph": graph,
          "events": events,
          "entities": entities,
      }
  
file_path: cugraph/python/cugraph/cugraph/structure/hypergraph.py
imports: import cudf
  import numpy
  from cugraph.structure.graph_classes import Graph
label_desc: Use image node_id 1 for calling a global function with example usage: hypergraph(values, columns, dropna, direct, graph_class, categories, drop_edge_attrs, categorical_metadata, SKIP, EDGES, DELIM, SOURCE, TARGET, WEIGHTS, NODEID, EVENTID, ATTRIBID, CATEGORY, NODETYPE, EDGETYPE) and returns: dict