class_docstr: Class which stores vertex and edge properties that can be used to construct
  Graphs from individual property selections and used later to annotate graph
  algorithm results with corresponding properties.
class_docstr_tok: ["Class","which","stores","vertex","and","edge","properties","that","can","be","used","to","construct","Graphs","from","individual","property","selections","and","used","later","to","annotate","graph","algorithm","results","with","corresponding","properties","."]
docstr: Return a subgraph of the overall PropertyGraph containing vertices
  and edges that match a selection.
  
  Parameters
  ----------
  create_using : type or instance of cugraph.Graph or PropertyGraph, optional
      Creates a Graph to return using the type specified. If an instance
      is specified, the type of the instance is used to construct the
      return Graph, and all relevant attributes set on the instance are
      copied to the return Graph (eg. directed). If not specified the
      returned Graph will be a directed cugraph.MultiGraph instance.
  selection : PropertySelection, optional
      A PropertySelection returned from one or more calls to
      select_vertices() and/or select_edges(), used for creating a Graph
      with only the selected properties. If not specified the returned
      Graph will have all properties. Note, this could result in a Graph
      with multiple edges, which may not be supported based on the value
      of create_using.
  edge_weight_property : string, optional
      The name of the property whose values will be used as weights on
      the returned Graph. If not specified, the returned Graph will be
      unweighted. Ignored for PropertyGraph return type.
  default_edge_weight : float64, optional
      Value that replaces empty weight property fields.
      Ignored for PropertyGraph return type.
  check_multi_edges : bool (default True)
      When True and create_using argument is given and not a MultiGraph,
      this will perform a check to verify that the edges in the edge
      dataframe do not form a multigraph with duplicate edges.
      Ignored for PropertyGraph return type.
  renumber_graph : bool (default True)
      If True, return a Graph that has been renumbered for use by graph
      algorithms. If False, the returned graph will need to be manually
      renumbered prior to calling graph algos.
      Ignored for PropertyGraph return type.
  add_edge_data : bool (default True)
      If True, add meta data about the edges contained in the extracted
      graph which are required for future calls to annotate_dataframe().
      Ignored for PropertyGraph return type.
  
  Returns
  -------
  A Graph instance of the same type as create_using containing only the
  vertices and edges resulting from applying the selection to the set of
  vertex and edge property data.
  
  Examples
  --------
  >>>
