implement algorithms.graph.transitive_reduction()