cugraph.experimental.PropertyGraph.select_edges#

PropertyGraph.select_edges(expr)[source]#

Evaluate expr and return a PropertySelection object representing the edges that match the expression selection criteria.

Parameters:
exprstring

A python expression using property names and operators to select specific edges.

Returns:
PropertySelection

Can be used for calls to extract_subgraph() in order to construct a Graph containing only specific edges.

Examples

>>> import cudf
>>> import cugraph
>>> 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_edges("(_TYPE_ == 'etype') & (some_property == 'd')")
>>> G = pG.extract_subgraph(selection=selection,
...                         create_using=cugraph.Graph(directed=True),
...                         renumber_graph=False)
>>> print (G.edges())
src  dst
0   96   88