Advanced maths

Transitive reduction calculator for a directed acyclic graph

Remove exactly the reachability-redundant edges of a DAG and inspect its transitive closure without creating a separate page for the inverse relation.

Your numbers

Labels are 1 through this count. Include isolated vertices.
One directed from,to pair per row. Repeated ordered pairs and self-loops are rejected. Cycles are unsupported.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

A directed acyclic graph can contain edges already implied by longer directed paths. Transitive reduction removes those redundant direct links while preserving which vertices can reach which others. This calculator first verifies acyclicity, obtains a topological order and computes descendant reachability. An edge is omitted when another successor of its source can already reach its target. The output marks retained input rows and also lists the transitive closure, allowing the original, reduced and implied relations to be compared on one page.

THE FORMULARetain u→v exactly when no alternative directed u-to-v path exists; preserve the original nonempty-path reachability relation.

A worked example

Start with edges 1→2,2→3,1→3,3→4 and 1→4. Edge 1→3 is redundant because path 1→2→3 already implies it. Edge 1→4 is redundant because path 1→2→3→4 reaches the same target. The reduction keeps 1→2,2→3 and 3→4. Its closure has six ordered pairs: 1→2,1→3,1→4,2→3,2→4 and 3→4. The vertex order can remain the same even though the number of explicit edges changes from five to three.

Good to know

Simple directed acyclic graphs with 1–40 vertices and at most 200 edges. Duplicate ordered pairs and self-loops are rejected. Cyclic inputs require different conventions and are not supported. Closure uses nonempty paths and therefore adds no reflexive diagonal pairs. The reduction preserves reachability, not path multiplicity, travel time, reliability, capacity or the meaning of an independently important direct edge. The reduced edge set is unique for a finite DAG; a topological ordering need not be.

Reachability equivalence is stronger than preserving one valid order

A topological ordering only places each source before its target. Many different DAGs can admit the same order while implying different reachability relations. Removing arbitrary edges that appear compatible with the order can therefore lose real constraints. The reduction checks an alternative directed route for each omitted edge. Once finished, every original reachable ordered pair must still be reachable in the smaller graph.

The closure answers the complementary representation question: make every implied reachability pair explicit. It is listed with the reduction rather than treated as a new calculator URL. An isolated vertex remains in the declared vertex set but contributes no nonempty-path pair. This matters when comparing whole adjacency matrices: absence from the closure list does not mean that the vertex was deleted or that a self-reachability convention was silently introduced.

The chain preserves reachability after two redundant directed edges are removed1234Dashed edges are redundantReduced edges: 3Reachable ordered pairs: 6
Keep 1→2, 2→3, 3→4. The dashed 1→3 and 1→4 links add no reachable pair. The transitive closure still contains all six increasing ordered pairs.

A redundant precedence edge can still carry information worth preserving elsewhere

For pure precedence, a direct requirement from one task to another is logically implied if a chain of requirements already joins them. In a transport network, however, that same direct edge might be a faster route. In an evidence graph it might record a distinct source. Transitive reduction deliberately discards those extra edge-specific meanings. Use it only when the relation to preserve is reachability, rather than assuming every application benefits from fewer arrows.

The restriction to acyclic input is substantive. Directed cycles can make minimal reachability-preserving representations nonunique and alter the meaning of reduction. This page rejects them instead of deleting cycle edges under an unstated rule. The Topological sort calculator for a directed acyclic graph can provide an explicit cycle witness and valid precedence layers when the input is acyclic. Those layers describe order, while this page identifies exactly which direct constraints are unnecessary.

A few questions, answered

Does transitive reduction change the set of valid topological orders?

For a DAG interpreted as precedence, preserving all reachability preserves the same ordering constraints. It can change path counts and any edge-specific attributes.

Why are pairs such as 1→1 absent from closure?

This page defines closure using nonempty directed paths. In a DAG there is no such path from a vertex back to itself, so diagonal pairs are not added.

Find your calculator

Start typing to explore the library.