• No results found

Time Complexity

In document Graph Drawing Beyond the Beaten Tracks (Page 114-124)

In this section, we analyze the runtime of our algorithm that constructs a (32(2∆− 1)6 − 1)-page queue layout for planar graphs of maximum degree ∆. We first reevaluate our algorithm for ∆-matched graphs:

Lemma 5.6. Let G be a ∆-matched graph with an ordered concentric representa- tion R with the properties described in Property P.2. Then a k-page queue layout of G with k ≤ 2∆ − 2 can be computed with O(n) basic computations (additions, comparisons) that involve a constant number of values each.

Proof. We consider the runtime of each of the steps performed by the algorithm in the proof of Lemma 5.4:

1. The nesting value for each edge in M is computed. Given the ordered concentric representation of G, this can be performed with O(|M|) = O(n) basic computations.

2. The matching value for each vertex in G is computed. Based on the nesting value of each edge in M, the matching values of leaves can be computed with O(|M|) basic computations. For the remaining vertices, a bottom-up traversal of T yields the corresponding matching values. Hence, we compute all matching values with O(n) basic computations.

3. The layer group of each vertex v can be easily deduced from the matching value mv (v ) which was computed before and the layer ‘(v ) that is defined by

R. Hence, all layer groups can be computed with O(n) basic computations.

4. The linear order of vertices can be computed based on a single traversal through each of the linear orders ≺ for 0 ≤ ‘ ≤ h which are defined by

R; see Conditions C.1–C.3. Hence, this step can be done with O(n) basic

computations.

5. The assignment of edges to pages of the queue-layout are determined on the layer groups of their endpoints which were already computed. Hence, for each edge, we only have to look up two values. In total, we need O(m) = O(n) basic computations.

We conclude that the algorithm in the proof of Lemma 5.4 needs O(n) basic computations.

The time critical step in the computation of a queue layout of a general planar graph G of maximum degree ∆ is Step 2, that is, the construction of G2. Namely,

for a level edge (u; v ) on layer ‘, we introduce new trees Tu and Tv on ∆Θ(‘)

However, a BFS-tree of a planar graph may have height Θ(n). So in order to compute a queue layout of G efficiently, we cannot explicitly introduce such trees. Instead, we assign weights to level edges of G1 and compute a (2∆ − 2)-page

queue layout of G1 directly.

In fact, the purpose of such trees is the following: Consider two level edges (u; v ) and (u0; v0) on layer ‘. If (u; v ) nests (u0; v0) in ≺‘, replacing (u; v ) with

Tu, Tv and Mu;v ensures that g (u) = g (v ) > g (u0) = g (v0). This is because each

of the edges in Mu;v nests each edge of Mu0;v0 in ≺0 while |Mu;v| = (∆ − 1). We can achieve the same effect as follows: Instead of replacing each level edge (u; v ) with Tu, Tv and Mu;v we route it outside of layer 0. If we perform this operation

first on edges on layers with lower indices, this can be done in a single pass of the level edges on each of the layers. Then, we introduce a weight w (u; v ) equal to |Mu;v|. Since the new routing of edge (u; v ) corresponds to the routing of Tu, Tv

and Mu;v, the piece of (u; v ) outside of C0 nests everything that Mu;v would have

nested before. Moreover, if we perform this operation on all level edges, each level edge has a piece outside of C0.

We then update the computation of nesting values and matching values in Step 3 as follows: Edge (u; v ) has nesting value 0 if and only if its piece outside of C0 is not nested by any piece of another edge (u0; v0) outside of C0. Otherwise,

let (u0; v0) be the edge of maximum nesting value which has a piece outside of C 0

that nests the piece of (u; v ). Then, we set n((u; v )) = n((u0; v0)) + w (u0; v0). As a result, each vertex of G1 is assigned the same matching value as it would have

been assigned if we replaced level edges as discussed before. We point out that the largest nesting value is in O(∆n) since the height of the BFS-tree is bounded by

