cugraph.experimental.PropertyGraph.select_vertices#
- PropertyGraph.select_vertices(expr, from_previous_selection=None)[source]#
Evaluate expr and return a PropertySelection object representing the vertices that match the expression.
- Parameters:
- exprstring
A python expression using property names and operators to select specific vertices.
- from_previous_selectionPropertySelection, optional
A PropertySelection instance returned from a prior call to select_vertices() that can be used to select a subset of vertices to evaluate the expression against. This allows for a selection of the intersection of vertices of multiple types (eg. all vertices that are both type A and type B)
- Returns:
- PropertySelection
used for calls to extract_subgraph() in order to construct a Graph containing only specific vertices.
Examples
>>> import cugraph >>> import cudf >>> from cugraph.experimental import PropertyGraph >>> df = cudf.DataFrame(columns=["src", "dst", "some_property"], ... data=[(99, 22, "a"), ... (98, 34, "b"), ... (97, 56, "c"), ... (96, 88, "d"), ... ]) >>> pG = PropertyGraph() >>> pG.add_edge_data(df, type_name="etype", vertex_col_names=("src", "dst")) >>> vert_df = cudf.DataFrame({"vert_id": [99, 22, 98, 34, 97, 56, 96, 88], ... "v_prop": [1, 2, 3, 4, 5, 6, 7, 8]}) >>> pG.add_vertex_data(vert_df, type_name="vtype", vertex_col_name="vert_id") >>> selection = pG.select_vertices("(_TYPE_ == 'vtype') & (v_prop > 4)") >>> G = pG.extract_subgraph(selection=selection) >>> print (G.number_of_vertices()) 4