Algorithm Search⌘K

Proofs: Elimination tree

These are the human proofs of Elimination tree, at full length.

Cost of the elimination tree algorithms full

This proof shows: time.worst, space.extra, symbolic.worst.

ETREE. Lines L1 and L2 cost Θ(n)\Theta(n). Each of the mm nonzeros starts one climb. The forest given by the pointers anc\mathrm{anc} is a disjoint-set forest: a climb from ii is a find that follows pointers to the root rr of the set of ii and redirects every node passed, and setting anc[r]=k\mathrm{anc}[r] = k for the new singleton kk is a link with the new root on top, done before the compression it accompanies. So iteration kk performs finds and links of a sequence with mm finds and at most n−1n - 1 links, with full path compression and arbitrary linking. Tarjan and van Leeuwen (1984) bound such a sequence by O(n+mlog⁡2+m/nn)O(n + m \log_{2 + m/n} n) pointer operations, which is O(n+mlog⁡n)O(n + m \log n). Each find also costs Ω(1)\Omega(1), so the time is at least Ω(n+m)\Omega(n + m).

ROW-PATTERN. Lines L10 and L12 run once per nonzero of row kk of AA plus once per iteration of line L13. Each iteration of line L13 marks an unmarked node, which then appears in the output, so there are ∣R∣|R| of them, and lines L9, L11, L14 and L15 cost O(1+∣R∣)O(1 + |R|). Total O(1+∣row k of A∣+∣row k of L∣)O(1 + |\text{row } k \text{ of } A| + |\text{row } k \text{ of } L|).

Symbolic factorization. Summing over kk gives Θ(n+m+z)\Theta(n + m + z): at least the input and output, and at most a constant times their size.

POSTORDER. Building the child lists and the depth first search touch each node and each tree edge a constant number of times: Θ(n)\Theta(n).

Space. parent\mathrm{parent}, anc\mathrm{anc}, the marks, the child lists and the explicit stack have O(n)O(n) entries; outputs excluded, the extra space is Θ(n)\Theta(n). ■\blacksquare

Correctness of the elimination tree algorithms full

This proof shows: correctness, termination.

Structural model: lij≠0l_{ij} \ne 0 means structurally nonzero. Column jj of LL has its nonzeros exactly at the neighbours i>ji > j of jj in the elimination graph GjG_j, where G1=GG_1 = G and Gj+1G_{j+1} is obtained from GjG_j by deleting jj and joining all its neighbours pairwise (the Schur complement pattern).

Lemma 1 (fill paths). For u,v≥ju, v \ge j, u≠vu \ne v, the edge {u,v}\{u, v\} is in GjG_j if and only if GG has a path from uu to vv whose interior vertices are all smaller than jj. Hence for i>ji > j, lij≠0l_{ij} \ne 0 if and only if GG has an ii to jj path with interior vertices smaller than jj.

Proof. Induction on jj; for j=1j = 1 the paths have no interior and the claim is the definition of GG. Suppose it holds for jj. An edge {u,v}\{u, v\} with u,v>ju, v > j is in Gj+1G_{j+1} if it was in GjG_j or if both uu and vv are neighbours of jj in GjG_j. By the hypothesis the first case gives a path with interior below jj, and the second gives two paths u→ju \to j and j→vj \to v with interiors below jj, whose concatenation (shortened to a simple path) has interior vertices at most jj. Conversely, take a simple uu to vv path with interior below j+1j + 1. If it avoids jj its interior is below jj and {u,v}∈Gj\{u, v\} \in G_j, so also in Gj+1G_{j+1}. Otherwise it passes jj once, and the two pieces show that uu and vv are neighbours of jj in GjG_j, so they are joined in Gj+1G_{j+1}. □\square

Lemma 2. If i>p>ji > p > j and lij≠0l_{ij} \ne 0, lpj≠0l_{pj} \ne 0, then lip≠0l_{ip} \ne 0.

Proof. ii and pp are neighbours of jj in GjG_j, so they are adjacent in Gj+1G_{j+1}; edges between surviving vertices are never removed, so they are adjacent in GpG_p, and lip≠0l_{ip} \ne 0. □\square

Theorem 3 (ancestor property). If lij≠0l_{ij} \ne 0 and i>ji > j, then ii is an ancestor of jj.

Proof. Induction on i−ji - j. Let p=parent(j)p = \mathrm{parent}(j), which exists and satisfies p≤ip \le i by its definition as a minimum. If p=ip = i we are done. Otherwise j<p<ij < p < i and Lemma 2 gives lip≠0l_{ip} \ne 0 with i−p<i−ji - p < i - j, so ii is an ancestor of pp, hence of jj. □\square

Lemma 4. If i<ji < j and GG has a path from ii to jj whose interior vertices are all smaller than jj, then jj is an ancestor of ii.

Proof. Induction on the path length. Let ww be the largest vertex of the path other than jj; then w≥iw \ge i. The subpath from ww to jj has interior vertices smaller than ww, so ljw≠0l_{jw} \ne 0 by Lemma 1 and jj is an ancestor of ww by Theorem 3. If w=iw = i we are done. Otherwise the subpath from ii to ww is shorter and has interior vertices below ww, so ww is an ancestor of ii by induction. □\square

Theorem 5 (row subtrees). For each kk, {j<k:lkj≠0}=⋃i<k, aki≠0{nodes on the tree path from i to k}∖{k}\{ j < k : l_{kj} \ne 0 \} = \bigcup_{i < k,\, a_{ki} \ne 0} \{ \text{nodes on the tree path from } i \text{ to } k \} \setminus \{k\}.

Proof. If aki≠0a_{ki} \ne 0 then lki≠0l_{ki} \ne 0 and kk is an ancestor of ii (Theorem 3), so the path exists. For ⊇\supseteq, walk up the path from ii: lki≠0l_{ki} \ne 0, and if lkj≠0l_{kj} \ne 0 with p=parent(j)<kp = \mathrm{parent}(j) < k, then lpj≠0l_{pj} \ne 0 and Lemma 2 gives lkp≠0l_{kp} \ne 0. For ⊆\subseteq, let lkj≠0l_{kj} \ne 0. By Lemma 1 there is a path k,w1,…,ws=jk, w_1, \ldots, w_s = j with w1,…,ws−1<jw_1, \ldots, w_{s-1} < j. Put i=w1i = w_1, so aki≠0a_{ki} \ne 0 and i≤ji \le j. If i<ji < j, the path w1,…,wsw_1, \ldots, w_s satisfies Lemma 4, so jj is an ancestor of ii. The ancestors of ii form a chain containing jj and kk, and j<kj < k, so jj lies on the path from ii to kk. □\square

Theorem 6 (ETREE). Let FkF_k be the forest on {1,…,k}\{1, \ldots, k\} obtained from the elimination tree by deleting the edges to parents larger than kk. After iteration kk of line L1: for v≤kv \le k, parent[v]\mathrm{parent}[v] is the true parent if it is at most kk and 00 otherwise; and anc[v]=0\mathrm{anc}[v] = 0 if vv is a root of FkF_k, while otherwise anc[v]\mathrm{anc}[v] is a proper ancestor of vv with anc[v]≤k\mathrm{anc}[v] \le k.

Proof. Induction on kk; before iteration 11 there is nothing to show. In iteration kk, the nodes whose parent is kk are, by definition, the j<kj < k with lkj≠0l_{kj} \ne 0 and ltj=0l_{tj} = 0 for j<t<kj < t < k, that is the roots of Fk−1F_{k-1} in the row pattern of kk. By Theorem 5 a root rr of Fk−1F_{k-1} is in that pattern exactly when its subtree in Fk−1F_{k-1} contains some ii with aki≠0a_{ki} \ne 0 (if rr is on the path from such an ii, ii is in its subtree; conversely rr and kk are both ancestors of ii and r<kr < k, so rr is on the path).

Consider the climb of lines L4 to L7 from such an ii. Every value it follows is an anc pointer, hence a proper ancestor, so the visited nodes increase strictly and the loop terminates. By the hypothesis, nodes that are not roots of Fk−1F_{k-1} have pointers into the same tree of Fk−1F_{k-1}, unless they were reset to kk earlier in this iteration. If the climb meets no such node it ends at the root rr of the tree of ii, where anc[r]=0\mathrm{anc}[r] = 0, and line L6 sets parent[r]=k\mathrm{parent}[r] = k, correctly. If it meets a node whose pointer is already kk, that node was passed by an earlier climb of this iteration, which continued to the same root rr and set its parent. No other parents are set, since line L6 acts only at roots of Fk−1F_{k-1} reached from such an ii, and those all have parent kk. Every node passed is in a tree now hanging from kk and receives anc=k\mathrm{anc} = k, a proper ancestor; nodes not passed keep valid pointers, since adding the node kk above some roots keeps every ancestor an ancestor; and anc[k]=0\mathrm{anc}[k] = 0 with kk a root of FkF_k. □\square

Theorem 7 (ROW-PATTERN). It returns the row pattern of kk, each node once, and clears its marks.

Proof. Only kk and output nodes are marked. A climb from ii with aki≠0a_{ki} \ne 0 follows the tree path towards kk, which is an ancestor of ii and is marked, so it stops, at the first marked node. The nodes it appends are on the path from ii to kk, and all unmarked nodes on that path below the stopping node are appended. A marked node on the path other than kk was output by an earlier climb, which also passed everything above it up to kk or to another marked node, and so on up to kk. So the union of the outputs is the union in Theorem 5, without repetition. Line L15 clears exactly what was marked. □\square

Theorem 8 (equivalent orderings). Let σ\sigma be an ordering of 1,…,n1, \ldots, n in which every node comes before its parent (a postorder is one). Eliminating GG in the order σ\sigma gives the same filled graph G+G^+ (the graph of L+LTL + L^T) as the original order. Hence the column counts are permuted by σ\sigma and the new tree is the old one relabelled.

Proof. Every neighbour ww of vv in G+G^+ is comparable with vv in the tree (Theorem 3), so the neighbours of vv that come after vv in σ\sigma are its ancestors, which are its neighbours larger than vv in the original order: the pattern of column vv of LL. These form a clique of G+G^+, because the elimination game made them one. So σ\sigma is a perfect elimination ordering of G+G^+, and eliminating G+G^+ in order σ\sigma adds nothing. Fill under σ\sigma is given by the paths of Lemma 1 with σ\sigma in place of the numbering; a path in GG is a path in G+⊇GG^+ \supseteq G, so the filled graph of GG under σ\sigma is contained in that of G+G^+, which is G+G^+.

Conversely let {i,j}∈G+\{i, j\} \in G^+ with j<ij < i, so jj is a descendant of ii and σ\sigma puts jj before ii. Lemma 1 gives a path from ii to jj in GG whose interior vertices are smaller than jj; for each interior ww, the piece from ww to jj satisfies Lemma 4, so ww is a descendant of jj and comes before jj in σ\sigma. This is a fill path in the order σ\sigma, so {i,j}\{i, j\} is in the filled graph under σ\sigma. The parent of a node is its smallest higher neighbour in G+G^+, and the higher neighbours are the same set in both orders; as they form a chain of ancestors, the smallest is the same node. □\square

Termination. Every loop is over a finite list except the climbs, which strictly increase the current node (Theorems 6 and 7), and the depth first search, which emits each node once. ■\blacksquare

Back to Elimination tree