the number of vertices. Hence, we can represent all nesting and matching values with a O(n log ∆) length binary string. Since we only use standard operations on such values (namely, addition and comparison), each such operation can be performed in time O(n log ∆).

Based on the matching and nesting values we can then compute a (2∆ − 2)- page queue layout using the linear order defined by Conditions C.1–C.3. As a result, we obtain the following:

Theorem 5.2. Let G be a planar graph of maximum degree ∆. Then, a k-page queue layout of G with k ≤ 32(2∆−1)6−1 can be computed in time O(n2log ∆).

Proof. We reconsider the steps of the algorithm supporting Theorem 5.1:

1. In order to construct G1 in Step 1, we compute an ordered concentric rep-

resentation R which can be done in time O(n) by Lemma 5.3. Then, we subdivide all interlevel edges in time O(n) since they are uniquely defined by

R. Finally, we obtain G1 by splitting each of the level edges at most twice.

Those edges are again well-defined by R and can be found in time O(n). 2. We use the new version of Step 2 as described above. Namely, we reroute

layers with lower indices. Hence, we traverse each layer once achieving time O(n) in total. Then, we assign weights to each level edge. As discussed above, the weights of level edges can be represented with O(n log ∆) bits each, hence, this takes time O(n2log ∆).

3. In Step 3, we first compute the nesting and matching values as described above. For nesting values, we have to make a pass over all level edges and in each step deal with a constant number of values representable by O(n log ∆) bits each. Hence, this takes time O(n2log ∆) time. Then, we calculate the

matching values in a bottom-up traversal during which O(n) calculations are performed. As a result, all matching values can be computed in time O(n2log ∆). We then use the remaining steps from Lemma 5.4 to compute

a (2∆ − 2)-page queue layout of G1. Since each basic computation may

involve numbers of size O(n log ∆) in bit representation, this may take time O(n2log ∆). Finally, we use Lemma 5.2 to compute the queue layout of G.

While the time complexity of Lemma 5.2 is not explicitly stated in [81], it is easy to see that it can be performed in time O(n) when there are only a constant number of subdivision vertices per edge. In particular, the main operation performed in the lemma is the computation of a track layout of a subgraph of G [79] which is repeated a number of times which is logarithmic in the constant number of subdivision vertices.

Since we proved that each of the three steps can be performed in total time O(n2log ∆), the theorem follows.

Monotone Arc Diagrams with

few Biarcs

Only subhamiltonian planar graphs, that is, subgraphs of planar graphs with Hamil- tonian cycles, admit a 2-page stack layout [40]. In general, up to four pages may be required for visualizing planar graphs in a stack layout [30, 161]. However, even 3-page stack layouts admit no nice embedding in the plane, since two pages have to use the same half-plane delimited by the spine which can introduce many intersections.

A different approach to visualize graphs with vertices restricted to a line are the so-called arc diagrams in which edges are realized on two pages, i.e., a half-plane below and a half-plane above the spine. In order to realize all planar graphs, some edges have to be drawn as biarcs, that is, a sequence of a segment above and a segment below the spine. In fact, all biarcs can even be down-up monotone, i.e., monotone with respect to the spine such that the left segment is below the spine. Arc diagrams find applications in circular layouts [65] and point set embed- dability problems, in particular, for the cases where edges are drawn as circular arcs [15] as well as 1-bend polylines [89, 130]. In the latter application, specifically down-up monotone arc diagrams are required. In either scenario, the number of biarcs in the arc diagram affects the quality of the drawing: In circular layouts, biarcs become curves that cross the circle to which vertices are restricted, while the number of points in universal point sets is tied to the number of biarcs that may be required in an arc diagram. As a result, the number of required biarcs has been investigated in the literature [51, 67, 120]. The best known upper bounds are b(n − 3)=2c for general plane arc diagrams and n − 4 for plane down-up monotone arc diagrams [51]. The lower bound for the required number of biarcs on the other hand is b(n − 8)=3c in both the down-up monotone and general case.

