rustworkx.transitive_reduction#
- transitive_reduction(graph, /)#
Returns the transitive reduction of a directed acyclic graph
The transitive reduction of
is a graph such that for all and in there is an edge in if and only if is in and there is no path from to in with length greater than 1.- Parameters:
graph (PyDiGraph) – A directed acyclic graph
- Returns:
a directed acyclic graph representing the transitive reduction, and a map containing the index of a node in the original graph mapped to its equivalent in the resulting graph.
- Return type:
Tuple[PyGraph, dict]
- Raises:
PyValueError – if
graph
is not a DAG