code: def jaccard(
      input_graph: Graph,
      vertex_pair: cudf.DataFrame = None,
      do_expensive_check: bool = False,  # deprecated
      use_weight: bool = False,
  ):
      """
      Compute the Jaccard similarity between each pair of vertices connected by
      an edge, or between arbitrary pairs of vertices specified by the user.
      Jaccard similarity is defined between two sets as the ratio of the volume
      of their intersection divided by the volume of their union. In the context
      of graphs, the neighborhood of a vertex is seen as a set. The Jaccard
      similarity weight of each edge represents the strength of connection
      between vertices based on the relative similarity of their neighbors. If
      first is specified but second is not, or vice versa, an exception will be
      thrown.
  
      NOTE: If the vertex_pair parameter is not specified then the behavior
      of cugraph.jaccard is different from the behavior of
      networkx.jaccard_coefficient.
  
      cugraph.jaccard, in the absence of a specified vertex pair list, will
      compute the two_hop_neighbors of the entire graph to construct a vertex pair
      list and will return the jaccard coefficient for those vertex pairs. This is
      not advisable as the vertex_pairs can grow exponentially with respect to the
      size of the datasets
  
      networkx.jaccard_coefficient, in the absence of a specified vertex
      pair list, will return an upper triangular dense matrix, excluding
      the diagonal as well as vertex pairs that are directly connected
      by an edge in the graph, of jaccard coefficients.  Technically, networkx
      returns a lazy iterator across this upper triangular matrix where
      the actual jaccard coefficient is computed when the iterator is
      dereferenced.  Computing a dense matrix of results is not feasible
      if the number of vertices in the graph is large (100,000 vertices
      would result in 4.9 billion values in that iterator).
  
      If your graph is small enough (or you have enough memory and patience)
      you can get the interesting (non-zero) values that are part of the networkx
      solution by doing the following:
  
      >>> from cugraph.datasets import karate
      >>> input_graph = karate.get_graph(download=True, ignore_weights=True)
      >>> pairs = input_graph.get_two_hop_neighbors()
      >>> df = cugraph.jaccard(input_graph, pairs)
  
      But please remember that cugraph will fill the dataframe with the entire
      solution you request, so you'll need enough memory to store the 2-hop
      neighborhood dataframe.
  
  
      Parameters
      ----------
      input_graph : cugraph.Graph
          cuGraph Graph instance, should contain the connectivity information
          as an edge list. The graph should be undirected where an undirected
          edge is represented by a directed edge in both direction.The adjacency
          list will be computed if not already present.
  
          This implementation only supports undirected, non-multi Graphs.
  
      vertex_pair : cudf.DataFrame, optional (default=None)
          A GPU dataframe consisting of two columns representing pairs of
          vertices. If provided, the jaccard coefficient is computed for the
          given vertex pairs.  If the vertex_pair is not provided then the
          current implementation computes the jaccard coefficient for all
          adjacent vertices in the graph.
  
      do_expensive_check : bool, optional (default=False)
          Deprecated.
  
          This option added a check to ensure integer vertex IDs are sequential
          values from 0 to V-1. That check is now redundant because cugraph
          unconditionally renumbers and un-renumbers integer vertex IDs for
          optimal performance, therefore this option is deprecated and will be
          removed in a future version.
  
      use_weight : bool, optional (default=False)
          Flag to indicate whether to compute weighted jaccard (if use_weight==True)
          or un-weighted jaccard (if use_weight==False).
          'input_graph' must be weighted if 'use_weight=True'.
  
  
      Returns
      -------
      df  : cudf.DataFrame
          GPU data frame of size E (the default) or the size of the given pairs
          (first, second) containing the Jaccard weights. The ordering is
          relative to the adjacency list, or that given by the specified vertex
          pairs.
  
          df['first'] : cudf.Series
              The first vertex ID of each pair (will be identical to first if specified).
          df['second'] : cudf.Series
              The second vertex ID of each pair (will be identical to second if
              specified).
          df['jaccard_coeff'] : cudf.Series
              The computed Jaccard coefficient between the first and the second
              vertex ID.
  
      Examples
      --------
      >>> from cugraph.datasets import karate
      >>> from cugraph import jaccard
      >>> input_graph = karate.get_graph(download=True, ignore_weights=True)
      >>> df = jaccard(input_graph)
  
      """
      if do_expensive_check:
          warnings.warn(
              "do_expensive_check is deprecated since vertex IDs are no longer "
              "required to be consecutively numbered",
              FutureWarning,
          )
  
      if input_graph.is_directed():
          raise ValueError("Input must be an undirected Graph.")
  
      if vertex_pair is None:
          # Call two_hop neighbor of the entire graph
          vertex_pair = input_graph.get_two_hop_neighbors()
  
      v_p_num_col = len(vertex_pair.columns)
  
      if isinstance(vertex_pair, cudf.DataFrame):
          vertex_pair = renumber_vertex_pair(input_graph, vertex_pair)
          vertex_pair = ensure_valid_dtype(input_graph, vertex_pair)
          src_col_name = vertex_pair.columns[0]
          dst_col_name = vertex_pair.columns[1]
          first = vertex_pair[src_col_name]
          second = vertex_pair[dst_col_name]
  
      elif vertex_pair is not None:
          raise ValueError("vertex_pair must be a cudf Dataframe")
  
      first, second, jaccard_coeff = pylibcugraph_jaccard_coefficients(
          resource_handle=ResourceHandle(),
          graph=input_graph._plc_graph,
          first=first,
          second=second,
          use_weight=use_weight,
          do_expensive_check=False,
      )
  
      if input_graph.renumbered:
          vertex_pair = input_graph.unrenumber(
              vertex_pair, src_col_name, preserve_order=True
          )
          vertex_pair = input_graph.unrenumber(
              vertex_pair, dst_col_name, preserve_order=True
          )
  
      if v_p_num_col == 2:
          # single column vertex
          vertex_pair = vertex_pair.rename(
              columns={src_col_name: "first", dst_col_name: "second"}
          )
  
      df = vertex_pair
      df["jaccard_coeff"] = cudf.Series(jaccard_coeff)
  
      return df
  
file_path: cugraph/python/cugraph/cugraph/link_prediction/jaccard.py
imports: from cugraph.utilities import ensure_cugraph_obj_for_nx, df_edge_score_to_dictionary, renumber_vertex_pair
  import cudf
  import warnings
  from typing import Union, Iterable
  from pylibcugraph import jaccard_coefficients
  from pylibcugraph import ResourceHandle
  from cugraph.structure import Graph
  from cugraph.utilities.utils import import_optional
label_desc: Use image node_id 2 for calling a global function with example usage: jaccard(input_graph, vertex_pair, do_expensive_check, use_weight) and returns: df