It is noteworthy, that monotone arc diagrams are not as well understood as general arc diagrams while they are specifically required in some applications. In

this chapter1, we provide more insight in this regard by showing the following:

Theorem 6.1. Every planar graph admits a plane down-up monotone arc diagram with at most b15=16n − 5=2c biarcs that can be computed in linear time.

As a side result we describe a SAT formulation, that is based on [39], with which we verified the following:

Observation 6.1. No Kleetope based on a triangulation with up to 14 vertices requires more biarcs in its down-up monotone arc diagrams compared to its general arc diagrams even if the outer face is arbitrarily prescribed.

In the remainder of the chapter, we first describe an algorithm that asserts Theorem 6.1 in Sections 6.1 to 6.4. More precisely, in Section 6.1, we provide an overview of our algorithm that inserts vertices one at a time. Here, we also introduce the distinction between default steps of the algorithm and more complex steps in which vertices are inserted above so-called open configurations. Then, we discuss the default steps in Section 6.2 and the steps involving open configurations in Section 6.3. We summarize the proof of Theorem 6.1 in Section 6.4. Afterwards, we shift our attention to the SAT formulation in Section 6.5.

6.1

Overview of the Algorithm

Our algorithm is an elaborate improvement of the algorithm by Cardinal et al. [51]. We assume w.l.o.g. that the input graph of our algorithm is a triangulation; otherwise we can triangulate it. We insert the n vertices v1; : : : ; vn according

to a canonical ordering. Recall that Gi denotes the graph consisting of vertices

v1; : : : ; vi while Ci is the outer face of the drawing of Gi. In addition, d egGi(v )

denotes the degree of vertex v in Gi.

We will pay close attention to the part of the outer face Ci −1 of the drawing

of graph Gi −1 that is covered by vertex vi. More formally, we say that vi covers

an edge e (or vertex v , respectively) if and only if e (v , respectively) is an edge (vertex, respectively) on Ci −1 but not on Ci. In addition, we distinguish two types

of proper arcs, namely mountains (above the spine) and pockets (below the spine). Every edge that is not a proper arc, will be realized as a down-up biarc. In order to bound the number of biarcs created by our algorithm, we require that one credit is allocated to each biarc. When inserting vertex vi, we also introduce ¸

credits to the drawing that can either be allocated to biarcs or stored on edges whose endpoints are on the outer face Ci so that they can be used later.

The following invariants hold after inserting vertex vi for the drawing of Gi:

I.1 Every edge is either drawn as a proper arc or as a down-up biarc.

vi p‘ pr ‘i ri (a) vi p‘ pr ri ‘i (b)

Figure 6.1: Inserting a vertex vi onto a pocket costs at most 1 − ı credits if

d egGi(vi) ≥ 4: (a) If ri 6= pr, the credit from pocket (p‘; pr) reduces the cost to at

most 1 − ı. (b) If ri = pr, at least one pocket (or mountain) left of p‘ is covered.

I.2 Let w1 = v1; w2; : : : ; wp−1; wp= v2 denote the vertices of Ci ordered from left

to right along the spine. Then, edge (v1; v2) forms the lower envelope of the

drawing of Gi while the path (w1; w2; : : : ; wp−1; wp) forms the upper envelope.

All edges of Ci are drawn as proper arcs.

I.3 Every mountain whose left endpoint is part of Ci is allocated 1 credit.

I.4 Every pocket on the outer face Ci is allocated ı credits, for some constant

ı ∈ [0; 1).

I.5 Every biarc in Gi is allocated 1 credit.

In most cases, we do not discuss explicitly that we maintain the invariants. We visualize the assignment of credits to edges in the figures with coin symbols and for ı and a full credit, respectively. In addition, if we cover an edge that was assigned credits in Gi −1 but not in Gi, we visualize that some unused credit can be

