How this calculation works
Compute dominator sets and immediate dominators in a directed graph relative to a selected start vertex. A vertex dominates another when every directed path from the start to that vertex passes through it. The immediate-dominator relation summarizes these mandatory passage points as a rooted tree on reachable vertices. This is a path-necessity question rather than a shortest-path calculation.
d dominates v iff every start-to-v path passes through d; idom(v) is its deepest strict dominator.A worked example
Both branches from zero merge at vertex three before reaching four. Vertex three is therefore the immediate dominator of four. Zero dominates every reachable vertex, while neither one nor two dominates three because the opposite branch bypasses it.
Good to know
Simple directed graph≤30 vertices. Unreachable nodes have no start-rooted dominator set; the start has no strict immediate dominator. This is path dominance, not neighborhood domination, postdominance or a full control-dependence analysis.
Every path is the key quantifier
A vertex appearing on one convenient route is not necessarily a dominator. It must appear on every route from the start, including routes that pass through cycles.
Each reachable vertex dominates itself, and the start dominates all reachable vertices. Removing a non-start dominator blocks access to the vertices it dominates. Direction matters: an edge pointing back toward the start does not automatically provide a forward bypass.
A dominator lies on every start-to-vertex path; this is unrelated to neighborhood coverage by a dominating set. The Graph homomorphism count calculator for two graphs offers a complementary calculation under its own stated assumptions.
Reachability comes first
Vertices unreachable from the selected start have no immediate dominator in the returned reachable dominator tree. Treating the statement about every path as vacuously true for unreachable vertices would be unhelpful for this interface, so they are explicitly separated.
The start also has no immediate dominator because it is the root. A null entry can therefore describe either root status or unreachable status; consult the reachability output to distinguish them.
Worked example and mathematical rule
Both branches from zero merge at vertex three before reaching four. Vertex three is therefore the immediate dominator of four. Zero dominates every reachable vertex, while neither one nor two dominates three because the opposite branch bypasses it.
d dominates v iff every start-to-v path passes through d; idom(v) is its deepest strict dominator.
The fixed-point intersection rule
For a reachable non-start vertex, its dominators are itself together with the intersection of its reachable predecessors’ dominator sets. Repeatedly applying this rule removes candidates until the sets stabilize.
Intersections express the requirement that a candidate lie on every way into the vertex. Cycles do not require enumerating infinitely many walks. The bounded small-graph implementation uses this transparent set method rather than claiming the efficiency of specialized large-graph dominator algorithms.
Reading the immediate-dominator tree
Among a vertex’s strict dominators, the immediate dominator is the closest mandatory predecessor in the dominance ordering. It need not be connected to the vertex by an original graph edge.
Following tree parents gives all strict dominators back to the start. The tree compresses dominance relationships but does not preserve alternative routes, travel distances or edge multiplicity. Do not use it as a replacement routing graph for other computations.
Control-flow and network interpretations
In a program control-flow graph, a dominator identifies a block that must execute before another reachable block. In a directed access network, it identifies a mandatory passage vertex.
Both interpretations rely on a correct graph abstraction and start point. Exceptional control flow, conditional edges omitted from a diagram or multiple legitimate entry points can change the answer. A synthetic super-start can model several entries, but that modeling step should be made explicit.
Sanity checks with bypasses
In a directed chain, every earlier vertex dominates every later vertex. In a diamond, the two branch vertices do not dominate the merge, while the shared entry does.
Add a bypass edge around a suspected bottleneck and recalculate to see which dominance relationships disappear. Reversing all edges asks a different reachability problem; postdominators instead require an exit-oriented construction. The calculator does not silently reinterpret the selected start as a program exit.
A few questions, answered
Is an immediate dominator always an adjacent predecessor?
No. It is nearest in the dominance relation, not necessarily joined by a graph edge.
How are unreachable vertices represented?
They are listed outside the reachable tree and have no immediate dominator.
Can cycles be included?
Yes. The set fixed point handles directed cycles.
Does this compute postdominators?
No. That requires an explicitly exit-oriented graph construction.