A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Transitive Closure and Reachability

College Depth 72 in the knowledge graph I know this Set as goal
1topic build on this
325prerequisites beneath it
See this on the map →
Binary RelationsIntroduction to Graph TheoryReflexive and Transitive Closure
relations graph-theory closure

Core Idea

The transitive closure of a relation R is the smallest transitive relation containing R. It adds edges wherever there is a path in the graph representation of R. The transitive closure can be computed using matrix multiplication (reaching all paths) or using DFS/BFS for reachability queries.

Explainer

From your study of binary relations, you know that a relation R on a set A is transitive if whenever (a, b) ∈ R and (b, c) ∈ R, it follows that (a, c) ∈ R. Many natural relations fail this property in their raw form. "Directly reports to" in an organization is not transitive: Alice reports to Bob, Bob reports to Carol, but Alice does not directly report to Carol. The transitive closure R⁺ fixes this by adding all the implied pairs — it is the smallest transitive relation that contains R. Applied to the example, R⁺ would include all pairs (a, b) where a is anywhere in b's chain of command, directly or indirectly.

The connection to graph theory, which you have seen as a soft prerequisite, makes this concrete. Represent the relation R as a directed graph: nodes are elements of A, and there is an edge from a to b whenever (a, b) ∈ R. Then (a, b) ∈ R⁺ if and only if there is a directed path from a to b in the graph. Computing the transitive closure is exactly the reachability problem: from each node, which other nodes can you reach by following directed edges? This is why DFS or BFS from every node correctly computes the transitive closure — you explore all reachable nodes from each starting point.

The matrix approach gives the same answer algebraically. Represent R as an n × n boolean matrix M where M[i][j] = 1 if (i, j) ∈ R. The matrix Mᵏ (under boolean multiplication, where 1+1=1) has a 1 in position (i,j) whenever there is a path of length exactly k from i to j. The transitive closure matrix is M¹ OR M² OR M³ OR ··· OR Mⁿ. Since any path that isn't a cycle has length at most n − 1, the series terminates at n. Warshall's algorithm implements this efficiently in O(n³), iterating over intermediate nodes and updating reachability in place.

The reflexive-transitive closure R* — your next topic — adds one more property: it includes all pairs (a, a) as well, encoding "can reach in zero or more steps." This is the relation that captures reachability including staying in place, and it arises naturally in formal language theory (as the Kleene star of a language) and in program verification (where R* over a transition relation describes all possible states reachable from a starting state). Understanding transitive closure is the prerequisite for reasoning about what states a system can reach, which is fundamental to model checking and formal verification.

Practice Questions 5 questions

Prerequisite Chain

Understanding ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesSet Operations: Union, Intersection, and ComplementCartesian Products and RelationsPartial OrdersBinary RelationsTransitive Closure and Reachability

Longest path: 73 steps · 325 total prerequisite topics

Prerequisites (2)

Leads To (1)