reallocated with green coin symbols and for ı and a full credit, respectively. In most cases, we will insert vertex vi above one of the edges it covers, i.e.,

between its leftmost neighbor ‘i and its rightmost neighbor ri on Ci −1. The fol-

lowing two lemmas are directly derived from the two different cases (some covered edge is a pocket or no covered edge is a pocket) that can arise in the algorithm by Cardinal et al. [51] and give a first bound for ¸.

Lemma 6.1. If at least one pocket is covered by vi, vertex vi can be inserted for

a cost c ≤ 1 such that Invariants I.1 to I.5 hold. If d egGi(vi) ≥ 4, then c ≤ 1 − ı.

Proof. Vertex vi is always placed onto the rightmost covered pocket (p‘; pr) while

all incident edges are drawn as proper arcs; see Fig. 6.1. In particular, edges (p‘; vi) and (vi; pr) are drawn as pockets while all remaining new edges are drawn

as mountains which satisfies Invariants I.1 and I.2.

If (vi; pr) is not covered, we reallocate the ı credits from (p‘; pr) to it to

maintain Invariant I.4. Otherwise, consider a vertex r to the right of pr incident

v

i

m

m

r

i

r

i (a) vi ‘i m ri mr′ (b)

Figure 6.2: (a) Inserting a vertex vi on top of mountains only costs at most 1 + ı

credits. (b) If d egGi(vi) ≥ 4, the cost can be reduced to 5 − d egGi(vi).

On the other hand, since (p‘; pr) is the rightmost pocket, the left neighbor of r

on Ci −1 is connected to r with a mountain mr. By Invariant I.3, mr has a credit

which we can reallocate to (vi; r ).

In addition edge (‘i; vi) may be either realized as a mountain or as a pocket. If it

is realized as a mountain, we have to allocate one credit on it by Invariant I.3, while if it is realized as a pocket, we have to allocate ı credits on it by Invariant I.4. It might not be possible to redistribute these credits from covered edges, i.e., c ≤ 1. This suffices to prove the part of the lemma where d egGi(vi) < 4.

If ri 6= pr, pocket (vi; pr) is not on the outer face and hence does not need

to carry ı credits. Then, the ı credits from edge (p‘; pr) can be reallocated and

c ≤ 1 − ı; see Fig. 6.1a. If ri = pr and d egGi(vi) ≥ 4, there exists at least

one covered edge e on the outer face whose right endpoint is p‘ that we did not

consider so far. Since the left endpoint of e is covered by vi, we can reallocate its

credits; see Fig. 6.1b. By Invariants I.3 and I.4, e was allocated at least ı credits in Ci −1 and we can insert vi for c ≤ 1 − ı.

So far, we discussed the case where vi covers a pocket. If this is not the

case, vertex vi has no access to the spine between its leftmost neighbor ‘i and its

rightmost neighbor ri and biarcs have to be created. In such a case, one mountain

m of the outer face will be pushed down, that is, m and all mountains that have the

same left endpoint as m are transformed into down-up biarcs. By Invariant I.3 each of those mountains carries a credit so pushing down m does not violate Invariant I.5. The following lemma estimates the cost for inserting vi when covering only

mountains:

Lemma 6.2. If only mountains are covered by vi, vertex vi can be inserted for a

cost c ≤ 1 + ı such that Invariants I.1 to I.5 hold. If d egGi(vi) ≥ 4, the cost is c ≤ 5 − d egGi(vi).

Proof. First, consider the case where d egGi(vi) ≤ 3. Here, we push down the

leftmost mountain (m‘; mr) and place vi between m‘ and mr and realize edge

(a) (b)

Figure 6.3: A repeatable configuration that (a) creates many biarcs when using only down-up biarcs and (b) creates only one biarc when using only up-down biarcs.

