pub fn transitive_reduction(dag: &Graph) -> Result<Graph, GraphError>Expand description
Returns the transitive reduction of dag: the same nodes, keeping each edge u -> v unless
another path leads from u to v.
From each node, the result reaches the same nodes as dag, with as few edges as possible; on a
DAG, this result is unique. For a graph with cycles, reduce the DAG of its SCCs, which is
components::sccs_of(&graph).condense().
The reduction is computed with a row of bits per node for the nodes it reaches. The rows take node_count² / 8 bytes, about 1.25 GB for 100 000 nodes.
Time: O(node_count + edge_count log max_out_degree + (node_count + edge_count) x node_count / 64). Memory: 4 bytes per node and per edge for the result; while it runs, node_count² / 8 bytes for the rows and O(node_count + edge_count) more.
§Errors
An InvalidArgument error if dag has a cycle, a self-loop
included.
§Panics
With an invalid argument message if a depth-first path is longer than 2^30 - 5 nodes.