docstr_tok: ["Return","a","subgraph","of","the","overall","PropertyGraph","containing","vertices","and","edges","that","match","a","selection",".","Parameters","--","--","--","--","--","create_using",":","type","or","instance","of","cugraph.Graph","or","PropertyGraph",",","optional","Creates","a","Graph","to","return","using","the","type","specified",".","If","an","instance","is","specified",",","the","type","of","the","instance","is","used","to","construct","the","return","Graph",",","and","all","relevant","attributes","set","on","the","instance","are","copied","to","the","return","Graph","(","eg",".","directed",")",".","If","not","specified","the","returned","Graph","will","be","a","directed","cugraph.MultiGraph","instance",".","selection",":","PropertySelection",",","optional","A","PropertySelection","returned","from","one","or","more","calls","to","select_vertices","(",")","and\/or","select_edges","(",")",",","used","for","creating","a","Graph","with","only","the","selected","properties",".","If","not","specified","the","returned","Graph","will","have","all","properties",".","Note",",","this","could","result","in","a","Graph","with","multiple","edges",",","which","may","not","be","supported","based","on","the","value","of","create_using",".","edge_weight_property",":","string",",","optional","The","name","of","the","property","whose","values","will","be","used","as","weights","on","the","returned","Graph",".","If","not","specified",",","the","returned","Graph","will","be","unweighted",".","Ignored","for","PropertyGraph","return","type",".","default_edge_weight",":","float64",",","optional","Value","that","replaces","empty","weight","property","fields",".","Ignored","for","PropertyGraph","return","type",".","check_multi_edges",":","bool","(","default","True",")","When","True","and","create_using","argument","is","given","and","not","a","MultiGraph",",","this","will","perform","a","check","to","verify","that","the","edges","in","the","edge","dataframe","do","not","form","a","multigraph","with","duplicate","edges",".","Ignored","for","PropertyGraph","return","type",".","renumber_graph",":","bool","(","default","True",")","If","True",",","return","a","Graph","that","has","been","renumbered","for","use","by","graph","algorithms",".","If","False",",","the","returned","graph","will","need","to","be","manually","renumbered","prior","to","calling","graph","algos",".","Ignored","for","PropertyGraph","return","type",".","add_edge_data",":","bool","(","default","True",")","If","True",",","add","meta","data","about","the","edges","contained","in","the","extracted","graph","which","are","required","for","future","calls","to","annotate_dataframe","(",")",".","Ignored","for","PropertyGraph","return","type",".","Returns","--","--","--","-","A","Graph","instance","of","the","same","type","as","create_using","containing","only","the","vertices","and","edges","resulting","from","applying","the","selection","to","the","set","of","vertex","and","edge","property","data",".","Examples","--","--","--","--",">",">",">"]
code: def extract_subgraph(
      self,
      create_using=None,
      selection=None,
      edge_weight_property=None,
      default_edge_weight=None,
      check_multi_edges=True,
      renumber_graph=True,
      add_edge_data=True,
  ):
      """
      Return a subgraph of the overall PropertyGraph containing vertices
      and edges that match a selection.
  
      Parameters
      ----------
      create_using : type or instance of cugraph.Graph or PropertyGraph, optional
          Creates a Graph to return using the type specified. If an instance
          is specified, the type of the instance is used to construct the
          return Graph, and all relevant attributes set on the instance are
          copied to the return Graph (eg. directed). If not specified the
          returned Graph will be a directed cugraph.MultiGraph instance.
      selection : PropertySelection, optional
          A PropertySelection returned from one or more calls to
          select_vertices() and/or select_edges(), used for creating a Graph
          with only the selected properties. If not specified the returned
          Graph will have all properties. Note, this could result in a Graph
          with multiple edges, which may not be supported based on the value
          of create_using.
      edge_weight_property : string, optional
          The name of the property whose values will be used as weights on
          the returned Graph. If not specified, the returned Graph will be
          unweighted. Ignored for PropertyGraph return type.
      default_edge_weight : float64, optional
          Value that replaces empty weight property fields.
          Ignored for PropertyGraph return type.
      check_multi_edges : bool (default True)
          When True and create_using argument is given and not a MultiGraph,
          this will perform a check to verify that the edges in the edge
          dataframe do not form a multigraph with duplicate edges.
          Ignored for PropertyGraph return type.
      renumber_graph : bool (default True)
          If True, return a Graph that has been renumbered for use by graph
          algorithms. If False, the returned graph will need to be manually
          renumbered prior to calling graph algos.
          Ignored for PropertyGraph return type.
      add_edge_data : bool (default True)
          If True, add meta data about the edges contained in the extracted
          graph which are required for future calls to annotate_dataframe().
          Ignored for PropertyGraph return type.
  
      Returns
      -------
      A Graph instance of the same type as create_using containing only the
      vertices and edges resulting from applying the selection to the set of
      vertex and edge property data.
  
      Examples
      --------
      >>>
      """
      if selection is not None and not isinstance(
          selection, EXPERIMENTAL__MGPropertySelection
      ):
          raise TypeError(
              "selection must be an instance of "
              f"PropertySelection, got {type(selection)}"
          )
  
      # NOTE: the expressions passed in to extract specific edges and
      # vertices assume the original dtypes in the user input have been
      # preserved. However, merge operations on the DataFrames can change
      # dtypes (eg. int64 to float64 in order to add NaN entries). This
      # should not be a problem since the conversions do not change the
      # values.
      if (
          selection is not None
          and selection.vertex_selections is not None
      ):
          selected_vertex_dataframe = self.__vertex_prop_dataframe[
              selection.vertex_selections
          ]
      else:
          selected_vertex_dataframe = None
  
      if (
          selection is not None
          and selection.edge_selections is not None
      ):
          selected_edge_dataframe = self.__edge_prop_dataframe[
              selection.edge_selections
          ]
      else:
          selected_edge_dataframe = self.__edge_prop_dataframe
  
      # FIXME: check that self.__edge_prop_dataframe is set!
  
      # If vertices were specified, select only the edges that contain the
      # selected verts in both src and dst
      if (
          selected_vertex_dataframe is not None
          and not selected_vertex_dataframe.empty
      ):
          has_srcs = selected_edge_dataframe[self.src_col_name].isin(
              selected_vertex_dataframe.index
          )
          has_dsts = selected_edge_dataframe[self.dst_col_name].isin(
              selected_vertex_dataframe.index
          )
          edges = selected_edge_dataframe[has_srcs & has_dsts]
          # Alternative to benchmark
          # edges = selected_edge_dataframe.merge(
          #     selected_vertex_dataframe[[]],
          #     left_on=self.src_col_name,
          #     right_index=True,
          # ).merge(
          #     selected_vertex_dataframe[[]],
          #     left_on=self.dst_col_name,
          #     right_index=True,
          # )
      else:
          edges = selected_edge_dataframe
  
      # Default create_using set here instead of function signature to
      # prevent cugraph from running on import. This may help diagnose errors
      create_kind = "cugraph"
      if create_using is None:
          create_using = cugraph.MultiGraph(directed=True)
      elif isinstance(create_using, type(self)):
          rv = type(create_using)()
          create_kind = "propertygraph"
      elif type(create_using) is type and issubclass(
          create_using, type(self)
      ):
          rv = create_using()
          create_kind = "propertygraph"
      if create_kind == "cugraph":
          # The __*_prop_dataframes have likely been merged several times and
          # possibly had their dtypes converted in order to accommodate NaN
          # values. Restore the original dtypes in the resulting edges df prior
          # to creating a Graph.
          self.__update_dataframe_dtypes(edges, self.__edge_prop_dtypes)
          return self.edge_props_to_graph(
              edges,
              create_using=create_using,
              edge_weight_property=edge_weight_property,
              default_edge_weight=default_edge_weight,
              check_multi_edges=check_multi_edges,
              renumber_graph=renumber_graph,
              add_edge_data=add_edge_data,
          )
      # Return a subgraph as PropertyGraph
      if (
          selected_vertex_dataframe is None
          and self.__vertex_prop_dataframe is not None
      ):
          selected_vertex_dataframe = (
              self.__vertex_prop_dataframe.copy()
          )
          num_vertices = self.__num_vertices
          vertex_type_value_counts = self.__vertex_type_value_counts
      else:
          num_vertices = None
          vertex_type_value_counts = None
      if edges is not None and edges is self.__edge_prop_dataframe:
          edges = edges.copy()
          edge_type_value_counts = self.__edge_type_value_counts
      else:
          edge_type_value_counts = None
  
      rv._build_from_components(
          vertex_prop_dataframe=selected_vertex_dataframe,
          edge_prop_dataframe=edges,
          dataframe_type=self.__dataframe_type,
          series_type=self.__series_type,
          vertex_prop_dtypes=dict(self.__vertex_prop_dtypes),
          edge_prop_dtypes=dict(self.__edge_prop_dtypes),
          vertex_vector_property_lengths=dict(
              self.__vertex_vector_property_lengths
          ),
          edge_vector_property_lengths=dict(
              self.__edge_vector_property_lengths
          ),
          last_edge_id=self.__last_edge_id,
          is_edge_id_autogenerated=self.__is_edge_id_autogenerated,
          # Cached properties
          num_vertices=num_vertices,
          vertex_type_value_counts=vertex_type_value_counts,
          edge_type_value_counts=edge_type_value_counts,
      )
      return rv
  
imports: import cudf
  import cupy
  import cugraph
  import dask_cudf
  import cugraph.dask
  from cugraph.utilities.utils import import_optional, create_list_series_from_2d_ar
  from typing import Union
label_desc: Use image node_id 27 for calling the EXPERIMENTAL__MGPropertyGraph obj's underlying member method code with example usage: obj.extract_subgraph(create_using, selection, edge_weight_property, default_edge_weight, check_multi_edges, renumber_graph, add_edge_data) and returns: rv, self