The credits for newly created biarcs are already allocated to the corresponding edges by Invariant I.3. In order to satisfy Invariant I.4, we have to allocate ı credits to (m‘; vi). In addition, we have to allocate 1 credit to each mountain

incident to vi. We have to pay the credit for mountain (vi; mr). If ri 6= mr, we

have d egGi(vi) = 3 and we also cover mountain (mr; ri) and can reallocate the

credit to the new mountain (vi; ri); see Fig. 6.2a. Therefore, c ≤ 1 + ı.

Second, consider the case where d egGi(vi) ≥ 4. Here, we instead push down

the rightmost mountain (m0

‘; m

0

r) and place vi between m‘0 and m

0

r and realize edge

(m0; vi) as a pocket and all other edges incident to vi as a mountain; see Fig. 6.2b.

Here, we have to allocate a credit to new mountains (‘i; vi) and (vi; ri). However,

there are at least d egGi(vi) − 3 more covered mountains whose left endpoints got

covered as well. When redistributing the credits of these mountains, we achieve a cost of 2 − (d egGi(vi) − 3) = 5 − d egGi(vi).

It is noteworthy that in the proofs of Lemmas 6.1 and 6.2, we only reallocate credits from arcs on Ci −1. However, if we cover the left endpoint of a mountain

not on Ci −1 there may be some slack. Also observe that so far we can only say

that ¸ ≤ 1 + ı. By setting ı = 0, we obtain the result from Cardinal et al. [51]. In order to reduce the number of biarcs, we want to choose ı > 0 to improve the result from Lemma 6.1. This will prove useful as in the critical case of Lemma 6.2, we create new pockets whose ı credits may be reallocated in a future step.

We also point out that it is impossible that the case d egGi(vi) < 4 continually

occurs due to the density of maximal planar graphs. However, it is possible that a sequence of degree two vertices that becomes stacked on top of mountains can occur in the canonical ordering; see Fig. 6.3a. In such a case, for every inserted vertex a biarc is created and the worst-case cost of 1 + ı is achieved. However, if we would adopt a symmetric scheme with up-down biarcs, we would only end up with one created biarc for the first inserted vertex; see Fig. 6.3b.

In order to use this behavior, we actually create two drawings, called forward (where we only use down-up biarcs) and reverse (where we only use the symmetric up-down biarcs). In the forward drawing −→Γi of Gi, we use the version of Invari-

ants I.1 and I.3 as stated before while in the reverse drawing ←−Γi of Gi we use

symmetric formulations. More precisely, in ←−Γi, we use up-down biarcs instead of

down-up ones while mountains whose right endpoints (in contrast to the left ones) are part of Ci are allocated 1 credit. From the two resulting drawings, we choose

the one with fewer biarcs after inserting all vertices. Note that Ci can be drawn

differently in −→Γi and

←−

Γi which will give rise to many different cases later.

As mentioned before, we want to claim later that on average we can save the credits allocated to one pocket of the outer face. Hence, we will show in the remainder of the description of the algorithm that we can insert vertices at an average cost ¸ = 2 − ı. Unfortunately, this may not be the case for a single vertex that is considered in isolation: Consider a vertex vi of degree three that

is inserted above two mountains in both −→Γi −1 and

←−

Γi −1; see Fig. 6.4b. In both

drawings, we tightly achieve the cost of 1 + ı credits as stated in Lemma 6.2. Hence, we pay 2 + 2ı for both drawings, which is 3ı credits more than ¸. In fact, it is not possible to improve this result here when placing vi between ‘i and

ri which however is necessary to maintain Invariant 2.

We solve this problem by introducing open configurations. An open configu- ration C consists of up to two adjacent vertices c1 and possibly c2 on the outer

face and their incident edges where the insertion of c1 and possibly c2 could not be

covered by the ¸ or possibly 2¸ credits introduced when inserting c1 and possibly c2. Each open configuration C is associated with a debt d (C) which is the amount

In document Graph Drawing Beyond the Beaten Tracks (Page 114-124)