Class DominatorTree<N>

java.lang.Object
com.google.javascript.jscomp.graph.DominatorTree<N>
Type Parameters:
N - Value type that the graph node stores.

public final class DominatorTree<N> extends Object
Computes the dominator tree of a directed graph.

A node d dominates a node n if every path from the entry node to n must go through d.

The "immediate dominator" of n is the unique dominator d of n such that d != n and d is dominated by every other dominator of n (excluding n itself).

This implementation uses the iterative algorithm by Cooper, Harvey, and Kennedy. See .

  • Method Details

    • compute

      public static <N> DominatorTree<N> compute(DiGraph<N,?> graph, N entry)
      Computes the dominator tree for the given graph starting from the entry node.
      Parameters:
      graph - The directed graph to analyze.
      entry - The entry node of the graph.
      Returns:
      A DominatorTree instance.
    • getImmediateDominator

      public N getImmediateDominator(N node)
    • getDominatedSubtreeSize

      public int getDominatedSubtreeSize(N node)
    • getAllSubtreeSizes

      public com.google.common.collect.ImmutableMap<N,Integer> getAllSubtreeSizes()