E1 E2 Ei Ek−1 G, π π ← π 0 π0= π π06= π π0= π π06= π π06= π π06= π π0= π π06= π
Figure 4.18:Operation principle of the meta-algorithm Cascade.
these algorithms into one that efficiently constructs a linear ordering adhering to all properties at the same time.
4.9.1 A Cascading Meta-Algorithm
Let G be a graph and π be an arbitrary linear ordering of G. We assume that for every property we want to establish, there is a property-enforcing routine E(G, π) that applies an improvement to the input linear ordering π if π did not adhere to the respective property and otherwise leaves π unchanged. In the former case, E(G, π) returns an improved linear ordering π′, in the latter, the return value equals the argument, π.
At the beginning of this chapter, we introduced a meta-algorithm Iterate that takes one such property-enforcing routine as input and calls it repeatedly until the property has finally been established. In order to achieve the same for multiple properties, we devise a meta-algorithm Cascade(G, π, L= ⟨E0, . . . , Ek−1⟩), which takes an entire list of property-enforcing routines as input.Figure 4.18illustrates the operation principle of this procedure.
The algorithm passes the graph G and the current linear ordering π to each property- enforcing routine of the list in turn, starting with E0. If a property-enforcing routine Ei returns π unmodified, then the linear ordering passed to Ei already respected the corresponding property. If Ei is the last property-enforcing routine in the list, the algorithm terminates. Otherwise, the next step consists in passing the linear ordering to Ei+1. Whenever a routine returns a different linear ordering than it has been given as argument, the algorithm jumps back to the first element of the list, E0.
Algorithm 4.12Cascade
Require: graph G, linear ordering π, list L = ⟨E0, . . . , Ek−1⟩ of property-enforcing routines E(G, π)
Return: a linear ordering that respects all properties enforced by the elements of L
1: procedureCascade(G, π, L= ⟨E0, . . . , Ek−1⟩)
2: c← 0
3: while c < k do
4: π′ ← Ec(G, π)
5: if π′ = π then
6: c← c + 1 ▷continue to next routine
7: else
8: c← 0 ▷restart from E0 with linear ordering π′
9: π← π′
10: return π
Algorithm 4.12 lists the implementation of Cascade in more detail. The counter variable c is initialized with0 inline 2. In the following loop, the property-enforcing procedure Ecis called with parameters G and π. In case that the returned linear ordering
π′ equals π, the variable c is incremented, otherwise, it is reset to0 and π becomes π′.
The loop terminates once c reaches k.
Lemma 4.21
Let π be a linear ordering of a graph G and let L = ⟨E0, . . . , Ek−1⟩ be a list of property-enforcing routines that either return an improvement of the given linear ordering, or return the linear ordering that has been passed as argument. Then, Cascade(G, π, L) returns a linear ordering respecting all properties enforced by E0, . . . , Ek−1and runs in time O(m) times the maximum running time of Ei(G, π), where1 ≤ i < k.
Proof. Let Ei be an arbitrary property-enforcing routine. By contract, Ei returns its argument, π, if and only if π respects the property to enforce. Otherwise, it returns a modified linear ordering π′whose cardinality of the induced set of backward arcs is at least one less than that of π.
Consider the listing inAlgorithm 4.12. Let r denote the number of times that the variable c is reset to0 inline 9. Every reset coincides with a property-enforcing routine
4.9 A PsiOpt-Algorithm 129 returning a new linear ordering, which in turn implies that the cardinality of the induced set of backward arcs has decreased by at least one. In consequence, r cannot exceed |π|, where π here denotes the initial linear ordering that was passed to Cascade as parameter. More precisely, r < |π|, because we only consider strongly connected graphs and r = |π| would imply that the set of backward arcs induced by the linear ordering at termination was empty, i. e. , that the graph G was acyclic.
Next, we want to analyze the steps taken between two resets of the variable c, includ- ing its initialization inline 2. Let j denote the value of c immediately before one such reset. Then, since the previous reset, all property-enforcing routines Eiwith0 ≤ i ≤ j have been called and all except for Ej returned the linear ordering π unmodified. The number of steps taken between two resets of the variable c equals the sum of the steps required for each Ei,0 ≤ i ≤ j, which is asymptotically equivalent to the maximum of the time complexity of the involved property-enforcing routines. As j < k and
r ∈ O(m), Cascade runs in time O(m) times the maximum running time of Ei(G, π), where0 ≤ i < k.
As to the correctness of Cascade, consider the sequel of the algorithm starting with the last reset of the variable c. Here, the algorithm passes the current linear ordering to each property-enforcing routine of the list. Each routine must return π unmodified, because if not, there would be another reset of the variable c. Consequently, the current linear ordering respects all properties enforced by E0, . . . , Ek−1and, as there can be no further reset, Cascade terminates.
4.9.2 Establishing the Necessary Properties Simultaneously
We now turn to proving the two theorems stated at the very beginning of this chapter. There, we introduced the predicateΨoptfor linear orderings with the following definition: Ψopt(π) ⇔ ∀ψ ∈ Ψ : ψ(π), where Ψ denotes the set of predicates corresponding to the properties introduced earlier in this chapter. Hence,
Ψ = {Nest, Path, NoBlock, MPath, MNoBlock, Elim}. As announced at the beginning of this chapter, we show:
Theorem 4.1(restated)
Proof. Let π be a linear ordering. ByCorollary 4.17, Opt(π) implies MNoBlock(π) and byCorollary 4.18, if MNoBlock(π) holds, then also Nest(π), Path(π), NoBlock(π), and MPath(π). Finally,Corollary 4.20yields that Opt(π) also implies Elim(π), which con- cludes the proof ofTheorem 4.1.
The results of the previous subsection immediately enable us to construct a Ψopt- algorithm PsiOpt(G, π), which establishes the Nesting Property, the Path Property, the Blocking Vertices Property, the Multipath Property, the Multipath Blocking Ver- tices Property, and the Eliminable Layouts Property simultaneously. As to this, we use the meta-algorithm Cascade and set the list of property-enforcing routines to
L:= ⟨EnforceNesting, EnforceForwardPaths, EnforceNoBlocking, EnforceMultiPaths,
EnforceMultiPathsNoBlocking, EliminateLayouts⟩. Then, it is convenient to define PsiOpt(G, π) as Cascade(G, π, L). Let κ(n, m) again be the time complexity of computing a minimum cut in a unit-capacity network.
Lemma 4.22
PsiOpt(G, π) establishes the Nesting Property, the Path Property, the Blocking Vertices Property, the Multipath Property, the Multipath Blocking Vertices Prop- erty, and the Eliminable Layouts Property simultaneously on a linear ordering π of a graph G and runs in time O(n · m · κ(n, m)).
Proof. If for all property-enforcing routines contained in the list L held that they either leave the linear ordering unchanged or improve it, the claim would immediately follow byLemma 4.21. Unfortunately, this is not the case for EliminateLayouts. It is known, however, that the elimination process applied within this routine never constructs a linear ordering whose induced set of backward arcs has greater cardinality than the one it received as an input.
Therefore, let us briefly consider the situation when EliminateLayouts returns a new linear ordering π′, but the cardinality of the induced set of backward arcs remains constant, i. e. , |π| = |π′|. Whenever a routine returns a new linear ordering, Cascade reinvokes all property-enforcing routines of the list L. Observe that EliminateLayouts is the last item in L and that EliminateLayouts is the only property-enforcing routine in L that may return a new linear ordering that is neither an improvement nor a worsening. There are two possibilities: Either the modification applied by EliminateLayouts to the linear ordering that it has been passed as argument destroyed one of the properties
4.9 A PsiOpt-Algorithm 131 established earlier by one of the other property-enforcing routines or the new linear ordering still respects all of them despite the modification. In the former case, the property-enforcing routine for the destroyed property must apply an improvement. As shown in the proof ofLemma 4.21, there are at most O(m) improvements of the linear ordering possible. In the latter case, the property-enforcing routines preceding EliminateLayoutsin L do not change the linear ordering and Cascade terminates with one additional run through the elements of L.
Consequently, the number of resets of the variable c inAlgorithm 4.12is still bounded by O(m). The running times of the elements of L are as follows: O(m) for EnforceNest- ing, O (min{n · m, nω}) for EnforceForwardPaths, O(min{n·m, nω}) for EnforceNoBlock- ing, O(n · κ(n, m)) for EnforceMultiPaths, O(n · κ(n, m)) for EnforceMultiPathsNoBlock- ing, and O(n · m) for EliminateLayouts, where ω denotes the exponent in the running time of fast matrix multiplication algorithms and ω ≥ 2 (cf. Section 4.4), and κ(n, m) represents the time complexity of computing a minimum cut in a unit-capacity network with κ(n, m) ∈ Ω(m) (cf.Section 4.6).
With O(min{n·m, nω}) ⊆ O(n·m) and O(n·m) ⊆ O(n·κ(n, m)), the maximum running time of a property-enforcing routine in L equals O(n · κ(n, m)). Hence, PsiOpt(G, π) runs in time O(n · m · κ(n, m)).
By choosing an arbitrary initial linear ordering to be passed as an argument to PsiOpt(G, π), we obtain an algorithm that constructs a Ψ-optimal linear ordering π. This concludes the proof ofTheorem 4.2if we substitute O(m·min{n23, m12}) for κ(n, m),
which is the running time of Dinic’s algorithm (cf.Section 4.6.2):
Theorem 4.2(restated)
There is an O(n · m2· min{n23, m12})-time algorithm that constructs a Ψ-optimal linear ordering π.
Utilizing the result ofCorollary 4.18, which states that the Multipath Blocking Vertices Property implies the Nesting Property, Path Property, Blocking Vertices Property, and Multipath Property, the algorithm PsiOpt(G, π) can alternatively also be defined as Cascade(G, π,⟨EnforceMultiPathsNoBlocking, EliminateLayouts⟩). This neither affects the validity ofLemma 4.22nor the proof ofTheorem 4.2.
For subcubic graphs, we obtain a slightly more efficientΨopt-algorithm by observing that due toCorollary 4.3, the Nesting Property ensures that every vertex can be incident to at most one backward arc. In consequence, the Path Property together with the
Nesting Property implies the Multipath Property. Furthermore, the Eliminable Layouts Property ensures that every vertex that has an incident backward arc has only either incoming or outgoing forward arcs, but not both. Consequently, if a linear ordering π of a subcubic graph respects the Nesting Property, the Path Property, and the Eliminable Layouts Property, then no cropped forward path can contain a left-blocking or right- blocking vertex, thus, π also respects the Blocking Vertices Property, which is, for the same reason as above, equivalent to the Multipath Blocking Vertices Property. There- fore, it suffices to define theΨopt-algorithm for subcubic graphs, PsiOptCubic(G, π), as Cascade(G, π,⟨EnforceNesting, EnforceForwardPaths, EliminateLayouts⟩).
For subcubic graphs, we have that m= 3
2n, i. e. , m ∈ O(n). The time complexities of EnforceNesting, EnforceForwardPaths, and EliminateLayouts therefore all reduce to O(n2). With the same argument regarding the handling of EliminateLayouts as in the proof ofLemma 4.22, we derive fromLemma 4.21:
Corollary 4.21
There is an O(n3)-time algorithm that constructs a Ψ-optimal linear ordering π of a subcubic graph.