rustworkx.collect_bicolor_runs#
- collect_bicolor_runs(graph, filter_fn, color_fn)#
Collect runs that match a filter function given edge colors.
A bicolor run is a list of group of nodes connected by edges of exactly two colors. In addition, all nodes in the group must match the given condition. Each node in the graph can appear in only a single group in the bicolor run.
- Parameters:
graph (PyDiGraph) – The graph to find runs in
filter_fn – The filter function to use for matching nodes. It takes in one argument, the node data payload/weight object, and will return a boolean whether the node matches the conditions or not. If it returns
True
, it will continue the bicolor chain. If it returnsFalse
, it will stop the bicolor chain. If it returnsNone
it will skip that node.color_fn – The function that gives the color of the edge. It takes in one argument, the edge data payload/weight object, and will return a non-negative integer, the edge color. If the color is None, the edge is ignored.
- Returns:
a list of groups with exactly two edge colors, where each group is a list of node data payload/weight for the nodes in the bicolor run
- Return type:
list