This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.
Filters a graph’s edges by some criteria conditioned on a edge’s data payload and returns those edges’ indices.
This function takes in a function as an argument. This filter function will be passed in an edge’s data payload and is required to return a boolean value stating whether the edge’s data payload fits some criteria.
from rustworkx import PyGraph from rustworkx.generators import complete_graph graph = PyGraph() graph.add_nodes_from(range(3)) graph.add_edges_from([(0, 1, 'A'), (0, 1, 'B'), (1, 2, 'C')]) def my_filter_function(edge): if edge: return edge == 'B' return False indices = graph.filter_edges(my_filter_function) assert indices == 
filter_function – Function with which to filter edges
The edge indices that match the filter
- Return type: