Hopcroft-Tarjan

From Algowiki
Revision as of 14:33, 30 October 2014 by Weihe (talk | contribs) (→‎Correctness)
Jump to navigation Jump to search

Abstract view

Algorithmic problem: Biconnected components

Type of algorithm: two steps.

Step 1

Abstract view: A variation of DFS, where for each node [math]\displaystyle{ v\in v }[/math] two additional nonnegative integral numbers are computed:

  1. The 'depth of [math]\displaystyle{ v }[/math] in the arborescence created by the DFS procedure.
  2. The lowpoint, that is, the minimal depth of any node [math]\displaystyle{ w/in V }[/math] such that [math]\displaystyle{ (u,w)\in A }[/math] for some immediate or non-immediate successor of [math]\displaystyle{ v }[/math] in the DFS tree.

Implementation:

  1. The DFS maintains a global integral number, the current depth. Whenever a node is seen for the first time, its depth attribute is set identical to the current depth. In each forward step, the current depth is increased by one, in each backward step, it is decreased by one.
  2. Whenever a node [math]\displaystyle{ v\in V }[/math] is seen for the first time, its lowpoint is set identical to its depth. Whenever an arc [math]\displaystyle{ (v,w) }[/math] is examined such that [math]\displaystyle{ w }[/math] has already been seen and the depth of [math]\displaystyle{ w }[/math] is smaller than the lowpoint of [math]\displaystyle{ v }[/math], the lowpoint of [math]\displaystyle{ w }[/math] is set identical to the depth of [math]\displaystyle{ w }[/math].

Step 2

Abstract view: A repeated application of DFS, where the start nodes of the individual DFS runs are exactly those nodes [math]\displaystyle{ v\in V }[/math] for which the lowpoint of [math]\displaystyle{ v }[/math] is not smaller than the depth of [math]\displaystyle{ v }[/math]. These nodes are considered in ascending order of their finishing times as computed in step 1. The nodes hit in a DFS run are removed from [math]\displaystyle{ G }[/math] before the next DFS run commences. The node sets visited in the individual DFS runs are the biconnected components.

Correctness

Obviously, the depth and the lowpoint are set correctly according to their intended semantics.

In the following, the root of a biconnected component [math]\displaystyle{ C }[/math] is the first node of [math]\displaystyle{ C }[/math] seen in the DFS in step 1. We say that the root [math]\displaystyle{ v_1 }[/math] of some biconnected component [math]\displaystyle{ C_1 }[/math] follows the root [math]\displaystyle{ v_2 }[/math] of some biconnected component [math]\displaystyle{ C_2 }[/math] if [math]\displaystyle{ v_1\neq v_2 }[/math] and both nodes were on the DFS path in step 1 at some stage such that [math]\displaystyle{ v_2 }[/math] preceded [math]\displaystyle{ v_1 }[/math] on this path.

We have to show that the nodes whose lowpoints are not smaller than their depths are exactly the roots of biconnected components in the arborescence created in step 1.

First consider a node [math]\displaystyle{ v\in V }[/math] whose lowpoint is smaller than its depth. Then [math]\displaystyle{ v }[/math] cannot be

Complexity

Statement: The asymptotic complexity is linear.

Proof: Follows immediately from the linear asymptotic complexity of DFS.