σ1 σ0 σ5 σ2 σ3 σ4 σ5 σ1 σ0 σ2 σ3 σ4
Figure 3.4:Two possible topological sortings of the condensed example graph.
that ∀ (u, v) ∈ A : ξ(u) < ξ(v). Descriptively, every arc must point from a vertex with a lower topsort number to a vertex with a higher topsort number. A graph is acyclic if and only if it can be sorted topologically. Just as there may be a number of different linear extensions to a partial order, there may be equally many topological sortings of an acyclic graph. For illustration,Figure 3.4shows two possible topological sortings of the condensed example graph.
Computing a topological sorting and inherently checking whether a graph is acyclic can be accomplished in time O(n+m) by repeatedly removing a source v from the graph and assigning it the topsort number ξ(v) in increasing order. We refer to the algorithm that returns a topological sorting of an acyclic graph G as TopSort(G).
The strongly connected components of a graph can also be retrieved in time O(n + m) using, e. g. , Tarjan’s algorithm [Tar72], which is based on depth-first search. At the same time, the graph’s condensation may be constructed.
3.3 Feedback Arc Sets and Linear Orderings
This section is to introduce notation that relates especially to the mathematical handling of feedback arc sets and linear orderings.
3.3.1 Feedback Arc Sets
A feedback arc set B, sometimes also called a cycle cover, for a graph G = (V, A) is a set of arcs B ⊆ A such that the subgraph restricted to A \ B is acyclic. The set F = A \ B is referred to as the acyclic arc set of G with respect to B and the subgraph restricted to F,
G⏐
⏐F, as the according acyclic subgraph.
Given a set of arcs B ⊆ A, we say that B is feasible, if it forms a valid feedback arc set. In conformance with the definitions inSection 3.1, a feedback arc set is called minimal, if no arc can be removed from it such that it remains feasible. Analogously, a feedback arc
v8 v9 v10 v11 v8 v9 v10 v11 v8 v9 v10 v11 (a) (b) (c)
Figure 3.5: A feasible feedback arc set(a), a minimal feedback arc set(b), and an optimal
(minimum) feedback arc set(c)for the subgraph σ5, highlighted by dotted red arcs. set is minimum, if its cardinality is minimum among all feedback arc sets of G. In this case, the feedback arc set is also said to be optimal.
Figure 3.5shows three different feedback arc sets for the strongly connected subgraph
σ5 of the example graph. In the first example, Figure 3.5(a), one of the arcs(v8, v9), (v9, v10), or (v10, v11) could be removed from the feedback arc set while still maintaining
feasibility. This is not the case for the feedback arc set depicted inFigure 3.5(b), however, its cardinality is not minimum among all feedback arc sets, asFigure 3.5(c)testifies. In fact, the last figure shows an optimal feedback arc set.
We denote the cardinality of an optimal feedback arc set by τG or simply τ, if no ambiguity arises.
If B is an (optimal) feedback arc set for a graph G, then BRis an (optimal) feedback arc set for the reverse graph GR. In particular, this implies that τG= τ
GR.
The optimal feedback arc set is the empty set if and only if the graph is acyclic.
3.3.2 Linear Orderings
A linear ordering πG of G= (V, A) is a bijective mapping πG : V → {0, . . . , n − 1} that assigns a unique LO position πG(v) to every vertex v ∈ V . An arc (u, v) is called forward, if
πG(u) < πG(v), and otherwise backward. Two vertices u, v ∈ V are said to be consecutive
with respect to πG, if their LO positions differ by exactly one, i. e. , |πG(u) − πG(v)| = 1. More generally, a set X ⊆ V of vertices is called consecutive with respect to πG, if maxu,v∈X|πG(u) − πG(v)| = |X| − 1.
Linear orderings are usually visualized by aligning the vertices horizontally and sorting them according to their LO positions in increasing order from left to right. Forward arcs are then drawn as arches above or on the same level as the vertices, while backward arcs appear below it. We denote by FπG and BπG the set of arcs that are
3.3 Feedback Arc Sets and Linear Orderings 45
v11 v10 v9 v8 v11 v9 v10 v8 v8 v9 v10 v11
(a) (b) (c)
Figure 3.6: Linear orderings of the subgraph σ5, such that the backward arcs in(a),(b),
and(c)each correspond to the respective feedback arc set shown inFigure 3.5.
v0
v1 v2
Figure 3.7:A feasible feedback arc set without corresponding linear ordering.
classified by πG as forward and backward, respectively. We omit the subscript and simply write π instead of πGif the graph it refers to is clear from the context.
In fact, linear orderings bear resemblance to topological sortings, but with the im- portant distinction that the latter do not allow for backward arcs. If we consider the subgraph restricted to the forward arcs, however, then π indeed is a topological sorting of this subgraph. Consequently, π defines an acyclic subgraph G⏐
⏐Fπof G along with a
feedback arc set, which corresponds exactly to the set of arcs classified as backward, Bπ. Note that if we consider instead the subgraph restricted to the backward arcs excluding loops, then the reversal of π again is a topological sorting. Hence, G⏐
⏐Bπ may contain
cycles of length at most one. We say that a vertex v ∈ V is a pseudosource with respect to a linear ordering π if v is a source in G⏐
⏐Fπ. Analogously, a vertex v ∈ V is called a
pseudosinkwith respect to a linear ordering π if v is a sink in G⏐ ⏐Fπ.
Figure 3.6uses the subgraph σ5of the example graph again and shows three linear orderings. The set of backward arcs in each of them corresponds to the feedback arc set depicted in the respective subfigure ofFigure 3.5.
A linear ordering uniquely identifies a feedback arc set Bπ and an acyclic arc set Fπ, whereas the opposite does not hold true in general. On the contrary, every topological sorting of G⏐
⏐Fπyields a linear ordering π′such that Bπ′ ⊆ Bπ, i. e. , the topological sorting
may “accidentally” have classified arcs of Bπas forward. This implies that, first, there may be multiple linear orderings that define the same feedback arc set and, second, not every feedback arc set B has a corresponding linear ordering π such that B = Bπ. For a
v8 v9 v10 v11 v11 v10 v9 v8 (a) (b)
Figure 3.8:Construction of linear ordering that corresponds exactly to the feedback arc
set depicted inFigure 3.5(a): reversal of non-loop backward arcs(a)and topological sorting(b). For illustration, reversed backward arcs are drawn below the vertex level. graph consisting only of a cycle of length k >1, for example, such as the graph shown inFigure 3.7, the set of all arcs is feasible, but we have already argued in the paragraph before last that for any linear ordering π, the subgraph G⏐
⏐Bπmust be acyclic except for
loops. If this requirement is met, however, a construction of π is possible, which is also exemplified inFigure 3.8.
Observation
If there is an acyclic arc set F ⊆ A of a graph G = (V, A) and the set B = A \ F does not contain a cycle of length k ≥ 2, a corresponding linear ordering π can be obtained such that B = Bπ by topologically sorting the graph that consists of
G⏐
⏐F plus the reverse of each arc in B that is not a loop.
The characteristic of inducing the same set of backward arcs yields an equivalence relation ∼B on the set of linear orderings of a graph. The equivalence class of π hence is the set containing all linear orderings π′ that induce exactly the same set of backward arcs as π, i. e. , [π]∼B = {π′ | Bπ′ = Bπ}. Using the above observation, [π]∼B can be constructed explicitly by compiling all topological sortings.
To ease notation, we define |π| = |Bπ|. We also adopt the terminology from sets and say that a linear ordering π is optimal, if its induced feedback arc set Bπis. To express that a linear ordering π is optimal, we denote it by π∗, i. e. , we always have |πG| = τG. Note∗ that all linear orderings in the equivalence class[π∗]
∼B of an optimal linear ordering π∗ are also optimal.
For a linear ordering π, we define the reverse linear ordering πRas πR: V → {0, . . . , n − 1} where πR(v) = n − 1 − π(v) for every vertex v ∈ V . This definition complies well with the definition of the reverse graph: If πGis a linear ordering of G, then πGRforms the
3.3 Feedback Arc Sets and Linear Orderings 47 corresponding linear ordering for GRsuch that BπGRequals the set of backward arcs induced by πGR on GR, i. e. , BπGR = BπG
R. In particular, this implies that πG is an optimal linear ordering of G if and only if πGRis an optimal linear ordering of GR. Note that also the reversion of a linear ordering is an involution, i. e. , πGRR = πG.
Finally, we simplify Bπ and Fπ to B and F, respectively, if the linear ordering that these sets are obtained from is unambiguous. In the context of a linear ordering π, B and F always refer to Bπand Fπ.
3.3.3 Forward Paths and Layouts
Given a linear ordering π of a graph G= (V, A), a path P is called forward path if every arc in P is forward.
For every vertex v ∈ V , π defines four (multi-)sets of arcs: F−(v), F+(v), B−(v),
B+(v), which contain the incoming forward, outgoing forward, incoming backward, and outgoing backward arcs of v according to π. Additionally, we use F(v) = F−(v) ∪
F+(v) and B(v) = B−(v) ∪ B+(v) if we do not want to distinguish between incoming
and outgoing arcs. We denote the cardinalities by f−(v) = |F−(v)|, f+(v) = |F+(v)|,
b−(v) = |B−(v)|, and b+(v) = |B+(v)|. Analogously, we set f(v) = f−(v) + f+(v) =
|F(v)|, and b(v) = b−(v) + b+(v) = |B(v)| to express the total number of forward
and backward arcs incident to v, respectively. For ease of notation, let φ[X], for φ ∈ {F−,F+,B−,B+,f−,f+,b−,b+}, be the canonical extension of the function φ to sets of
elements, e. g. , F−[X] = ⨄
v∈XF−(v) and f−[X] = |F−[X]|. The linear ordering π induces a layout L : V → N4
0 such that for each vertex v ∈ V , L(v) is the 4-tuple (f−(v), f+(v), b−(v), b+(v)).
Note that if we consider the reverse graph GRalong with the reverse linear ordering πR, then for every vertex v ∈ V , its incoming forward arcs according to π in G correspond to its outgoing forward arcs according to πRin GRand its outgoing forward arcs according to π in G correspond to its incoming forward arcs according to πRin GR. Likewise, its incoming backward arcs according to π in G correspond to its outgoing backward arcs according to πRin GRand its outgoing backward arcs according to π in G correspond to its incoming backward arcs according to πRin GR.
In order to improve comprehensibility, we use pictograms that visualize the layout as a shorthand notation for the4-tuples, depending on the degree of accuracy needed. In a pictogram, a simple arc ( ) always signifies exactly one arc, whereas an arc with a double shaft ( ) serves as a representative for a set of arcs. We use a dotted version
( ), if the represented arc set may be empty, otherwise, the lines are drawn solid. In the latter two cases, identical colors and drawing styles of two double shaft arcs indicate identical arc set cardinalities, provided that they are incident to the same vertex. (We would run out of drawing styles if we also kept this invariant across different vertices.) The pictogram , for instance, represents a vertex v with L(v) = (i, j, k, l), where
i≥ 0, j = k + 1, k ≥ 1, and l = 2.