algo — C++23 日本語リファレンス GitHub

dominator_tree

クラス · 支配木(Lengauer-Tarjan 法)

template <graph_type G>
struct dominator_tree;

概要

支配木(Lengauer-Tarjan 法)

始点 root から到達可能な各頂点 $v$ について、その直接支配点 (immediate dominator) $\mathrm{idom}(v)$ を計算する。root から $v$ への すべての経路が必ず通る頂点のうち、$v$ に最も近いものが $\mathrm{idom}(v)$。 $\mathrm{idom}(root) = root$ とする。root から到達不能な頂点は $-1$。 辺の重みは無視する。計算量はほぼ $O((V + E)\alpha(V))$。

テンプレートパラメータ

名前 説明
G グラフ型(list_graph<T> / csr_graph<T> のいずれでも可)

計算量

構築・破棄

名前 説明 計算量
(constructor) 始点rootからの支配木を構築する $O((V+E)\alpha(V))$

メンバ関数

名前 説明 計算量
idom (1) 直接支配点を取得する(root は自分自身、到達不能な頂点は -1)
(2) 直接支配点の配列を取得する
$O(1)$

メンバの詳細

(constructor)

dominator_tree(const G &g, int root = 0);

始点rootからの支配木を構築する

idom

// (1)
int idom(int v) const;

// (2)
const std::vector<int> &idom() const;

(1) 直接支配点を取得する(root は自分自身、到達不能な頂点は -1)

(2) 直接支配点の配列を取得する