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 Theory→→Reflexive 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 Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Set Operations: Union, Intersection, and Complement → Cartesian Products and Relations → Partial Orders → Binary Relations → Transitive Closure and Reachability

Longest path: 73 steps · 325 total prerequisite topics

Prerequisites (2)

Leads To (1)