Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 1, no. 1, pp. 1–25 (1997)
2-Layer Straightline Crossing Minimization: Performance of Exact and Heuristic Algorithms Michael J¨ unger Institut f¨ ur Informatik Universit¨at zu K¨ oln http://www.informatik.uni-koeln.de/ls juenger/
[email protected]
Petra Mutzel Max-Planck-Institut f¨ ur Informatik Saarbr¨ ucken http://www.mpi-sb.mpg/∼mutzel/
[email protected] Abstract We present algorithms for the two layer straightline crossing minimization problem that are able to compute exact optima. Our computational results lead us to the conclusion that there is no need for heuristics if one layer is fixed, even though the problem is NP-hard, and that for the general problem with two variable layers, true optima can be computed for sparse instances in which the smaller layer contains up to 15 nodes. For bigger instances, the iterated barycenter method turns out to be the method of choice among several popular heuristics whose performance we could assess by comparing their results to optimum solutions.
Communicated by P. Eades: submitted August 1996; revised November 1996.
Research supported in part by DFG-Grant Ju204/7-1, Forschungsschwerpunkt “Effiziente Algorithmen f¨ ur diskrete Probleme und ihre Anwendungen” and by ESPRIT LTR Project no. 20244 – ALCOM-IT
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
1
2
Introduction
Directed graphs are widely used to represent structures in many fields such as economics, social sciences, mathematics and computer science. A good visualization of structural information allows the reader to focus on the information content of the diagram. Examples are entity-relationship diagrams, PERTdiagrams, or any flow diagram. A common method for drawing directed graphs has been introduced by Sugiyama et al. [14] and Carpano [1]. In the first step, the vertices are partitioned into a set of k levels, and in the second step, the vertices within each level are permuted in such a way that the number of crossings is small. In this paper we focus on the second step. Let us assume that we are given a k-layered network, i.e., a graph G = (V, E) = (V1 , V2 , . . . , Vk , E) with vertex sets V1 , . . . , Vk , V = V1 ∪ V2 . . . ∪ Vk , Vi ∩ Vj = ∅ for i 6= j, and an edge set E connecting vertices in levels Vi and Vj with i 6= j (1 ≤ i, j ≤ k). Vi is called the i-th layer. A k-layered network is drawn in such a way that the vertices in each layer Vi are drawn on a horizontal line Li with y-coordinate k − i, and the edges are drawn as straight lines. Essentially, a k-layered network is a k-partite graph that is drawn in a special way. Even for 2-layered graphs the straightline crossing minimization problem is NP-hard [9]. The problem consists of aligning the two shores V1 and V2 of a bipartite graph G = (V1 , V2 , E) on two parallel straight lines (layers) such that the number of crossings between the edges in E is minimized when the edges are drawn as straight lines. Let n1 = |V1 |, n2 = |V2 |, m = |E|, and let N (v) = {w ∈ V | e = {v, w} ∈ E} denote the set of neighbors of v ∈ V = V1 ∪ V2 in G. Any solution is obviously completely specified by a permutation π1 of V1 and a permutation π2 of V2 . k = 1 if πk (i) < πk (j) and 0 otherwise. Thus πk (k = 1, 2) For k = 1, 2 let δij nk is uniquely characterized by the vector δ k ∈ {0, 1}( 2 ) . Given π and π , the 1
2
number of crossings is C(π1 , π2 ) = C(δ 1 , δ 2 ) =
nX 2 −1
n2 X
X
X
1 2 1 2 δkl · δji + δlk · δij
(1)
1 2 1 2 δkl · δji + δlk · δij .
(2)
i=1 j=i+1 k∈N (i) l∈N (j)
=
nX 1 −1
n1 X
X
X
k=1 l=k+1 i∈N (k) j∈N (l)
In practice, the crossing minimization problem for k-layered networks is reduced to a series of 2-layer straightline crossing minimization problems in the following way. In a preprocessing step, we add artificial vertices to the layers Li for all the edges traversing Li (i = 2, . . . , k − 1). For i = 1, 2, . . . , k − 1, we solve the 2-layer crossing minimization problem for the two adjacent layers Li and Li+1 with Li fixed, repermuting the vertices on layer Li+1 . Then we go backward, fixing layer Li and repermuting the vertices on layer Li−1 for i = k, k − 1, . . . , 2. The heuristic consists of repeating these two loops until no more improvement is obtained.
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
3
Unfortunately, the 2-layer straightline crossing minimization problem with the permutation of one layer fixed is also NP-hard [7]. Therefore, a lot of effort went into the design of efficient heuristics, for the version in which one permutation is fixed as well as for the general case (see, e.g., [16, 14, 6, 8, 4, 2] and [15]). Eades and Kelly [6] observe that the computation of true optima would be desirable in order to assess the performance of various heuristics, however, they believe that the NP-hardness of the problem renders such an experimental evaluation impractical. In this paper, we would like to demonstrate that, if one permutation is fixed, it is indeed possible to compute the exact minima in surprisingly short computation times. In section 2, we outline our algorithm which transforms the problem to a linear ordering problem that is subsequently solved via the branch and cut method. In section 3, we give computational results that allow us to assess the performance of several popular heuristics accurately. Assume the permutation π1 of V1 is fixed. For each pair of nodes i, j ∈ V2 , i 6= j, we define cij to be the number of crossings between edges incident with i and edges incident with j if π2 is such that π2 (i) < π2 (j). Then L=
nX 2 −1
n2 X
min{cij , cji }
i=1 j=i+1
is a trivial lower bound on the number of crossings. One observation in our experiments was that this trivial lower bound is surprisingly good. In section 4, we utilized this fact and the branch and cut algorithm of section 2 for the design and implementation of a program that solves the general two layer straightline crossing minimization problem to optimality. 7
2
1
4
3
8
5
6
4
2
1
3
5
6
7
8
a
b
c
d
e
f
g
h
e
c
h
a
d
f
g
b
(a)
(b)
Figure 1: Crossing minimal drawings with (a) fixed lower layer and (b) both layers free Figure 1 demonstrates that the number of crossings can indeed be considerably less if both layers can be freely permuted. The left drawing was given in [14] with fixed lower layer, [14] obtained the shown drawing with 48 crossings that we could show to be optimum. The right drawing is the optimum when both layers can be freely permuted. It has only 19 crossings.
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
4
As was to be expected, two sided crossing minimization can be done only for small instances. For large instances, we adopt the common method that consists of fixing the first layer, “optimizing” the second, fixing the found permutation of the second, “optimizing” the first, etc., back and forth, until the crossing number is not reduced anymore. We follow this iterative approach both using the heuristics of section 3 as well as the exact algorithm. The results are somewhat surprising, e.g., using the barycenter heuristic rather than exact one-sided crossing minimization yields slightly better results.
2
Branch and Cut for One Sided Crossing Minimization
The one sided straightline crossing minimization problem consists of fixing a permutation π1 of V1 and finding a permutation π2 of V2 such that the number of straightline crossings C(π2 ) = C(δ 2 ) =
nX 2 −1
n2 X
X
X
1 2 1 2 δkl · δji + δlk · δij
i=1 j=i+1 k∈N (i) l∈N (j)
is minimized. Let
X
cij =
X
1 δlk
k∈N (i) l∈N (j)
denote the number of crossings among the edges adjacent to i and j if π2 (i) < π2 (j). Then C(π2 ) = C(δ 2 )
=
nX 2 −1
n2 X
2 2 cij δij + cji (1 − δij )
(3)
i=1 j=i+1
=
nX 2 −1
n2 X
2 (cij − cji )δij +
i=1 j=i+1
nX 2 −1
n2 X
cji .
(4)
i=1 j=i+1
2 and aij = cij − cji we solve the linear ordering problem For n = n2 , xij = δij
(LO) minimize
Pn−1 Pn i=1
j=i+1
aij xij
0 ≤ xij + xjk − xik ≤ 1 0 ≤ xij ≤ 1 xij integral
(5) for 1 ≤ i < j < k ≤ n (6) for 1 ≤ i < j ≤ n (7) for 1 ≤ i < j ≤ n.
(8)
Pn−1 Pn If z is the optimum value of (LO), z + i=1 j=i+1 cji is the minimum number of crossings. The constraints of (LO) guarantee that the solutions correspond indeed precisely to all permutations π2 of V2 . Furthermore, it can be shown that the “3-cycle constraints” are necessary in any minimal description of the feasible
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
5
solutions by linear inequalities, if the integrality conditions are dropped. The NP-hardness of the problem makes it unlikely that such a complete linear description can be found and exploited algorithmically. Further classes of inequalities with a number of members exponential in n that must be present in a complete linear description of the feasible set, are known, and some of them can be exploited algorithmically. For the details see [12]. When the integrality conditions in (LO) are dropped, only 2 n2 hypercube inequalities and 2 n3 3-cycle inequalities are left that define a relaxation of (LO) which has been proven very useful in practical applications. In [10] a branch and cut algorithm for (LO) is proposed that solves this relaxation with a cutting plane approach, since writing down all 3-cycle inequalities, even though taking only polynomial space, and solving the corresponding linear program, is not practical for space reasons. Rather, the algorithm starts with the hypercube constraints that are handled implicitly by the LP-solver, and iteratively adds violated 3-cycle constraints and deletes nonbinding 3-cycle constraints after an LP has been solved, until the relaxation is solved. If the optimum solution is integral, the algorithm stops, otherwise it is applied recursively to two subproblems in one of which a fractional xij is set to 1 and in the other set to 0. In [11] such a branch and cut approach could be used to find optimum linear orderings with n up to 60 in an application involving input-output matrices that are used in economic analysis. For the many details and the inclusion of further useful inequalities in the cutting plane part, see [10]. A new implementation of the algorithm is used in our computational experiments. It is written in C and uses the CPLEX [3] software for solving the linear programming relaxations coming up in the course of the computation.
3
One Sided Crossing Minimization
The fact that we are able to compute optimum solutions allows us to assess the quality of various popular heuristics for one-sided two layer straightline crossing minimization experimentally. Our computational comparison includes the following heuristics: the barycenter heuristic by [14], the median heuristic by [8], the stochastic heuristic by [4], the greedy-insert heuristic by [6], the greedy-switch heuristic by [6], the split heuristic by [6], and the assign heuristic by [2]. The barycenter heuristic [14] and the median heuristic [8] are the most popular ones. They are also called “averaging heuristics”, since they simply compute the “average position”, i.e., the barycenter or median, for each vertex and sort the vertices according to these numbers. Surprisingly, these simple heuristics turned out to be among the most promising ones. The stochastic heuristic [4], originally designed for permuting both layers, generates a series of “assessment number matrices” while greedily placing a vertex in layer 1 or layer 2. The assessment numbers are based on some frequency numbers arising from stochastic considerations on the complete bipartite graph. The greedy-insert heuristic [6] proceeds by successively choosing the next vertex v to be the one which mini-
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
6
mizes the number of crossings that edges adjacent to v make with edges adjacent to vertices to the left of v. The greedy-switch heuristic [6] passes over all consecutive pairs of vertices and switches them if it would decrease the number of crossings. This is done until no more switching takes place. The split heuristic chooses a pivot vertex v, and places every other vertex to the left or right of v according to whether it would make fewer crossings. This step is applied recursively to order the left hand set and the right hand side of v. The assignment heuristic [2] reduces the problem to an assignment problem. The entries in the assignment matrix are computed based on the adjacency matrix and on a four dimensional matrix representing the complete bipartite graph. In order to gain confidence in the correctness of our implementations, we repeated the computational tests in [6]. We could reproduce their results accurately. Also the results in [2] on the assign heuristic are in line with ours. There are no published computational results for the stochastic heuristic, but a personal communication with the author [5] confirms the correctness of our implementation. All subsequent figures and tables use the following notation: – ni : Number of nodes on layer i for i = 1, 2 – m: Number of edges – Lowerbound: The trivial lower bound for the number of crossings – Minimum: The minimum number of crossings (computed by the branch and cut algorithm) – Barycenter: The number of crossings found by the barycenter heuristic – Median: The number of crossings found by the median heuristic – Stoch: The number of crossings found by the stochastic heuristic – Gre-ins: The number of crossings found by the greedy-insert heuristic – Gre-swi: The number of crossings found by the greedy-switch heuristic – Split: The number of crossings found by the split heuristic – Assign: The number of crossings found by the assign heuristic For each type of graph, we measured the following three numbers: the average number of crossings taken over all sampled instances of this type, the relative size of this number in percentage of the minimum number of crossings, and the average running time in seconds on a SUN Sparcstation 10. All samples are generated by the program random bigraph of the Stanford GraphBase by Knuth [13]. The generators are hardware independent and are available from the authors so that exactly the same experiments can be run by anyone who is interested.
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
Lowerbound Minimum Barycenter Median Stoch Gre-ins Gre-swi Split Assign
110.5 110 109.5 109 108.5
107.5 107 106.5 106 105.5 105 104.5 104 103.5 103
Percentage off Optimum 100 (SOL / OPT)
108
102.5 102 101.5 101 100.5 100 99.5 0.1
0.2
0.3
0.4
0.5 0.6 Density
0.7
0.8
0.9
Figure 2: Results for 100 instances on 20 + 20 nodes with increasing density
7
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
0.8
Minimum Barycenter Median Stoch Gre-ins Gre-swi Split Assign
0.75 0.7 0.65
0.55 0.5 0.45 0.4 0.35
Time in Seconds on a SPARC10
0.6
0.3 0.25 0.2 0.15 0.1 0.05 0 0.1
0.2
0.3
0.4
0.5 0.6 Density
0.7
0.8
0.9
Figure 3: Time for 100 instances on 20 + 20 nodes with increasing density
8
185 180 175 170 165 160 155 150
Percentage off Optimum 100 (SOL / OPT)
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
Lowerbound Minimum Barycenter Median Stoch Gre-ins Gre-swi Split Assign
145 140 135 130 125 120 115 110 105 100
10
20
30
40 50 60 70 Number of Nodes per Layer
80
90
100
Figure 4: Results for 10 instances of sparse graphs with increasing size
9
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
9 8.5 8 7.5 7 6.5
Minimum Barycenter Median Stoch Gre-ins Gre-swi Split Assign
Time in Seconds on a SPARC10
9.5
6 5.5 5 4.5 4 3.5 3 2.5 2 1.5 1 0.5 0 10
20
30
40 50 60 70 80 Number of Nodes per Layer
90
100
Figure 5: Time for 10 instances of sparse graphs with increasing size
10
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
11
In Figures 2 and 3, we give the results for “20+20-graphs”, i.e., bipartite graphs with 20 nodes on each layer and various fixed numbers of edges chosen uniformly and independently from the set of all possible edges. Each average is taken over 100 samples. The most surprising fact is perhaps that the exact computation by the branch and cut algorithm is faster than many of the heuristics. Only the barycenter and the median heuristic are between two to four times faster than the exact algorithm. The stochastic and assign heuristic take about the same time as the exact algorithm, whereas the split and the two greedy heuristics take much longer (see Fig. 3). The best results are obtained by the split heuristic. But also the results of the barycenter and the stochastic heuristic are quite good. For sparse graphs, the assign and the greedy-switch heuristic are quite far away from the optimum solution (10%, resp., 50%), whereas they achieve good solutions for dense graphs. However, in automatic graph drawing the graphs are usually sparse. The median heuristic is between 1% and 14 % away from the optimum solution. Greedy-insert shows the worst behaviour. Surprisingly, the lower bound is very close to the optimum solution, even in the sparse case (see Fig. 2). In Figures 4 and 5, we concentrate on sparse instances in which, on the average, every node has two adjacent edges. We believe that such instances are among the most interesting in practical applications. It turns out that the stochastic, the split, and the barycenter heuristic perform very well in terms of quality (1%-4% off the optimum solution), however, the split heuristic takes roughly the same time as the branch and cut computation up to size 80+80, whereas the barycenter heuristic obtains results of similar quality as split, but much faster. The assign and the median heuristic are about 10% away from the optimum solution. Greedy-insert and greedy-switch behave worst for sparse graphs (see Fig. 4). For n = 60, the ranking of the heuristics with respect to increasing time is barycenter, median, greedy-insert, assign, greedy-switch, stochastic, exact, and split (see Fig. 5). In Table 1, we repeat an experiment by Dresbach [4] for instances defined by Warfield [16] as follows: For k = 3, 4, 5, 6, 7, 8 we let n1 = k, n2 = 2k − 1, and the adjacency matrix of the bipartite graph is a n1 × n2 matrix whose rows are labelled 1, 2, . . . , k, whose columns are labelled 1, 2, . . . , 2k − 1, and column j contains j in k-digit binary notation. Layer 1 is fixed and layer 2 is “optimized”. Again, it turns out that barycenter is the fastest method with excellent quality solutions. The results of the stochastic heuristic, the barycenter and the split heuristic are very close to the optimum solution. Up to size 7+127, the branch and cut algorithm needs only moderate computation time, for the instance 8+255 it is not competitive in terms of time, but we found it surprising that such a big linear ordering instance with n = 255 could be solved at all. The branch and cut algorithm was the only method that found the true optima for k ≥ 6, whereas for 3 ≤ k ≤ 5, the fact that the optimum value equals the value of the trivial lower bound seems to indicate that these instances are not hard.
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997) n1 n2 3
7
m
Low
Min
12
8
8
Bary Median Stoch Gre-ins Gre-swi 8
13
8
11
100.00 100.00 162.50 100.00 137.50 4
15
32
95
31
80
756
63
192
4998
29745
8
100.00 100.00 100.00
0.00
0.00
0.02
0.00
0.00
0.02
0.00
95
127
95
122
98
95
101
103.16 100.00 106.32
0.00
0.00
0.00
0.03
0.02
0.05
0.07
0.02
756
758
922
756
934
804
760
780
106.35 100.53 103.17
0.03
0.00
0.03
0.18
0.08
0.40
0.43
0.08
5002
5015
5818
5004
6023
5523
5043
5120
100.00 100.26 116.31 100.04 120.41 7 127 448
Assign
8
95
100.00 100.27 121.96 100.00 123.55 6
Split
0.00
100.00 100.00 133.68 100.00 128.42 5
8
110.42 100.90 102.36
0.73
0.05
0.07
1.38
0.38
2.87
2.65
0.38
29778
29883
33641
29841
35152
34366
30086
30386
100.00 100.35 112.97 100.21 118.05
115.41 101.03 102.04
20.50
20.20
0.17
0.20
9.02
1.98
12
24.30
2.18
8 255 1024 165375 165602 166098 183342 165824 192633 202957 167546 168056 100.00 100.30 110.71 100.13 116.32
122.56 101.17 101.48
7200.00
147.00 189.00
0.95
1.08
67.90
7.33
21.50
Table 1: Results for Dresbach instances
4
Two Sided Crossing Minimization
The trivial lower bound on the number of crossings that turned out to be excellent in our previous experiments, can obviously be adapted to partial orderings rather than complete orderings (permutations) on one of the layers. This encouraged us to devise a simple branch and bound algorithm for the general two layer straightline crossing minimization problem in which both π1 and π2 must be determined. Namely, we enumerate all permutations π1 (without loss of generality we can assume |V1 | ≤ |V2 |, V1 = {1, 2, . . . , n}) as follows: Initially all v ∈ V1 are unfixed. At depth l in a depth-first-search, l − 1 nodes of V1 are fixed in positions 1, 2, . . . , l − 1. Then the first unfixed node in the canonical ordering of V1 is fixed at position l, and the trivial lower bound L is computed for the resulting partial ordering. If L is greater than the value of the best known solution, the next unfixed node in the canonical ordering of V1 is fixed at position l, else we move to position l + 1, if l < n, and otherwise (l = n) we call the branch and cut algorithm to determine an optimum ordering of V2 and update the best known solution, if necessary. Backtracking, i.e., moving from position l to position l − 1 occurs whenever the list of unfixed nodes at depth l in the enumeration tree is exhausted. Before the enumeration is entered, a heuristic solution is determined in order to initialize the best known solution. A good initial solution makes the enumeration tree smaller. We use this algorithm to determine optimum solutions for 10+10 graphs
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
13
with increasing edge densities, 100 samples for each type of graph. All heuristics are iterated between the two layers until a local optimum is obtained, as outlined in the introduction, starting from the canonical ordering on V1 . An additional column labelled “LR-Opt” gives according results for the iterated minimum crossing computation by branch and cut, which is, remarkably, sometimes outperformed by the best iterated heuristics. For sparse instances, the minimum is much better than any of the heuristically found solutions (see Figure 7). The best heuristics barycenter, median, and LR-opt are very far away from the optimum solution. For density 0.1 the number of crossings is between 5 times and 33 times higher than the minimum straightline crossing number. For density 0.2 the best solution is still 60% away from the optimum. The ranking of the heuristics here is barycenter, LR-opt, split, median, stochastic, greedy-switch, assign, greedy-insert. The rank of greedy-switch improves for dense graphs. It turns out that with increasing density, the computation times increase rapidly for the minimum computation, whereas the heuristics are not very sensitive to density. The running times for the heuristics stay under 0.4 seconds, whereas the computation by the exact algorithm increased from 1.1 seconds for density 0.1 to 1550 seconds for density 0.9. In Figure 6, we show an example of a 10+10 graph with 20 edges. The first drawing was found by the LR-opt heuristic and has 30 crossings, the second by the barycenter heuristic and contains 10 crossings and the third one is the optimum solution with only 4 crossings. 4
5
1
10
9
3
8
2
7
6
h
j
f
d
b
g
a
e
i
c
4
5
9
7
8
2
10
6
3
1
h
j
d
e
g
c
b
a
i
f
4
5
9
7
8
3
6
2
10
1
h
j
d
e
g
b
i
c
a
f
Figure 6: Time for 10 instances of sparse graphs with increasing size
Percentage off Optimum 100 (SOL / OPT)
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
Minimum LR-Opt Barycenter Median Stoch Gre-ins Gre-swi Split Assign
900 850 800 750 700 650 600 550 500 450 400 350 300 250 200 150 100 0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
Density
Figure 7: Results for 100 instances on 10 + 10 nodes with one trial
14
Percentage off Optimum 100 (SOL / OPT)
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
Minimum LR-Opt Barycenter Median Stoch Gre-ins Gre-swi Split Assign
900 850 800 750 700 650 600 550 500 450 400 350 300 250 200 150 100 0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
Density
Figure 8: Results for 100 instances on 10 + 10 nodes with 10 trials
15
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
8000 7500 7000
LR-Opt Barycenter Median Stoch Gre-ins Gre-swi Split Assign
Number of Crossings
8500
6500 6000 5500 5000 4500 4000 3500 3000 2500 2000 1500 1000 500 0 10
20
30
40 50 60 70 80 Number of Nodes per Layer
90
100
Figure 9: Results for 10 instances on sparse graphs (absolute)
16
550
500
450
400
350
300
Percentage off the solution of barycenter: 100 (SOL / BARY)
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
17
LR-Opt Barycenter Median Stoch Gre-ins Gre-swi Split Assign
250
200
150
100 10
20
30
40 50 60 70 80 Number of Nodes per Layer
90
100
Figure 10: Results for 10 instances on sparse graphs (relative to barycenter)
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
18
Within one hour of computation time, we can find optimum solutions for 11+11 instances with up to 80% density, 12+12 with up to 50% density, 13+13 with up to 30% density, 14+14, 15+15, 16+16 with up to 10% density. In Figure 8, we repeat the same experiment with 10 starts from random orderings of the nodes in V1 and take the best solutions found. The results show that a considerable performance gain for all heuristics can be achieved. LR-Opt, barycenter and split obtain results of similar good quality. But still, for sparse graphs, they are at least 7% away from the optimum, split even 44%. Figures 9 and 10 deal with the more interesting sparse instances of bigger size for which we can not compute the optimum anymore. Thus, we divided the number of crossings found by the heuristics (shown in Figure 9) by that computed by barycenter (see Figure 10). This allows us to compare the behaviour of the heuristics for one layer fixed against the free case. Barycenter constantly gives the best solutions for sparse graphs. Also, median is, contrary to the one-layer fixed case, among the best heuristics. Barycenter, LR-opt, median and split give the best solutions. However, we do not know how far their solutions are away from the optimum. Stochastic behaves worse for two free layers, although it was originally designed for this problem. Assign and greedy-insert are among the worst heuristics, but their quality seems to stay constant with increasing number of nodes, in contrary to greedy-switch. With 10 different starts from random orderings of the nodes in V1 , the quality of the results improves only slightly. The data of all of our experiments is given in the Appendix. Summarizing, the barycenter method turns out to be the clear winner, both in terms of quality as well as in terms of computation time.
5
Conclusions
The outcome of our computational experiments lead to the following conclusions. (1) When one layer is fixed, and the free layer does not contain more than 60 vertices, which is well beyond typical practical instance sizes, the exact minimum crossing number can be efficiently computed in practice, so there is no real need for heuristics. (2) In the general case, small sparse instances, which often occur in applications, can be solved to optimality if the smaller sized shore has up to about 15 vertices. For larger instances, the iterated barycenter method, started with a few random orderings of one layer, is clearly the method of choice among all tested methods.
Acknowledgements We would like to thank Thomas Ziegler for implementing and running all heuristics in this paper except LR-opt and Stefan Dresbach for helpful discussions concerning the stochastic heuristic.
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
19
References [1] M. J. Carpano. Automatic display of hierarchized graphs for computer aided decision analysi s. IEEE Trans. Syst. Man Cybern., SMC-10(11):705– 715, 1980. [2] C. Catarci. The assignment heuristic for crossing reduction. IEEE Transactions on Systems, Man, and Cybernetics, 25(3), 1995. [3] CPLEX Optimization Inc. Using the CPLEX callable library and the CPLEX mixed integer library, 1993. [4] S. Dresbach. A new heuristic layout algorithm for DAGs. In U. Derigs and A. B. . A. Drexl, editors, Operations Research Proceedings 1994, pages 121–126. Springer Verlag, Berlin, 1994. [5] S. Dresbach, 1995. Personal communication. [6] P. Eades and D. Kelly. Heuristics for reducing crossings in 2-layered networks. Ars Combin., 21.A:89–98, 1986. [7] P. Eades and S. Whitesides. Drawing graphs in two layers. Theoretical Computer Science 131, pages 361–374, 1994. [8] P. Eades and N. Wormald. Edge crossings in drawings of bipartite graphs. Algorithmica, 10:379–403, 1994. [9] M. Garey and D. Johnson. Crossing number is NP-complete. SIAM J. Algebraic Discrete Methods, 4:312–316, 1983. [10] M. Gr¨ otschel, M. J¨ unger, and G. Reinelt. A cutting plane algorithm for the linear ordering problem. Operations Research, 32:1195–1220, 1984. [11] M. Gr¨ otschel, M. J¨ unger, and G. Reinelt. Optimal triangulation of large real world input-output matrices. Statistische Hefte, 25:261–295, 1984. [12] M. Gr¨ otschel, M. J¨ unger, and G. Reinelt. Facets of the linear ordering polytope. Mathematical Programming, 33:43–60, 1985. [13] D. Knuth. The Stanford GraphBase: A Platform for Combinatorial Computing. ACM Press, Addison-Wesley Publishing Company, New York, 1993. [14] K. Sugiyama, S. Tagawa, and M. Toda. Methods for visual understanding of hierarchical systems. IEEE Trans. Syst. Man Cybern., SMC-11(2):109– 125, 1981. [15] V. Valls, R. Marti, and P. Lino. A branch and bound algorithm for minimizing the number of crossing arcs in bipartite graphs. Journal of Operational Research, 90:303–319, 1996. [16] J. Warfield. Crossing theory and hierarchy mapping. IEEE Trans. Syst. Man Cybern., SMC-7(7):502–523, 1977.
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
6
20
Appendix: Tables
The tables show the average number of crossings taken over all sampled instances of this type, the relative size of this number in percentage of the minimum number of crossings, and the average running time in seconds on a SUN Sparcstation 10 for the investigated heuristics and exact algorithms. ni m
Low
Min
Bary
Median
Stoch
Gre-ins
Gre-swi
Split
20 40
180.35
180.75
185.34
206.27
185.44
248.37
275.99
183.39
199.09
99.78
100.00
102.54
114.12
102.60
137.41
152.69
101.46
110.15
0.02
0.01
0.01
0.05
0.02
0.04
0.08
0.02
957.62
959.23
968.80
1051.14
970.01
1175.11
1044.14
964.35
988.76
99.83
100.00
101.00
109.58
101.12
122.51
108.85
100.53
103.08
0.03
0.01
0.01
0.06
0.05
0.10
0.11
0.03
2422.32
2433.53
2564.82
2437.39
2763.72
2460.94
2428.23
2453.89
100.00
100.46
105.88
100.62
114.09
101.59
100.24
101.30
0.03
0.01
0.01
0.07
0.10
0.16
0.16
0.04
4627.72
4638.24
4825.06
4644.35
5098.27
4644.10
4632.17
4657.85
100.00
100.23
104.26
100.36
110.17
100.35
100.10
100.65
0.04
0.01
0.02
0.08
0.17
0.23
0.23
0.04
7561.88
7571.08
7817.99
7582.47
8157.86
7572.24
7566.79
7589.64
100.00
100.12
103.39
100.27
107.88
100.14
100.07
100.37
0.05
0.02
0.02
0.09
0.24
0.31
0.31
0.05
20 80
20 120 2420.14 99.91 20 160 4625.79 99.96 20 200 7560.42 99.98
Assign
20 240 11314.37 11315.55 11323.26 11625.54 11338.06 12033.34 11321.10 11318.68 11336.09 99.99
100.00
100.07
102.74
100.20
106.34
100.05
100.03
100.18
0.07
0.02
0.03
0.09
0.34
0.42
0.41
0.06
20 280 15859.70 15860.35 15865.69 16225.57 15883.69 16667.12 15863.66 15861.76 15874.86 99.99
100.00
100.03
102.30
100.15
105.09
100.02
100.01
100.09
0.09
0.03
0.03
0.10
0.45
0.52
0.53
0.07
20 320 21290.56 21290.76 21294.12 21727.43 21313.78 22116.56 21292.93 21291.56 21300.43 99.99
100.00
100.02
102.05
100.12
103.88
100.01
100.00
100.05
0.11
0.03
0.04
0.11
0.59
0.65
0.66
0.08
20 360 27751.63 27751.69 27752.99 28257.47 27768.41 28459.57 27752.01 27751.84 27754.31 100.00
100.00
100.01
101.82
100.06
102.55
100.00
100.00
100.01
0.14
0.04
0.04
0.12
0.74
0.81
0.80
0.09
Table 2: Results for 100 instances of the one sided crossing minimization problem on 20 + 20 nodes with increasing density (see Figs. 2 and 3)
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
ni
m
Low
Min
Bary
10
20
37.90
38.00
38.90
45.40
38.70
46.40
50.90
38.50
40.60
99.74
100.00
102.37
119.47
101.84
122.11
133.94
101.32
106.84
0.00
0.00
0.00
0.01
0.00
0.01
0.02
0.00
171.70
171.90
175.70
193.70
174.90
240.80
293.60
174.70
195.10
99.88
100.00
102.21
112.68
101.74
140.08
170.80
101.63
113.50
0.01
0.01
0.01
0.05
0.02
0.05
0.09
0.02
436.60
438.30
451.90
491.10
451.30
602.30
692.40
445.60
475.90
99.61
100.00
103.10
112.05
102.97
137.42
157.97
101.67
108.58
0.11
0.01
0.01
0.13
0.05
0.11
0.25
761.50
765.70
785.60
856.60
782.70 1105.00 1367.50 783.20
842.30
99.45
100.00
102.60
111.87
102.22
144.31
178.60
102.29
110.00
0.30
0.01
0.02
0.28
0.08
0.22
0.57
0.09
20
30
40
40
60
80
Median Stoch
Gre-ins Gre-swi
Split
21
Assign
0.05
50 100 1247.30 1252.20 1279.90 1389.50 1273.20 1770.60 2200.50 1277.80 1375.90 99.61
100.00
102.21
110.97
101.68
141.40
175.73
102.04
109.88
0.68
0.02
0.03
0.50
0.13
0.32
1.00
0.14
60 120 1683.10 1687.60 1738.30 1890.90 1720.20 2453.10 2994.50 1736.10 1855.30 99.73
100.00
103.00
112.05
101.93
145.36
177.44
102.87
109.94
1.09
0.03
0.04
0.83
0.18
0.61
1.67
0.24
70 140 2465.00 2479.00 2541.30 2730.00 2522.50 3592.20 4498.80 2549.20 2688.60 99.44
100.00
102.51
110.13
101.76
144.91
181.48
102.83
108.46
4.46
0.04
0.04
1.28
0.26
0.73
2.82
0.36
80 160 3153.90 3172.10 3254.60 3521.60 3232.90 4583.10 5885.70 3240.60 3488.90 99.43
100.00
102.60
111.02
101.92
144.48
185.55
102.16
109.99
6.42
0.05
0.06
1.85
0.33
0.99
4.11
0.51
90 180 4104.00 4132.80 4233.70 4566.80 4206.80 5843.70 7331.30 4293.90 4561.60 99.30
100.00
102.44
110.50
101.79
141.40
177.39
103.90
110.38
25.13
0.05
0.06
2.66
0.41
1.32
5.84
0.75
100 200 5127.40 5162.70 5287.50 5728.80 5247.60 7469.90 9407.50 5333.50 5627.50 99.32
100.00
102.42
110.97
101.64
144.69
182.22
103.31
109.00
435.51
0.06
0.08
3.35
0.49
1.45
7.56
0.90
Table 3: Results for 10 instances of the one sided crossing minimization problem of sparse graphs with increasing size (see Figs. 4 and 5)
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
ni m
Min
LR-Opt
Bary
10 10
0.29
1.64
1.52
1.53
100.00
565.52
524.14
527.59
10 20
10 30
Median Stoch 2.71
Gre-ins Gre-swi 4.32
9.61
Split
Assign
2.63
5.42
934.48 1489.66 3313.79 906.90 1868.97
1.10
0.01
0.01
0.01
0.03
0.02
0.02
0.04
0.01
11.62
19.99
18.78
24.08
26.96
38.85
34.81
23.25
34.96
100.00
172.03
161.62
207.23
232.01
334.34
299.57
200.09
300.86
3.89
0.02
0.01
0.01
0.06
0.04
0.03
0.07
0.02
56.60
66.98
65.30
81.78
82.98
109.96
80.29
70.11
97.80
100.00
118.34
115.37
144.49
146.61
194.28
141.86
123.87
172.79
14.06
0.02
0.02
0.02
0.07
0.06
0.07
0.11
0.02
10 40 146.89
157.91
157.70
189.55
182.77
225.26
165.65
160.20
202.10
100.00
107.50
107.36
129.04
124.43
153.35
112.77
109.06
137.59
43.02
0.03
0.02
0.02
0.08
0.10
0.11
0.15
0.03
10 50 276.78
287.32
288.15
333.25
320.21
387.87
296.38
290.79
343.65
100.00
103.81
104.11
120.40
115.69
140.14
107.08
105.06
124.16
91.58
0.04
0.03
0.02
0.09
0.13
0.15
0.21
0.03
10 60 463.17
475.04
475.52
539.59
509.38
598.98
482.76
478.46
542.88
100.00
102.56
102.67
116.50
109.98
129.32
104.23
103.30
117.21
206.61
22
0.06
0.03
0.03
0.10
0.17
0.22
0.28
0.03
10 70 698.35
709.91
710.88
782.33
747.20
854.61
715.73
712.73
779.79
100.00
101.66
101.79
112.03
107.00
122.38
102.49
102.06
111.67
379.12
0.07
0.04
0.03
0.11
0.22
0.29
0.35
0.04
10 80 1008.38 1021.46 1021.44 1110.39 1051.66 1165.97 1025.84 1024.78 1083.39 100.00
101.30
101.30
110.12
104.29
115.63
101.73
101.63
107.44
763.53
0.08
0.04
0.03
0.12
0.27
0.34
0.40
0.04
10 90 1405.57 1420.68 1421.86 1524.18 1430.86 1516.62 1423.90 1421.72 1456.97 100.00
101.08
101.16
108.44
101.80
107.90
101.30
101.15
103.66
1549.12
0.07
0.03
0.03
0.12
0.29
0.32
0.37
0.04
Table 4: Results for 100 instances of the two sided crossing minimization problem on 10 + 10 nodes with increasing density (see Figs. 7 and 8)
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
ni m
Min
LR-Opt
Bary
10 10
0.29
0.30
0.31
0.71
0.73
100.00
103.45
106.90
244.83
251.72
1.10
0.11
0.08
0.08
0.27
10 20
Median Stoch
Gre-ins Gre-swi 2.10
3.95
Split 0.42
724.14 1362.07 144.83 0.21
0.16
0.38
Assign 2.15 741.38 0.10
11.62
12.50
12.44
16.57
17.44
30.55
21.00
13.83
25.44
100.00
107.57
107.06
142.60
150.09
262.91
180.72
119.02
218.93
3.89
0.18
0.12
0.13
0.52
0.38
0.34
0.64
0.17
56.60
57.27
57.46
68.66
66.33
97.22
62.59
58.30
79.97
100.00
101.18
101.52
121.31
117.19
171.77
110.58
103.00
141.29
14.06
0.26
0.17
0.15
0.68
0.60
0.62
1.01
0.23
10 40 146.89
147.35
147.73
166.41
159.31
205.97
150.34
148.24
174.12
100.00
100.31
100.57
113.29
108.46
140.22
102.35
100.92
118.54
43.02
0.36
0.21
0.18
0.79
0.90
1.02
1.45
0.26
10 30
10 50 276.78
277.11
277.78
304.62
292.34
363.43
277.85
277.61
308.26
100.00
100.12
100.36
110.06
105.62
131.31
100.39
100.30
111.37
91.58
23
0.47
0.26
0.22
0.87
1.23
1.50
2.03
0.30
10 60 463.17
463.76
464.07
499.41
478.48
565.63
464.54
464.17
497.17
100.00
100.13
100.19
107.82
103.31
122.12
100.30
100.22
107.34
206.61
0.59
0.32
0.25
0.96
1.65
2.15
2.67
0.34
10 70 698.35
698.75
699.23
745.00
712.78
816.80
699.37
699.04
728.95
100.00
100.06
100.13
106.68
102.07
116.96
100.15
100.10
104.38
379.12
0.68
0.34
0.29
1.03
2.23
2.78
3.30
0.37
10 80 1008.38 1008.62 1008.88 1070.82 1018.66 1120.31 1008.96 1008.94 1031.45 100.00
100.02
100.05
106.19
101.02
111.10
100.06
100.06
102.29
763.53
0.81
0.37
0.31
1.11
2.70
3.39
3.89
0.41
10 90 1405.57 1406.14 1406.22 1490.03 1410.31 1461.52 1406.43 1406.44 1416.64 100.00
100.04
100.05
106.01
100.34
103.98
100.06
100.06
100.79
1549.12
0.70
0.33
0.34
1.17
2.86
3.13
3.53
0.44
Table 5: Results for 100 instances of the two sided crossing minimization problem on 10 + 10 nodes with increasing density, 10 trials each (see Figs. 7 and 8)
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
ni
m LR-Opt
Bary
10
20
19.70
15.70
0.02
0.02
0.01
0.05
0.04
0.04
0.06
0.02
20
40
73.70
72.50
79.60
132.50
170.70
237.70
91.20
161.90
0.10
0.03
0.04
0.36
0.17
0.17
0.41
0.06
30
60
176.00
147.90
188.50
288.20
442.30
549.80
208.30
370.00
0.48
0.10
0.09
1.18
0.49
0.48
1.33
40
80
309.80
273.30
374.20
555.70
1.81 50 100 457.70 5.87 60 120 645.60 13.34 70 140 861.30 24.95
Median Stoch 25.70
0.17
0.14
392.30
561.90
0.25 567.00 0.38
0.17
27.20
2.72
Gre-ins Gre-swi 35.80
34.20
Split
Assign
20.90
32.40
760.60 1207.00 368.80 0.93
0.67
3.45
24
0.15 684.40 0.28
824.40 1284.40 1971.20 548.10 1125.60 5.92
1.37
1.10
7.14
0.47
811.20 1219.90 1954.80 2667.90 811.10 1531.20 0.24
8.58
2.24
1.87
10.52
0.73
764.60 1146.20 1689.30 2549.30 4122.80 1032.40 2182.40 0.55
0.34
14.09
2.89
2.19
19.48
1.02
80 160 1246.10 1080.70 1481.30 2183.30 3279.40 5495.90 1467.70 2984.90 62.65
0.68
0.52
21.09
4.58
3.22
25.01
1.46
90 180 1697.70 1272.40 1848.00 2859.50 4280.00 6853.70 1762.40 3708.20 86.37
1.10
0.57
31.84
6.41
4.30
38.36
2.28
100 200 2027.30 1555.10 2084.10 3453.10 5405.00 8796.30 2209.40 4591.00 178.93
1.46
0.82
40.23
7.41
5.25
47.78
2.67
Table 6: Results for 10 instances of the two sided crossing minimization problem of sparse graphs (see Figs. 9 and 10)
M. J¨ unger et al., 2-Layer Crossing Minimization, JGAA, 1(1) 1–25 (1997)
ni
m LR-Opt
Bary
10
20
13.60
12.70
18.70
17.50
30.00
0.12
0.15
0.12
0.55
0.40
48.30
59.10
89.00
150.80
Median Stoch
Gre-ins Gre-swi
Split
Assign
22.30
14.70
25.70
0.34
0.68
0.16
163.40
63.70
128.60
20
40
51.00 0.98
0.42
0.39
3.61
1.82
1.58
3.93
0.68
30
60
133.40
117.00
145.80
228.60
421.30
422.10
160.10
321.80
5.55
0.96
0.76
11.48
4.59
4.18
13.13
1.42
40
80
234.10
212.40
271.40
432.80
724.50
949.80
279.90
589.70
18.45
1.75
1.29
26.57
8.25
7.42
31.26
6.91
325.60
407.30
2.79
2.06
50 100 384.20 52.01 60 120 541.10 128.12 70 140 733.20 304.08
479.90 4.38 641.30 5.79
715.60 1245.60 1715.90 462.70 51.33
13.59
11.60
60.80
25
966.20 4.83
599.90 1106.80 1909.70 2472.10 654.00 1425.80 2.93
92.08
21.97
18.27
114.07
7.14
858.00 1489.30 2514.30 3640.00 896.90 1973.20 3.82
139.95
30.18
23.22
175.83
11.04
80 160 1022.90 903.70 1145.10 1993.30 3248.70 4843.50 1169.60 2634.00 619.36
7.57
5.28
204.64
38.96
31.18
264.82
14.59
90 180 1282.50 1044.70 1323.70 2516.50 4209.10 6228.20 1466.40 3289.20 1134.67
10.81
6.55
307.44
57.13
43.19
377.72
20.20
100 200 1599.20 1313.20 1793.20 3119.40 5323.90 8145.30 1807.60 4165.10 2313.48
13.76
8.02
402.74
67.13
50.24
504.25
27.12
Table 7: Results for 10 instances of the two sided crossing minimization problem of sparse graphs, 10 trials each
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 1, no. 2, pp. 1–15 (1997)
Optimal Algorithms to Embed Trees in a Point Set Prosenjit Bose School of Computer Science Carleton University Ottawa, Ontario, K1S 5B6 http://www.scs.carleton.ca
[email protected]
Michael McAllister
Jack Snoeyink
Department of Computer Science University of British Columbia Vancouver, BC, V6T 1Z4 http://www.cs.ubc.ca
[email protected] [email protected] Abstract We present optimal Θ(n log n) time algorithms to solve two tree embedding problems whose solution previously took quadratic time or more: rooted-tree embeddings and degree-constrained embeddings. In the rootedtree embedding problem we are given a rooted tree T with n nodes and a set of n points P with one designated point p and are asked to find a straight-line embedding of T into P with the root at point p. In the degree-constrained embedding problem we are given a set of n points P where each point is assigned a positive degree and the degrees sum to 2n − 2 and are asked to embed a tree in P using straight lines that respects the degrees assigned to each point of P . In both problems, the points of P must be in general position and the embeddings must not have crossing edges.
Communicated by Peter Eades: submitted March, 1996; revised August, 1996.
P. Bose et al., Optimal Algorithms to Embed . . ., JGAA, 1(2) 1–15 (1997)
1
2
Introduction
The problem of deciding whether a set of points admits a certain combinatorial structure, as well as computing an embedding of that structure on the point set, has been a recurrent theme in many fields. The list of problems falling into this category is virtually endless. We mention a few of the structures that are current topics of research. The triangulation of a point set is a structure that has spurred much research because of its many applications in areas such as finite element methods, graphics, medical imaging, Geographic Information Systems (GIS), statistics, scattered data interpolation, and pattern recognition, to name a few [17, 18]. The combinatorial structure of interest in this paper is the tree, which is well-studied in the literature. For example, the study of spanning trees of a set of points has a long history. From a graph drawing perspective (see [6] for a survey of graph drawing), the traditional questions ask whether a (rooted or free) tree T = (V, E) can be embedded in the plane such that some criterion is satisfied: e.g., that the area of the resulting embedding is small [5, 11], that the symmetry present in the tree is revealed in the embedding [13], or that T is isomorphic to the minimum-weight spanning tree [7, 15] or proximity graph [2, 3] of the points in which the vertices are embedded. In essence, the tree is given as input and one needs to construct a set of points in which to embed the tree such that it satisfies the criterion. The two tree embedding problems that we study have a slightly different perspective: the points are given as input, and the tree may or may not be. We say that an n-node tree T = (V, E) can be straight-line embedded onto a set of n points P , if there exists a one-to-one mapping φ: V → P from the nodes of T to the points of P such that edges of T intersect only at nodes. That is, edges (φ(u1 ), φ(v1 )) ∩ (φ(u2 ), φ(v2 )) = ∅, for all u1 v1 6= u2 v2 ∈ E. We show, in the final section, that to obtain a straight-line embedding of any tree in a set of n points requires Ω(n log n) time. The first problem, called the rooted-tree embedding problem, was originally posed by Perles at the 1990 DIMACS workshop on arrangements: Given n points P in general position and an n-node tree T rooted at node ν, can T be straight-line embedded in P with ν at a specified point p ∈ P ? Perles showed that this was possible if p was on the convex hull of P , which is the smallest convex set containing the points P . Pach and T¨ or˝ ocsik [20] showed that such an embedding is possible if p was not the deepest point of P , obtained by repeatedly discarding points on the convex hull. Finally, Ikebe et al. [10] showed that there was always such an embedding. All three algorithms use quadratic time. We show that one can use a deletion-only convex hull structure [4, 9] to obtain
Prosenjit Bose was partially supported by an NSERC and a Killam Postdoctoral Fellowship. Michael McAllister was partially supported by an NSERC Postgraduate Fellowship. Jack Snoeyink was partially supported by an NSERC Research Grant and a B.C. Advanced Systems Institute Fellowship.
P. Bose et al., Optimal Algorithms to Embed . . ., JGAA, 1(2) 1–15 (1997)
3
O(n log2 n) time and then improve this to Θ(n log n) time. If p is the point with greatest y-coordinate then the O(n log2 n) algorithm can embed the tree such that all paths from the root to a leaf are vertically monotone. The second problem, degree-constrained embedding or dc-embedding, is similar, although the tree T is not specified. Consider a point set P = {p1 , p2 , . . . , pn } in general position in the plane where each Pnpi is assigned a positive integral value di as its degree; the degrees satisfy i=1 di = 2n − 2. Can some tree T be straight-line embedded on the set of points P such that a tree node of degree di maps to point pi , for all i? Tamura and Tamura (now Ikebe) [24] showed that such a tree always exists and presented an O(n2 log n) time algorithm to compute one. We present an optimal Θ(n log n) time algorithm for this problem. Similar embedding problems can be posed for planar graph embeddings in a set of points; the graphs with embeddings into a fixed point set have been characterised by Gritzmann et al. [8]. They showed that the class of outer-planar graphs is the largest class of graphs that admits an embedding in any point set neda and and provided an embedding algorithm that runs in O(n2 ) time (Casta˜ Urrutia [16] later rediscovered this result). Recently, Bose [1] presented an O(n log3 n) time embedding algorithm for this problem. Finding an optimal O(n log n) time embedding algorithm for embedding these graphs remains an open problem.
2
Hull Trees
Our algorithms for embedding trees use segments from the convex hull to avoid intersections between embedded edges. Consequently, we need efficient access to the convex hull of points. Moreover, we need the ability to delete points from the convex hull as we embed tree vertices at them. Overmars and van Leeuwen’s [19] dynamic convex hull structure permits arbitrary insertion into and deletion from the set of points. We opt for hull trees [4, 9], which provide better amortised time complexities for point deletions. This section provides a brief introduction to hull trees. A hull tree of a set of n points P stores the upper or lower convex hull of P ; the entire convex hull of P can be represented by two hull trees. A hull tree for P ’s upper hull is a binary tree in which each leaf is a point of P and internal nodes represent an edge in the upper hull of the node’s leaves (figure 1). Each internal node in the tree stores • the upper hull edge between the convex hull of the point set at leaves in the node’s left subtree and the node’s right subtree. • the number of leaves in its subtree. • in the dc-embedding problem, each leaf has a degree value given in the problem’s input. An internal node to the hull tree stores the sum of the degrees of the leaves in its subtree. We use two of the hull tree operations described by Hershberger and Suri [9]: point deletion and set partition. The point deletion operation removes a point
P. Bose et al., Optimal Algorithms to Embed . . ., JGAA, 1(2) 1–15 (1997)
4
from the hull tree. The hull edges at internal nodes on a path from the point’s leaf node to the root of the hull tree may need to be recomputed as a result of the deletion; a bottom-up merge of hulls along the path to the root accomplishes this task. In the set partition operation, we are given a vertical line and we want to split, or partition, the hull tree into two parts: one hull tree (7,15) for the points left of the vertical line and one (10,15) hull tree for the remaining points. Assume (2,5) that the vertical line goes through a point q. The path from the root to the leaf for q in the hull tree contains all the hull edges that cross 1 4 5 8 9 12 13 16 the vertical line. Split the hull tree along this 7 path, duplicating the path in each part to 5 maintain connectivity. As with the deletion 10 2 operation, recompute the hull edges that ap15 pear along the path in each part to get two hull trees. Finally, use the point deletion operation to remove the duplicated point from Figure 1: Top level of a hull one of the hull trees as necessary. The height of the hull tree does not in- tree (above) and upper hull crease with point deletions or set partitions. edges (below). Each of the hull tree operations uses O(log n) amortised time over any schedule of O(n) operations. The set partition operation takes O(log n) time to divide the hull tree into two parts and to duplicate the path. The remaining time in the set operation is the same as in point deletion; it is the time required to recompute the hull edges along one path. Create a potential function for the hull tree by assigning each internal node a value equal to the number of hull edges that appear above the node’s edge. The initial potential of the tree is O(n log n). When recomputing the hull edges, we either keep the same edge or the replacement hull edge has fewer hull edges below it, thus lowering the overall cost of the tree. If we find the replacement hull edge at a node v by walking along the two hulls of the left and right subtrees of v then updating the edges along the path takes O(log n + k) time where k is the number of hull edges over which we walked and the amount by which the potential function decreases. Consequently, the path update takes O(log n) amortised time.
3
Embedding a rooted tree with the root on the convex hull
In this section we give an algorithm for embedding a rooted tree with the root at a specified point p that is on the convex hull—general specification of p is discussed in section 4. In this restricted case, we embed the tree and preserve the order of the children about each tree node. Ikebe et al. [10] and Pach
P. Bose et al., Optimal Algorithms to Embed . . ., JGAA, 1(2) 1–15 (1997)
5
and T¨ or˝ ocsik [20] each provide a quadratic time algorithm whose time can be reduced to O(n log2 n). After briefly sketching this reduction, we present an O(n log n) algorithm. Ikebe et al. embed a tree T into a set of points P with the root at a point p on the convex hull of P by locating rays `0 , `1 , . . . , `m from p such that there are exactly |Ti | points between `i−1 and `i where T1 , . . . , Tm are the subtrees of the root of T . The lines `1 , . . . , `m are found by linear time median search. The subtrees T1 , . . . , Tm are then recursively embedded in the points between adjacent `i . This leads to an algorithm with a Θ(n2 ) worst-case time. If the points of P are placed in a convex hull maintenance structure that supports deletions in O(log n) amortised time [4, 9] then we can find the lines `i without resorting to a full median search. Let TL be the leftmost subtree of T and let TR be T \ TL . Assume that |TL | ≤ |TR |; reverse the roles of TL and TR if this is not the case. Delete, one at a time, |TL | points from the convex hull that appear as the left neighbour of p after reconstructing the convex hull every time. These are precisely the points between `0 and `1 . Rebuild the convex hull maintenance structure for the deleted points; recursively embed TL in the new convex hull structure and TR in the convex hull structure left after the deletions. The revised complexity of the algorithm is O(n log2 n) from the recurrence T (n) = T (n−k)+T (k)+O(min (k, n − k) log n) where 1 ≤ k ≤ n−1. This O(n log2 n) embedding algorithm can guarantee that each path in the embedding from the root ν to each leaf is vertically monotone if p is the highest point of P . When the algorithm recursively embeds TL , it selects the deleted point with greatest y-coordinate as the root for TL . Similarly, when the root ν has unit degree, the algorithm chooses the point of P with second greatest y-coordinate as the root for the single subtree of ν. The deleted points with greatest y-coordinate are found in O(|TL |) time; the point of P with second greatest y-coordinate is found in O(log n) time by keeping the points of P sorted by y-coordinate in a balanced tree and updating the tree along with the convex hull maintenance structure. The time recurrence and time complexity for the algorithm remain unchanged. Recomputing convex hulls costs us an extra log factor in the above algorithm. To avoid this, we propose an algorithm that uses the same notion of isolating the points for one subtree but that uses only vertical separation lines and the upper hull of the points, assuming that p lies on the upper hull. When the root of the tree is not in, or immediately adjacent to, the isolated set of points, the algorithm embeds the tree along a path on the upper hull to reach the subset. By handling the leftmost or rightmost subtree of the root and then deleting the points used along the upper hull, the algorithm prevents embedded tree edges from crossing. Since all division lines are vertical, the set partition operation on hull trees in section 2 divides the hull tree in O(log n) amortised time and provides a better time complexity. In our algorithm, each point has a label whose value is one of left, right, or any. When the root of the tree is a leaf, the label of the root’s point indicates the direction along the upper hull where the only neighbour of the root should be embedded. For a root of higher degree, the algorithm uses recursion to
P. Bose et al., Optimal Algorithms to Embed . . ., JGAA, 1(2) 1–15 (1997)
Embed a tree T , rooted at node ν, into a set of points P with distinguished point p on the upper hull of P . Assume: P is stored in a deletion-only, upper-hull data structure UH (P ). The initial label for each point is any. Procedure EmbedinUH(T, ν, P, p) Let ν 0 be the leftmost child of ν, Let TL be the subtree rooted at ν 0 , and Let TR be T \ TL . 1. If node ν has degree zero, then Embed node ν at point p and end. 2. If node ν has unit degree, then Embed node ν at point p. Let r be the neighbour of p on UH (P ) specified by p’s label, where any allows either neighbour. Delete p from UH (P ). EmbedinUH(TL , ν 0 , P \ {p}, r) and end. 3. Else ν has degree at least two. Let q be the left neighbour of p on UH (P ), if it exists. Binary search UH (P ) for a vertical line ` with |TR | − 1 points of P \ {p} to its right. 3a. If line ` intersects edge (p, q) as in figure 2 Partition UH (P ) along ` into two upper hulls, UH (PL ) to the left and UH (PR ) to the right of `. EmbedinUH(TL , ν 0 , PL , q). EmbedinUH(TR , ν, PR , p). 3b. Else if line ` is to the left of point q Label point q with right. Change the root of T to ν 0 . EmbedinUH(T, ν 0 , P, q). 3c. Else line ` is to the right of point p Restart at 3 and reverse left and right. That is, embed the rightmost subtree of ν, reverse the roles of left and right in the sidedness tests, and use the label left instead of right in case 3b,
Algorithm 1: Embedding tree T with point p on the upper hull of P
6
P. Bose et al., Optimal Algorithms to Embed . . ., JGAA, 1(2) 1–15 (1997)
7
detach and embed leftmost and rightmost subtrees of the root and the labels retain path information that leads back to the embedded root of the original tree. All points are initially assigned the label any before invoking the recursive algorithm. Our algorithm appears as procedure EmbedinUH() in Algorithm 1. Theorem 1 Suppose that we are given an n-node tree T with root node ν and a set of n points P in general position with the point p on the upper hull UH (P ). EmbedinUH() straight-line embeds T in P with ν at point p in O(n log n) time. Proof : We prove the algorithm correct by induction on the number of nodes in T . If T has a single node then case 1 embeds ν at p as required. Suppose that T has n nodes and that the algorithm correctly embeds trees of n − 1 nodes or less for n ≥ 2. If ν has unit degree then TR is only ν. Case 2 embeds ν at p as required and TL is embedded by the induction hypothesis. The edge from ν to TL is an edge of UH (P ) so it cannot intersect any edge in the embedding of TL . If ν has degree two or more then there are three possibilities corresponding to cases 3a, 3b, and 3c: • line ` intersects edge (p, q) as shown in figure 2 • line ` is to the left of point q • line ` is to the right of point p If ` intersects edge (p, q) then step 3a embeds TL and TR by the induction hypothesis and the embeddings are joined by upper hull edge (p, q) that lies outside the embeddings of TL and TR ; no intersections occur.
TL
TR
PL
p
PR
q 0
`
Figure 2: Divided tree T and point set P . If ` lies to the left of q then we must ensure that the algorithm eventually embeds ν at p. In the recursive call of case 3b, TR is rooted as the rightmost child of ν 0 in T and the new dividing line `0 lies to the left of `. Consequently, either TL \ν 0 is embedded completely to the left of the vertical line through q with ν 0 still to be embedded at q, or the root of T is shifted left again during the embedding of TL . Assume the former case, since the latter case
P. Bose et al., Optimal Algorithms to Embed . . ., JGAA, 1(2) 1–15 (1997)
8
eventually leads to it as the root of T continues to shift left. After the embedding of TL \ ν 0 , the remaining upper hull to the right of q is identical to UH (P ) right of q since all deletions occur to the left of q. In particular, p is still the right neighbour of q on the upper hull. Once TL \ ν 0 is embedded, ν 0 is a leaf connected to the root of TR . Case 2 then embeds ν 0 at q and the label at q, still right since the root shifts in T were leftward only, generates a recursive call to embed TR into the remaining points with ν going to point p. In the final case, ` lies to the right of p. If R is the rightmost subtree of ν in T then the vertical line that has exactly |R| nodes to its right lies to the right of `. Embedding T rooted at ν into P at point p by descending R rather than TL will not enter case 3c again while embedding R. Instead, one of cases 3a or 3b will perform the required embedding. For the complexity, the initial hull tree for UH (P ) is computed in O(n log n) time and the points of P receive their initial labels in O(n) time. Each of the algorithm steps is accomplished in O(log n) amortised time. When the root is a leaf of the tree (case 2), a point gets deleted from the hull tree in amortised O(log n) time and the height of the hull tree does not increase. Each of cases 3a and 3b fix the location of an unassigned tree node ν 0 at some point; this can only happen n times. Case 3a takes O(log n) time to split the hull tree while case 3b takes constant time. The direction switch of case 3c occurs at most once per subtree of a node—O(n) times. The O(log n) time search for the vertical line ` at the start of case 3 is always paired with one of cases 3a, 3b, or 3c and is therefore done O(n) times. Consequently, EmbedinUH() runs in O(n log n) time. A sample embedding, computed by an Ipe macro [23], appears in figure 3. p
(a)
(b)
p
(c)
Figure 3: A rooted tree (a), a point set with distinguished point p (b), and the embedding of the tree (c).
4
Embedding a rooted tree
In this section we simplify the case analysis of Ikebe et al. [10] and apply our new algorithm to compute a straight-line embedding of T in P with the root of T at a specified point. Following Ikebe et al., we no longer attempt to preserve the ordering of children at a vertex in this embedding. We begin by improving
P. Bose et al., Optimal Algorithms to Embed . . ., JGAA, 1(2) 1–15 (1997)
9
a quadratic-time algorithm used by previous researchers [10, 20] to embed trees with two nodes mapped to adjacent hull vertices. Theorem 2 Suppose that we are given an n-node tree T with distinguished nodes ν and η (ν 6= η), and a set of n points P in general position having edge (p, q) on the convex hull CH (P ). There is an algorithm that, in O(n log n) time, embeds T in P with ν at p and η at q. Proof : Assume that we have a convex hull maintenance structure for P that supports deletions of hull vertices in amortised O(log n) time; such a structure can be built initially in O(n log n) time [4, 9]. Let Tη be the induced subtree of T \ ν that contains η and let Tν be the complement, T \ Tη . We can find a line through p with |Tν | − 1 points on one side and q on the other side by repeatedly deleting the point of the hull adjacent to p that is different from q. When done, delete p and apply theorem 1 to embed Tν in the deleted points with ν at p. This takes O(|Tν | log n) time. Point q is on the hull of the points that remain. Let p0 be the hull vertex adjacent to q where the open segment pp0 does not intersect the hull. Let ν 0 , the child of ν in subtree Tη , be the root of Tη . Recursively embed Tη with ν 0 at p0 and η at q. The total time required for data structure building, point deletion, and tree embedding is O(n log n). η |Tβ |
|Tα | r
ν Tm
p
Tα Tβ
q
|Tm |
Figure 4: Partitioning T at a centroid η and embedding in P Now we can embed a rooted tree T in a point set P with the root at a chosen point p. The basic idea is illustrated in figure 4: Use a centroid node η to partition T into a subtree Tm and two forests Tα and Tβ such that we can find in P the vertices of an empty triangle 4pqr with rays from p, q, and r that divide P into convex sets in which Tm , Tα and Tβ can be embedded according to theorems 1 or 2. The partition of the tree influences the partition of the point set, and vice versa. Some special cases (when the point p is on the convex hull, the root is a centroid, or a forest is empty) are handled along the way. Theorem 3 Given an n-node tree T with root node ν and a set of n points P in general position, we can embed T in P with ν at a chosen point p ∈ P in O(n log n) time. Proof : If p is on the convex hull CH (P ), then we can use the algorithm of theorem 1. Otherwise, sort the points of P radially around p.
P. Bose et al., Optimal Algorithms to Embed . . ., JGAA, 1(2) 1–15 (1997)
10
Let η be a centroid node of T —that is, if we remove η and its incident edges from T , then we are left with connected subtrees with at most |T |/2 nodes [12]. For our purposes, the size of a subtree is the number of nodes other than ν that it contains. Let subtree Tm be a maximum-size subtree of T \ η. We now determine forests Tα and Tβ and three rays from p that form angles ≤ π whose interiors contain |Tα |, |Tm | − 1, and |Tβ | points, as in figure 5. First, find a line `p through p that bisects the points—each open halfspace contains (n − 1)/2 points. To see that such a line exists, consider the integer function D(θ) whose value is the difference between the number of points in the left and right halfspaces of a line through p at angle θ. By our general position assumption, the value of D changes by ±1 when the line hits or passes a point. Since D(θ) = −D(θ + π), the function D(θ) has a zero. Second, choose a point a 6∈ P on `p * so that and a point b ∈ P left of pa c the interior of angle 6 apb is as large as possible and contains |Tm | − 1 points. |Tβ | `p Recall that |Tm | does not count ν if |Tα | ν ∈ Tm . There are essentially two choices—a can be chosen on either p side of p, and then b is determined a as the |Tm |th point counterclockwise b |Tm | * If there is a point around p from pa. * then perturb a into 6 apb. of P on pa → → and← When done, the lines ← pa pb de- Figure 5: Find bisector `p , then termine two opposite angles as in fig- * pb and * pc ure 5: angle 6 apb has |Tm | − 1 points not including b, and the opposite has at least |Tm | points. Third, enumerate the sizes of subtrees of T \ η as |Tm |, n1 , n2 , . . . , nk , and let N (i) = 1 + n1 + n2 + · · · + ni . Choose a point c in the angle * for some 0 ≤ i ≤ k. opposite 6 apb that is the N (i)th point clockwise from pa, Such an index i exists because the angle contains at least |Tm | points and N (j + 1) − N (j) = nj ≤ |Tm |. Now let Tα consist of the subtrees of T \ η with sizes n1 , . . . , ni and let Tβ be the rest of the subtrees. In two special cases we can finish the embedding easily: If η = ν, we embed ν into p and embed Tm , Tα , and Tβ by the algorithm of theorem 1. If η has degree 2, then Tβ is empty—in this case, we embed η into c and embed Tα and Tm into their appropriate angles with (c, b) connecting η to Tm . Whether ν goes with Tα or with Tm , it can be embedded at p according to theorem 2. Otherwise, if η 6= ν then determine the convex hull of points inside 6 bpc, including b and c but not p. We can assume, without loss of generality, that * and is node ν is in Tm or Tα . Let (q, r) be the hull edge that intersects ap closer to p. Note that triangle 4pqr is empty of points of P , as in figure 6.
P. Bose et al., Optimal Algorithms to Embed . . ., JGAA, 1(2) 1–15 (1997)
11
Finally, determine q 0 ∈ P such * that the open region bounded by pa, *0 r0 pq, and qq contains |Tm | − 1 points; c this can be done by sorting points * radially around q. The right of ap *0 |Tα | |Tβ | slope of qq lies between the slopes of * * r rq and pb for the following reasons: q p rq (dotted in figIf q 0 is not left of * ure 6) then the open region bounded b *0 a * pq, and qq does not include by pa, * |Tm | ¡ 1 any point of P from 6 cpb. If qq 0 does q0 * not intersect pb, then the open region *0 * pq, and qq includes bounded by pa, Figure 6: Finding (q, r) all points inside 6 apb. Similarly, determine r0 ∈ P such *0 * pr, and rr contains |Tα | that the interior of the open region bounded by pa, * pc and * qr. Thus, the three points. The slope of rr0 lies between the slopes of * * *0 * qq , and rr0 are convex. unbounded regions defined by 4pqr, pa, We use theorems 1 or 2 to embed Tα , Tm , and Tβ in the appropriate regions with ν at p, the root of Tm at q, and η at r. Sorting, computing convex hull structures, and embedding each take O(n log n) steps.
5
Finding degree-constrained embeddings
A problem similar to the rooted-tree embedding of section 3 is to find a tree with non-crossing straight line edges in a set of points when the vertex degree for each point in the plane is given but the tree itself is not provided. Tamura and Tamura [24] called this a degree-constrained embedding (dc-embedding), observed that such an embedding exists if and only if the sum of the degrees for n points is 2n − 2, and provided an algorithm to find a dc-embedding in O(n2 log n) time. Using hull trees and partitions, we obtain an O(n log n) time algorithm for the same problem: Theorem 4 If we are given n points P = {p1 , p2 , . . . , pn } inPgeneral position n where each point pi is labelled with a positive integer di and i=1 di = 2n − 2 then there is an algorithm that takes O(n log n) time to find a dc-embedding on P . Proof : Create a deletion-only upper hull maintenance structure for the points of P as described in section 2. For the convenience of the proof, assume that the names of the points in P are sorted by x-coordinate: pi < pj Pj for i < j. Assume that n > 1. Finally, let S(j) = 2j − 1 − i=1 di .
P. Bose et al., Optimal Algorithms to Embed . . ., JGAA, 1(2) 1–15 (1997)
12
The points on the upper hull of P fall into one of three categories: 1. there is a point of unit degree and a point of degree at least two on the hull 2. all points on the hull have unit degree 3. all points on the hull have degree at least two 12 1
32 (a)
pk 1 1 1 left subproblem right subproblem (b)
2
` a
b
pk
32 3
left subproblem right subproblem (c)
Figure 7: Three cases of recursion for the dc-embedding algorithm. In the first case, there must exist two such points that are adjacent along the hull. Join these points by an edge, delete the point of unit degree from the hull, and decrease the degree of the other point by 1 (see figure 7a). The rest of the dc-embedding is then built recursively. If all the hull points have unit degree then either n = 2, or d2 ≥ 2, or there exists an index k such that S(k − 1) > 0 and S(k) ≤ 0. If n = 2 then join the two vertices and stop. If d2 ≥ 2 then join p1 to p2 by a tree edge, delete p1 from the upper hull UH (P ), decrease d2 by 1, and recurse. If d2 = 1 then S(2) = 1 > 0 and S(n − 1) = 0 so the third condition holds for some k with 1 < k < n. By definition, S(k) = S(k − 1) + 2 − dk which implies that dk ≥ 3. Partition P and UH (P ) at pk with pk belonging to both smaller sets (see figure 7b). In the left subset, assign pk a degree of S(k − 1) + 1 which is greater than zero and at most dk − 1. In the right subset, assign pk the remaining degree from dk . Compute a dc-embedding for each subset recursively; the resulting trees will be connected through pk . Finally, if all the hull points have degree at least two then there exists an index k such that S(k) = 0 since S(1) < 0 and S(n − 1) ≥ 0 and the difference S(j)−S(j −1) increases by at most 1 whenever pj has unit degree. Let ` be a vertical line between pk and pk+1 and let a and b be the left and right endpoints of the upper hull edge of P that intersects ` (figure 7c). Partition P and its upper hull along `, join points a and b by a tree edge, decrease the degrees of points a and b by 1 each, and recursively find the dc-embedding for the subsets of P left and right of `. The time complexity of each step is O(log n) amortised time. The index k that satisfies the given conditions is found with a zero-finding search in the sequence S(1), S(2), . . ., S(n) that is stored in the hull tree. A binary search in the hull tree finds the index k in O(log n) time. The deletions and hull partitions of the steps are each done in O(log n) amortised time.
P. Bose et al., Optimal Algorithms to Embed . . ., JGAA, 1(2) 1–15 (1997)
13
Each of the steps occurs O(n) times since it either embeds a tree edge or partitions the convex hull where the partition vertex becomes a leftmost or rightmost hull vertex and is ineligible for a later partition. A sample dc-embedding appears in figure 8. 4
4 5
3
4
2
3
5
4
2
Figure 8: A sample dc-embedding. Unlabelled vertices have unit degree.
6
Lower Bounds
In this section, we provide Ω(n log n) lower bounds on quadratic algebraic decision trees for computing a straight-line embedding of a tree onto a set of n points and for computing a dc-embedding on n points. Theorem 5 establishes the optimality of our algorithms for solving these problems. The same bound can be established with a reduction to the unit cost RAM model used by Paul and Simon [21] for their lower bound on sorting. Theorem 5 Finding a straight-line embedding of any tree T with n nodes into a set P of n points requires Ω(n log n) time. Proof : An Euler tour of a tree T embedded into a set of n points gives a chain on 2n points in which no segments cross. Using such a chain from an embedding of any tree T into the point set P , a careful implementation of Melkman’s algorithm [14] will then compute the convex hull of P in O(n) time. The Ω(n log n) lower bound for computing the convex hull of P [22] implies the same lower bound for finding any straight-line embedding of T into P .
Acknowledgments We thank the referees for their suggestions on improving the presentation and organisation of this paper.
P. Bose et al., Optimal Algorithms to Embed . . ., JGAA, 1(2) 1–15 (1997)
14
References [1] P. Bose. On embedding an outer-planar graph in a point set. In Proceedings of Graph Drawing 97, page to appear, Rome, Italy, 1997. [2] P. Bose, G. Di Battista, W. Lenhart, and G. Liotta. Proximity constraints and representable trees. In R. Tamassia and I. G. Tollis, editors, Graph Drawing (Proc. GD ’94), volume 894 of Lecture Notes in Computer Science, pages 340–351. Springer-Verlag, 1995. [3] P. Bose, W. Lenhart, and G. Liotta. Characterizing proximity trees. Algorithmica: Special Issue on Graph Drawing, 16:83–110, 1996. [4] B. Chazelle. On the convex layers of a planar set. IEEE Trans. Info. Theory, IT-31:509–517, 1985. [5] P. Crescenzi and A. Piperno. Optimal-area upward drawings of AVL trees. In R. Tamassia and I. G. Tollis, editors, Graph Drawing (Proc. GD ’94), volume 894 of Lecture Notes in Computer Science, pages 307–317. SpringerVerlag, 1995. [6] G. Di Battista, P. Eades, R. Tamassia, and I. G. Tollis. Algorithms for drawing graphs: an annotated bibliography. Comput. Geom. Theory Appl., 4:235–282, 1994. [7] P. Eades and S. Whitesides. The realization problem for Euclidean minimum spanning trees is NP-hard. In Proc. 10th Annu. ACM Sympos. Comput. Geom., pages 49–56, 1994. [8] P. Gritzmann, B. Mohar, J. Pach, and R. Pollack. Embedding a planar triangulation with vertices at specified points (solution to problem e3341). American Mathematical Monthly, 98:165–166, 1991. [9] J. Hershberger and S. Suri. Applications of a semi-dynamic convex hull algorithm. BIT, 32:249–267, 1992. [10] Y. Ikebe, M. Perles, A. Tamura, and S. Tokunaga. The rooted tree embedding problem into points in the plane. Discrete & Computational Geometry, 11:51–63, 1994. [11] G. Kant, G. Liotta, R. Tamassia, and I. Tollis. Area requirement of visibility representations of trees. In Proc. 5th Canad. Conf. Comput. Geom., pages 192–197, Waterloo, Canada, 1993. [12] D. E. Knuth. Fundamental Algorithms, volume 1 of The Art of Computer Programming. Addison-Wesley, second edition, 1973. [13] J. Manning and M. J. Atallah. Fast detection and display of symmetry in trees. Congressus Numerantium, 64:159–169, 1988.
P. Bose et al., Optimal Algorithms to Embed . . ., JGAA, 1(2) 1–15 (1997)
15
[14] A. Melkman. On-line construction of the convex hull of a simple polyline. Information Processing Letters, 25:11–12, 1987. [15] C. Monma and S. Suri. Transitions in geometric minimum spanning trees. In Proc. 7th Annu. ACM Sympos. Comput. Geom., pages 239–249, 1991. [16] N. C. neda and J. Urrutia. Straight line embeddings of planar graphs on point sets. In Proc. 8th Canad. Conf. Comput. Geom., pages 312–318, 1996. [17] A. Okabe, B. Boots, and K. Sugihara. Spatial Tessellations: Concepts and Applications of Voronoi Diagrams. John Wiley & Sons, 1992. [18] J. O’Rourke. Computational Geometry in C. Cambridge Univ. Press, 1994. [19] M. Overmars and J. van Leeuwen. Maintenance of configurations in the plane. J. Comp. Sys. Sci., 23:166–204, 1981. [20] J. Pach and J. T¨ or˝ ocsik. Layout of rooted trees. In W. T. Trotter, editor, Planar Graphs, volume 9 of DIMACS Series, pages 131–137. American Mathematical Society, 1993. [21] W. Paul and J. Simon. Decision trees and random access machines. Logic and Algorithmics, Monograph 30, L’Enseignement Math´ematique, 1987. [22] F. P. Preparata and M. I. Shamos. Computational Geometry: an Introduction. Springer-Verlag, New York, NY, 1985. [23] O. Schwarzkopf. The extendible drawing editor Ipe. In Proc. 11th Annu. ACM Sympos. Comput. Geom., pages C10–C11, 1995. [24] A. Tamura and Y. Tamura. Degree constrained tree embedding into points in the plane. Information Processing Letters, 44:211–1214, 1992.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 1, no. 3, pp. 1–13 (1997)
Low-degree Graph Partitioning via Local Search with Applications to Constraint Satisfaction, Max Cut, and Coloring Magn´ us M. Halld´orsson Science Institute University of Iceland IS-107 Reykjavik, Iceland http://www.hi.is/~mmh
[email protected]
Hoong Chuin Lau Information Technology Institute 11 Science Park Road Singapore 117685
[email protected] Abstract We present practical algorithms for constructing partitions of graphs into a fixed number of vertex-disjoint subgraphs that satisfy particular degree constraints. We use this in particular to find k-cuts of graphs of 1 maximum degree ∆ that cut at least a k−1 (1 + 2∆+k−1 ) fraction of the k edges, improving previous bounds known. The partitions also apply to constraint networks, for which we give a tight analysis of natural local search heuristics for the maximum constraint satisfaction problem. These partitions also imply efficient approximations for several problems on weighted bounded-degree graphs. In particular, we improve the 3 best performance ratio for the weighted independent set problem to ∆+2 , and obtain an efficient algorithm for coloring 3-colorable graphs with at most 3∆+2 colors. 4
Communicated by M. F¨ urer: submitted February 1996; revised March 1997.
Halld´orsson, Lau, Low-degree Graph Partitioning, JGAA, 1(3) 1–13 (1997)
1
2
Introduction
Graph partitioning is a common theme in combinatorial optimization. We consider in this paper partitions of the vertices into a fixed number of induced subgraphs so that the indegrees of the vertices, or their degrees within their assigned subgraph, be within pre-specified upper bounds. The simplest objective is to limit the maximum indegree, while more generally we have bounds for each vertex which depend on the degree of that vertex. Since it is NP-complete in general to determine if a partition exists, we seek instead weak restrictions on the indegree upper bounds that guarantee existence. An immediate area of application is the Max k-Cut problem, which is to partition the vertices of a graph into k parts so as to maximize the number of the edges going between subgraphs. This is the dual problem of minimizing the average indegree. Edge cutting can be generalized beyond pure graphs to constraint systems: each edge is a binary relation whose satisfaction depends on the assignment of the incident vertices. The maximum constraint satisfaction problem, Max-Csp, is to find a k-partition of the vertices that maximizes the number of satisfied edges. Constraint satisfaction is a recurring theme in Artificial Intelligence with a variety of applications, e.g. in machine vision, temporal reasoning and scheduling. It generalizes other important combinatorial problems including Satisfiability. The Max-Csp problem naturally involves a parameter known as consistency: an instance is r-consistent, if for any constraint and any value of one incident vertex, there are r choices for the other vertex that satisfy the constraint. Note that Max k-Cut is a special case of (k − 1)-consistent MaxCsp. Our treatment of Max k-Cut and Max-Csp is characterized by two attributes. First, we seek to analyze the performance of simple and natural local search algorithms, which was our initial motivation in the current study. Second, the analysis focuses on the absolute ratio of the algorithms, which is the fraction of the edges (or constraints) that are cut (or satisfied). This is contrasted with the relative ratio, better known as the performance ratio, which is the ratio of the number of edges satisfied by the algorithm to the size of the optimal solution. When the maximum indegree is fixed while the number of subgraphs is allowed to vary, we obtain a form of a coloring problem. In the standard Graph Coloring problem, indegree is fixed to be zero. The partitions we obtain also apply to these coloring problems. Our results After preliminary definitions in Section 2, we consider plain local search for Max-Csp in Section 3. We show that it produces a k-partition of r-consistent instances such that the number of satisfied constraints incident on r a vertex v of degree d(v) is at least d r·d(v) k e. This gives an absolute ratio of k , which is tight. Slightly better bounds hold for special cases. We next give, in Section 4, a method, also based on local search, that produces tighter partitions. It obtains a partition of a graph where, for a non-
Halld´orsson, Lau, Low-degree Graph Partitioning, JGAA, 1(3) 1–13 (1997)
3
constraint graph, each vertex v assigned to the t-th subgraph is of indegree at 1 −1c. We use this to obtain an absolute ratio of k−1 most b d(v)+t k k (1+ 2∆+k−1 ) for 1 Max k-Cut, improving the best previous known ratio of k−1 k (1 + n ). This can be implemented in O(∆n) time. We, however, find that this approach cannot improve the ratio for Max-Csp. Finally, we derive, in Section 5, improved performance ratios for Graph Coloring and a family of induced subgraph problems in weighted bounded-degree graphs. These use a simplification of our partitioning that reduces to a result of Lov´ asz, where the bounds for all the vertices are identical. We obtain 3 for the weighted independent set problem, and a performance ratio of ∆+2 1/d(∆ + 1)/3e for all hereditary induced subgraph problems on weighted graphs in linear time. Also, we show how to color 4-clique-free graphs, which include colors in linear time. 3-colorable graphs, using at most 3∆+2 4 Previous results A number of approximation results are known for Max k-Cut. Let n and m denote the number of vertices and edges in the input graph, re1 1 [10], 12 + 2(n−1) spectively. For k = 2, there are absolute ratios of 12 + 2n [12], and 12 + n−1 4m [20], while the relative ratio has recently been improved to about 0.878 by Goemans and Williamson [9]. For k > 2, the best absolute ratio 1 is k−1 k (1 + n ) [22], while Frieze and Jerrum [7] generalized the results of [9], ln k achieving a relative ratio of k−1 k + Θ( k2 ). For Max-Csp, the only published absolute ratio we are aware of is the 1 n−1 + ık [20] for domain size k = 2 and consistency r = 2 4m ratio of Poljak and Turz´ 1. An absolute ratio of kr can be observed for a greedy algorithm, which would also be the derandomized version of the randomized schema similar to that used by Yannakakis [23] and Goemans and Williamson [8] used to approximate maximum satisfiability. As for relative ratios, Khanna et al. [14] considered weighted Max-Csp with domain size 2. They achieved a ratio of 14 via a sophisticated local search algorithm. More recently, this ratio was improved to 12 by Trevisan [21] using randomized rounding of linear programs. The current best ratio is 0.859, due to Feige and Goemans [6] via randomized rounding of semidefinite programs. Lau and Watanabe [16] have proved a ratio of 0.408 for Max-Csp with domain size 3, and in general a ratio of k1 for domain k.
2
Preliminaries
Let G denote an unweighted, undirected, not necessarily simple, graph, with vertex set V and edge set E. Let n denote the number of vertices, m the number of edges, and d(v) the degree of vertex v. Let k be a positive integer. Graph partitioning The maximum k-cut problem (Max k-Cut) is defined as follows:
Halld´orsson, Lau, Low-degree Graph Partitioning, JGAA, 1(3) 1–13 (1997)
4
INSTANCE: Graph G = (V, E), and positive integer k. SOLUTION: A partition of V into k subsets such that the number of edges across subsets is maximized. Constraint Satisfaction The domain of a vertex v is the set of assignable values for v. For our purpose, these domains are all {1, . . . , k}. An assignment is a mapping of vertices to values in their respective domains. A constraint R(u, v) between vertices u and v, is a binary relation on {1, . . . , k} × {1, . . . , k} which defines the pairs of values that can be assigned to u and v simultaneously. A constraint R(u, v) is said to be satisfied by an assignment f iff (f (u), f (v)) is in R(u, v). The maximum constraint satisfaction problem (Max-Csp) is defined as follows: INSTANCE: Graph G = (V, E), with constraint relation R(u, v) associated with each edge (u, v) ∈ E, and positive integer k. SOLUTION: An assignment f : V → {1, . . . , k} such that the number of satisfied constraints is maximized. An assignment can be viewed as a partition of vertices into k classes, or subsets. We shall use “edge” and “constraint” interchangably. Consistency A constraint R(u, v) is said to be r-consistent (1 ≤ r ≤ k) iff, for every value x, 1 ≤ x ≤ k, there exist at least r consistent values y such that (x, y) ∈ R(u, v), and vice versa. A Max-Csp instance is r-consistent iff all its constraints are r-consistent. Let Max-Csp(k, r) represent the class of Max-Csp instances which have domain size k and are r-consistent. Observe that Max k-Cut is equivalent to Max-Csp(k, k − 1) with all constraints being the “not-equal” constraint ((x, y) ∈ R(u, v) iff x 6= y). Approximation Let A be an algorithm for a maximization problem. We say that A approximates the problem within a relative ratio ρ (0 < ρ ≤ 1) iff on all instances, A returns a solution whose value is at least ρ times the value of the optimal solution in time polynomial in the size of the input. We say that A approximates the problem within an absolute ratio iff it returns a solution whose value is at least times the largest possible solution on each given input. Clearly, an absolute ratio implies a no smaller relative ratio but not vice versa. Satisfiable instances A Max-Csp instance G = (V, E) is said to be satisfiable if all its constraints can be simultaneously satisfied. It is known that ratios that hold for the class of 1-consistent instances also hold for the class of satisfiable instances. Observation 1 If 1-consistent Max-Csp can be approximated within absolute ratio ρ, then satisfiable Max-Csp can be approximated within absolute ratio ρ.
Halld´orsson, Lau, Low-degree Graph Partitioning, JGAA, 1(3) 1–13 (1997)
5
Proof. Let G be an instance of satisfiable Max-Csp of m constraints. Then we can construct a 1-consistent CSP instance G0 = (V, E 0 ) in time O(nk 2 ) [5] such that: (1) each vertex in V has domain size at most k; (2) E 0 ⊆ E (though the underlying relations may not be the same); and (3) for any assignment f , a constraint in E 0 is satisfied iff it is satisfied in E, while all constraints in E − E 0 are always satisfied. Suppose f is an assignment which satisfies at least m0 constraints in G0 . The same f then satisfies at least m0 + (m − m0 ) ≥ m constraints in G.
3
Simple Local Search
In this section, we consider the performance of a simple local search procedure for Max-Csp. The objective value of an assignment is the number of constraints that it satisfies. Two assignments f and f 0 are said to be neighbors if their values differ on exactly one vertex. An assignment is a local optimum iff its objective value is at least that of all its neighbors. Let LS be the following simple local search, or hillclimbing, procedure: Start with any arbitrary initial assignment f . while (there is a neighbor f 0 of f with a higher objective value) do f ← f0 output f The following lemma is the key to our analysis: Lemma 2 Let f be any locally optimal solution computed by LS from an instance of Max-Csp(k, r). Then, for all vertices v, the number of constraints incident on v that are satisfied by f is at least d r·d(v) k e. Proof. Let v be a vertex, and evaluate the number of satisfied constraints as we examine all k possible values for v. Only the constraints incident on v are affected, while consistency ensures that each of them is satisfied at least r times, independent of the value of the other incident vertices. Thus, the locally optimal value for v must satisfy at least d rd(v) k e of the incident constraints. We obtain a bound on the performance of simple local search. Theorem 3 LS approximates Max-Csp(k, r) within an absolute ratio of
r k.
Proof. Termination of the search is guaranteed by the fact that the objective function is monotone increasing with a maximum of m. Then, summing up over P = rm all the vertices, at least 12 v rd(v) k k constraints are satisfied, by Lemma 2. This bound is tight in that there are instances, even satisfiable ones, where the heuristic satisfies no more than kr constraints. We present these in Section 4.1. This result can, however, be slightly strengthened when the degrees of the vertices satisfy a certain congruence relation.
Halld´orsson, Lau, Low-degree Graph Partitioning, JGAA, 1(3) 1–13 (1997)
6
Corollary 4 Suppose there is an s, 1 ≤ s ≤ k−1, such that, for each constraint, s the residue (k − r)d(v) mod k is at least s. Then, LS satisfies at least m kr + n 2k constraints. Proof. least:
The number of satisfied constraints incident on a given vertex v is at
k−r rd(v) + s rd(v) e = d(v) − d d(v)e + 1 = . k k k Summing over all vertices, the total number of satisfied constraints is at least: P 1 r s r s (d(v) v 2 k + k ) = m k + n 2k . d
4
Modified Local Search
We present in this section a lemma on low-degree partitioning of graphs, and its application to improved approximations of Max k-Cut. The bounds on the degrees in the resulting partition are specified in terms of a matrix, which we define as follows. Definition 1 Let G = (V, E) be a graph on n vertices, k be an integer, and A be a n × k integer matrix. A is a degree partitioning matrix (DPM) of G if, k X
A[v, j] ≥ d(v) − k + 1,
for each vertex v ∈ V .
j=1
A DPM suggests a partition f where, for each vertex v, the number indeg(v) of neighbors within its subgraph is bounded from above by the corresponding entry A[v, f (v)]. We shall argue the existence of such a partition, as a corollary of the termination of a simple local improvement algorithm. Given a k-partition f , let degj (v) denote the number of vertices in subset j that are adjacent to v. Namely, degj (v) = |{w : (v, w) ∈ E and f (w) = j}|. Let indegf (v) be a shorthand for degf (v) (v). We omit f when implicit. We consider a local search algorithm that evaluates the following local condition: (1) A[v, j] − degj (v) has a maximum at j = f (v). The local search rule is simply to change the assignment of a vertex to one satisfying (1). The termination condition is that the local condition be satisfied at each vertex. Observe that the local condition can always be fulfilled with a non-negative value A[v, j] − degj (v), given the defining property of the DPM. We find that the local search always terminates, and does so relatively quickly, especially given a starting assignment of rudimentary quality. Lemma 5 Consider a graph G, an associated DPM A, and a starting assignment f . Then, at most X 1 (2) (max A[v, j]) − A[v, f (v)] + indegf (v) j 2 v∈G
Halld´orsson, Lau, Low-degree Graph Partitioning, JGAA, 1(3) 1–13 (1997)
7
iterations are performed until a locally optimal assignment is obtained under condition (1). Before we give the proof, we note that this shows that in most cases the number of iterations is O(m). This holds for instance when given a greedy initial assignment or the trivial assignment that maximizes the A-value for each vertex independently. It also holds when the improvements are scheduled so that all vertices are tested for improvement in the first n iterations, e.g. by using a worklist approach. Finally, one would expect in all applications that all entries A[v, j] would be bounded by the degree d(v) of the vertex. In all of these cases, the number of iterations is O(m). It, however, appears plausible that there exist an initial assignment and a sequence of improvements whose number is asymptotically greater than m. P Proof. Consider the potential function Ψ(f ) = v [2A[v, f (v)] − indeg(v)], which measures the progress towards a locally optimal solution. In an iteration of the algorithm, a single vertex v is moved from partition i to partition j. This changes the potential only for the part contributed by v on one hand, and by the neighbors of v in subsets i and j on the other hand. The resulting change in potential is ∆Ψ
=
(2A[v, j] − degj (v)) − (2A[v, i] − degi (v)) + (degi (v) − degj (v))
=
2 [(A[v, j] − degj (v)) − (A[v, i] − degi (v))]
The local search rule ensures that A[v, j]−degj (v) is strictly greater than A[v, i]− degi (v) when v is moved from partition i to j. Hence ∆Ψ ≥ 2. The difference in the potential of the final, locally optimal solution f 0 and the initial solution f is X [2(A[v, f 0 (v)] − A[v, f (v)]) + indegf (v) − indegf 0 (v)]. v
Hence, half this number of iterations suffices. We now use this partitioning to approximate Max k-Cut. For this, we need a slightly stronger local improvement search. Theorem 6 Max k-Cut can be approximated within an absolute ratio of 1 2∆+k−1 ).
k−1 k (1+
Proof. The k-partition is obtained in two steps. First, we find a partition that is locally optimal w.r.t. (1). We then apply standard local search, optimizing the number of cut edges, until local optima is achieved. c − 1, for For the former, we use an evenly split DPM, with A[v, t] = b d(v)+t k each vertex v and each subgraph t. For such a balanced DPM, the application of standard local search preserves optimality w.r.t. (1). Namely, if degj (v) < degi (v), then A[v, j] − degj (v) ≥ A[v, i] − degi (v), since A[v, i] and A[v, j] differ by at most one. Hence, we obtain an assignment f that is locally optimal under both criterias.
Halld´orsson, Lau, Low-degree Graph Partitioning, JGAA, 1(3) 1–13 (1997)
8
We now focus on bounding the quality of the resulting assignment. Local optimality w.r.t. (1) ensures that indeg(v) ≤ b
d(v) + f (v) c − 1. k
(3)
Let Unsat denote the number of edges that are not satisfied, i.e. have both endpoints within the same subgraph. Let Vi denote the set of vertices in the i-th subgraph. Applying (3) and simplifying by ignoring the floor, we obtain Unsat =
k 1 X m n 1XX − + indeg(v) ≤ t · |Vt |. 2 t k 2 2k t=1
(4)
v∈Vt
Replace the last term of the sum using |Vk | = n − Unsat ≤
Pk−1 t=1
|Vt |, to get
k−1 1 X m − (k − t) · |Vt |. k 2k t=1
(5)
By standard local optimality, each vertex v in the graph is adjacent to at least indeg(v) vertices in Vt , while each vertex in Vt can contribute to at most ∆ of these adjacencies. Hence, the number of vertices in Vt is bounded by |Vt | ≥
X indeg(v) Unsat = 2 , ∆ ∆
t = 1, . . . , k − 1.
v∈G
Plug this into (5) to obtain Unsat ≤ Thus, Unsat ≤
m (k − 1)Unsat − . k 2∆
(6)
k−1 m k−1 m /(1 + ) = (1 − ). k 2∆ k 2∆ + k − 1
Hence, at least
1 k−1 (1 + ) k 2∆ + k − 1 edges are satisfied, yielding the theorem. m
Time complexity In the case of a balanced DPM as above, the difference in the initial and final potential (as in Lemma 5) is at most n plus the difference in the number of satisfied edges. By using a Greedy initial assignment, the initial m number of unsatisfied edges is at most m k . Thus, n + k iterations suffice. The local search algorithms can be implemented to require only amortized O(∆) time per iteration. We pre-compute the degrees of the vertices into each
Halld´orsson, Lau, Low-degree Graph Partitioning, JGAA, 1(3) 1–13 (1997)
9
subgraph in the starting partition, and then only O(∆) updates are needed in each iteration. Hence, the total complexity is at most O(∆ m k ). If we are content with the performance bounds, and do not seek local optima, the local search can be terminated prematurely when sufficiently many edges m
4.1
Extension to Constraint Satisfaction
The concept of a degree partitioning matrix and the corresponding partition can also be extended to constraint systems. A matrix A is said to be a DPM of an r-consistent constraint graph G if, k X
A[v, j] ≥ (k − r)d(v) − k + 1,
for each vertex v.
i=1
Define degj (v) to be the number of constraints incident on v that are not satisfied if the assignment of v is changed to j (assuming a given assignment f ). As before, indeg(v) = degf (v) (v). The algorithm and its proofs of optimality and time complexity remain the same. It is tempting to try to prove a similar result for Max-Csp(k, r). Unfortunately, this is not possible, since instances can be constructed where a locally optimal solution satisfies at most an kr fraction of the constraints. In fact, even the relative ratio of the algorithm is tight. Theorem 7 Local search under (1) does not approximate Max-Csp within better than kr , neither absolute nor relative. Namely, there is an infinite sequence of satisfiable instances where some locally optimal solutions satisfy only an kr fraction of the constraints. Proof. Given k and r, we construct the following constraint graph G. G contains 3k vertices vi,j , for i = 0, . . . , k − 1 and j = 0, 1, 2, each of degree 2k. There are constraints between vi,j and vi0 ,j 0 whenever j 6= j 0 , given by: R(vi,j , vi0 ,j+1 mod 3 ) = { (x, y) : [(i0 −i)+(y−x)] mod k lies between 0 and r−1 }. Notice that the constraints are not symmetric. An optimal solution assigns each vertex vi,j to subset i, yielding a totally satisfied solution. Suppose we have an initial assignment where all vertices are assigned to subset k − 1. Then each vertex vi,j is consistent with 2r of the adjacent vertices; i.e. r vertices of the form vi0 ,j+1 mod 3 and r of the form vi0 ,j−1 mod 3 . Hence, indeg(vi,j ) ≤ 2k − 2 = A[vi,j , k − 1]. Furthermore, one can verify that moving a single vertex to a different subgraph leaves the number of incident satisfied constraints unchanged. Hence, we have a local optima with an absolute and relative ratio of kr . Note that this proof can be extended to graphs of any number of layers greater than 2.
Halld´orsson, Lau, Low-degree Graph Partitioning, JGAA, 1(3) 1–13 (1997)
10
It is also easy to construct multigraphs where at most an kr fraction of the constraints can be simultaneously satisfied. In the case of simple constraint graphs, however, it appears that a slightly larger fraction is satisfiable, while it 1 )) bound of Max k-Cut. does not exceed the kr (1 + Θ( ∆
5
Applications to induced subgraph problems and graph coloring
An important special case of the graph partitioning in the previous section is when we only seek to bound the maximum indegree from above. In this case, Lemma 5 reduces to the following result of Lov´ asz. Lemma 8 (Lov´ asz [18]) Let G = (V, E) be a multigraph without self loops. P Let t1 , t2 , . . . , tk be non-negative integers such that i (ti +1)−1 = ∆(G). Then, V can be partitioned into k subsets inducing subgraphs G1 , G2 , . . . Gk such that ∆(Gi ) ≤ ti , for i = 1, 2, . . . k. m By (2), we achieve this in O( m k ) iterations, or O(∆ k ) time. This lemma has several elegant applications to the approximation of induced subgraph and vertex partitioning problems. A property of graphs is said to be hereditary if, whenever it holds for a graph it also holds for any induced subgraph.
Theorem 9 Hereditary weighted induced subgraph problems can be approximated within relative ratio of 1/d(∆ + 1)/3e in linear time. Proof. We partition the graph into at most s = d ∆+1 3 e graphs of degree at most 2, in linear time, using Lemma 8. Such graphs consist of disjoint paths and cycles, and allow for a linear time solution of hereditary induced subgraph problems via dynamic programming. Any property π holds either for every path, or for all paths of length up to q, where q is a fixed constant, and the same dichotomy holds for cycles. Our approximate solution will be the largest of the (exact) solutions from these s subgraphs. The optimal solution of the whole graph can contain at most as many vertices from each subgraph as the optimal solution on that subgraph. Hence, the optimal solution is at most s times as large as the approximate solution. One such problem is Max Compatible Constraint Satisfaction [4, MS11], This is problem on a CSP instance, where the objective is to find an assignment to a subset of the vertices that satisfies all the induced constraints. Corollary 10 Max Compatible Constraint Satisfaction can be approximated within a relative ratio of 1/d ∆+1 3 e in linear time. The previous best approximation for the weighted independent set problem 2 due to Hochbaum [11]. We can use her approximation for ∆ = 3 to improve is ∆ our ratio when ∆ is a multiple of 3.
Halld´orsson, Lau, Low-degree Graph Partitioning, JGAA, 1(3) 1–13 (1997)
11
Proposition 11 The weighted independent set problem can be approximated 3 3 . When ∆ mod 3 = 2, the ratio is ∆+1 , while within a relative ratio of ∆+2 3 when ∆ mod 3 = 0, the ratio is ∆+3/2 . Proof. When ∆ mod 3 is congruent to 1 or 2, the claim follows from Theorem 9. When ∆ mod 3 = 0, partition the vertices into ∆ 3 classes, where all but possibly the last have maximum degree 2. Find a 23 -approximate weighted independent set in the last class, compute optimal solutions of the other classes, and let output the largest of all of these. Let W denote the weight of our solution. The weight of the optimal solution is at most the sum of the weights of the optimal solutions on the ∆ 3 subgraphs. The weight of the optimal solution of the last subgraph is at most 32 W , but at most W for the other subgraph. Hence, ∆ 1 the weight of the optimal solution is at most [ 32 + ( ∆ 3 − 1)]W = [ 3 + 2 ]W . By applying a preprocessing method championed by Hochbaum [11], we can obtain improved approximations of weighted vertex cover, for ∆ ≥ 5. The relative approximation of minimization problems is defined identically to that of maximization problems, except that the ratio is necessarily greater than 1. Corollary 12 The weighted vertex cover problem can be approximated within 3 in time O(∆n3/2 ). 2 − ∆+2
5.1
Coloring
Lov´ asz’s lemma also has implications for the coloring of bounded-degree graphs, as observed previously by Catlin [3], Borodin and Kostochka [2] and Lawrence [17]. The constructive nature of the lemma has apparently not been made explicit before. Our implementation yields an efficient coloring algorithm. Proposition 13 Graphs without 4-cliques can be colored with linear time.
3∆+2 4
colors in
Proof. Partition the input graph into subgraphs of degree 3 or 4 via Lemma 8, with (∆ + 2) mod 3 subgraphs of degree 4 and the remaining ones of degree 3. Assuming the graph contains no clique on 4 vertices, each subgraph Gi can be colored with ∆(Gi ) colors by the algorithm that follows from Lov´ asz’ constructive proof of Brooks’ theorem [19]. This can be generalized to (t−1)∆+(t−2) colors for graphs without t-cliques. t Karger, Motwani and Sudan [13] have recently obtained a ∆1−Ω(1) log n approximation for 3-coloring. The advantage of our approach, however, is speed, simplicity, ease of implementation, and better bounds for all constant (or slightly superconstant) values of ∆.
Acknowledgement We would like to thank Osamu Watanabe for his helpful comments, and the referees for suggestions for improved presentation. A portion of this paper appeared in preliminary form in [15].
Halld´orsson, Lau, Low-degree Graph Partitioning, JGAA, 1(3) 1–13 (1997)
12
References [1] Paola Alimonti. New local search approximation techniques for maximum generalized satisfiability problems. Inf. Proc. Let., 57(3):151–158, 12 Feb 1996. [2] O. V. Borodin and A. V. Kostochka. On an upper bound of a graph’s chromatic number, depending on the graph’s degree and density. J. Combin. Theory Ser. B, 23:247–250, 1977. [3] P. A. Catlin. A bound on the chromatic number of a graph. Discrete Math., 22:81–83, 1978. [4] P. Crescenzi and V. Kann. A compendium of NP optimization problems. Dynamic on-line survey available at ftp.nada.kth.se, also in http://www.nada.kth.se/~viggo/problemlist/compendium.html, Oct. 1995. [5] Rina Dechter and Judea Pearl. Network-based heuristics for constraint satisfaction. Artif. Intell., 34:1–38, 1988. [6] Uriel Feige and Michel Goemans. Approximating the Value of Two-Prover Proof Systems, with Applications to MAX 2SAT and MAX DICUT. In Proc. Israel Symp. on Theoretical Computer Science, 182–189, 1995. [7] Alan Frieze and Mark Jerrum. Improved approximation algorithms for MAX k-CUT and MAX BISECTION. Algorithmica, 18(1):67–81, May 1997. [8] Michel X. Goemans and David P. Williamson. New 3/4 Approximation Algorithms for the Maximum Satisfiability Problem. SIAM J. Disc. Math, 7(4):656–666, 1994. [9] Michel X. Goemans and David P. Williamson. Improved Approximation Algorithms for Maximum Cut and Satisfiability Problems Using Semidefinite Programming. J. ACM, 42:1115-1145, 1995. [10] D. J. Haglin and S. M. Venkatesan. Approximation and intractability results for the maximum cut problem and its variants. IEEE Transactions on Computers, 40:110–113, 1991. [11] D. S. Hochbaum. Efficient bounds for the stable set, vertex cover, and set packing problems. Disc. Applied Math., 6:243–254, 1983. [12] Y. Kajitani, J. D. Cho, and M. Sarrafzadeh. New approximation results on graph matching and related problems. In Graph-Theoretic Concepts in Computer Science, International Workshop (WG), pages 343–358. Springer Verlag LNCS (903), 1994.
Halld´orsson, Lau, Low-degree Graph Partitioning, JGAA, 1(3) 1–13 (1997)
13
[13] D. Karger, R. Motwani and M. Sudan. Approximate Graph Coloring by Semidefinite Programming. In Proc. 35th IEEE Symp. on Found. of Comp. Sci., pages 2–13, 1994. [14] S. Khanna, R. Motwani, M. Sudan, and U. Vazirani. On syntactic versus computational views of approximability. In Proc. 35th IEEE Symp. on Found. of Comp. Sci., pages 819–830, 1994. [15] H. C. Lau. Approximation of constraint satisfaction via local search. In Proc. 4th Wksp. on Algorithms and Data Structures (WADS), pages 461– 472. Springer LNCS (955), 1995. [16] H. C. Lau and O. Watanabe. Randomized Approximations of the Constraint Satisfaction Problem. Nordic J. Computing, 3:405–424, 1996. [17] J. Lawrence. Covering the vertex set of a graph with subgraphs of smaller degree. Discrete Math., 21:61–68, 1978. [18] L. Lov´ asz. On decomposition of graphs. Stud. Sci. Math. Hung., 1:237–238, 1966. [19] L. Lov´ asz. Three short proofs in graph theory. J. Combin. Theory Ser. B, 19:269–271, 1975. [20] Svatopluk Poljak and Daniel Turz´ık. A polynomial time algorithm for constructing a large bipartite subgraph, with an application to a satisfiability problem. Can. J. Math, 34(3):519–524, 1982. [21] Luca Trevisan. Positive Linear Programming, Parallel Approximation and PCPs. In Proc. European Symp. on Algorithms (ESA). Springer LNCS (1136), 1996. [22] P. M. Vit´ anyi. How well can a graph be n-colored. Discrete Math, 34:69–80, 1981. [23] M. Yannakakis. On the Approximation of Maximum Satisfiability. J. Algo, 17:475–502, 1994.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 2, no. 1, pp. 1–24 (1998)
Algorithms for Cluster Busting in Anchored Graph Drawing Kelly A. Lyons Centre for Advanced Studies IBM Toronto Laboratory http://www.cas.ibm.ca/
[email protected]
Henk Meijer
David Rappaport
Department of Computing and Information Science Queen’s University http://www.qucis.queensu.ca/
[email protected] [email protected] Abstract Given a graph G and a drawing or layout of G, it is sometimes desirable to alter or adjust the layout. The challenging aspect of designing layout adjustment algorithms is to maintain a user’s mental picture of the original layout. We present a new approach to layout adjustment called cluster busting in anchored graph drawing. We then give two algorithms as examples of this approach. The goals of cluster busting in anchored graph drawing are to more evenly distribute the nodes of the graph in a drawing window while maintaining the user’s mental picture of the original drawing. We present simple and efficient iterative heuristics to accomplish these goals. We formally define some measures of distribution and similarity and give empirical results based on these measures to quantify our methods. The theoretical analysis of our heuristics presents a formidable challenge, thus justifying our empirical analysis. Communicated by G. Di Battista: submitted April 1996; revised March 1998.
Research supported in part by an IBM Toronto Laboratory Centre for Advanced Studies PhD Fellowship and by an NSERC of Canada grant.
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 2
1
Introduction
A graph G = (V, E) is a set of n nodes V = {v0 , v1 , . . . , vn−1 } and a set of edges E = {eij = {vi , vj } | there is an edge between vi ∈ V and vj ∈ V }. The edges can be directed, in which case eij 6= eji or undirected, in which case eij = eji . The problem of drawing a graph given its combinatorial description G is termed layout creation in [25]. Layout creation algorithms try to position the nodes and edges of G such that certain optimization criteria are satisfied. In the case where graphs with an existing layout must be redrawn, the layouts can have clusters of nodes that are close together, making the labels of the nodes and the interactions between the nodes hard to read and understand. The reapplication of a layout creation algorithm is not useful for layout adjustment, because a new layout that is drastically different from the existing one destroys the user’s mental picture of the layout [4, 11, 25]. Given a combinatorial description of a graph G along with an existing drawing D of G, the goal of layout adjustment algorithms is to produce a new drawing D0 of G such that the layout can be easily read and such that the user’s mental picture of D is not destroyed. Our results have been applied to the CORDS project at the Centre for Advanced Studies (CAS) at the IBM Software Solutions Toronto Laboratory [3, 13, 14]. The CORDS research project (which ended in 1995) studied the design, development, and management of distributed applications. One of the underlying services provided by the CORDS architecture was the support for visualization. The following layout adjustment problems were identified as part of the visualization component in the CORDS project. The programming of distributed systems with a vast number of processors and communications links requires a method for visualizing the network as well as the systems running on the network [13]. In particular, there is a requirement to draw graphs of networks in which the nodes represent geographic locations such as cities in a country or buildings on a campus. The geographic locations of the nodes provide meaning to a user who is looking at the layout; therefore, it is important to retain this location information when drawing the graph. Other types of graphs that must be displayed by a visualization system are those that have been created by a user using a graph editor [2]. In this case, the user has put nodes in positions that either have meaning initially or gain importance after the graph has been viewed. After the user has edited the layout, the layout can become hard to read and understand. In 1993, members of the CORDS team built a prototype to validate the architecture [1], and early versions of the layout adjustment algorithms presented in this paper were used to draw graphs of networks and graphs that were initially drawn manually. In [10, 11, 25], an approach to layout adjustment called preserving the mental map is presented in which some measure of similarity between the node positions in D and the node positions in D0 is preserved while trying to separate
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 3 overlapping nodes. In [11], several mathematical models of a user’s mental map are presented. One such model, called the cluster model, uses the notion of the shape of a set of points. The idea of using proximity graphs to define the shape of a set of points is used in pattern recognition [31, 32, 33] and suggested in [11] as a good measure of a user’s mental map. Proximity graphs of a set of points include the convex hull, the minimum spanning tree, and the sphere of influence graph. The mental map is preserved between two layouts if the proximity graphs defined on the node positions of the two layouts are the same. In [25], these concepts are further explored, algorithms are presented, and some experiences with visualization systems are given. In this paper, we weaken the requirement that the measure of similarity be preserved. Instead, we try to improve the distribution of the nodes in the new layout according to some measures of distribution (a process we call cluster busting) while simultaneously trying to minimize the difference between the two layouts according to some measures of difference (a process we call anchored graph drawing). We present two heuristic algorithms for layout adjustment that are based on this approach. Cluster busting in anchored graph drawing was introduced in [21]. A drawing of a graph is denoted by D = (G, S, W ), where G = (V, E) is a graph, S = {p0 , p1 , . . . , pn−1 } is a set of points, and W is a window that contains S. The window is an isothetic rectangle in the plane such that bl = (xbl , ybl ) is the bottom left corner of W and tr = (xtr , ytr ) is the top right corner. A drawing D0 = (G, S 0 , W 0 ) denots a transformation of D where S 0 = {p00 , p01 , . . . , p0n−1 } and W 0 contains S 0 . The goal of cluster busting in anchored graph drawing is to produce a new drawing D0 of an existing drawing D such that the following criteria are satisfied: CB1 W = W 0 CB2 The nodes in D0 should be more evenly distributed inside W than the nodes in D, CB3 The general shape of D0 should be the same as D. These criteria are the same as those presented in [10]. Note that criteria CB1 and CB2 do not take the edges of the graph into consideration. It is unclear from the description of criterion CB3 whether or not the shape of the drawing includes the edges of the graph. Our algorithms ignore the edges of the graph when determining the new node positions. The definition of “shape” presented in [10] also excludes the edges of the graph. In Section 2 we present related work. In Section 3, we present measures of distribution and similarity. Two cluster busting in anchored graph drawing algorithms are presented in Section 4. In Section 5 we present results, and we conclude with future areas of research in Section 6.
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 4
2
Related Work
A comprehensive survey of graph drawing algorithms is presented in [8]. Compared to the number of layout creation algorithms available, little work has been done in designing dynamic graph drawing algorithms or layout adjustment algorithms [8]. An early result in dynamic graph drawing is an algorithm for drawing trees that change [27]. More recently, polylogarithmic algorithms that update drawings of trees, special types of digraphs, and general planar graphs are presented in [5]. In [4], user-defined constraints (in the form of linear equations of two variables) are added to an existing layout algorithm to keep drawings stable. Examples of constraints that a user might want to specify include absolute positioning (for example, if nodes are placed on horizontal levels, a node may be constrained to a specific level or a specific position within a level), relative positioning (node pi is to the left of node pj ), or clusters (grouping nodes together in a cluster that can be further constrained by size and/or position). Constraints are defined on an x, y coordinate system: The fact that node pi should be vertically above node pj translates to two equations, xi = xj , and yi < yj . A constraint manager maintains a list of all constraints, keeps the set of constraints consistent, and provides functions to add, delete, and query the status of constraints. It is shown how user-defined constraints can be added to many existing layout algorithms. In [24], incremental graph layout allows graphs to be updated without disturbing the existing nodes and edges in the layout. Nodes and edges are added one at a time such that one node cannot overlap another and an edge cannot cross a node. In these layouts, every node is a rectangle and every edge is a sequence of horizontal and vertical segments. In [10], algorithms are presented that preserve the mental map of the drawing according to the orthogonal ordering model of a user’s mental map; that is, for each pair of node positions pi and pj in D with corresponding positions p0i and p0j , respectively, in D0 : • x0i < x0j if and only if xi < xj , and • yi0 < yj0 if and only if yi < yj where pi = (xi , yi ). Preserving the orthogonal ordering of the nodes while keeping the nodes inside the original-sized display window may not allow enough movement to distribute the nodes so that it can be determined if there are edges between them [22]. As with several other successful methods for drawing general undirected graphs, our algorithms are heuristic; therefore, we present quantitative measures of the layouts that provide evidence that the algorithms satisfy the criteria in practise. In [23, 26, 29, 34], quantitative measures are also used to evaluate layouts produced by heuristic algorithms. For example, a heuristic algorithm
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 5 that tries to produce drawings with uniform edge lengths, evenly distributed nodes, and minimal edge crossings is presented in [34]. The algorithm finds an initial placement of each node by minimizing a cost function made up of three components representing each of the three criteria. A quantitative measure is defined for each of the criteria, and layouts produced by the algorithm are compared with layouts produced by the algorithms in [6] and [17] based on these measures. In the following section we define quantitative measurements of layouts for evaluating the cluster busting in anchored graph drawing algorithms presented in Section 4.
3
Measuring Similarity and Distribution
It is straight forward to measure if a drawing is inside a given drawing window; however, quantifying even distribution and similarity are much more difficult. In this section we present one model of distribution and two models of similarity, and define measurements of layouts based on these models. In [22], additional models of distribution and similarity are presented.
3.1
Measuring Distribution
Criterion CB2 states that the nodes in D0 should be more evenly distributed inside W than the nodes in D. In order to judge if the nodes in one drawing are more evenly distributed in W than the nodes in another drawing, we need a method (or methods) for measuring the distribution of points in a given bounded region. We must not only consider the distribution of the nodes relative to each other but also the distance between each node and the boundary of W . We have determined through observation that if the ideal distance between two nodes is dI , then the ideal distance between a node and the boundary of W is 0.5dI . We call a method for measuring the distribution of points a model E of distribution. Given a model E of distribution, let the distribution measure of the nodes in a drawing D = (G, S, W ) according to the model E be: ΞE (S), where ΞE (S) ≥ 0.0 increases as S becomes more evenly distributed under the model E. An intuitive way of quantifying the distribution of a set of points is to say that a set of points is evenly distributed in a given bounded region if the minimum distance between any two points in the set is maximized; that is, if the distance between a closest pair of points is maximized. We call this model the CP model of distribution and define the measure of distribution according to the CP model as: ΞCP (S) = min{min{dist (pi , pj )}, i6=j
min {2|xi − xw |, 2|yi − yw |}}
w∈{tr,bl}
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 6 where tr and bl are the top right and bottom left corners of W , respectively. It follows that the nodes in a drawing D are more evenly distributed than those in D0 under the CP model if ΞCP (S) > ΞCP (S 0 ). The cost of computing ΞCP (S) for a drawing D with n nodes is O(n) time given the Voronoi diagram of the nodes, which can be computed in O(n log n) time [28].
3.2
Measuring Similarity
Criterion CB3 states that the general shape of D0 should be the same as D. In [11] and [25], several mathematical models of the user’s mental map of a drawing D are defined, and D0 is said to have the same shape as D if D0 and D are the same according to one of the models. Since this condition is relaxed in cluster busting in anchored graph drawing, we must have a way of measuring difference or similarity between D and D0 according to a given model. In this section, we present measures of difference between two sets of points based on two models of a user’s mental map. Each of the models described in this section quantifies similarity between two sets of node positions and does not consider edges of the input graph. For a given mental map model M , we define δM (S, S 0 ) as the number of changes in S 0 from S under the model M , and let UB M (n) be an upper bound on the number of changes in a drawing with n nodes under the model M . The upper bound is set to the maximum value when the maximum is known; otherwise, the lowest known upper bound is used. The measure of difference according to the model M is given by DM (S, S 0 ) =
δM (S, S 0 ) UB M (n)
In this way, we ensure that 0.0 ≤ DM (S, S 0 ) ≤ 1.0. If DM (S, S 0 ) = 0.0, then there is no difference between the drawings D and D0 according to the model M and the transformation from D to D0 preserves the mental map under M . We say two drawings D and D0 are not very different or are similar under a model M if DM (S, S 0 ) is small, and the two drawings are as different as they can be according to measure M if DM (S, S 0 ) = 1.0. It is important to note that the values of DM (S, S 0 ) are normalized between 0.0 and 1.0 in order to compare values of DM (S, S 0 ) for different-sized drawings produced by different layout programs under the same model M . It is inappropriate to compare DM1 (S, S 0 ) and DM2 (S, S 0 ) on the same drawing for different models M1 and M2 . The similarity models presented in this section have been chosen based on ideas and results borrowed from the fields of psychology and pattern recognition, and because of their geometric nature, efficiency of computation, and ease of implementation. According to Gregson [19], under the normative definition of similarity a declaration is made that a certain operation is being used to
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 7 measure similarity between two objects but no presupposition is made about how accurate that operation is as an actual judge of similarity. 3.2.1
λ-Matrix (λM) Model
In [18], Goodman and Pollack introduce a process called geometric sorting, which defines an ordering on n points in d > 1 dimensions. Their idea of sorting generalizes from the one-dimensional case where a set of n numbers is given. Consider these numbers as n points on a horizontal line L. Two sets of points S and S 0 on a line are in the same order (have the same order type) if for every pair of points, pi < pj if and only if p0i < p0j . According to Goodman and Pollack, two sets of points S and S 0 in the plane have the same order type (are in the same order) if for every triple of points, (pi , pj , pk ) are oriented counterclockwise if and only if (p0i , p0j , p0k ) are oriented counterclockwise [18]. Their method of determining if two sets of points have the same order type without having to compare every triple by defining the λmatrix of a set of points is a follows: Given a set of points S, let λ(pi , pj ) be the number of points to the left of the directed line from pi to pj . We define λ(pi , pi ) to equal n. The n × n matrix containing λ(pi , pj ), for i = 0, 1, 2, . . . , n − 1 and j = 0, 1, 2, . . . , n − 1 is called the λ-matrix of S. The set Λ(pi , pj ) is the set of points to the left of the directed line from pi to pj . It is shown in [18] that the sets Λ(pi , pj ) can be determined given the sets λ(pi , pj ), and an algorithm is presented for computing the λ-matrix of a set of n points in O(n2 log n) time. In [12], an algorithm is presented that computes the λ-matrix of a set of n points in the plane in O(n2 ) time. Two sets of points have the same order type if their λ-matricies are the same. Several possible applications of this technique are presented in [18], including pattern recognition in which new images can be compared to a given image by comparing their λ-matrices. We use λ-matrices to compare two drawings D and D0 of n nodes by computing the sum of the differences in entries in the λ-matrices of S and S 0 : δλM (S, S 0 ) =
n−1 X n−1 X
|λ(pi , pj ) − λ(p0i , p0j )|
i=0 j=0
In [22], it is shown that the upper bound on δλM (S, S 0 ) for n nodes is: (n − 1)2 UB λM (n) = n 2 therefore, DλM (S, S 0 ) =
δλM (S, S 0 ) UB λM (n)
The upper bound is achieved when the set of points are all on the convex hull and the ordering around the convex hull is reversed [22].
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 8 3.2.2
Distances Moved (DM) Model
A natural measure of difference between two sets of points is the distance that each point has moved. The value of δDM (S, S 0 ) is computed by summing the distance between pi and p0i for i = 0, 1, 2, . . . , n − 1: 0
δDM (S, S ) =
n−1 X
dist (pi , p0i )
i=0
The time required to compute δDM (S, S 0 ) is O(n) since there are n distances. √ Each distance is at most 2 since the sets S and S 0 are within the unit square; therefore, we define the upper bound on δDM (S, S 0 ) for n nodes as: √ UB DM (n) = 2n and let
δDM (S, S 0 ) UB DM (n) The upper bound is achieved when all the points move from some corner of W to a diagonal corner. DDM (S, S 0 ) =
4
The Layout Algorithms
Both the algorithms presented in this paper are iterative, and at each iteration heuristics are used to determine where to move the nodes. We restrict the movement of the nodes to inside the drawing window, which guarantees that criterion CB1 is satisfied. In Section 5 we evaluate and compare the algorithms according to criteria CB2 and CB3. Let S = S 0 be the input positions of the nodes, and let S t = {pt0 , pt1 , . . . , ptn−1 } be the positions of the nodes after iteration t. The output positions of the nodes are given by the set S 0 . After each iteration t, tests can be performed to measure the distribution of the points in S t and the differences between S and S t . The algorithms iterate until a specified distribution or similarity measure exceeds a given threshold. If the thresholds are not reached, the algorithms iterate Imax times. When the algorithm returns, the user is presented with the resulting layout, and is given the option of changing the thresholds and continuing or accepting the layout the way it is. The similarity and distribution models to be used, the value Imax , and the threshold values can be given as part of the input (for experienced users) or defaults can be used.
4.1
The Voronoi Diagram Cluster Buster (VDCB) Algorithm
The VDCB algorithm is based on the well-studied Voronoi diagram. Given a set S = {p0 , p1 , . . . , pn−1 } of n points, the Voronoi diagram of S, VD(S) is a
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 9 partition of the plane into n convex (not necessarily bounded) regions such that the region or polygon Vor (pi ) associated with the point pi is the set of points that are closer1 to pi than to any other point in S [28, 35]. An implementation by Kenny Wong [36] of Fortune’s sweep-line algorithm [16] is used by the implementations of our algorithms. The Clipped Voronoi Diagram of a set S of n points, CVD (S), is VD(S) clipped within W and can be computed in O(n log n) time. The idea of using the Voronoi diagram of the set S to constrain the movement of the nodes came about while trying to determine how to satisfy criterion CB3. Restricting the nodes to move within their Voronoi regions guarantees that p0i is closer to pi than to any pj ∈ S, j 6= i. However, in small Voronoi regions that are close together, the allowable movement is too restricted to more evenly distribute the nodes. To allow the nodes in these small regions to become more evenly distributed, the process is iterated. At each iteration, the nodes move to a point that is inside their Voronoi region, and the Voronoi diagram of the new layout is computed. We can no longer guarantee that p0i is closer to pi than to any other pj ∈ S, j 6= i. To more evenly distribute the nodes, the nodes should move away from Voronoi edges they are close to and move closer to the Voronoi edges they are further from; therefore, it was decided to move each node to the centroid of the Voronoi region. Given a node pi , the centroid of Vor(pi ) is defined as: R R x, y Vor (pi ) Vor (pi ) cdi = Area(Vor (pi )) The n centroids can be computed in O(n) time [22]. The VDCB algorithm is presented in Figure 1. The VDCB algorithm runs in O(t ∗ (n log n + T (n))) time, where t ≤ Imax is the number of iterations and T (n) is the time taken to perform the measurements.
4.2
The GeoForce Algorithm
The Geographic Force or GeoForce algorithm is based on the idea of using forces and springs to model interactions between nodes in a drawing of a graph [7, 9, 15, 17, 20, 29, 30]. The basic idea in each of the spring-based or forcebased algorithms is the same: Nodes with no edge between them are repelled from each other by a force that depends on the distance between them and nodes connected by an edge are attracted to each other by a force that depends on the distance between them. The initial layout is usually created arbitrarily. At each iteration of the algorithm, forces are computed on the nodes, and one or all of the nodes are moved to a position according to the acting forces. 1 The
distance between two points is the Euclidean distance.
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 10
algorithm VDCB(D) initialize: stop iterating ← FALSE; t ← 0; S t ← S while t < Imax and not stop iterating Compute CVD(S t ) for each i find cdti pt+1 ← cdti i t←t+1 for each distribution measure E if ΞE (S t ) ≥ the defined threshold for E then stop iterating ← TRUE S0 ← St for each similarity measure M if DM (S t ) ≥ the defined threshold for M then stop iterating ← TRUE S 0 ← S t−1 output: D0
Figure 1: The VDCB algorithm.
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 11 The GeoForce algorithm came about by adapting the idea of the force-based algorithms with the hopes of achieving their success in practise. Criterion CB3 states that the general shape of the drawing should be similar to the shape of the original drawing; therefore, attractive forces are applied between each node and its position in the original layout. Since the second goal of cluster busting in anchored graph drawing is to more evenly distribute the nodes in the drawing window, repelling forces are applied between every pair of nodes and between each node and the sides of the drawing window. The forces applied, constants used, and techniques for dealing with the boundary of W have been chosen by implementing different methods, trying a few values in combination with other values, and observing the effect on sample layouts. There are n + 3 forces repelling each node and one force attracting each node. Therefore, we take the average repelling force and subtract the attractive force. The total force applied to pi at iteration t is given by: fit =
FS (pti ) + FR (pti ) − fA (dist (pti − pi )) n+3
where FS (pti ) is the repelling force between pti and each of the sides of W , FR (pti ) is the repelling force between pti and ptj , j = 0, 1, . . . , n − 1, j 6= i, and fA is the attractive force between pti and its original position pi . FS (pti ) and FR (pti ) are computed as: X (fS (|xti − xw |) + fS (|yit − yw |)) FS (pti ) = w∈{bl,tr}
and
FR (pti ) =
X
fR (dist (pti , ptj ))
j6=i
The force functions, fR (d), fA (d), and fS (d) are computed as follows. The repelling force should move the nodes to some ideal distance away from one another. p Fruchterman and Reingold define the ideal distance between nodes as dI = area/n, where area is the area of the drawing window [17]. We have found that bounding the amount of force applied when d = 0.0 and applying no force when d > dI results in a smooth behaviour. We let fR (d) be the linear function passing through (0, C1 ) and (dI , 0), where C1 is a constant representing the maximum force applied. This function p is easy to compute, and in practise gives good results for C1 = 100.0 and dI = area/n. The attractive force is applied to pull each node towards its original position. We found that the following function gives good results: fA (d) = C2 d, where C2 = 1.0 is a constant. Each side of W exerts a repelling force on each of the nodes. We let fS (d) be a linear function passing through (0, MF ) and (dI , 0), where MF is the maximum force exerted. We found that good results were obtained with MF = 10.0 ∗ n.
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 12 As Eades does in [9] and Fruchterman and Reingold do in [17], the acting forces are computed for all nodes in the given layout and then the nodes are moved according to the forces, rather than dealing with the nodes one at a time as in [7] and [20]. The GeoForce algorithm differs from other force-directed algorithms because we limit the movement of a node pi within a region that takes into consideration its proximity to the other nodes. The nodes are only allowed to move within a specified percentage of the distance to their Voronoi edges. Let fit be the total force acting on pti at iteration t such that pti + fit is the point that pti would move to according to the force fit . Extend the ray from pti to pti + fit if necessary until it intersects an edge of Vor (pti ). Let Ii be that intersection point. We set the step-size for the node pti to be sti = C4 ∗ dist (pti , Ii ) where C4 is a constant. We sti ∗fit t = pti + fit or pt+1 = pti + |f then set either pt+1 t | , whichever is closer to pi . By i i i experimentation, we found that C4 = 0.25 works well. The GeoForce algorithm operates like a “smart” VDCB algorithm: The nodes are moved to a location inside their Voronoi regions, but the heuristic used to choose that location is based on forces acting on the nodes rather than just blindly choosing the centroid of the regions. The GeoForce algorithm is presented in Figure 2. It runs in O(t ∗ (n2 + T (n))) time where t ≤ Imax is the number of iterations and T (n) is the time taken to perform the measurements.
5
Results
In this section, we evaluate and compare the VDCB and GeoForce algorithms. To do this, we execute each algorithm on a variety of random input layouts and measure the layouts after a differing number of iterations. We generate layouts with K clusters of k points each inside W such that n = Kk. The region W can 1 . We want to evaluate our be evenly divided into K square regions with area K layout algorithms on layouts with clusters of nodes such that the interactions between the nodes are hard to read; that is, we want each region that contains a cluster of nodes to be small. Therefore, we let each cluster occupy a square region with O( K12 ) area. We first compute K cluster centres by generating K random points inside W : {c0 , c1 , . . . , cK−1 }. Let si be the square with centre ci and area KC2 where C is a constant. The squares are clipped within W , and k random points are generated uniformly inside each clipped si . The result is a set of K clusters in the unit square. When K = n, we let pi = ci , i = 0, 1, . . . K − 1. Executing the algorithms on a variety of random layouts gives a measure of the goodness of the algorithms with respect to random layouts. For each type of initial layout, we generated 1000 random layouts of that type and took the average value for each of the measurements. Let the average value of ΞE (S) be ΞE (S) for the distribution model E, and let the average value of DM (S, S 0 ) be DM (S, S 0 ) for the similarity model M . The measurements were performed after
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 13
algorithm GeoForce(D) initialize: stop iterating ← FALSE; t ← 0; S t ← S while t < Imax and not stop iterating for each i Compute the force fit acting on pti Compute CVD(S t ) for each i sti ∗fit if dist (pti , pti + fit ) < dist (pti , pti + |f t | ) then i t+1 t t pi ← pi + f i else sti ∗fit ← |f pt+1 t| i i t←t+1 for each distribution measure E if ΞE (S t ) ≥ the defined threshold for E then stop iterating ← TRUE S0 ← St for each similarity measure M if DM (S t ) ≥ the defined threshold for M then stop iterating ← TRUE S 0 ← S t−1 output: D0
Figure 2: The GeoForce algorithm.
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 14 t = 1, 2, . . . , 10, 20, . . . , 100 iterations of each of the algorithms. Table 1 shows values of ΞCP (S) for different types of layouts and for both layout algorithms.
n
25
50
100
K
n/K
ΞCP (S)
ΞCP (S 1 )
ΞCP (S 1 )
ΞCP (S 10 )
ΞCP (S 10 )
ΞCP (S 100 )
ΞCP (S 100 )
GeoForce
VDCB
GeoForce
VDCB
GeoForce
VDCB
25
1
0.0297158
0.0594681
0.0867467
0.1045789
0.1274640
0.1188087
0.1702646
1
25
0.0124560
0.0286982
0.0428854
0.0785006
0.0901596
0.1096014
0.1662676
5
5
0.0069397
0.0215777
0.0375028
0.0873186
0.1107191
0.1153616
0.1678225
50
1
0.0142302
0.0324772
0.0548724
0.0652549
0.0883792
0.0857881
0.1214667
1
50
0.0061505
0.0150611
0.0258729
0.0425497
0.0529996
0.0620407
0.1141157
2
25
0.0047297
0.0109252
0.0199791
0.0392802
0.0513587
0.0644586
0.1156817
5
10
0.0032214
0.0078346
0.0153701
0.0403736
0.0643745
0.0709301
0.1180011
10
5
0.0024422
0.0077468
0.0180950
0.0442022
0.0732051
0.0768871
0.1195598
25
2
0.0020711
0.0154545
0.0412309
0.0578902
0.0841695
0.0821875
0.1206015
100
1
0.0071465
0.0192338
0.0351218
0.0397486
0.0614420
0.0583786
0.0853836
1
100
0.0029802
0.0083215
0.0159633
0.0242627
0.0336719
0.0330132
0.0666534
2
50
0.0022414
0.0056704
0.0119749
0.0201109
0.0277523
0.0344893
0.0716336
4
25
0.0017113
0.0039890
0.0091445
0.0170900
0.0293285
0.0377601
0.0756969
10
10
0.0011238
0.0030085
0.0069926
0.0163230
0.0405262
0.0436906
0.0798743
25
4
0.0008172
0.0028873
0.0124229
0.0195724
0.0514290
0.0502511
0.0829412
50
2
0.0007292
0.0070734
0.0244130
0.0326964
0.0573149
0.0544592
0.0840577
Table 1: ΞCP (S 1 ), ΞCP (S 1 0), and ΞCP (S 1 00) for several initial layouts and both layout algorithms. Tables 2 and 3 give values of D λM (S, S 0 ) and DDM (S, S 0 ) for different n and for both layout algorithms. According to the similarity model M , the average difference between two random layouts is D M (S, P ). The experiments show that, on average, the GeoForce and VDCB algorithms more evenly distribute the nodes in a drawing according to the CP model of distribution. In all cases, ΞCP (S 1 ) > ΞCP (S), and ΞCP (S t+1 ) > ΞCP (S t ) for all types of input for both layout algorithms.
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 15
n
D λM (S, P )
25 50 100
0.5645142 0.5571432 0.5525959
Worst D λM (S, S 1 ) GeoForce 0.0696986 0.0583581 0.0439622
Worst DλM (S, S 1 ) VDCB 0.1397622 0.1188550 0.0966927
Table 2: DλM (S, P ) and D λM (S, S 1 ) after one iteration of the VDCB and GeoForce algorithms.
n
D DM (S, P )
25 50 100
0.3671019 0.3721420 0.3690213
Worst DDM (S, S 1 ) GeoForce 0.0275942 0.0183423 0.0125748
Worst D DM (S, S 1 ) VDCB 0.0790956 0.0701698 0.0419749
Table 3: D DM (S, P ) and D DM (S, S 1 ) after one iteration of the VDCB and GeoForce algorithms.
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 16 Layouts with roughly the same number of clusters as nodes in each cluster are the most different after several iterations according to the λM model. However, layouts that start out the most evenly distributed according to the CP model change the least according to the λM measure after several iterations of the layout algorithms. According to the DM model of similarity, layouts with one or two clusters are most different after several iterations, because as the nodes become spread out they move further from where they started than in layouts with more clusters. As with the λM model, layouts that start out the most evenly distributed according to the CP model change the least according to the DM model after several iterations of the layout algorithms. The VDCB algorithm more evenly distributes the nodes after fewer iterations than the GeoForce algorithm; therefore, we compare the difference between S 0 be the layout S and S 0 for layouts S 0 with the same distribution level. Let SA after adjustment by the algorithm A ∈ {VDCB, GeoForce}. We say that the algorithm A1 performs better than the algorithm A2 on specific types of layouts 0 0 than between S and SA if the difference levels are smaller between S and SA 1 2 0 0 when the distribution levels of SA1 and SA2 are roughly the same. The type of initial layout has a significant effect on which layout algorithm performs better. On average, the GeoForce algorithm performs better for layouts with a small number of clusters, and the VDCB algorithm performs better for layouts with a large number of clusters. In the GeoForce algorithm the nodes move less far at each iteration than in the VDCB algorithm for all types of layouts, because of the forces acting on the nodes. In layouts with a small number of big clusters, small Voronoi regions constrain the movement of the nodes in the VDCB algorithm as well; therefore, the number of iterations necessary for the VDCB algorithm to reach a given level of distribution is greater for these types of layouts. For layouts with a large number of small clusters, the VDCB algorithm distributes the nodes evenly after very few iterations where the GeoForce algorithm requires a greater number of iterations to achieve the same level of distribution. During the extra iterations needed, the repelling forces act on the nodes, causing the layouts to become more different from the original layout than those produced by the VDCB algorithm. For layouts with one cluster uniformly distributed in W initially, one to three iterations of either algorithm is sufficient to distribute the nodes such that their interactions are readable. After one or two iterations, the VDCB algorithm distributes the nodes more evenly than the GeoForce algorithm but the VDCB algorithm moves the nodes further than necessary. The layouts are more similar to the original layout according to each of the measures with the GeoForce algorithm. Figure 3 shows such a layout with n = 25 nodes and the layout after one iteration of the GeoForce algorithm. Figure 4 shows the same layout after one iteration of the VDCB algorithm. Figure 5 shows a layout with K = 25 clusters of size 4 each and the layout after 20 iterations of the GeoForce algorithm. Figure 6 shows the same layout
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 17
Figure 3: A layout with K = 25 clusters of size 1 each, and that layout after one iteration of the GeoForce algorithm.
Figure 4: A layout with K = 25 clusters of size 1 each, and that layout after one iteration of the VDCB algorithm.
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 18
Figure 5: A layout with K = 25 clusters of size 4 each, and that layout after 20 iterations of the GeoForce algorithm. after 11 iterations of the VDCB algorithm. The layout produced by the VDCB algorithm is more evenly distributed according to the CP model, and is more similar to the original layout according to the similarity measures presented in this paper. Human observers may judge the GeoForce layout to be more similar to its original layout than the VDCB layout. This is partly because the notion of clustered nodes seems to be completely removed in the VDCB layout. The notion of clustering is an important model of a user’s mental map [11, 25]; however, the similarity measures presented in this paper do not adequately capture the notion of clustering. In [22], the number of changes in the Delaunay triangulation of the node positions is used as a measure of similarity that better represents the clusters. The layout produced by the VDCB algorithm in Figure 6 was less similar than that produced by the GeoForce algorithm according to the number of changes in the Delaunay triangulation. Although the GeoForce algorithm was designed to perform cluster busting in anchored graph drawing in a “smarter” way than the VDCB algorithm, we have seen that it does not always do so. In fact, we would recommend using the VDCB algorithm over the GeoForce algorithm in most cases. The possibility remains that a different choice of force functions and/or constants in the GeoForce algorithm might result in an algorithm that consistently performs better than the VDCB algorithm. This possibility is discussed further in the next section.
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 19
Figure 6: A layout with K = 25 clusters of size 4 each, and that layout after 11 iterations of the VDCB algorithm.
6
Conclusions and Future Work
In this paper, we identified a new approach to drawing graphs with an existing layout that we call cluster busting in anchored graph drawing. We presented two heuristic algorithms for solving this problem. We provided measurements for evaluating layouts produced by the algorithms based on the stated goals. These measurements were used to evaluate and compare the algorithms. We found that using heuristics is a good approach to drawing graphs in general and for cluster busting in anchored graph drawing in particular. Using quantitative measurements is useful for understanding the behaviour of heuristic algorithms. The measurements allow the algorithms to be tested on a larger number of layouts than if evaluations are based solely on visually judging example layouts. There are several areas for further research. It remains a difficult problem to use the quantitative measurements to determine stopping conditions, because of the large number of factors involved. Possible enhancements are to allow more user input during the layout process or to use animation. The user watches the layout change at each iteration, and stops the algorithm manually when the resulting layout is satisfactory. We support the conclusion of Messinger et al. in [23] that more research is needed into subjective issues that users find important for “good” drawings of graphs. This is particularly true in the case when the aesthetic factor is
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 20 something as subjective as similarity. Different force functions and constants might result in a GeoForce algorithm that consistently performs better than the VDCB algorithm. The forces and constants in the current GeoForce algorithm were determined by trying a few values and viewing sample layouts produced by an algorithm using those values. Subjective judgements were made as to which choices gave better layouts by one or two people observing the layouts. It would be interesting to use the quantitative measures to judge several layouts after each choice of forces and constants. This way many more layouts could be judged on different combinations of the forces and constants. An important area for future work in layout adjustment algorithms is to take the edges of the graphs into consideration. This is a difficult problem that was also not addressed in algorithms for preserving the mental map [10]. There are a couple of ways that edges can be incorporated into layout adjustment algorithms. First, similarity measures can include changes in the edges in the drawing. Second, layout adjustment algorithms can optimize edge criteria such as keeping the number of edge crossings small in the new layout while retaining similarity in the node positions. A model of the mental map that takes the positions of the edges in a layout into consideration is presented in [25]. Figure 7(a) taken from [25] shows a drawing of a graph of n = 6 nodes and m = 7 edges. The edges and nodes in the drawing divide the plane into regions called faces. The outside face is bounded by edges and nodes listed in clockwise order: f1 = AbBcCgF deDf Ef Da. Three other faces are given by f2 = AdeDa, f3 = CgF de, and f4 = AbBcCed. A dual graph is defined such that there is a node in the dual graph for each face defined above, and there is an edge between two nodes in the dual graph whose faces share a boundary. Figure 7(b) shows the dual graph of the layout in Figure 7(a). Two layouts have the same topology if they have the same dual graph. An adjustment algorithm preserves the topology of a drawing if the new drawing has the same topology as the original drawing. The difference between two topologies (such as the number of edge changes in the dual graph) could be used as a measure of difference between two drawings that includes the edges of the graph. This measure could be used to evaluate our algorithms and other cluster busting in anchored graph drawing algorithms according to the topology model of a user’s mental map. Since both algorithms are iterative, it would be interesting if we could prove that the algorithms converge. In [22], it is shown that in the VDCB algorithm, n = st nodes at vertices of an isothetic grid of size s by t do converge. A discussion of the convergence of the VDCB algorithm for the case of n points in general is also presented. It is an open problem to prove that the VDCB algorithm converges for general input.
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 21
A
a
b
B
c
d e
D f
f1
f2
f3
f4
C g
E
F
(a)
(b)
Figure 7: A layout and the dual graph representing its topology.
Acknowledgements The authors would like to thank Patrick Finnigan, Jacob Slonim, and other members of the CORDS project for their input and ideas as well as the referees whose suggestions simplified the presentation.
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 22
References [1] G. K. Attaluri, D. P. Bradshaw, P. J. Finnigan, N. Hinds, M. Kalantar, K. A. Lyons, A. D. Marshall, J. Pachl, and H. Tran. Operation Jump Start: A CORDS integration prototype using DCE. In Proceedings of the 1993 CAS Conference Volume II, pages 621–636, October 1993. [2] D. W. Bachmann, M. E. Segal, M. M. Srinivasan, and T. J. Teorey. Netmod: a design tool for large-scale heterogeneous campus networks. Technical report, Department of Electrical Engineering and Computer Science and Center for Information Technology Integration, The University of Michigan, Ann Arbor, Michigan, June 1990. [3] M. A. Bauer, N. Coburn, D. L. Erickson, P. J. Finnigan, J. W. Hong, P.-˚ A. Larson, J. Pachl, J. Slonim, D. J. Taylor, and T. J. Teorey. A distributed system architecture for a distributed application environment. IBM Systems Journal, 33(3):399–425, 1994. [4] K.-F. Bohringer and F. Newbery Paulisch. Using constraints to achieve stability in automatic graph layout algorithms. In Proceedings of the ACM Conference on Computer Human Interaction (CHI), pages 43–51, April 1990. [5] R. F. Cohen, G. Di Battista, R. Tamassia, I. G. Tollis, and P. Bertolazzi. A framework for dynamic graph drawing (extended abstract). In Proceedings of the Eighth Annual ACM Symposium on Computational Geometry, pages 261–270, 1992. [6] R. Davidson and D. Harel. Drawing graphs nicely using simulated annealing. Technical report, Department of Applied Mathematics and Computer Science, Weizmann Institute of Science, April 1991. [7] R. Davidson and D. Harel. Drawing graphs nicely using simulated annealing. ACM Journal on Graphics, 15(4), October 1995. [8] G. Di Battista, P. Eades, R. Tamassia, and I. G. Tollis. Algorithms for drawing graphs: an annotated bibliography. Comput. Geom. Theory Appl., 4:235–282, 1994. [9] P. Eades. A heuristic for graph drawing. Congressus Numerantium, 42:149– 160, 1984. [10] P. Eades and W. Lai. Algorithms for disjoint node images. In The Fifteenth Australian Computer Science Conference (ACSC-16), pages 253–265, January 1992.
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 23 [11] P. Eades, W. Lai, K. Misue, and K. Sugiyama. Preserving the mental map of a diagram. Technical Report IIAS-RR-91-16E, International Institute for Advanced Study of Social Information Science, Fujitsu Laboratories Ltd., Aug. 1991. [12] H. Edelsbrunner, J. O’Rourke, and R. Seidel. Constructing arrangements of lines and hyperplanes with applications. SIAM Journal on Computing, 15:341–363, 1986. [13] D. L. Erickson, P. J. Finnigan, G. K. Attaluri, M. A. Bauer, D. Bradshaw, N. Coburn, M. P. Consens, M. Z. Hasan, J. W. Hong, K. A. Lyons, T. P. Martin, G. W. Neufeld, W. Powley, D. Rappaport, D. J. Taylor, T. J. Teorey, and Y. Yemini. CORDS: An update to the prototypes. Technical Report TR-74.120, August 1993. [14] P. J. Finnigan and K. A. Lyons. Narratives of space and time: Visualization for distributed systems. In Proceedings of the 1991 CAS Conference, pages 363–391, October 1991. [15] C. J. Fisk, D. L. Caskey, and L. E. West. ACCEL: Automated circuit card etching layout. Proceedings of the IEEE, 55(11):1971–1982, November 1967. [16] S. Fortune. A sweepline algorithm for Voronoi digrams. Algorithmica, 2:153–174, 1987. [17] T. Fruchterman and E. Reingold. Graph drawing by force-directed placement. Softw. – Pract. Exp., 21(11):1129–1164, 1991. [18] J. E. Goodman and R. Pollack. Multidimensional sorting. SIAM Journal on Computing, 12(3):484–507, August 1983. [19] R. A. M. Gregson. Psychometrics of Similarity. Academic Press, 1975. [20] T. Kamada and S. Kawai. An algorithm for drawing general undirected graphs. Information Processing Letters, 31:7–15, 1989. [21] K. A. Lyons. Cluster busting in anchored graph drawing. In Proceedings of the 1992 CAS Conference Volume I, pages 7–17, November 1992. [22] K. A. Lyons. Cluster Busting in Anchored Graph Drawing. PhD thesis, Queen’s University, 1994. [23] E. B. Messinger, L. A. Rowe, and R. R. Henry. A divide-and-conquer algorithm for the automatic layout of large directed graphs. IEEE Transactions on Systems, Man, and Cybernetics, SMC-21(1):1–11, January/February 1991.
K. A. Lyons et al., Algorithms for Cluster Busting, JGAA, 2(1) 1–24 (1998) 24 [24] K. Miriyala, S. W. Hornick, and R. Tamassia. An incremental approach to aesthetic graph layout. In Proc. Internat. Workshop on Computer-Aided Software Engineering (CASE ’93), 1993. [25] K. Misue, P. Eades, W. Lai, and K. Sugiyama. Layout adjustment and the mental map. Journal of Visual Languages and Computing, 6(2):195–209, 1995. [26] S. Mitrovic and S. Murer. A tool to display hierarchical acyclic dataflow graphs. In N. N. Mirenkov, editor, Proceedings of the International Conference on Parallel Computing Technologies, pages 304–315. World Scientific, 1991. [27] S. Moen. Drawing dynamic trees. IEEE Software, 7:21–28, July 1990. [28] F. P. Preparata and M. I. Shamos. Computational Geometry: An Introduction. Springer-Verlag, 1985. [29] N. R. Quinn Jr. and M. A. Breuer. A forced directed component placement procedure for printed circuit boards. IEEE Transactions on Circuits and Systems, CAS-26(6):377–388, 1979. [30] L. Steinberg. The backboard wiring problem: A placement algorithm. SIAM Review, 3(1):37–50, January 1961. [31] G. T. Toussaint. Pattern recognition and geometrical complexity. In Proceedings of the Fifth International IEEE Conference on Pattern Recognition, pages 1324–1347, December 1980. [32] G. T. Toussaint. Computational geometric problems in pattern recognition. In J. Kittler, K. S. Fu, and L. F. Pau, editors, Pattern Recognition Theory and Applications, pages 73–91. D. Reidel Publishing Company, 1982. [33] G. T. Toussaint. Computational geometry: Recent results relevant to pattern recognition. In P. A. Devijver and J. Kittler, editors, Proceedings of the NATO Advanced Study Institute on Pattern Recognition Theory and Applications, pages 295–305, June 1986. [34] D. Tunkelang. An aesthetic layout algorithm for undirected graphs. Master’s thesis, Massachusetts Institute of Technology, 1992. [35] G. Voronoi. Nouvelles applications des parametres continus `a la theorie des formes quadratiques. Deuxi`eme m´emoire: Recherches sur les parall´elo`edres primitifs. Journal fur die Reine und Angewandte Mathematik, 138:198–287, 1908. [36] K. Wong and H. A. M¨ uller. An efficient implementation of fortune’s planesweep algorithm for Voronoi diagrams. Technical report, Department of Computer Science, University of Victoria, Victoria, B.C., October 1991.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 2, no. 2, pp. 1–17 (1998)
A Broadcasting Algorithm with Time and Message Optimum on Arrangement Graphs Leqiang Bai
Hajime Maeda
Department of Communication, Osaka University http://nanase.comm.eng.osaka-u.ac.jp/personal/maeda.html/
[email protected] [email protected]
Hiroyuki Ebara Faculty of Engineering, Kansai University
[email protected]
Hideo Nakano Media Center, Osaka City University http://www.media.osaka-cu.ac.jp/ nakano/
[email protected] Abstract In this paper, we propose a distributed broadcasting algorithm with optimal time complexity and without message redundancy for one-toall broadcasting in the one-port communication model on arrangement graph interconnection networks. The algorithm exploits the hierarchical property of the arrangement graph to construct different-sized broadcasting trees for different-sized subgraphs. These different-sized broadcasting trees constitute a spanning tree on the arrangement graph. Every processor individually performs its broadcasting procedure based on the spanning tree. It is shown that a message can be broadcast to all the other n! − 1 processors in at most O(k lg n) steps on the (n, k)-arrangement (n−k)! graph interconnection network. The algorithm can also guarantee that each of processors on the arrangement graph interconnection network receives the message exactly once.
Communicated by Alon Itai: submitted June 1996; revised May 1998.
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998) 2
1
Introduction
The star graph [1] is one of the widely studied interconnection network topologies. It has been proposed as an attractive alternative to the hypercube with many superior characteristics. A major practical difficulty with the star graph is related to its number of nodes: n! for the n−star graph. Recently, a new interconnection network topology called the (n, k)-arrangement graph has been proposed in [5]. This topology is a generalized class of star graphs in the sense that a star graph is a special arrangement graph, and presents a cure for the design drawback of the star graph. It brings a solution to the problem of growth of the number n! of nodes in the n−star graph with respect to the dimension n. Namely, the (n, k)-arrangement graph has more flexibility in selecting the design parameters: size, diameter, and degree than the star graph. It also keeps all the desirable topological qualities of the star graph topology such as hierarchical structure, vertex and edge symmetry, simple routing and many fault tolerance properties. Broadcasting is one of the fundamental communication problems for distributed memory interconnection networks. In broadcasting, one processor (or node) has a message which needs to be communicated to everyone; such a processor is called the source of broadcasting and every other node to which the message needs to be sent is called the destination of broadcasting. Broadcasting is a very important operation used in various linear algebra algorithms, database queries, transitive closure algorithms, and linear programming algorithms. The interconnection network must facilitate efficient broadcasting so as to achieve high performance during execution of jobs. The efficiency of the broadcasting algorithms is characterized by the time complexity, the number of steps required, and the message complexity, the total number of messages exchanged, to complete the broadcasting. Hence, it is desirable to develop a broadcasting algorithm that optimizes both the time complexity and the message complexity. The broadcasting problems on the hypercube and the star graph have been investigated in recent years. In [8], Johnsson and Ho presented three new communication graphs for hypercubes and defined scheduling disciplines, so that the communication tasks are completed within a small constant factor of the best known lower bounds. In [11], Sheu, Liaw and Chen presented a distributed broadcasting algorithm without message redundantly in star graphs. It takes 2n − 3 steps in the multi-port communication model. In [9], Mendia and Sarkar proposed a broadcasting algorithm with the optimal time complexity in the one-port communication model on the star graph. It exploits the rich structure of the star graph and works by recursively partitioning the original star graph into smaller star graphs. In [12], Sheu, Wu and Chen proposed a broadcasting algorithm that broadcasts a message to all nodes in the star graph at the optimal time based on the algorithm in [9]. It also performs broadcasting without redundant messages. In [4], Bai, Yamakawa, Ebara and Nakano proposed a broadcasting algorithm in the one-port commu-
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998) 3 nication model on the arrangement graph. It can broadcast a message to all nodes in optimal time. But the message complexity of the algorithm is not optimal. In this paper, we consider the one-to-all broadcasting problem in the oneport communication model on the arrangement graph and propose a distributed broadcasting algorithm in the message passing mode. By exploiting the rich topological properties of the arrangement graph to construct different sized broadcasting trees for different sized subgraphs recursively, this algorithm can broadcast a message to all the other nodes on the arrangement graph in the optimal time complexity in the sense of O−notation and without message redundancy. The remainder of this paper is organized as follows. The arrangement graph , its basic properties and some definitions are introduced in Section 2. The broadcasting algorithm is described in Section 3. The conclusion is given in Section 4.
2
Preliminaries
Let n and k with 1 ≤ k ≤ n be two integers, and let us write < n >= {1, 2, . . . , n} and < k >= {1, 2, . . . , k}. Let Pnk be the set of permutations of k elements chosen from < n >. The k elements of a permutation p are denoted p1 , p2 , . . . , pk ; we write p = p1 p2 . . . pk . Definition 1 The (n, k)-arrangement graph An,k = (V, E) is an undirected graph given by: V = {p1 p2 . . . pk | pi in < n > and pi 6= pi0 f or i 6= i0 } = Pnk , and E = {(p, q)| p and q in V and f or some i ∈< k >, pi 6= qi and pi0 = qi0 f or i 6= i0 } .
(1)
The (4, 2)−arrangement graph is shown in Figure 1. It illustrates that A4,2 can be decomposed into 4 smaller subgraphs, where each of them has the fixed element i for 1 ≤ i ≤ 4 in position 2. Each of subgraphs contains three nodes. The (n, k)−arrangement graph is a regular graph of degree k(n − k), the (n−1)! n! , and diameter b 32 kc. Notice that there are (n−k)! nodes number of nodes (n−k)! in An,k which have the element pi in position i for any fixed pi ∈< n > and i ∈< k >. These nodes form a subgraph of An,k . The arrangement graph still has many other good characteristics. For a more thorough coverage of the arrangement graph, refer to [5]. As shown in Definition 1, there are n − k elements that are not used in permutation p. We define the label pout of the node p to denote these elements. Using the label pout , we define the operator gij that carries out the permutation p and the label pout of the node p. In this way, we represent the node p and its edges on the arrangement graph so that the node p corresponds to the
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998) 4
42
22
12
32
14
34
42 13
31 24
12
32 23
21 41
43
Figure 1: (4,2)- arrangement graph
permutation p with a label pout , and its edges correspond to the actions of the operators on the permutation p and the label pout . Let IN T (p) = {p1 , p2 , . . . , pk }, which is the set of k elements of < n > used in permutation p, and let EXT (p) =< n > −IN T (p), which is the set of n − k elements of < n > not used in permutation p. Definition 2 For each node p, define Pout , which we call the set of labels pout of p, to be the set of elements of Pnn−k given: Pout = {pk+1 . . . pj . . . pn | pj in EXT (p) f or k + 1 ≤ j ≤ n and pj1 6= pj2 f or j1 6= j2 } .
(2)
Example. Consider < n >= {1, 2, 3, 4, 5}, < k >= {1, 2, 3} and p = 245. Then, Pout = {13, 31} and the two possible values of pout are 13 and 31. Definition 3 The operator gij (p, pout ): Pnk → Pnk takes a node p to its adjacent node p0 where p0 and p differ only in the ith position, and the element in the ith position of p0 is the element in the jth position of pout , 1 ≤ i ≤ k, k + 1 ≤ j ≤ n. We define g0 to be the identity operator, and pg0 = p for all p and pout .
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998) 5 Example. Let p = 123 be a node in A5,3 and be acted on by g15 . For the different pout = 45 or 54, pg15 = 523 or 423. From the definitions of operator and label, we know that the operator gij of the node p has the different actions for the different pout of the node p. In this paper, we assume that the source node has a given pout and any node acted on by the operator acts on its pout ; any node revises its pout based on the received message and uses this pout before receiving a new message. Let F irsti (p) have as its value the first i elements of the node p, that is, F irsti (p) = p1 p2 ...pi , 1 ≤ i ≤ k, and F irst0 (p) = λ, where λ is the empty string. For given p = p1 p2 ......pk and pout = pk+1 ...pn , let Electi (p, pout ) have as its value the ith element of p and pout , that is, Electi (p, pout ) = pi , 1 ≤ i ≤ n. We will write Electi (p) when pout is understood. Here, we give two definitions of subgraphs based on permutation p and its label pout on the arrangement graph. We say Aln,k the lth level subgraph of An,k and the level l + 1 is lower than the level l. Definition 4 The induced subgraph Aln,k (F irstl (p)), 1 ≤ l ≤ k, of An,k for a node p, is the induced subgraph having as vertices the set of the nodes whose the l (F irstl (p)) of the first l elements are p1 p2 ...pl , and A0n,k = An,k . The set Vn,k l nodes in An,k (F irstl (p)) is given by: l (F irstl (p)) = {p1 . . . pl pl+1 . . . pi . . . pk | Vn,k pi ∈< n > −{p1 , ..., pl } , l + 1 ≤ i ≤ k} ∈ V .
(3)
1 (2) = {2pq|p, q 6= 2} is the set of the nodes of the subgraph A15,3 (2) Example. V5,3 on A5,3 , where each of the nodes in the subgraph A15,3 (2) has the element 2 in the first position.
Definition 5 We will write, for p and its pout , the expression Aln,k (Electi (p)) for Aln,k (F irstl (q)), where q = p1 ...pl−1 pi , l − 1 ≤ i ≤ n. Example. Let p = 123, with its pout = 45, be a node in A5,3 . Then F irst1 (p) = 1 and Elect4 (p) = 4. Each of the nodes in A15,3 (F irst1 (p)) = A15,3 (1) has the element 1 in position 1. Each of the nodes in A25,3 (Elect4 (p)) = A25,3 (F irst1 (p)4) = A25,3 (14) has the element 4 in position 2 and the element 1 in position 1. 1 1 1 1 1 (1), V5,3 (2), V5,3 (3), V5,3 (4), V5,3 (5)}. V5,3 = {V5,3 Definitions 4 and 5 mean that Aln,k (F irstl (p)) and Aln,k (Electi (p)) are defined based on the node p, pout pair. Each of the nodes in Aln,k (F irstl (p)) has the same l elements in the first l positions as the node p has. Each of the nodes in Aln,k (Electi (p)) has the element Electi (p) in position l and the same l − 1 elements in the first l − 1 positions as the node p has.
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998) 6
3
Broadcasting Algorithm
In this section, we consider one-to-all broadcasting problem on a fault-free arrangement graph An,k , and develop a broadcasting algorithm with the optimal time complexity in the sense of O−notation and without message redundancy. We assume that a node consists of a processor with bidirectional communication links to each of its adjacent nodes. Any node knows the condition of its adjacent links and has a large enough buffer to preserve the message that it sends and received. At any given time, a node can communicate with at most one of its adjacent nodes. There are no faults on the arrangement graph. Theorem 1 [10] If an interconnection network consists of N nodes or processors that can communicate with at most one of its adjacent nodes at any given time, then any one-to-all broadcasting algorithm on the network must take at least Ω(lg N ) steps. The (n, k)-arrangement graph is a graph with hierarchical structure. Since we use recursively its hierarchical property to develop our broadcasting algorithm on An,k , we consider the broadcasting procedure on some subgraph Aln,k of An,k , 0 ≤ l ≤ k. Let p be a source node in some Aln,k and be ready to broadcast a message to its n−l node-disjoint subgraphs Al+1 n,k (Electi (p)), l+1 ≤ i ≤ n, l of An,k (F irstl (p)). According to the relationship of p and n − l subgraphs Al+1 n,k of Aln,k (F irstl (p)), n − l subgraphs Al+1 n,k can be divided into the following three cases: case 1: Al+1 n,k (Elect(l+1) (p)) in which p is. case 2: Al+1 n,k (Electi (p)), l + 2 ≤ i ≤ k, which are not directly connected to p. case 3: Al+1 n,k (Electi (p)), k + 1 ≤ i ≤ n, which are directly connected to p. Since the node p is in Al+1 n,k (Electl+1 (p)), we only need to send the message to k − l − 1 node-disjoint subgraphs Al+1 n,k (Electi (p)), l + 2 ≤ i ≤ k, and n − k (Elect (p)), k + 1 ≤ i ≤ n. In case 2, p is not node-disjoint subgraphs Al+1 i n,k directly connected to any node that belongs to Al+1 n,k (Electi (p)), l + 2 ≤ i ≤ k. This is because the element Electi (p) in position l + 1 of the nodes in Al+1 n,k (Electi (p)), l + 2 ≤ i ≤ k, is in IN T (p). To send a message to some subgraphs of Al+1 n,k (Electi (p)), l+2 ≤ i ≤ k, we have to send the message to some intermediate nodes that are directly connected to some nodes in Al+1 n,k (Electi (p)), l + 2 ≤ i ≤ k, and then send the message to these subgraphs. In case 3, some nodes in Al+1 n,k (Electi (p)), k + 1 ≤ i ≤ n, are directly connected to p since the elements Electi (p) in position l + 1 of the nodes in Al+1 n,k (Electi (p)|k + 1 ≤ i ≤ n) are not in IN T (p). If p sends a message to all n − l node-disjoint
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998) 7 l subgraphs Al+1 n,k of An,k (F irstl (p)) sequentially, it takes O(n − l) steps for p to complete this broadcasting procedure. Applying recursively this procedure, it takes O{(k − l)(n − l)} steps for p to broadcast a message to all the other nodes (n−l)! nodes in Aln,k (F irstl (p)) and an in Aln,k (F irstl (p)). Since there are N = (n−k)! optimal broadcasting procedure requires at most O(lg N ) = O((k − l) lg(n − l)) steps based on Theorem 1, this broadcasting procedure is not optimal in time complexity. If we only consider broadcasting the message to at least one of the nodes in l each of n − l node-disjoint subgraphs Al+1 n,k of An,k (F irstl (p)) and then making each of the nodes that received broadcast the message on the given lower level subgraph, a broadcasting algorithm with optimal time has been proposed in [4]. This algorithm embeds the intermediate nodes in a broadcasting tree to achieve a broadcasting procedure with the optimal time complexity. But it is not optimal in the message complexity. The reason is that it did not consider that different intermediate nodes belong to different level subgraphs and should broadcast the message on different level subgraphs. To perform the broadcasting procedure with time and message optimality on Aln,k (F irstl (p)), we define the intermediate node p(i) that is directly connected to Al+1 n,k (Electi (p)) for l + 2 ≤ i ≤ k as follows.
Definition 6 There may be many intermediate nodes. An intermediate node p(i) is a node that satisfies F irsti−1 (p(i)) = F irsti−1 (p) and Electn (p(i)) = Electi (p) for l + 2 ≤ i ≤ k. Lemma 1 The intermediate node p(i) is adjacent to Al+1 n,k (Electi (p)), l + 2 ≤ i ≤ k. Proof: For l + 2 ≤ i ≤ k, p(i)g(l+1)n is in Al+1 n,k (Electi (p)).
2
Table 1: The broadcasting procedure from p to each of Al+1 n,k (Electi (p)), l + 2 ≤ i ≤ n. Phase beginning 1
the receiving nodes p p(k),..., p(l + 2) p(i)g(l+1)n , l + 2 ≤ i ≤ k,
2
p(j) k+1≤j ≤n
comments the node p is in Al+1 n,k (Electl+1 (p)) p(i), l + 2 ≤ i ≤ k, is adjacent to Al+1 n,k (Electi (p))) p(i)g(l+1)n , l + 2 ≤ i ≤ k, is in Al+1 n,k (Electi (p))) p(j), k + 1 ≤ j ≤ n, is in Al+1 n,k (Electj (p))
As shown in Table 1, we divide the broadcasting procedure for p to broadcast the message to each of Al+1 n,k (Electi (p)), l + 2 ≤ i ≤ n, into two phases:
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998) 8 Phase 1: The node p and the intermediate nodes p(i0 ), l + 2 ≤ i ≤ i0 ≤ k, broadcast the message to the intermediate nodes p(i), l + 2 ≤ i ≤ k. Then, the intermediate nodes p(i), l + 2 ≤ i ≤ k, broadcast the message to Al+1 n,k (Electi (p)) at one step. Phase 2: The node p, the intermediate nodes p(i), l + 2 ≤ i ≤ k, and the nodes 0 0 p(j 0 ) in Al+1 n,k (Electj (p)), k + 1 ≤ j ≤ j ≤ n − 1, broadcast the message l+1 to the nodes p(j) in An,k (Electj (p)), k + 1 ≤ j ≤ n − 1. Then, the node p sends the message to Al+1 n,k (Electn (p)) at the last step. Phase 1. At the beginning of broadcasting procedure, p sends the message to p(k) = pgkn . Then, F irstk−1 (p(k)) = F irstk−1 (p) and Electn (p(k)) = k. At the next step, p and p(k) send the message to p(k − 1) = pg(k−1)n and p(k − 2) = p(k)g(k−2)n respectively. Then, F irstk−2 (p(k − 1)) = F irstk−2 (p) and F irstk−3 (p(k − 2)) = F irstk−3 (p). In this way, the message can be sent to k − l − 1 intermediate nodes p(i), l + 2 ≤ i ≤ k. Because each step doubles the number of the nodes that receive the message, there are 2m nodes that receive the message at the mth step. It takes O(lg(k − l)) steps for p to complete the broadcasting procedure to k − l − 1 intermediate nodes respectively adjacent to k − l − 1 node-disjoint subgraphs Al+1 n,k (Electi (p)) for l + 2 ≤ i ≤ k. Then, the k − l − 1 intermediate nodes p(i), l + 2 ≤ i ≤ k, can send the message to k − l − 1 subgraphs Al+1 n,k (Electi (p)) respectively at one step. Phase 2. Because Electj (p(i)) = Electj (p) for l + 2 ≤ i ≤ k and k + 1 ≤ j ≤ n − 1, the intermediate node p(i) for l + 2 ≤ i ≤ k is also directly connected to Al+1 n,k (Electj (p)) for k + 1 ≤ j ≤ n − 1. After k − l − 1 intermediate nodes p(i), l + 2 ≤ i ≤ k, receive the message, we can make the source node and these intermediate nodes send respectively the message to k − l nodes p(j) in k − l node-disjoint subgraphs Al+1 n,k (Electj (p)), k + 1 ≤ j ≤ k + (k − l) ≤ n − 1. Here, p(k + 1) = pg(l+1)(k+1) and p(k + (i − l)) = p(i)g(l+1)(k+(i−l)) for l + 2 ≤ i ≤ k. Since Electi (p(j)) = Electi (p) for k+1 ≤ j ≤ k+(k−l) < i ≤ n−1, the node p(j) can also send the message to p(j +2(k −l)) at the next step if j +2(k −l) ≤ n−1. Similarly, additional step doubles the number of subgraphs that received the message, it takes O(lg n−k k−l ) steps to complete the broadcasting procedure to n − k − 1 node-disjoint subgraphs Al+1 n,k (Electj (p)) for k + 1 ≤ j ≤ n − 1. Then, l+1 p can send the message to An,k (Electn (p)) at the last step. After completing the broadcasting procedures of Phase 1 and 2, there is only one node that received the message in each of Al+1 n,k (Electi (p)) for l + l+1 2 ≤ i ≤ n. The node in each of An,k (Electi (p)) for l + 2 ≤ i ≤ n can be considered a source node to broadcast the message within the given (l+1)th level subgraphs. In Al+1 n,k (Electl+1 (p)), there are k − l nodes that hold the message, which are p and p(i), l + 2 ≤ i ≤ k. If they are all considered the sources of Al+1 n,k (Electl+1 (p)), some nodes in this subgraph will receive the message more than once. To ensure that each node in the broadcasting procedure receives once only, we develop the broadcasting procedure Phase 3 that can perform the
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998) 9 l+1 broadcasting in Al+1 n,k (Electl+1 (p)) by decomposing An,k (Electl+1 (p)) into the different level node-disjoint subgraphs based on p and p(i) for l+2 ≤ i ≤ k. Here, we first give two Lemmas concerning the decomposing of Al+1 n,k (F irstl+1 (p)) into the different level subgraphs based on p and p(i) for l + 2 ≤ i ≤ k.
Lemma 2 Based on p and the intermediate node p(l + 2) for l + 2 ≤ k, Al+1 n,k (F irstl+1 (p)) can be decomposed into the (l + 2)th level node-disjoint subgraphs as follows. [ l+1 l+2 l+2 (F irstl+1 (p)) = { Vn,k (Electi (p(l + 2)))} ∪ Vn,k (F irstl+2 (p)) . Vn,k l+2≤i≤n−1
(4) l+2 l+2 (Electl+2 (p)) = Vn,k (F irstl+2 (p)). Since Proof: Based on Definition 5, Vn,k = F irstl+1 (p(l + 2)) [ and Electn (p(l + 2)) = Electl+2 (p) from DefiF irstl+1 (p) [
Electj (p) =
nition 6,
l+3≤i≤n
Electi (p(l + 2)). Therefore,
l+2≤i≤n−1
l+1 l+2 (F irstl+1 (p)) = Vn,k (Electl+2 (p)) ∪ { Vn,k
={
[ l+2≤i≤n−1
[
l+2 Vn,k (Electi (p))}
l+3≤i≤n l+2 Vn,k (Electi (p(l + 2)))}
l+2 ∪ Vn,k (F irstl+2 (p)) .
2 k is in Al+2 n,k (Electl+2 (p(l + 2))) that l + 2 ≤ i ≤ n, of Al+1 n,k (F irstl+1 (p)).
From Lemma 2, p(l + 2) for l + 2 ≤ is one of the subgraphs Al+2 n,k (Electi (p)), The node p(l + 2) can be considered a source node to broadcast the message on Al+1 n,k (F irstl+1 (p)). Since F irstl+2 (p) = F irstl+2 (p(l + 3)) for l + 3 ≤ n, p(l + 3) l+2 is in Al+2 n,k (Electn (p(l + 3))) = An,k (F irstl+2 (p)). Therefore, p(l + 2) can apply the broadcasting procedures of Phase 1 and 2 to broadcast the message to the l+2 subgraphs Al+2 n,k (Electi (p)), l+3 ≤ i ≤ n−1, and remains An,k (Electn (p(l+2))) for p(l + 3). To avoid message redundancy, we will recursively use p(i), l + 2 ≤ i−1 i ≤ k, to perform broadcasting in Ai−1 n,k (Electn (p(i))) = An,k (F irsti−1 (p)). Lemma 3 Based on p and p(i), l + 2 ≤ i ≤ k, Al+1 n,k (F irstl+1 (p)) can be decomposed into the different level node-disjoint subgraphs as follows: [ l+1 i (F irstl+1 (p)) = { Vn,k (Electj (p(i)))} ∪ p . Vn,k (5) l+2≤i≤k,i≤j≤n−1
Proof: Recursively applying Lemma 2 until p.
2
Table 2 shows the broadcasting procedures of Phase 3 based on Lemma 3 for p(i), l + 2 ≤ i ≤ k, to broadcast the message to the given different level node-disjoint subgraphs on Al+1 n,k (F irstl+1 (p)). The node p(l + 2) can apply the broadcasting procedures of Phase 1 and 2 to broadcast the message
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998)10 l+2 on Al+1 n,k (F irstl+1 (p)) and only remains An,k (Electn (p(l + 2))) for p(l + 3) if l+2 p(l + 3) ≤ k, where An,k (Electn (p(l + 2))) = Al+2 n,k (F irstl+2 (p)). Similarly, (F irst p(l + 3) can broadcast the message on Al+2 l+2 (p)) and only remains n,k l+3 An,k (Electn (p(l + 3))) for p(l + 4) if l + 4 ≤ k. Recursively applying the broadcasting procedure that p(i) broadcasts the message on Ai−1 n,k (F irsti−1 (p)) and i only remains An,k (Electn (p(i))) for p(i+1) until p, the message can be broadcast with message redundancy in the given different level node-subgraphs.
Table 2: The broadcasting procedures of the intermediate nodes p(i), l + 2 ≤ i ≤ k. sending node p(l + 2) in Al+1 n,k (F irstl+1 (p)) .. . p(i − 1) in Ai−2 n,k (F irsti−2 (p)) p(i) in Ai−1 (F irsti−1 (p)) n,k p(i + 1) in Ain,k (F irsti (p)) .. . p(k) in Ak−1 n,k (F irstk−1 (p)) p no sending
sending to subgraphs Al+2 n,k (Electj (p(l + 2))) l+2≤j ≤n−1 .. . Ai−1 (Elect j (p(i − 1))) n,k i−1≤j ≤n−1 Ain,k (Electj (p(i))) i≤j ≤n−1 Ai+1 n,k (Electj (p(i + 1))) i+1≤j ≤n−1 .. . Akn,k (Electj (p(k))) k ≤j ≤n−1
not sending to subgraph Al+2 n,k (Electn (p(l + 2))) = Al+2 n,k (F irstl+2 (p)) .. . Ai−1 (Elect n (p(i − 1))) n,k = Ai−1 (F irst i−1 (p)) n,k i An,k (Electn (p(i))) = Ain,k (F irsti (p)) i+1 An,k (Electn (p(i + 1))) = Ai+1 n,k (F irsti+1 (p)) .. . Akn,k (Electn (p(k))) = Akn,k (F irstk (p)) = p
Now, we will present a broadcasting algorithm with optimal time complexity and without message redundancy for one-to-all broadcasting on an arrangement graph Aln,k . Let Broadcasting algorithm denote our one-to-all broadcasting algorithm. We will describe it based on three phases as shown in Table 1 and 2. Since the node p(j), k + 1 ≤ j ≤ n − 1, is the source node in Al+1 n,k (Electj (p(j))), we only need to improve Phase 2 so that the node p(j), k + 1 ≤ j ≤ n − 1, will start to broadcast the message on Al+1 n,k (Electi (p(j))) in Phase 2 after completing the broadcasting procedure from p to each of Al+1 n,k (Electi (p)), k + 1 ≤ i ≤ n − 1. In the broadcasting procedure, the nodes that hold the message send the broadcasting request to the other nodes. Every node individually starts to perform its broadcasting algorithm while receiving the request. Let M denote a broadcasting request. A request M consists of following six parameters as shown in Table 3 and M = {Data, pout , l, i, m, ID}. At the beginning of broadcasting, M = {Data, pout , l, 0, 0, 0}. The formal description of our broadcasting algorithm is given below.
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998)11 Table 3: Parameters that a request M contains 1 2 3 4 5 6
Data pout l i m ID ID = 0 ID = 1 ID = 2
Message to be broadcast. The given label to be sent to the receiving node. Dimension of subgraph. Integer used for determining edges. Used for determining the order of broadcasting. Used for determining the phase of node in broadcasting. The source node. The message is sent to p(i), l + 2 ≤ i ≤ k. The message is sent to p(j), k + 1 ≤ j ≤ n − 1.
Broadcasting algorithm(M ) var i, n, l, k, m, ID : integer; gij : operator; begin /* p decides its pout based on M and sends M to the receiving node */ the node p gets M from buffer; /* begin Phase 1: broadcast M to p(i), l + 2 ≤ i ≤ k */ if ID = 0 and l ≤ k − 2 then begin repeat /* the source node broadcasts M to p(i), l + 2 ≤ i ≤ k */ m := m + 1; i := k + 1 − 2m−1 ; if i ≥ l + 2 then p sends M (Data, pout , l, i, m, 1) to pgin until i < l + 2 end; if ID = 1 then begin I = i; repeat /* p(i0 ), l + 2 ≤ i < i0 ≤ k broadcast M to p(i) */ m := m + 1; i := I − 2m−1 ; if i ≥ l + 2 then p sends M (Data, pout , l, i, m, 1) to pgin until i < l + 2; p sends M (Data, pout , l + 1, 0, 0, 0) to pg(l+1)n /* p(i), l + 2 ≤ i ≤ k, broadcast M to Al+1 n,k (Electi (p))) */ end; /* end Phase 1 */ /* begin Phase 2: broadcast M to p(i), k + 1 ≤ i ≤ n, and in Al+1 n,k (Electi (p)), k + 1 ≤ i ≤ n − 1 */ if ID = 0 and l ≤ k − 1 then begin m := 0; repeat /* the source node broadcasts M to p(i), k + 1 ≤ i ≤ n − 1 */ m := m + 1; i := k + 1 + (2m−1 − 1)(k − l); if i ≤ n − 1 then p send M (Data, pout, l, i, m, 2) to pg(l+1)i until i > n − 1 p send M (Data, pout , l + 1, 0, 0, 0) to Al+1 n,k (Electn (p))) /* sends M to p(n) in Al+1 n,k (Electn (p))) */ end;
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998)12 if ID = 1 then begin m := 0; repeat /* p(i0 ), l + 2 ≤ i0 ≤ k, broadcast M to p(i), k + 2 ≤ i ≤ n − 1 */ m := m + 1; i := k + I − l + (2m−1 − 1)(k − l); if i ≤ n − 1 then p send M (Data, pout, l, i, m, 2) to pg(l+1)i until i > n − 1 end; if ID = 2 then begin I := i; repeat /* p(i0 ), k + 1 ≤ i0 < i ≤ n − 1, broadcast M to p(i) */ m := m + 1; i := I + (2m−1 )(k − l); if i ≤ n − 1 then p send M (Data, pout, l, i, m, 2) to pg(l+1)i ; until i > n − 1 Broadcasting algorithm(Data, p, l + 1, 0, 0, 0) /* p(i), k + 1 ≤ i ≤ n − 1, broadcast M in Al+1 n,k (Electi (p)) */ end; /* end Phase 2 */ /* begin Phase 3: p(i), l + 2 ≤ i ≤ k − 1, broadcasts M in Ai−1 n,k (F irsti−1 (p)) */ if ID = 1 then begin l := I; m := 0; repeat /* Phase 1 of the source node */ m := m + 1; i := k + 1 − 2m−1 ; if i ≥ l + 2 then p sends M (Data, pout , l, i, m, 1) to pgin until i < l + 2 m := 0; repeat /* the source node broadcasts M to p(i), k + 1 ≤ i ≤ n − 1 */ m := m + 1; i := k + 1 + (2m−1 − 1)(k − l); if i ≤ n − 1 then p send M (Data, pout, l, i, m, 2) to pg(l+1)i until i > n − 1 end /* end Phase 3 */ end;
Figure 2 illustrates the broadcasting procedure for A7,4 to be decomposed into its 7 subgraphs A17,4 , 6 subgraphs A27,4 , 5 subgraphs A37,4 and 4 subgraphs A47,4 based on the source node and the intermediate nodes. Let the source node 1234 have the given pout = 567 and be denoted 1234(567). The source node 1234(567) broadcasts the message to 3 intermediate nodes p(i), 2 ≤ i ≤ 4, in A17,4 (1) and the other 6 subgraphs A17,4 (Electi (p)), 2 ≤ i ≤ 7, after completing the broadcasting procedure of Phase 1 and 2 from 1234(567) to the other 6 subgraphs A17,4 . In A17,4 (1), there are 3 intermediate node p(2) = 1437(562), p(3) = 1274(563) and p(4) = 1237(564) that received the message. These 3 nodes are the source nodes of A17,4 (1), A27,4 (12) and A37,4 (123) respectively . Since p(2) ∈ A17,4 (14) and p ∈ A17,4 (12), the source node p(2) = 1437(562) in A17,4 (1) only needs to broadcast the message to A27,4 (13), A27,4 (15), A27,4 (16) and A27,4 (17) in executing the broadcasting procedure of Phase 3. In the same way as p(2) = 1437(562) does on A17,4 (1) , the source node p(3) = 1274(563) in A27,4 (12) only
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998)13
A7,4
p(3)
source node p
1274(563)
2
3 1
A7,4 (3)
1234(567) 3
1
p(4) 1
4 1
1237(564)
p(2) 2
3
4
1
A7,4 (6)
1
3 1
A7,4 (5)
A7,4 (7)
source node p(2) 2 A7,4 (13) A27,4 (14)
A7,4 (15)
A7,4 (16)
A7,4 (17)
p A 27,4 (12)
3 A7,4 (125)
3 A7,4 (126)
p A37,4 (123)
A 27,4 (12)
source node p(3) 3 A7,4 (124) A 37,4(127) source node p(4)
1235(764)
2
1236(574)
A7,4 (4)
1
A7,4 (1)
1437(562)
2
p 1234(567)
2
A7,4 (2)
A17,4 (1)
A37,4 (123)
Figure 2: Partitioning A7,4 into its subgraphs based on the properties of nodes
needs to broadcast the message to A37,4 (124), A37,4 (125) and A37,4 (126), and the source node p(4) = 1237(564) on A37,4 (123) only needs to broadcast the message to A47,4 (1235) and A47,4 (1236). Since any one of A27,4 can be considered as one A5,2 , we will take A5,2 for example to illustrate Broadcasting algorithm in figure 3. Figure 3 illustrates the broadcasting tree from the source node 12 on A5,2 by applying our algorithm. Let 12(345) be the source node. Each of the nodes that receive the message decides its pout based on the received message. The number-labeled edges denote the steps in broadcasting. The node 15(342) is a intermediate node in Phase 1. It only sends to 13(542) and 14(352), and does not send to 12(345) on A15,2 (1). This is because 12(345) holds the message and A25,2 (12) = A25,2 (Elect5 (15(342))). This figure shows that our algorithm completes the broadcasting in 6 steps without redundant messages on A5,2 . Now, we prove that the algorithm Broadcasting algorithm is optimal in the time and message complexity. Lemma 4 After applying Phase 1 and 2, Broadcasting algorithm can broadcast a message from the source node p in Aln,k (F irstl (p)) to k−l−1 intermediate nodes in Al+1 n,k (F irstl+1 (p)) and to only one node in each of n−l−1 node-disjoint
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998)14
source node 12(345) 3 1 4 15(342) 3
13(542) 5
1 5,2
A (1)
2
52(341) 4 6
2 14(352) 3 4 23(541)
53(241) 5
1 A5,2 (5)
32(145) 4 5
54(321)
41(352)
34(125)
51(342)
42(315)
31(245)
35(142)
25(341) 5
45(312) 4
21(345)
5
6
3
1
A5,2(2) 24(351)
43(512)
A5,21 (4)
A15,2(3)
Figure 3: The broadcasting from the source node 12(345) in A5,2
subgraphs Al+1 n,k (Electi (p)), l + 2 ≤ i ≤ n, in O(lg(n − l)) steps. Proof: In Phase 1, there are k − l − 1 nodes intermediate p(i), l + 2 ≤ i ≤ k, that received the message. These nodes belong to Al+1 n,k (F irstl+1 (p)). Since k − l − 1 nodes p(i), l + 2 ≤ i ≤ k, send respectively the message to k − l − 1 node-disjoint subgraphs Al+1 n,k (Electi (p)), l + 2 ≤ i ≤ k, only once in Phase 1, and there is only one node p(j) which received the message in Phase 2 in each of n−k node-disjoint subgraphs Al+1 n,k (Electj (p)), k +1 ≤ j ≤ n, the source node p can broadcast a message to only one node in each of n − l − 1 node-disjoint subgraphs Al+1 n,k (Electi (p)), l + 2 ≤ i ≤ n. Let L1 and L2 denote the number of the steps required for the nodes in Phase 1 and 2 to broadcast the message to each of the other n−l −1 subgraphs Al+1 n,k only once. Let L denote the number of the steps required for p to complete the broadcasting procedure of Phase 1 and 2. As shown in Phase 1, since l + 2 ≤ k + 1 − 2m−1 and l + 2 ≤ I − 2m−1 with max(I) = k, L1 = max{1 + dlg(k − l − 1)e, 2 + dlg(k − l − 2)e} ≤ 2 + dlg(k − l)e. Similarly, L2 ≤ 2 + dlg n−l−2 k−l e as shown in Phase 2. Therefore, L = L1 + L2 = O(1) + O(lg(k − l) + lg
n−l−2 ) = O(lg(n − l)) . k−l
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998)15 2 Lemma 5 In applying Phase 3, each of k − l − 1 intermediate nodes p(i), l + 2 ≤ i ≤ k, is the source node in each of k − l − 1 different level subgraphs Ai−1 n,k (F irsti−1 (p)). Proof: Based on Lemma 2 and 3, it is trivial to prove Lemma 5.
2
Theorem 2 Broadcasting algorithm on Aln,k can broadcast a message from
(n−l)! − 1 nodes in at most O((k − l) lg(n − l)) the source node to all the other (n−k)! steps without redundant messages.
Proof: We use induction to prove that Broadcasting algorithm has no redundant messages on Aln,k . As a basis, it is easy to prove that this algorithm has no redundant messages for l = k and l = k − 1 on Aln,k since Akn,k is only a node and Ak−1 n,k is a complete graph. Assume that Broadcasting algorithm has no redundant messages on Al+1 n,k for 1 ≤ l + 1 ≤ k − 2. Let p be the source node of broadcasting in Aln,k (F irstl (p)). Aln,k (F irstl (p)) can be decomposed into the (l + 1)th level node-disjoint subgraphs as follows. [ l+1 l+1 l (F irstl (p)) = Vn,k (F irstl+1 (p)) ∪ { Vn,k (Electi (p))} Vn,k l+2≤i≤n
From Lemma 4, each of Al+1 n,k (Electi (p)), l + 2 ≤ i ≤ n, has a source node after applying Phase 1 and 2. Hence, Broadcasting algorithm is no redundant messages on these subgraphs by the inductive hypothesis. From Lemma 5, the intermediate nodes p(l+2) is the source node in the subgraph Al+1 n,k (F irstl+1 (p)). l+1 Based on Lemma 2, An,k (F irstl+1 (p)) can be decomposed into the lower level node-disjoint subgraphs as follows. [ l+1 l+2 l+2 (F irstl+1 (p)) = { Vn,k (Electi (p(l + 2)))} ∪ Vn,k (F irstl+2 (p)) . Vn,k l+2≤i≤n−1
Since the intermediate nodes p(l+2) in Phase 3 execute the broadcasting procedure of Phase 1 and 2 except for not sending the message to Al+2 n,k (Electn (p(l + l+2 l+2 2))) = An,k (F irstl+2 (p)), each of An,k (Electi (p(l + 2))), l + 3 ≤ i ≤ n − 1, has a source node after applying Phase 3. Since p(l + 2) is in Al+2 n,k (Electl+2 (p(l + 2))) l+2 and p(i) for l + 3 ≤ i ≤ k is in An,k (Electn (p(l + 2))) = Al+2 n,k (F irstl+2 (p)), Broadcasting algorithm has no redundant messages on Al+1 n,k (F irstl+1 (p)) by inductive hypothesis. It is shown that our algorithm can broadcast the message from the source node to each of the other nodes exactly once on Aln,k . Now, we prove that Broadcasting algorithm takes O((k − l) lg(n − l)) steps to complete broadcasting on Aln,k . Based on Lemma 4, our algorithm can reduce
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998)16 the broadcasting problem size on Aln,k to the broadcasting problem size on Al+1 n,k in O(lg(n − l)) steps for 0 ≤ l ≤ k − 1 recursively. Since, in the broadcasting procedure of our algorithm, Aln,k is decomposed into its lower level subgraphs until Akn,k , the message is broadcast to all the other nodes on Aln,k through at most k − l source nodes in different lower level subgraphs. Let Length denote the number of the steps required for broadcasting a message on Aln,k . Length ≤ (k − l)O(lg(n − l)) = O((k − l) lg(n − l)) 2 Theorem 3 Broadcasting algorithm can broadcast a message from the source n! −1 nodes in at most O(k lg n) steps without redundant node to all the other (n−k)! messages on An,k . Proof: Based on Theorem 2, it is trivial to prove Theorem 3.
2
As shown in Theorem 1, since an optimal broadcasting algorithm requires at most Ω(k lg n) steps to complete broadcasting on An,k , Broadcasting algorithm is optimal in the time complexity. Since this algorithm broadcasts a message only once to each of the other nodes on An,k , it is also optimal in the message complexity.
4
Conclusion
In this paper, we have presented a one-to-all distributed broadcasting algorithm for the fault-free arrangement graph interconnection network. This algorithm is based on the hierarchical property of the arrangement graph. It can broadcast a message to all the other nodes on the (n, k)-arrangement graph in at most O(k lg n) steps. It can also guarantee that each of the other nodes on the arrangement graph receives the message exactly once. It is shown that our Broadcasting algorithm can perform the broadcasting on the arrangement graph with optimal time and message complexity.
Acknowledgments The authors would like to thank the reviewers for their constructive and helpful comments. They have made many helpful revisions and suggestions that have significantly improved the presentation.
L. Bai et al., Broadcasting on Arrangement Graphs, JGAA, 2(2) 1–17 (1998)17
References [1] S. B. Akers, D. Harel, and B. Krishnamuthy. The star graph: An attractive alternative to the n-cube. In Proc. Int. Conf. Parallel Processing, pages 393–400, 1987. [2] S. B. Akers and B. Krishnamuthy. A Group-Theoretic Model for Symmetric Interconnection Networks. IEEE Trans. Comput., 38(4):555–566, 1989. [3] S. G. Akl, B. Qiu, and I. Stojmenovic. Fundamental algorithm for the star and pancake interconnection networks with applications to computational geometry. Networks, 23(4):215–225, 1993. [4] L. Q. Bai, P. M. Yamakawa, H. Ebara, and H. Nakano. A Broadcasting Algorithm on the Arrangement Graph. Computing and Combinatorics, Lecture Notes in Computer Science 959, Springer, pages 462–471, 1995. [5] K. Day and A. Tripathi. Arrangement graphs: A class of generalized star graphs. Information Processing Letters, 42:235–241, 1992. [6] P. Fraigniaud. Asymptotically Optimal Broadcasting and Gossiping in Faulty Hypercube Multicomputers. IEEE Trans. Comput., 41(11):1410– 1419, 1992. [7] E. Horowitz and A. Zorat. The binary tree as interconnection network: Application to multiprocessing systems and VLSI. IEEE Trans. Comput.. 30(4):245–253, 1981. [8] S. L. Johnsson and C. T. Ho. Optimal Broadcasting and Personalized Communication in Hypercubes. IEEE Trans. Comput., 38(9):1249–1268, 1989. [9] V. E. Mendia and D. Sarkar. Optimal Broadcasting on the Star Graph IEEE Trans. Parallel Distrib. Syst., 3(4):389–396, 1992. [10] J. Misic and Z. Jovanovic. Communication Aspects of the Star Graph Interconnection Network. IEEE Trans. Parallel Distrib. Syst., 7(5):678–687, 1994. [11] J. P. Sheu, W. H. Liaw, and T. S. Chen. A broadcasting algorithm in star graph interconnection network. Information Processing Letters, 48:237–241, 1993. [12] J. P. Sheu, C. T. Wu, and T. S. Chen. An Optimal Broadcasting Algorithm without Message Redundancy in Star Graphs. IEEE Trans. Parallel Distrib Systs, 6(6):653–658, 1995. [13] J. Y. Tien, C. T. Ho, and W. P. Yang. Broadcasting on Incomplete Hypercubes. IEEE Trans. Comput., 42(11):1393–1398, 1993.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 2, no. 3, pp. 1–16 (1998)
A Visibility Representation for Graphs in Three Dimensions Prosenjit Bose
Hazel Everett
Carleton University, Canada
[email protected]
Universit´e du Qu´ebec `a Montr´eal, Canada
[email protected]
S´andor P. Fekete
Michael E. Houle
Universit¨at zu K¨ oln, Germany
[email protected]
University of Newcastle, Australia
[email protected]
Anna Lubiw
Henk Meijer
University of Waterloo, Canada
[email protected]
Queen’s University, Canada
[email protected]
Kathleen Romanik
G¨ unter Rote
University of Maryland, USA
[email protected]
Technische Universit¨ at Graz, Austria
[email protected]
Thomas C. Shermer
Sue Whitesides
Simon Fraser University, Canada
[email protected]
McGill University, Canada
[email protected]
Christian Zelle Technische Universit¨ at Graz, Austria
[email protected] Abstract This paper proposes a 3-dimensional visibility representation of graphs G = (V, E) in which vertices are mapped to rectangles floating in R 3 parallel to the x, y-plane, with edges represented by vertical lines of sight. We apply an extension of the Erd˝ os-Szekeres Theorem in a geometric setting to obtain an upper bound of n = 56 for the largest representable complete graph Kn . On the other hand, we show by construction that n ≥ 22. These are the best existing bounds. We also note that planar graphs and complete bipartite graphs Km,n are representable, but that the family of representable graphs is not closed under graph minors. Communicated by M. T. Goodrich: submitted February 1996; revised February 1997. Research on this paper was supported by FCAR, NSERC, NSF, and DFG.
P. Bose et al., 3-D Visibility Representation, JGAA, 2(3) 1–16 (1998)
1
2
Introduction
The problem of drawing or representing graphs has been studied extensively in the literature (see the paper of Di Battista et al. [11] for a survey of graph drawing research and its applications). In particular, determining a visibility representation of a graph, where the vertices of the graph map to disjoint sets or objects in the plane and the edges are expressed as visibility relations between these sets, has received considerable attention recently due to the large number of applications in areas such as VLSI wire routing, algorithm animation, CASE tools, and circuit board layout. However, visibility representations in 3dimensions have received less attention. In this paper, we define a 3-dimensional visibility representation and study its properties. This paper combines experimental results with the results of two conference papers [4, 14] and a technical report [5], which have motivated a number of other conference papers such as [2, 7, 15, 17, 21]. Closely related questions have been examined in [10, 19]. This paper introduces the basic concepts and fundamental results in this area.
1.1
Previous results
We begin by reviewing some of the results in 2-dimensional visibility representations. To do this, we first discuss in more detail the most common types of visibility representations that have been studied. A visibility representation is defined by specifying a class of objects to represent the vertices and the visibility relation between the objects. In two dimensions, common choices for objects are axis-aligned line segments or rectangles. Two visibility relations that have been considered previously are defined as follows: • Two objects are (mutually) visible if and only if they can be joined by a line segment that does not intersect any other object. Often, the direction of the line segment is restricted to be axis-parallel. • Two objects are -visible if and only if they can be joined by a family of parallel line segments such that no segment intersects any other objects, and the union of the segments covers a region of positive area, i.e., positive “width” . Again, the direction of the line segments is often restricted to be axis-parallel. For example, in Figure 1, line segments 1 and 2 are visible but not -visible. Line segments 2 and 3 as well as line segments 1 and 3 are -visible. However, line segments 1 and 3 are not vertically -visible. Line segments 2 and 4 are not visible by either of the above notions of visibility. Although these two different types of visibility seem closely related, the restrictions imposed by -visibility often radically change the class of graphs that admit visibility representations. See [22] for a discussion of the different definitions of visibility and the sensitivity of results to the choice of visibility definition. Now we can describe some previous results concerning 2-dimensional visibility representations. Wismath [24] and Tamassia and Tollis [22] independently
P. Bose et al., 3-D Visibility Representation, JGAA, 2(3) 1–16 (1998)
1
3
2
3
4
Figure 1: An illustration of visibility relations.
showed that every 2-connected planar graph admits a visibility representation where the vertices are represented by closed disjoint horizontal line segments in the plane and where two vertices are adjacent if and only if their corresponding segments are vertically -visible. (More precisely, they showed that such a representation exists for a graph if and only if the graph is planar and has an embedding with all cut vertices on the exterior face.) For the same model, Kant et al. [18] studied the visibility representations of trees. When the vertices are represented by disjoint axis-aligned rectangles in the plane and visibility is defined as -visibility in the horizontal and vertical directions, Wismath [24] showed that every planar graph admits a visibility representation. Dean and Hutchinson [10] proved that K8 is the largest complete graph that admits a visibility representation in this model. For an overview of the various visibility representations studied, see [11].
1.2
3-Dimensional visibility representation
This paper studies a 3-dimensional visibility representation for graphs G = (V, E). First we define this representation. Consider an arrangement of closed, disjoint rectangles in R 3 such that the planes determined by the rectangles are perpendicular to the z-axis, and the sides of the rectangles are parallel to the xor y-axes. Two rectangles Ri and Rj are z-visible if and only if between the two rectangles there is a closed cylinder C of positive length and radius such that the ends of C are contained in Ri and Rj , the axis of C is parallel to the z-axis, and the intersection of C with any other rectangle in the arrangement is empty. Througout this paper, a given graph G = (V, E) is said to be representable if and only if its n vertices can be associated with n disjoint rectangles parallel to the x, y-plane in R 3 such that vertices vi and vj are adjacent in G if and only if their corresponding rectangles Ri and Rj are z-visible. One motivation for considering this type of 3-dimensional representation is the fact that, in addition to all planar graphs, many non-planar graphs can also be represented. Indeed we will exhibit a representation of K22 , but prove that
P. Bose et al., 3-D Visibility Representation, JGAA, 2(3) 1–16 (1998)
4
complete graphs of size n ≥ 56 are not representable. The fact that a clique as large as K22 is representable may prove useful for graph visualization purposes. Given an arbitrary graph on n ≤ 22 vertices, one can take a visibility representation (as defined above) of Kn as defined above and, for each edge e ∈ E(G), draw in z-axis parallel lines of sight between the rectangles corresponding to the endpoints of e. This gives what is called a weak visibility representation, as G cannot be recovered from the positions of the rectangles1 . However, weak representation is entirely appropriate when, for example, the purpose is to visualize the graph or to produce a VLSI layout.
Figure 2: The structure of a software package, as drawn by one of its users. Figures 2 and 3 suggest that for visualizing diagrams involving graphs whose vertices are associated with text and various other properties, a 3-dimensional visibility representation may prove useful. Figure 2 gives a hand-drawn diagram of a software package. (This package is used for analyzing and forecasting the savings of millions of customers of the German public loan banks. See [3].) Figure 3 gives a view from the top of a 3-dimensional visibility representation; in addition to the adjacency information, the size of a rectangle corresponds approximately to the importance of the files and routines it represents; input files are black, whereas output files are white. Furthermore, this type of representation permits taking advantage of the fact that the given directed graph is 1 When the graph can be recovered from the geometry of its representation, the representation is sometimes called strong.
P. Bose et al., 3-D Visibility Representation, JGAA, 2(3) 1–16 (1998)
5
REAL_SSPKT REAL_BSPK REAL_BWZ REALT1_EXEC NVSOLL_BSPK NVSOLGEN_EXEC MASTER_BSPK REAL_BSPKT1
VAR_BSPK
GENSPA_CNSUT1
BWZ_BSPK
F2_VORAU
NVSCAL_BSPK
GENSPA_EXEC
FT02F001_BSPK
SIM12_EXEC
ANSDEF_BSPK
MITKOL1_EXEC
GENDEF_BSPK STANDARD_BSPK
UEBER91_EXEC
REALGEN_EXEC REALLS_BSPK
KOLLEKT_BSPK SIMPSOL_BSPK
V_BSPK VERSION_BSPK
LSEARCH_BSPK
ANSCHLUSS_BSPK
STAT_BSPK
LSOUT_BSPK LSEARC 91_EXEC
FIND_FILE
STAT_BSPK F2PREP12_EXEC FT02F001_BSKP FT01F001_BSPK
BSM_PRINT
BSM_DATAFORM
BSM12_EXEC BSM_BWZ
VARIO_INFOHAN BSM_BWZ
BSM_HELP
BSM_DUMP
PEEP B8kkT
Figure 3: Top view of a representation of the software package.
acyclic: the edges are directed from lower rectangles to higher rectangles. Alternatively, instead of viewing the representation from the top, on a workstation one could view the rectangles as boxes that have thickness in the z direction, so that text could be written on the sides of the box. The representation could then be examined from multiple viewpoints and could be explored by travelling around inside the picture. We make no claim that the top view of the 3-dimensional representation shown in Fig. 3 is easier to understand than the handmade drawing of Fig. 2. However, we believe that the interplay between geometry and combinatorics demonstrated by the type of visibility representation defined in this paper makes such representations interesting in their own right. Furthermore, we believe that the possibility of drawing graphs in 3 dimensions, with vertices represented as solid objects such as boxes, is well worth further investigation. The rest of this paper is organized as follows: In Section 2, we show that Kn does not have a representation for n ≥ 56. On the other hand, we show in Section 3 that Kn has a representation for values of n ≤ 22. In Section 4, we note that all planar graphs and all complete bipartite graphs are representable, but that the family of representable graphs is not closed under graph minors.
P. Bose et al., 3-D Visibility Representation, JGAA, 2(3) 1–16 (1998)
6
Section 5 concludes the paper.
2
An upper bound
In this section, we provide an upper bound on the size of the largest clique that can be represented. We show that Kn does not have a representation for any n > 55. This result, based on [14], improves the previous best known result of n > 102 from [4, 5].
2.1
Sequences of 4-tuples
We consider sequences of n rectangles lying parallel to the x, y-plane in R 3 , and ordered by increasing z-coordinate. We call a sequence valid if its associated visibility graph is Kn . Consider the projections of all the rectangles in a valid sequence onto the x, y-plane. Because each two must intersect and the objects are axis-aligned rectangles, application of a Helly-type argument shows that the intersection of all the projections must be non-empty [9]. Thus we can choose a common point O (henceforth regarded as the origin) belonging to the interior of each of the projections. To simplify the notation, we do not distinguish between a rectangle and its projection onto the x, y-plane; the meaning will be clear from the context. Without loss of generality, we may assume that all rectangles in a representation have distinct, non-negative integer z-coordinates. Each rectangle R in a valid sequence can be described in terms of the perpendicular distances from O to each of its sides. Instead of giving the x, y coordinates of the vertices of R, we describe R as a 4-tuple (Er , Nr , Wr , Sr ) whose coordinates give, respectively, the distances from O ∈ R to the east, north, west and south sides of R. We can assume without loss of generality that no two rectangles of a valid sequence share the same value on any of the four coordinates E,N ,W ,S. Hence we can assume that each coordinate value of each of the n rectangles is an integer in the range [1, n] without changing the visibility relationships among the rectangles. Consider two rectangles A = (Ea , Na , Wa , Sa ) and B = (Eb , Nb , Wb , Sb ) in a valid sequence, and denote by A ∩ B the intersection of their projections onto the x, y-plane. Then A ∩ B contains O, and the coordinates of A ∩ B are EA∩B = min{Ea , Eb }, NA∩B = min{Na , Nb }, WA∩B = min{Wa , Wb } and SA∩B = min{Sa , Sb }. We say that a corner of A ∩ B is free if it is not covered by any of the projections of rectangles occuring between A and B in the sequence. Suppose A and B are rectangles in a valid sequence. Then since O belongs to all the rectangles, at least one of the corners of A ∩ B must be free. This is because any rectangle that covers a corner also covers O and hence an entire quadrant of A ∩ B. Thus if A ∩ B had no free corner, it would be covered by the union of the intervening rectangles that cover at least one corner of A ∩ B. The northeast corner of A ∩ B is not covered by a particular rectangle R = (Er , Nr , Wr , Sr ) between A and B if and only if the boolean expression Er <
P. Bose et al., 3-D Visibility Representation, JGAA, 2(3) 1–16 (1998)
7
min{Ea , Eb } OR Nr < min{Na , Nb } is true. Similar conditions hold for the other three corners. We summarize: the rectangles A and B can see each other if and only if at least one of the following free corner conditions FC holds simultaneously for all the rectangles R between A and B: FCne (A, B) northeast is free: (Er < min{Ea , Eb } OR Nr < min{Na , Nb }); FCnw (A, B) northwest is free: (Nr < min{Na , Nb } OR Wr < min{Wa , Wb }); FCsw (A, B) southwest is free: (Wr < min{Wa , Wb } OR Sr < min{Sa , Sb }); FCse (A, B) southeast is free: (Sr < min{Sa , Sb } OR Er < min{Ea , Eb }). Now we give a definition that is needed in the following discussions. Given a valid sequence of n rectangles (E1 , N1 , W1 , S1 ), . . . , (En , Nn , Wn , Sn ), we define the sequences VE = (E1 , ...En ), VN = (N1 , ...Nn ), VW = (W1 , ...Wn ), and VS = (S1 , ...Sn ).
2.2
Unimaximal sequences
The next definition and lemma provide a key tool in our analysis. Definition 2.1 A sequence x1 , x2 , . . . of distinct integers is called unimaximal if it has exactly one local maximum, i. e., for all i, j, k with i < j < k, we have xj > min{xi , xk } for i < j < k. Lemma 2.2 For all m > 1, in every sequence of m 2 + 1 distinct integers, there exists at least one unimaximal subsequence of length m. On the other hand, there exists a sequence of m 2 distinct integers that has no unimaximal subsequence of length m. This result arises from the Erd˝ os-Szekeres Theorem [13], whose pigeon-hole proof was given by [16]. Lemma 2.2 is attributed by F. P. K. Chung [6] to V. Chv´ atal and J. M. Steele, among others. Lemma 2.3 In a representation of K5 by five rectangles, with no other rectangles present, it is impossible that both sequences VN and VS are unimaximal. Proof: Suppose both VN and VS are unimaximal. Then the relations Nr > min{Na , Nb } and Sr > min{Sa , Sb } must hold for all rectangles A, B, and R between A and B. Now consider the conditions FCne , FCnw , FCsw , FCse . For FCne (A, B) to be true, it must be the case that Er < min{Ea , Eb } for all R between A and B. The same is true for FCse (A, B). Similarly, for FCnw (A, B) or FCsw (A, B) to be true, Wr must be less than min{Wa , Wb }. Hence the free corner conditions reduce to the following. One of the two possibilities (Wr < min{Wa , Wb }) or (Er < min{Ea , Eb }) holds simultaneously for all rectangles R
P. Bose et al., 3-D Visibility Representation, JGAA, 2(3) 1–16 (1998)
8
between A and B. This means that all rectangles A and B can see each other along a line of sight with y-coordinate 0. By intersecting the arrangement of five rectangles with the x, z-plane, we get an arrangement of 5 line segments in this plane that all see each other. This contradicts the fact that only planar graphs can be represented by vertical visibility of horizontal line segments in a plane. (See [22, 24] for results on such representations in the plane.) 2
2.3
The bound
Theorem 2.4 No complete graph Kn has a z-visibility representation for n ≥ 56. Proof: Suppose we had a representation of Kn with n ≥ 56. Lemma 2.2 implies that VN has a unimaximal sequence VN0 of length 11. Consider the associated subsequence VS0 of length 11. It follows again from Lemma 2.2 that there is a subsequence VS00 of length 5 that is unimaximal. Remove the rectangles not associated with the subsequence. This destroys no visibility lines, so the five remaining rectangles represent K5 . However, both VS00 and its corresponding 2 subsequence VN00 are unimaximal. This contradicts Lemma 2.3.
3
A lower bound
In this section we show by construction that the complete graph on 22 vertices is representable. This improves the previous lower bound of 20 in [5].
3.1
The construction
Figure 4 gives the representation of K22 discovered by the algorithm. At each stage, a new rectangle is added; each white dot indicates a corner of visibility for a rectangles at a lower level. The following table shows the coordinates of the 22 rectangles in the notation of the previous section.
P. Bose et al., 3-D Visibility Representation, JGAA, 2(3) 1–16 (1998)
Figure 4: A representation of K22 .
9
P. Bose et al., 3-D Visibility Representation, JGAA, 2(3) 1–16 (1998) Rectangle 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
3.2
North 22 11 9 8 7 5 1 17 16 4 15 19 14 6 3 2 20 13 10 18 12 21
South 22 13 6 2 19 17 18 14 12 20 15 16 1 3 4 5 7 8 9 10 11 21
West 22 15 18 12 9 8 7 5 4 1 3 2 19 6 10 11 16 14 20 13 17 21
10
East 22 16 15 20 8 11 12 1 2 14 3 4 6 18 17 19 5 7 9 10 13 21
How the representation was found
The representation of K22 was found using simulated annealing, a general randomized heuristic approach for finding good solutions for optimization problems. By starting with a randomly-generated candidate solution and applying local modifications, other candidate solutions are generated. The choice of local transformation is guided by an objective function which the procedure attempts to minimize. See [1, 20, 23] for more information regarding simulated annealing techniques. For a given n, the algorithm tries to find a realization of Kn . As described in the previous section, any configuration can be assumed to consist of a list of 4-tuples of numbers between 0 and n − 1, where all numbers for the same coordinate are distinct. Two configurations I and J are regarded as adjacent if the configuration J is obtained from I by swapping one of the edge coordinates of two rectangles in I. For a configuration I, the set of all configurations adjacent to I shall be called the neighborhood of I. The objective function that we want to minimize is defined as follows: for every pair of rectangles A and B in the collection, we assign a score equal to the minimum number of rectangles needed to be removed from the collection in order for A and B to become mutually visible. This score can be determined in a straightforward manner from the free corner conditions FC stated in the previous section, in linear time. The objective function is obtained by summing
P. Bose et al., 3-D Visibility Representation, JGAA, 2(3) 1–16 (1998)
11
these scores over all pairs of rectangles; this function is zero for any feasible realization of Kn and is positive otherwise. Simulated annealing generates a random element J in the neighborhood of the current solution I and compares their two objective values. If J is better than I, then J is accepted as the new current solution; otherwise, J is accepted with a probability that depends on the difference in the objective functions and on a parameter T , which is called the temperature. The higher the temperature, the more likely it is to accept worse solutions. The initial temperature should be of the same order of magnitude as the average change of objective function for a random swap. The temperature is gradually decreased until it is so low that no changes are accepted and the algorithm gets stuck at a local minimum. After some experimentation we chose to decrease T by a factor of 0.96 after every 100-th iteration. When spending more than 160 iterations in the same solution, the algorithm decides that it is caught in a local minimum, generates a new random configuration, and restarts. The program stops when the objective function reaches zero. Initially, we determined the neighboring solution by selecting two rectangles uniformly at random and swapping one of the four edge coordinates, again chosen randomly, in accordance with the general principles of simulated annealing. However, in order to accelerate the algorithm, we changed to a non-uniform selection. We defined a penalty function for each rectangle R in the collection, whose value is based on 1. the number of rectangle pairs whose visibility is blocked by R. 2. the number of rectangles not visible to R. If these numbers are large, the rectangle R is likely to be important for the objective function, and hence it is favored in the selection. We also considered an enlargement of the neighborhood by defining two configurations to be adjacent if one can be obtained from the other by swapping two, three, or all four edge coordinates between two of the rectangles. After experimenting with the choices of T and the size of the neighborhood for approximately one month, a z-visibility representation for K22 was found. The search for a representation of K23 was run more or less continuously on various workstations and personal computers for almost a year, without success.
4
Additional Results
The section presents some simple, additional representability results, most notably, that all planar graphs are representable.
4.1
Representations for planar graphs
In this section, we show that all planar graphs have a representation. There are two main ingredients in the proof. The first is the result due independently to
P. Bose et al., 3-D Visibility Representation, JGAA, 2(3) 1–16 (1998)
12
Wismath [24] and to Tamassia and Tollis [22] that any 2-connected planar graph has what [22] calls an ε-visibility representation. (Vertices correspond to closed, disjoint, horizontal line segments in the plane, and two vertices are adjacent in the graph if and only if their corresponding segments are ε-visible in the vertical direction.) The second ingredient is the use of the third dimension to deal with cut vertices. This is similar to an idea of [24] for obtaining a visibility representation for all planar graphs by rectangles in R 2 that have ε-visibility in both the x and y directions. For ease of notation, let P−∞ represent the plane z = −∞ and let P∞ represent the plane defined by z = +∞. Theorem 4.1 Every planar graph admits a z-visibility representation. Proof: We will prove, by induction on the number of 2-connected components, the following stronger result: Claim: Let G be a connected planar graph and let v be a vertex of G. Then G has a z-visibility representation such that each rectangle is visible from P∞ , but only the rectangle representing v is visible from P−∞ . Base case for the induction: G is 2-connected. We say a line segment is a y-segment if it is parallel to the y-axis and lies in the y,z-plane. By the result of Wismath [24] and Tamassia and Tollis [22], G can be represented by (planar) ε-visibility restricted to the z direction of y-segments, with only the segment representing the vertex v visible from below. Place the y,z-plane containing this configuration in 3-space at x = 0. Number the segments in order of decreasing z-coordinate. Expand each segment to an x,y-rectangle by pulling it out until its x-length is equal to its number. The rectangles then form a “staircase” shape. Each rectangle is visible from P∞ , and only the rectangle repesenting v is visible from P−∞ . Now assume the result is true for graphs with at most k 2-connected components. Let the number of 2-connected components of G be k + 1. Let x be a cut vertex of G, and break G at x into two subgraphs G1 ∪ {x} and G2 ∪ {x}. (Vertex x may still be a cut vertex in these subgraphs.) Suppose that v lies in G1 . By induction G1 has a z-visibility representation with all rectangles visible from P∞ and only the rectangle representing v visible from P−∞ . Identify a rectangular area A of the rectangle corresponding to the vertex x, such that A is visible from P∞ . By induction G2 has a z-visibility representation with all rectangles visible from P∞ and only the rectangle representing x visible from P−∞ . Scale the representation for G2 , so that it can be placed upward of the rectangular area A in the z-direction. After the representation of G2 is in place, remove the rectangle corresponding to x from the representation of G2 . The result is a z-visibility representation of G; all rectangles are visible from P∞ , and only the rectangle representing v is visible from P−∞ . This completes the proof. 2
P. Bose et al., 3-D Visibility Representation, JGAA, 2(3) 1–16 (1998)
4.2
13
Representations for bipartite graphs
As Figure 5 illustrates, every complete bipartite graph Km,n admits a z-visibility representation.
Figure 5: A z-visibility representation of Km,n
4.3
Nonclosure under graph minors
The family of representable graphs is not closed under graph minors. To prove this, consider the complete bipartite graph K56,56 , which has a z-visibility representation as illustrated in Figure 5. When an edge of a complete bipartite graph is contracted, it yields a vertex that is adjacent to all the vertices of the graph. If we contract the 56 edges of a perfect matching in K56,56 , then we obtain the complete graph K56 , which does not have a z-visibility representation by Theorem 2.4. This gives us the following result: Theorem 4.2 The class of graphs admitting a z-visibility representation is not closed under graph minors.
5
Conclusions and open problems
We have shown that for the 3-dimensional z-visibility representation introduced in this paper, all planar graphs have a representation, Kn has a representation for n ≤ 22, and Kn does not have a representation for n ≥ 56. Concerning bipartite graphs, we showed that Km,n is representable for all m and n. Finally, we showed that the family of graphs with a representation is not closed under graph minors. ¿From the point of view of pure discrete geometry and combinatorics, the problem of finding the exact upper upper bound for the representability of Kn remains a tantalizing one. The lower bound was found by computation (simulated annealing), and the upper bound was found by pushing the Erd˝ osSzekeres approach hard, using an extended version of the original theorem. However, from the point of view of graph visualization, it is already interesting that K22 has a z-visibility representation, as this means that all graphs with at most 22 vertices have a weak representation.
P. Bose et al., 3-D Visibility Representation, JGAA, 2(3) 1–16 (1998)
14
It was shown in [5] that K5,5 minus a perfect matching has a representation. We conjecture that K6,6 minus a perfect matching does not have a representation. It was also shown in [5] that the complete tripartite graphs Km,n,2 and Km,4,3 can be represented. What is the smallest graph that does not have a z-visibility representation?
Acknowledgments Our study of visibility representations began at Bellairs Research Institute of McGill University during the International Workshop on Visibility Representations organized by S. Whitesides and J. Hutchinson, February 12-19, 1993. We are grateful to the other conference participants Joan Hutchinson, Goos Kant, Marc van Kreveld, Beppe Liotta, J. R., Steve Skiena, Roberto Tamassia, Yanni Tollis, and Godfried Toussaint for their encouragement and comments.
References [1] E. Aarts, J. Korst. Simulated Annealing and Boltzmann Machines. A Stochastic Approach to Combinatorial Optimization and Neural Computing. Wiley, Chichester 1989 [2] H. Alt, M. Godau, and S. Whitesides. Universal 3-dimensional visibility representations for graphs. Proc. Graph Drawing 95, Passau 1996. Lecture Notes in Computer Science Vol. 1027, Springer-Verlag, 1996, pp. 8–19. [3] A. Bachem, S. P. Fekete, B. Knab, R. Schrader, I. Vannahme, I. Weber, R. Wegener, K. Weinbrecht, B. Wichern. Analyse großer Datenmengen und Clusteralgorithmen im Bausparwesen. To appear in Geld, Finanzwirtschaft, Banken und Versicherungen. Editors C. Hipp et al., VVW Karlsruhe, 1997. [4] P. Bose, H. Everett, S. P. Fekete, A. Lubiw, H. Meijer, K. Romanik, T. Shermer, and S. Whitesides. On a visibility representation for graphs in three dimensions. Proc. Graph Drawing ’93, Paris (S`evres), 1993, pp. 38– 39. [5] P. Bose, H. Everett, S. P. Fekete, A. Lubiw, H. Meijer, K. Romanik, T. Shermer, and S. Whitesides. On a visibility representation for graphs in three dimensions. Snapshots of Computational and Discrete Geometry, 3, eds. D. Avis and P. Bose, McGill University School of Computer Science Technical Report SOCS-94.50, July 1994, pp. 2–25. [6] F. R. K. Chung. On unimodal subsequences. J. Combinatorial Theory, Series A, 29, 1980, pp. 267–279. [7] F. J. Cobos, J. C. Dana, F. Hurtado, A. Marquez, and F. Mateos On a visibility representation of graphs. Proc. Graph Drawing 95, Passau
P. Bose et al., 3-D Visibility Representation, JGAA, 2(3) 1–16 (1998)
15
1996. Lecture Notes in Computer Science Vol. 1072, Springer-Verlag, 1996, pp. 152–161. [8] R. Cohen, P. Eades, T. Lin, and F. Ruskey. Three-dimensional graph drawing. Proc. Graph Drawing ’94, Princeton NJ, 1994. Lecture Notes in Computer Science LNCS Vol. 894, Springer-Verlag, 1995, pp. 1–11. [9] L. Danzer, B. Gr¨ unbaum, and V. Klee. Helly’s theorem and its relatives. Convexity, AMS Proc. Symp. Pure Math. 7, 1963, pp. 101–181. [10] A. Dean and J. Hutchison. Rectangle visibility representations of bipartite graphs. Proc. Graph Drawing ’94, Princeton NJ, 1994. Lecture Notes in Computer Science LNCS Vol. 894, Springer-Verlag, 1995, pp. 159–166. [11] G. Di Battista, P. Eades, R. Tamassia, and I. G. Tollis, Algorithms for automatic graph drawing: an annotated bibliography. Comput. Geometry: Theory and Applications, 4, 1994, pp. 235–282. Also available from wilma.cs.brown.edu by ftp. [12] G. Di Battista and R. Tamassia. Algorithms for plane representations of acyclic digraphs. Theoretical Computer Science, 61, 1988, pp. 175–198. [13] P. Erd˝ os and A. Szekeres. A combinatorial problem in geometry. Compositio Mathematica 2, 1935, pp. 463–470. [14] S. P. Fekete, M. E. Houle, and S. Whitesides. New results on a visibility representation of graphs in 3D. Proc. Graph Drawing 95, Passau 1996. Lecture Notes in Computer Science Vol. 1072, Springer-Verlag 1996, pp. 234–241. [15] S. P. Fekete and H. Meijer. Rectangle and box visibility graphs in 3D. To appear in Intern. J. Comp. Geom. Appl. [16] J. M. Hammersley. A few seedlings of research. Proc. 6th Berkeley Symp. Math. Stat. Prob., U. of California Press, 1972, pp. 345–394. [17] J. Hutchinson, T. Shermer, and A. Vince. On representations of some thickness-two graphs. Proc. Graph Drawing 95, Passau 1996. Lecture Notes in Computer Science Vol. 1072, Springer-Verlag 1996, pp. 324–332. [18] G. Kant, G. Liotta, R. Tamassia, and I. G. Tollis. Area requirements of visibility representations of trees. Proceedings of the 5th Canadian Conf. on Comp. Geom., Waterloo, Ontario, 1993, pp. 192–197. [19] E. Kranakis, D. Krizanc, and J. Urrutia. On the number of directions in visibility representations of graphs. Proc. Graph Drawing ’94, Princeton NJ, 1994, Lecture Notes in Computer Science LNCS Vol. 894, SpringerVerlag, 1995, pp. 167–176. [20] P. J. M. van Laarhoven, E. H. L. Aarts. Simulated Annealing. Theory and Applications. (Reprint with corrections.) Reidel, Dordrecht 1988.
P. Bose et al., 3-D Visibility Representation, JGAA, 2(3) 1–16 (1998)
16
[21] K. Romanik. Directed VR-representable graphs have unbounded dimension. Proc. Graph Drawing ’94, Princeton, NJ, 1994, Lecture Notes in Computer Science LNCS Vol. 894, Springer-Verlag, 1995, pp. 177–181. [22] R. Tamassia and I. G. Tollis. A unified approach to visibility representations of planar graphs. Discrete Comput. Geom. 1, 1986, pp. 321–341. [23] R. V. V. Vidal (ed.) Applied Simulated Annealing. Lecture Notes in Economics and Mathematical Systems, Vol. 396, Springer-Verlag, 1993. [24] S. K. Wismath. Characterizing bar line-of-sight graphs. Proc. ACM Symp. on Comp. Geometry, 1985, pp. 147–152.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 2, no. 4, pp. 1–20 (1998)
Scheduled Hot-Potato Routing Joseph (Seffi) Naor Department of Computer Science Technion, Haifa 32000, Israel http://www.cs.technion.ac.il/
[email protected]
Ariel Orda
Raphael Rom
Department of Electrical Engineering Technion, Haifa 32000, Israel http://www.ee.technion.ac.il/
[email protected] [email protected] Abstract This paper is concerned with fast, hot-potato routing, performed according to a predetermined schedule. At each time period each node selects an outgoing link, through which an incoming packet is sent. No buffers are used. We investigate first the problem of how to route a network-wide demand of packets, given the predetermined schedule. We show that certain versions of the problem have efficient solutions, while other versions are intractable. We then consider the problem of finding an optimal schedule given a network-wide demand of packets. We indicate that the problem is tractable for either a single source or single destination. However, for the multi-source multi-destination case we show that it is an NP-complete problem. We present an efficient heuristic for directed treenetworks, and adapt it to general topologies through a recursive scheme, for which an efficient performance bound is shown. Communicated by S. Khuller: submitted November 1996; revised November 1997.
Raphael Rom is also with Sun Microsystems, Mountain View, CA, 94043. A preliminary version of this paper appeared in the Proceedings of IEEE INFOCOM 1995, Boston, MA, USA, pp. 579-586. This work was supported by the Broadband Telecommunications R&D Consortium administered by the chief scientist of the Israeli Ministry of Industry and Trade.
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
1
2
Introduction
Due to the development of high-speed networks, there has recently been growing interest in efficient routing techniques that would allow a fast decision at the node regarding the edge through which an incoming packet should be routed. An efficient routing technique for a high-speed network is one that demands little “thinking” from the node. Ideally, a node would take an immediate routing decision (e.g., [4]). In addition, an efficient scheme for high-speed routing would avoid the use of buffering at intermediate nodes: ideally, a packet would flow throughout the network without queuing at nodes (e.g., [27]). Indeed, queuing means more delay and also a more complicated strategy from the node’s standpoint. A possible solution that addresses the above issues is that of scheduled hotpotato routing. Here, “scheduled” means that each node routes incoming packets to outgoing links according to a predetermined schedule, i.e., the identity of the outgoing link is a function solely of time. This means that the action taken by the node is immediate, and in particular it does not even need to look at the packet’s header in order to perform the routing. Moreover, the routing decision becomes even more simple if we just let one outgoing link be “active” at every time instant. By “hot-potato” routing we mean that packets are not queued enroute; rather, an incoming packet is immediately transferred to a neighboring node, or, if this is impossible, it is discarded. Thus, with scheduled hot-potato routing we let packets move smoothly and quickly among nodes, through high-speed links, without encountering intra-nodal queuing, nor switching delays. Nonetheless, such a strategy demands careful planning, both of the predetermined schedule and of its actual use, once it has been set. Hot-potato (also called deflection) routing has been given much attention in recent years, e.g., [7]–[20], mainly in the area of multiprocessing. Typically, however, in the above studies, hot-potato routing is applied to regular topologies and considers the identity (label) of the packet for making its routing decision. We note that deflection routing solutions are frequently plagued by deadlock and flow control problems [21]. Scheduled routing has also been the focus of several studies, e.g. [18]–[24], but these works considered the use of store-and-forward buffering. In this work we consider the combination of both principles, namely scheduling and hot-potato routing, in order to achieve an efficient method for routing in high-speed networks. Modern high-speed networks are oriented towards the support of long duration sessions. In such networks, a session is set up in advance, determining both the routes and the rate in which data will subsequently flow [23]. Because the lifetime of a session is relatively long, there is typically enough time to gather the data that is necessary to make the routing decision. Similar ideas to those presented in this paper have been applied to practical pilot networks, e.g., Isochronets [27], in which network bandwidth is time-divided among routing trees in order to allocate “green-band” paths for traffic destined
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
3
to a common root. However, until now, these ideas were tested only at the functional level, while the present work is the first to provide formal analysis. Two typical problems related to routing through pre-established connections are the design problem and the usage problem. The first is concerned with the efficient design of the long-term routing plan, once some data on the sourcedestination demands is collected. The second is concerned with the best use of an existing routing plan, for traffic patterns that were not necessarily accounted for at the time that the routing plan was devised, e.g., low-priority traffic classes. We note that the usage problem follows the philosophy of the best-effort traffic class in ATM networks [23]. The present work is an attempt at providing an analytical framework for this novel method of routing. We establish the problems that should be addressed, provide optimal solutions to some while proving the intractability of others, for which efficient heuristics are described and analyzed. Our solution applies to general topologies and provides bounds on the delivery delay of packets. Naturally, with such bounds in effect, neither deadlock nor flow control is an issue. These bounds on the delay also make our scheme particularly adequate for real-time applications. Specifically, we address the following problems. First, we consider a network for which a schedule has been predetermined, and investigate the usage problem, i.e., how to route a given demand of packets (for various source-destination pairs), through a pre-established schedule, in the most efficient way. We then consider the design problem, i.e., planning the best schedule for an expected demand of packets. We give an optimal solution for the first problem. We show that the second problem is intractable, even for very simple topologies. We indicate its tractability in some special cases and present efficient heuristics for the general case.
2
Model
The network is a directed graph G(V, E), where V is the set of nodes and E ⊆ V × V is the set of edges, or links. For a node i ∈ V , let INi be the set of neighbors k such that (k, i) ∈ E, and OU Ti be the set of neighbors k such that (i, k) ∈ E. We consider a discrete domain of time and a synchronous mode of operation. It is assumed that transmission delay on all links is of unit time, and refer to a packet as the amount of data that can be transmitted in a unit of time. Thus, at most one packet can be carried on a link at any time. A unit of time shall be referred to as a slot. Furthermore, it is assumed that nodes do not have buffers, and thus, an incoming packet has to be switched immediately to an outgoing link. Considering a time period of P , we define the nodal schedule of a node i, S i , to be a sequence {k0i , k1i , · · · , kτi , · · · , kPi −1 } such that, for 0 ≤ τ ≤ P − 1,
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
4
kτi ∈ OU Ti , i.e., the nodal schedule of i assigns to each time-slot within [0, P − 1] a single neighbor of node i (routing is discussed next). Note that P is a given quantity independent of any other network parameter (notably of |V |). Typically, one can assume that P is at most linear in |V |. Given a nodal schedule for each node, we define the network schedule S to be the set comprising of all nodal schedules, i.e., S = {S i |i ∈ V }. We now discuss the scheduled hot-potato routing for a given network schedule S. Consider a node i ∈ V and a time-slot t1 . If exactly one packet arrives at i at the beginning of that time-slot, then it is sent (immediately) through link (i, k), where k = kτi ∈ S i , and τ = t mod P . If more than one packet arrives at the same time, then an arbitrarily chosen (single) packet is routed according to the schedule, and the rest of the packets are eliminated. The network should support the flow of traffic between connections (or sessions), each identified by a pair of source and destination nodes. A demand D of size K on the network is a sequence of (not necessarily different) K sourcedestination pairs D = {(s1 , d1 ), (s2 , d2 ), · · · (sK , dK )}; each pair belongs to a certain connection and designates one packet transmission of that connection. At times, we denote by pj the packet associated with the j-th pair of D. In other words, D = {p1 , p2 , · · · pK }, where pj is a packet to be routed from node sj to node dj . If, for all j, sj ≡ s then we say that D is a single source demand; similarly, if for all j dj ≡ d then we say that D is a single destination demand; if both hold, we say that D is a single-source/single-destination demand. For ease of presentation we shall assume that each node may be a source of at most one packet, i.e., si 6= sj for i 6= j (this implies K ≤ |V |). Our results are easily adapted to handle the more general case, by splitting a source s with Ks packets into a sequence of Ks independent nodes each connected to s. Denote by MG,D the diameter of graph G with respect to D, i.e., the maximal minimum-hop distance among all source-destination pairs of D. Given a network demand D of size K, a departure plan ∆ is a sequence of (integer) times ∆ = {δ1 , δ2 , · · · δK } such that δj is the departure time of packet pj i.e., pj leaves the source node sj (for the first time) at the beginning of time-slot δj . A packet is routed between nodes until it arrives at its destination or it is eliminated. For given S and D, we say that a departure plan ∆ is proper if all packets arrive at their destinations, i.e., no eliminations nor livelocks occur. For S, D and a proper ∆, the arrival time αj of a packet pj is the time at which it reaches the destination; if the packet does not reach its destination, then we set αj = ∞. For given S and D, the termination time of a proper departure plan ∆ is the highest value of arrival times (possibly infinity). We note that, even if pj is the only packet in the network, for a given network schedule S, there may still be no departure time for pj that would bring it to its destination. Namely, for every departure time the packet will loop in the 1 All
times are global relative to some starting time denoted by t = 0.
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
5
network forever. We say that S is feasible for packet pj if there is some finite time t, such that if pj departs at t, then it arrives at its destination in finite time; t is said to be a feasible departure time for pj , given S. We say that a schedule S is feasible for demand D if it is feasible for each packet of D. ¿From the previous description it is not clear how packets are ever removed from the network. A useful way to view this is to assume that each node has a link emanating from it that terminates with the end users that are attached to that node. In other words, for a given node i, the set OU Ti contains a link to the attached end users. Thus, if a packet arrives at node i at time τ , and if schedule S i indicates that kτi is the edge that points to the end user, then we say that the packet is delivered to its destination. A variation on this approach is the one described in [4], where, by default, each packet, while being switched according to the nodal schedule, is also delivered to the end user attached to every node along the path, and is discarded by those nodes for which it is not intended (as is done in most LANs).
3
Use of a Given Schedule
In this section we consider the situation in which the network and its schedule are given and we look for ways to route packets through the network under various timing circumstances. The first question is whether a proper departure plan of finite termination time exists at all. The following lemma gives a necessary and sufficient condition. Lemma 1 Given a network G, a schedule S and a demand D, there is a proper departure plan ∆ with finite termination time if and only if S is feasible for D. Proof: Suppose that S is not feasible for D. Then, there is some packet pj that will not arrive at its destination, and thus no ∆ can have a finite termination time. Conversely, suppose that S is feasible for D. Let D = {p1 , p2 , · · · pK }. Then there are times t1 , t2 , · · · , tj , · · · , tK such that, for 1 ≤ j ≤ K, if pj departs at tj , and does not encounter any other packet, then it arrives at its destination within finite time. Denote the (finite) arrival times by α1 , α2 , · · · αK . Denote by P the period of S. We construct a proper departure time as b1 = d αP1 e · P , i.e., follows. Let p1 depart at t1 . It thus arrives at α1 . Let α we round up the arrival time of p1 to the nearest end of a period. We set the b1 + t2 . It is immediate that p2 arrives at α b1 + α2 . departure time of p2 at α In general, after fixing the departure time of the j-th packet, we calculate its (finite) arrival time, round it up to the nearest period, and add the value of tj+1 ; this determines a feasible departure time for the j + 1-st packet. Since K < ∞, this construction sets a departure plan that is proper and whose termination time is finite. 2
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
6
Lemma 2 Given a network G, a schedule S with period P and a demand D, S is feasible for D iff there is a proper departure plan ∆ whose termination time is at most (1) Tmax = 2K · (|V | − 1) · P + 2K Proof: Suppose that S is feasible for D. Consider a packet pj that leaves its source sj at a feasible departure time tj , and assume that it is the only packet traversing the network. Suppose that by time tj + (|V |− 1)·P + 1 the packet has not reached its destination dj . At all times t, tj ≤ t ≤ tj +(|V |−1)·P +1, define the state of the packet to be the pair (vjt , τ t ), where vjt ∈ V is the identity of the current node and τ t = t mod P . Since there are only (|V |−1)·P different states for which vjt 6= dj , there are times θ1 , θ2 , where tj ≤ θ1 < θ2 ≤ tj +(|V |−1)·P +1, such that vjθ1 = vjθ2 and τ θ1 = τ θ2 . Clearly, packet pj returns to node vjθ2 in times τ θ1 +i(θ2 −θ1 ) , for all integral i ≥ 1, and it does not visit node dj in between consecutive visits to vjθ2 . This means that pj never reaches its destination (for any choice of the departure time tj ), thus contradicting the feasibility of S with respect to D. Note that our assumption, that pj traverses the network alone, does not limit the generality of the contradiction, since a colliding message that is eliminated never reaches its destination. We conclude that a packet pj that leaves its source at a feasible departure time tj and traverses the network alone reaches its destination by time tj + (|V | − 1) · P + 1. By a similar argument, we can also conclude that tj ≤ (|V | − 1) · P + 1. Thus, by choosing a departure time δj ≤ ((|V |−1)·P +1)·(2j − 1) for each packet pj , 1 ≤ j ≤ K, we guarantee that it arrives at its destination no later than at time tj + ((|V | − 1) · P + 1) · 2j. We conclude that ∆ = {δ1 , δ2 , · · · δK } is a proper departure plan whose termination time is at most 2K · (|V | − 1) · P + 2K. In the other direction, if there is a proper departure time with finite termination time, then the schedule S is feasible for the demand D. 2 The above lemma enables us to consider a finite domain of time, whose size Tmax is polynomial in |V |, K, and P . It is clear that if packets are allowed to enter the network freely upon arrival, some of them may be eliminated. In an attempt to maximize throughput, it would be useful to exert some admission control, i.e., forbid the transmission of some of the packets so that throughput is enhanced. More formally, consider the following problem. Throughput Maximization (TM) Problem: Given a network G, a schedule S, a demand D, and a departure plan ∆, find a maximal set of packets that can be delivered to their respective destinations. To attack this problem, we observe that the dynamic behavior of the network G with schedule S over a finite domain of time T can be represented by an equivalent static network, called the Timed-Exploded (TE) version of G. Note that T is implicitly determined by the other parameters of the TM problem and is bounded by the value Tmax as computed in Lemma 2. Specifically, a
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
7
time-exploded version T EG,S,T of G and S, and of size T ≤ Tmax , is obtained in the following way. The graph T EG,S,T consists of T + 1 “layers” 0, · · · , T , where each contains |V | nodes, such that there is a 1 − 1 correspondence between the nodes of each layer and the nodes in V ; for each v ∈ V , and 0 ≤ t ≤ T , we denote by v t the node at level t that corresponds to node v. v t is said to be a descendant of v. The set of edges of T EG,S,T is defined as follows. First, for each v ∈ V , and 1 ≤ t < T , we insert an edge from v t to wt+1 , where w is the next node from v at time t according to schedule S, i.e., w = ktv . Then, for each packet t pj = (sj , dj ) ∈ D we insert an edge from s0j to sjj , where tj is the departure time of pj for the departure plan ∆. If tj = 0, then we insert an edge from s0j to w1 , where w1 is the next node from sj at time 0 according to schedule S. We remark that the notion of a Timed-Exploded graph was independently discovered by Symvonis and Tidswell [25]. They use a method which they call the multistage method and their graphs are called “multistage graphs”. Consider a path in T EG,S,T that starts at the 0th-level descendant of the source node in G of some packet pj ∈ D, and ends at a descendant of the destination node of pj . Such a path in T EG,S,T corresponds to the unique route in G that conforms to the schedule S, departure plan ∆, and upper bound T on the arrival time, and is referred to as a relevant path. The graph T EG,S,T has the additional following properties, that can easily be verified: • T EG,S,T is the union of at most |V | directed relevant paths. • Two relevant paths in T EG,S,T that meet at some node v t , continue from v t together until one of them (or both) reaches its destination. Notice that two such paths correspond to the routes of two packets that collide at node v at time t (causing one of them to be eliminated). Given these properties, solving problem T M amounts to answering the following question: what is the maximum number of disjoint relevant paths in T EG,S,T ? In order to answer this question, we construct the corresponding (undirected) path graph of T EG,S,T (P G(T EG,S,T )) as follows. In P G(T EG,S,T ), a node corresponds to every relevant path in T EG,S,T ; there is an edge between every two nodes that correspond to two (relevant) paths in T EG,S,T that are not edge-disjoint. Clearly, finding the maximum number of relevant edge-disjoint paths in T EG,S,T is equivalent to finding a maximum independent set in P G(T EG,S,T ), i.e., a maximum set of nodes such that any two nodes in the set are not adjacent. In general, both the problem of finding edge disjoint paths (between various source-destination pairs), and that of finding a maximum independent set, are known to be NP-Complete [8]. Nonetheless, we now show that in our case the problems are tractable, since the graph P G(T EG,S,T ) is chordal. A graph is called chordal if every cycle of length 4 or more contains a chord.
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
8
Chordal graphs constitute a graph family for which it is well known [10] that many NP-complete problems become tractable when restricted to it. In particular, a maximum independent set can be computed in linear time in a chordal graph [9, 10]. Lemma 3 P G(T EG,S,T ) is a chordal graph. Proof: To prove the lemma, we must show that P G(T EG,S,T ) does not contain a chordless cycle of length 4 or more. Our proof is based on the following observation regarding the path graph. If there is an edge between two nodes π1 and π2 of P G(T EG,S,T ), then there exists a time t0 such that the routes corresponding to π1 and π2 coincide for all t > t0 (until the end of the shorter route). Assume, to the contrary, that there exists a chordless cycle of length four whose vertices (numbered clockwise) are π1 , π2 , π3 , π4 . By the above observation, there exist times t1 , t2 , t3 , t4 , one for each edge on the cycle, such that from that time on, the two paths (corresponding to the two vertices on the edge) coincide. Assume, without loss of generality, that t1 , denoting the coincidence time of π1 and π2 , is the earliest of them. Since π3 coincides with π2 (at t2 > t1 ), and does not coincide with π1 , we conclude that π1 terminates before t2 . Consider now π4 . It coincides with π1 at t4 , and thus t1 < t4 < t2 , which implies that π4 coincides with π2 , contrary to the assumption. In a similar manner, it can be shown that the property holds for cycles of length larger than four. 2 Theorem 1 Problem T M can be solved by an O(|V | · T ) algorithm. Proof: Since T EG,S,T is the union of at most |V | directed relevant paths, the graph P G(T EG,S,T ) contains at most |V | vertices. Every relevant path can intersect at most T other relevant paths (based on its time of departure), or at most |V | relevant paths (based on the number of vertices). In other words, every relevant path can intersect at most min{|V |, T } other relevant paths, so that the number of edges in P G(T EG,S,T ) is at most O(min{|V |2 , |V |T }). Therefore, P G(T EG,S,T ) can be constructed in O(min{|V |2 , |V |T }) time. A maximum independent set in P G(T EG,S,T ) can be computed in linear time, 2 i.e., in O(min{|V |2 , |V |T }) time, yielding the theorem. Since T ≤ Tmax = O(K · |V | · P ) and K = O(|V |), we conclude that the above solution is polynomial in |V | and P . A natural question that arises in this context is that of finding a better use of a given schedule, i.e., assuming all packets in D are available at time t = 0, when should each depart. More formally: Schedule Usage (SU) Problem: Given a network G, a network schedule S, and a demand D, find a proper departure plan ∆ of minimum termination time. The decision version of Problem SU is defined as follows. Given a network G, a network schedule S, and a demand D, does there exist a proper departure
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
9
plan ∆ which terminates in time τ ? Unfortunately, this problem is intractable. This can be proven using a reduction from 3-SAT. We outline the reduction. Consider a 3-SAT instance with variables x1 , . . . , xn and clauses C1 , .., Cm . We construct a graph where we associate a source-sink pair with each variable and each clause. In addition, we have a node z such that each source has a direct edge to z. Let the source (sink) associated with variable xi be denoted by sxi (txi ), and let the source (sink) associated with clause Cj be denoted by sCj (tCj ). Source sxi has two outgoing edges, exi and ex¯i , (in addition to the edge going to z), where each starts a path ending at sink txi . The schedule is such that a packet is routed through exi (ex¯i ) at time-slot 2i − 1 (2i). At all other time-slots, a packet is routed to z. The idea is that if the packet of sxi is routed through edge exi , the variable xi is set to “true”, else if it is routed through edge ex¯i , then variable xi is set to “false”. Let clause Cj contain literals xj1 , xj2 , and xj3 . For simplicity of presentation, we assume here that all three literals of Cj are positive. Each source sCj has three outgoing edges, ej1 , ej2 , and ej3 (in addition to the edge going to z), where each starts a path ending at sink tCj . The schedule is such that a packet is routed through ej1 (ej2 , ej3 ) at time-slot 2j1 − 1 (2j2 − 1, 2j3 − 1). At all other time-slots, a packet is routed to z. The idea is that a packet leaving sCj at timeslot 2jk − 1 (k = 1, 2, 3) collides with a packet leaving source sxjk at time-slot 2jk , i.e., through the edge associated with the setting of xjk to “false”. This can be easily achieved for all clauses by adding dummy nodes and edges, such that paths would intersect at the desired time-slots. It is not hard to verify that by choosing a large enough period (yet linear in n + m), there is a proper departure plan that terminates in less than one period, if and only if there is a satisfying assignment to the 3-SAT instance. Given that Problem SU is intractable, we describe the following heuristic algorithm (Algorithm HSU) to find a good departure plan, which is based on a greedy approach. The main idea is to start at time t = 0, and schedule the maximal number of departures for that time. We then attempt to schedule the maximal number of departures for each successive time slot, using a residual time exploded graph, to avoid elimination by previously scheduled packets. We note that a similar heuristic was used by Symvonis and Tidswell [25]. Algorithm HSU: 1. Initialization: D0 = D, T E 0 = T EG,S,Tmax , t = 0. 2. Solve problem TM for D0 , T E 0 and a departure plan ∆0 such that tj = t b be the resulting maximal set. for all packets pj ∈ D0 . Let D b 3. Set δj = t for all packets pj ∈ D. 4. Remove from T E 0 all the edges of paths that correspond to the packets of b D.
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
10
b t = t + 1. 5. Set D0 = D0 \D; 6. If D0 6= ∅ then repeat Step 2, otherwise Stop: the departure plan is ∆ = {δ1 , . . . , δK }. Algorithm HSU terminates in at most Tmax iterations, since at each iteration, at least one path is selected and scheduled individually (Lemma 2 guarantees that even if the packets are routed one-by-one, the number of iterations is at most Tmax ). Note also that algorithm HSU is not restricted to a single packet per source; it will also work if D includes a separate element for each (duplicate) packet.
4
Designing an Optimal Schedule
In this section we consider the complementary problem to that considered in the previous section, namely, how to design a schedule rather than use a given one. Given demand D and schedule S, call the termination time, corresponding to the solution of Problem SU , the optimal termination time of S with respect to D. We refer to the optimal termination time for D as the minimum, among all optimal termination times, taken over all possible schedules. A schedule S that induces an optimal termination time (with respect to D) is called an optimal schedule. Note that by Lemma 2, the optimal termination time is bounded by equation (1). We are now ready to present our problem formally: Schedule Design (SD) Problem: Given a network G and a demand D, find an optimal schedule with respect to D. In other words, our aim is to find a schedule, with respect to demand D, that achieves the best possible termination time (through the solution of problem SU ). Due to the finiteness of the optimal termination time (see equation (1)), problem SD can be transformed into the following decision problem. T -constrained Schedule Design (TSD) Problem: Given a network G and a demand D, is there a schedule S for which there is a departure plan ∆ with termination time at most T ? We note that Problem SD can be optimally solved via Problem T SD, by performing a binary search over the feasible range of T .
4.1
Intractability
Unfortunately, problem T SD (and thus also problem SD) is intractable, as shown by the following theorem. Theorem 2 Problem T SD is NP-Hard.
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
11
Proof: We prove the theorem by a reduction to the 3SAT problem, which is known to be NP-Complete [8]. We adapt Karp’s proof [16] for the intractability of the Disjoint Paths Problem. Consider a version of the 3SAT problem, where each literal appears exactly κ times for some constant κ. This is the κ-3SAT problem which is known to be NP-Complete [14]. We show how to transform, in polynomial time, an instance of κ-3SAT into an equivalent instance of T SD. The source-destination pairs in the constructed problem will be in one-to-one correspondence with the clauses in κ-3SAT, i.e., pair (si , di ) will correspond to clause Ci . The graph G of T SD is obtained by joining together a number of subgraphs, each corresponding to a variable. If variable A occurs in clauses i1 , i2 , · · · iκ , and A¯ occurs in j1 , j2 , · · · jκ , then the subgraph corresponding to A is as shown in Figure 1 (for simplicity, the figure is for κ = 3). I.e., for 1 ≤ l ≤ κ, the “column” of sjl meets the “row” of Sil on the leftmost node, then it meets the row of Sil mod κ+1 on the next to the leftmost node, and so on, until at last it meets the row of sil mod κ−1 on the rightmost node. (If l mod κ = 1, then it meets the row of siκ on the rightmost node.) The overall graph is simply obtained by identifying, as a single node, all the occurrences of each si (or di ) in the various subgraphs.
l l l
l l l @ @ @ @ @ @ @ @ @ @ @l @l @l @ @ @ @ @ @ @ @ @ @ @ @l @ l @ l @
l l l
Figure 1: Reduction from 3SAT to TSD For the above graph G, consider the T SD problem for which each (si , di ) corresponds to a source-destination pair, and T = κ+1. It is easy to verify that, for this T SD problem to have an affirmative answer, all packets must depart at t = 0. Moreover, it is immediate that routing a packet through a row eliminates
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
12
the possibility of routing packets in any of the columns of the corresponding subgraph, and vice-versa. Thus, the given conjunctive normal form (of κ-3SAT ) is satisfiable, if and only if the T SD problem has a positive answer: if variable x is assigned “true”, select the horizontal paths in the subgraph for x, otherwise select the vertical paths. Thus, if either x or x ¯ occur in clause Ci and x is true in the assignment, then si and di will be joined in the subgraph for x. In the other direction, it is straightforward that an affirmative answer for the T SD problem implies the satisfiability of the corresponding κ-3SAT problem. Thus, we established a reduction of κ-3SAT to T SD. Since T SD is clearly in NP, this problem is NP-Hard. 2 Consider a network topology in which nodes are arranged on a line, such that each pair of adjacent nodes is connected by a bidirectional edge. Let D be such that traffic flows in both ways, i.e., some destinations are located to the right of their sources, while others are located to the left. Dinitz has shown [6] that even in this setting problem SD is intractable. We note, though, that a simple but efficient heuristic exists for the linear topology: first, all sources that have destinations to their right send (at time 0) their packets. Once these packets arrive, the other sources send (all at once) their packets. It is clear that by using this heuristic packets never collide and the termination time is at most twice that of the optimal termination time.
4.2
Tractable Special Cases
Consider the single destination case, i.e., where all packets have the same destination. Then, problem T SD can be solved in polynomial time in the following way. We construct T EG,T similar to the construction of T EG,S,T , as follows. As in graph T EG,S,T , T EG,T consists of T +1 “layers” 0, · · · , T , where each contains |V | nodes, such that there is a 1 : 1 correspondence between the nodes of each layer and nodes in V . The edge set of T EG,T is defined differently. Let v, w be vertices in G; there is an edge between every two nodes vt , wt+1 ∈ T EG,T , for 0 ≤ t ≤ T − 1, iff (v, w) ∈ E. Thus, for every path in T EG,T , a schedule S can be chosen, such that this path can be realized as a relevant path. Notice, however, that there exists a schedule that realizes two given paths in T EG,T (as relevant paths), if and only if the two paths are disjoint. This implies that the problem of satisfying a given demand D is equivalent to that of finding a set of disjoint paths, from the sources to the destinations, in the graph T EG,S,T . This problem can be cast as a {0, 1} multicommodity flow problem in T EG,T , where edges and vertices of T EG,T are assumed to have unit capacity. The general discrete multicommodity flow problem is intractable, even in its {0, 1} version; this is not surprising, since the intractability of T SD was essentially established by adapting Karp’s proof of the intractability of the disjoint paths problem. However, in the common destination case, the multicommodity
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
13
flow problem can be transformed into a single source/single destination maxflow problem, by connecting all sources to a (fictitious) common source (usually referred to as super-source). Hence, for the case of a single destination, T SD can be solved in polynomial time. A similar argument can be made for the single source case. The above implies that SD can also be solved in polynomial time for the case of a single destination or source. This is achieved by performing a binary search on the value of T . Since the arrival time of each packet, when transmitted alone, is bounded by MG,D (the diameter of the graph with respect to D, see Section 2), it follows that K · MG,D is an upper bound on the value of T . This increases the complexity of the solution by a multiplicative factor of O(log(K · MG,D )) = O(log(|V |)).
4.3
Heuristics
Consider first the special case of directed tree networks where edges are directed from children to parents. The only schedule that can be considered is the trivial one where each node always chooses its unique outgoing edge. We now devise a departure plan, which is not necessarily optimal, but for which we can bound the termination time. This plan will serve us in building a heuristic for general graph topologies. If the problem has at all a feasible solution, then the destination of each source-destination pair must be on the path between the source and the (common) root of the tree. Consider first a modified problem in which the root of the tree is the destination for all the packets in D. This is a common destination problem for which an optimal departure plan can be found. We use this departure plan for our (unmodified) problem, but route the packets only to their destination (instead of the root). It is not hard to see that this is a feasible departure plan which we now analyze. Lemma 4 For common destination directed tree networks (where the destination is the root of the tree), there is a departure plan whose termination time is bounded by K + MG,D . Proof: We claim that departure times can be scheduled such that packets arrive at the root, one packet per time-slot, after some initialization time which is not greater than MG,D . We prove this by induction on the number of vertices in the tree. It clearly holds for a tree containing two vertices. Let r be the root of the tree, let r1 , r2 , . . . , r` be its neighbors in the tree, and let T1 , . . . , T` be subtrees such that ri is the root of Ti . For each subtree Ti , we denote by Di the portion of the demand D originating within Ti . If the destination of a packet is the root r, then its destination in Di will be ri . By the inductive hypothesis, for each subtree Ti , there exists a departure plan with the above property. Since the subtrees interact only in the root r, it is clear that by performing “sequentially”
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
14
the departure plans computed for each of the subtrees, it is possible to obtain a departure plan in which packets arrive at the root r, one packet per time-slot. Clearly, in the worst case, the first packet will arrive at r after MG,D time slots. 2 We refer to the algorithm implied by this proof as the Train Algorithm. We note that the above upper-bound also applies to the inverse case, where edges are directed from the root to the leaves, and each destination is on a directed path from the corresponding source. In order to see that, reverse the direction of edges (so that now the root is a sink on the tree), and reverse the roles of sources and destinations. We thus have: Corollary 1 If G is a directed tree, in which the orientation is either towards the root or away from the root, and if there is a directed path from each source to each destination, then the Train Algorithm provides a departure plan with termination time of at most K + MG,D . Consider now the case of an undirected tree. The problem is that since there is no single orientation, source-destination pairs may need conflicting orientations. However, we show how the Train Algorithm can be used in this case such that termination times are still within a reasonable bound. Similar ideas have been used in Up/Down Routing [22]. We begin by choosing a node in the above tree, which we refer to as the separator. (A good way to choose a separator is discussed following Lemma 5). When the separator is removed, the tree is separated into components where each is a tree; denote by C1 , C2 , · · · , Cm these components with the separator attached to each. Denote by kij (i 6= j) the number of packets whose source to Cj . The total number of interbelongs to Ci while its destination belongs P component packets is therefore f = ij kij . We are interested in bounding the time required to deliver this intercomponent traffic, which we do using the following technical lemma. Lemma 5 The entire intercomponent traffic f for a given set of components C1 , . . . , Cm can be delivered within f + 2MG,D log f time steps. Proof: Let f1 = f . We partition the components into two sets A1 and B1 , and let n1 be the number of packets to be routed between these two sets. The partition into A1 and B1 is made such that at least half of the intercomponent packets flows between them, or, in other words, n1 ≥ f1 /2. (The standard 2approximation algorithm for the MAX-CUT problem achieves this.) In the first phase, first direct all the edges in the components of A1 towards the separator, and the edges in the components of B1 away from the separator, and send all the packets from A1 to B1 . Then, reverse the edge orientation and send all the packets from B1 to A1 . By corollary 1 this operation will take at most n1 + 2MG,D time steps.
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
15
In the next phase we need to transfer the traffic among components of A1 and among those of B1 . The number of packets to be dealt with at this phase is f2 = f1 − n1 ≤ f1 /2. This cannot be done completely in parallel, since the separator node is common to all of these components, and therefore becomes a bottleneck. Our approach is to keep the separator as busy as possible. Partition A1 into two subsets, A2 and B2 , in the same manner as before, i.e., such that at least half of the packets to be routed among the components of A1 is carried across the boundary between A2 and B2 . Similarly divide B1 . If n2 denotes the total amount of this traffic, then n2 ≥ f2 /2. In the way described in the proof of Lemma 4, this phase can be completed in n2 + 2MG,D time steps. Continuing in this manner, there are at most log f phases, so the entire process is done within X (ni + 2MG,D ) ≤ f + 2MG,D log f i
2
which completes the proof.
We now proceed to provide a good solution for the case of an undirected tree by a recursive application of the Train Algorithm. It is known that every tree has a separator, that if removed, separates the tree into components, where each component is a tree containing at most half of the nodes of the original tree [17]. In a similar way it can be shown that every tree, some of whose nodes are sources, has a separator such that if removed, separates the tree into components, such that each component is a tree containing at most half of the sources of the original tree. We choose such a node as our separator. We first send the intercomponent packets in the manner described in Lemma 5 and then apply the whole procedure, recursively, to the (undirected) tree defined by each component. Note that, in this case, different components do not share nodes, so the recursion can be applied concurrently to all components, i.e., packets will be routed concurrently as part of the recursive solution. Call this scheme the Undirected Train Algorithm. Lemma 6 The Undirected Train Algorithm guarantees a termination time of K + 2MG,D log2 K. Proof: Let Γ(k) be the execution time of the Undirected Train Algorithm for the given tree topology and for k packets. By Lemma 5 the intercomponent packets can be delivered within X X X kij + 2MG,D log( kij ) ≤ kij + 2MG,D log k ij
ij
ij
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
16
Due to the manner in which the separator is chosen, each component has at most k/2 packets. Hence, the recursive structure of the algorithm gives X k kij + 2MG,D log k + Γ(k) ≤ Γ 2 i,j We note that the summation of the term kij in the recursive expression cannot exceed k. Also, since there are at most log k stages to the recursion, the third term appears at most log k times. Thus Γ(k) is bounded by k + 2 log2 (k)MG,D . For the entire graph, k = K, which yields the required result. 2 Lemma 7 The Undirected Train Algorithm terminates in O(|V |2 log2 K) steps. Proof: Consider the selection of a separator as the initiation of a new iteration of the Undirected Train Algorithm. At the beginning of an iteration, a separator should be chosen, and this can be done in O(|V |) steps. Next, the number of intercomponent packets (i.e., the kij ’s), should be computed, consuming O(K) steps. Next, the iteration breaks, recursively, into O(log K) sub-iterations. At each sub-iteration a group of O(|V |) components has to be partitioned into two sets, and it is easy to see that this can be done in O(|V |2 ) steps. The subiteration concludes by executing the (directed) Train Algorithm on the directed tree implied by the chosen sets. It is easy to see that an execution of the Train Algorithm on a directed tree with O(|V |) nodes and packets can be performed in O(|V |) steps. Thus, each sub-iteration consists of O(|V |2 ) steps. Since there are O(log K) sub-iterations in an iteration, we conclude that each iteration terminates in O(|V |2 log K) steps. Finally, by the recursive structure of the Undirected Train Algorithm, it has O(log K) iterations, and the result follows. 2 The Undirected Train Algorithm suggests a heuristic algorithm (HSD) for any general topology: compute a spanning tree Θ for G, and then run the Undirected Train Algorithm on Θ. This gives us: Theorem 3 For any graph G and demand D, algorithm HSD terminates in O(|V |2 log2 K) steps and provides a departure plan whose termination time is bounded by K + 2|V | log2 K. Proof: The first claim follows from Lemma 7. The second claim follows from 2 Lemma 6, since MΘ,D < |V |. We note that, on a general graph, algorithm HSD makes use of only |V | − 1 edges. While the above analysis provides a guaranteed performance on general graphs, further improvements can be achieved by perturbing the output of HSD, in an attempt to make use of other, non-tree edges.
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
5
17
Conclusion
In this paper we investigated efficient schemes for high-speed routing, that rely on techniques of both hot-potato and scheduled routing. Such schemes are advantageous because they require neither packet buffering nor routing decisions based on packet contents. Our analysis was carried in two directions. First, we indicated how routing should be planned after a schedule has been fixed, and then analyzed the problem of designing an efficient schedule. For some of the problems, tractable solutions that are optimal have been found. Other problems were shown to be intractable. For these problems we presented heuristic solutions. In particular, for the schedule design problem we obtained a recursive algorithm for which an efficient performance bound has been proved. Several problems are still left open for further research. Additional versions of the general problem are the most obvious. Obtaining better heuristics is another one. For example, the heuristic algorithm presented for the design problem on a general topology currently achieves a bound of K + 2|V | log2 K. We would like to improve this bound to that of O(K + MG,D log2 K) which requires that MΘ,D = O(MG,D ). Whether such a spanning tree Θ exists and whether it can be constructed seem to be non-trivial problems.
Acknowledgement We would like to thank Efim Dinitz for several useful discussions.
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
18
References [1] A. Acampora and S. Shah. Multihop lightwave networks: a comparison of store-and-forward and hot-potato routing. In Proceedings of IEEE INFOCOM, pages 10–19, 1991. [2] A. Barnoy, P. Raghavan, B. Schieber, and H. Tamaki. Fast deflection routing for packets and worms. In Proceedings of the 12th ACM Symposium on Principles of Distributed Computing, pages 75–86, 1993. [3] A. Ben-Dor, S. Halevi, and A. Schuster. Potential function analysis of greedy hot-potato routing. To appear in Mathematical Systems Theory, 1997. Preliminary version in Proceedings of the 13th Symposium on Princi ples of Distributed Computing, 1994, pages 225–234. [4] I. Cidon, I. Gopal, and S. Kutten. New models and algorithms for future networks. In Proceedings of the 7th ACM Symposium on Principles of Distributed Computing, pages 74–89, 1988. [5] I. Cidon, S. Kutten, Y. Mansour, and D. Peleg. Greedy packet scheduling. SIAM Journal on Computing, 24:148–157, 1995. [6] E. Dinitz. Private communication, May 1993. [7] U. Feige and P. Raghavan. Exact analysis of hot-potato routing. In Proceedings of IEEE Symposium on Foundations of Computer Science, pages 553–562, November 1992. [8] M. Garey and D. Johnson. Computers and Intractability. Freeman, San Francisco, 1979. [9] F. Gavril. Algorithms for minimum coloring. Siam J. Computing, 1:180– 187, 1972. [10] M. Golumbic. Algorithmic Graph Theory and Perfect Graphs. Academic Press, New York, 1980. [11] A. Greenberg and J. Goodman. Sharp approximate models of deflection routing in mesh networks. In Proceedings of IEEE INFOCOM, pages 307– 318, 1983. [12] A. Greenberg and B. Hajek. Deflection routing in hypercube networks. IEEE Transactions on Communications, 40:1070–1081, 1992. [13] B. Hajek. Bounds on evacuation time for deflection routing. Distributed Computing, 5:1–6, 1991. [14] A. Itai. Two-commodity flow. Journal of the ACM, 25:596–611, 1978.
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
19
[15] C. Kaklamanis, D. Krizanc, and S. Rao. Hot potato routing on processor arrays. In Proceedings of the 5th ACM Symposium on Parallel Algorithms and Architectures, pages 273–282, 1993. [16] R. Karp. On the complexity of combinatorial problems. Networks, 5:45–68, 1975. [17] B. Korte, L. Lovasz, and H. Promel. Paths, Flow, and VLSI-Layout. Springer-Verlag, Berlin New-York, 1990. [18] Y. Mansour and B. Patt-Shamir. Greedy packet scheduling on shortest paths. Journal of Algorithms, 14:449–465, 1993. [19] N. Maxemchuck. Comparison of deflection and store and forward techniques in the manhattan street and shuffle exchange networks. In Proceedings of IEEE INFOCOM, pages 800–809, 1989. [20] I. Newman and A. Schuster. Hot-potato algorithms for permutation routing. IEEE Transactions on Parallel and Distributed Systems, 6(11):1168– 1176, November 1995. [21] L. M. Ni and P. K. McKinley. A survey of wormhole routing techniques in direct networks. IEEE Computer, 26(2):62–75, February 1993. [22] P. Palnati, E. Leonardi, and M. Gerla. Deadlock-free routing in an optical interconnect for high-speed wormhole routing networks. In Proceedings of the 1996 International Conference on Parallel and Distributed Systems, Tokyo, June 1996. [23] C. Partridge. Gigabit Networking. Addison-Wesley, 1994. [24] P. Rivera-Vega, R. Varadarajan, and S. Navathe. Scheduling data redistribution in distributed databases. In Proceedings of the 6th International Conference on Data Engineering, pages 166–173, Los Angeles, February 1990. [25] A. Symvonis and J. Tidswell. An empirical study of off-line permutation packet routing on two-dimensional meshes based on the multistage routing method. IEEE Transactions on Computers, 45(5):619–625, May 1996. [26] T. Szymanski. An analysis of hot potato routing in a fiber optic packet switched hypercube. In Proceedings of IEEE INFOCOM, pages 918–925, 1990. [27] Y. Yemini and D. Florissi. Isochronets: A high-speed network switching architecture. In Proceedings of IEEE INFOCOM, pages 740–747, 1993.
J. Naor et al., Scheduled Hot-Potato Routing, JGAA, 2(4) 1–20 (1998)
20
[28] Z. Zhang and A. Acampora. Performance analysis of multihop lightwave networks with hot potato routing and distance age priorities. In Proceedings of IEEE INFOCOM, pages 1012–1021, 1991.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 2, no. 5, pp. 1–23 (1998)
Treewidth and minimum fill-in on d-trapezoid graphs Hans L. Bodlaender
Department of Computer Science, Utrecht University P.O. Box 80.089, 3508 TB Utrecht, The Netherlands. http://www.cs.ruu.nl/~hansb/
[email protected]
Ton Kloks
Department of Applied mathematics and DIMATIA Charles University, Malostransk´e n´ am. 25 11800 Praha 1, Czech Republic.
[email protected]
Dieter Kratsch
Friedrich-Schiller-Universit¨at Fakult¨ at f¨ ur Mathematik und Informatik 07740 Jena, Germany. http://www.minet.uni-jena.de/~kratsch/
[email protected]
Haiko M¨ uller
Friedrich-Schiller-Universit¨at Fakult¨ at f¨ ur Mathematik und Informatik 07740 Jena, Germany. http://www.minet.uni-jena.de/~hm/
[email protected] Abstract We show that the minimum fill-in and the minimum interval graph completion of a d-trapezoid graph can be computed in time O(nd ). We also show that the treewidth and the pathwidth of a d-trapezoid graph can be computed in time O(n tw(G)d−1 ). In both cases, d is supposed to be a fixed positive integer and it is required that a suitable intersection model of the given d-trapezoid graph is part of the input. As a consequence, each of the four graph parameters can be computed in time O(n2 ) for trapezoid graphs and thus for permutation graphs even if no intersection model is part of the input. Communicated by S. Khuller: submitted August 1996; revised March 1998.
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
1
2
Introduction
The notions of treewidth and pathwidth have come to play a central role in several recent investigations in algorithmic graph theory, due to several applications in graph theory and other areas. One reason for this interest is that many well known and important graph problems become polynomial time, and usually even linear time solvable (and become member of NC), when restricted to a class of graphs with bounded tree- or pathwidth [1, 3, 4, 5, 7]. In general, such algorithms need to have a tree-decomposition or path-decomposition of suitable width given together with the input graph. Hence, an important problem is to find tree-decompositions (or path-decompositions) of minimum width. When the desired width of the tree-decomposition is bounded by a constant, then this problem can be solved in linear time [6]. However, the constant factor of this algorithm is exponential in the treewidth (of yes-instances), which limits its practicality. Thus, it is interesting for special classes of graphs to find algorithms, which are also polynomial in the treewidth. A related graph problem is the Minimum Fill-in problem. In this problem, we want to add as few edges as possible to a given graph to make it chordal. The importance of this problem lies mainly in the fact that it is equivalent to finding an order of Gaussian elimination steps of a (usually sparse) symmetric matrix, minimizing the number of generated non-zero entries [29]. Due to the lack of efficient algorithms for finding an optimal solution, in practice one usually has to work with certain heuristics. By now there is a large number of results on the algorithmic complexity of the problems Treewidth and Pathwidth when restricted to special graph classes. The Treewidth (resp. Pathwidth) problem ‘Given a graph G and a positive integer k, decide whether the treewidth (resp. pathwidth) of G is at most k’ remains NP-complete on cobipartite graphs [2] and on bipartite graphs [21]. (For information on graph classes we refer to [11, 19]. For other definitions we refer to Section 2.) For various special classes of graphs, it has been shown that the treewidth can be computed in polynomial time, as e.g. cographs [10], circular-arc graphs [32], chordal bipartite graphs [22], permutation graphs [9], circle graphs [20] and cointerval graphs [17]. The knowledge on the algorithmic complexity of the Minimum Fill-in problem when restricted to special graph classes is relatively small compared to that of Treewidth and Pathwidth. The Minimum Fill-in problem ‘Given a graph G and a positive integer k, decide whether there is a fill-in of G with at most k edges’ remains NP-complete on cobipartite graphs [36] and on bipartite graphs [33]. The only graph classes for which the Minimum Fill-in problem were known to be polynomial time solvable were for almost ten years the relatively small classes of cographs [13] and bipartite permutation graphs [31]. Now polynomial time algorithms for chordal bipartite graphs [12], multitolerance
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
3
graphs [27] as well as circle and circular-arc graphs [24] are available. Our paper is organized as follows. Preliminaries on treewidth, pathwidth, minimum fill-in, minimal separators and triangulations are given in Section 2. In Section 3 we define d-trapezoid graphs and we summarize some of their structural and algorithmic properties. d-trapezoid graphs are a common generalization of interval, permutation and trapezoid graphs such that 1-trapezoid graphs coincide with interval graphs and 2-trapezoid graphs coincide with trapezoid graphs. d-trapezoid graphs are intersection graphs of d-trapezoids in a so-called d-trapezoid diagram which consists of d parallel lines in which a d-trapezoid is defined by a collection of d intervals, one interval on each of the parallel lines (For more details see Definition 12.) In Section 4 we present the major structural results of the paper on which our efficient algorithms are based. In Theorem 17 we establish a representation theorem of minimal triangulations of a d-trapezoid graph G in terms of scanlines of a d-trapezoid diagram D(G). Hence in contrast to previous work in this area as e.g. [9, 20, 28, 32], our algorithms are based on a general representation theorem that enables the design of an algorithm for Treewith, Minimum Fill-in and possibly related problems (concerning the optimization of a graph parameter over all minimal triangulations of the graph). A similar representation theorem is given in [24] for circle and circular-arc graphs. In Section 5 we introduce so-called small scanlines and dense sequences of scanlines as tools to obtain significantly faster algorithms than by a straightforward application of the representation theorem. In Section 6 we present our polynomial time algorithms to solve NP-complete graph problems when their input is restricted to d-trapezoid graphs. Both algorithms require that d is a constant and that a d-trapezoid diagram of the given graph is part of the input. The algorithm to compute the treewidth and the pathwidth has running time O(n tw(G)d−1 ). The algorithm to compute the minimum fill-in and the minimum interval completion has running time O(nd ). Up to now the best known algorithms for all four problems had running time O(max(n2.376 d , n2d+2 )) [28]. Our algorithms are simple and efficient for trapezoid graphs (d = 2). In that case they do not even require a trapezoid diagram as part of the input. We obtain O(n2 ) algorithms to compute all the four graph parameters on trapezoid graphs (compared to running time O(n6 ) of the algorithm in [28]). Furthermore we obtain an O(n2 ) algorithm to compute the minimum fill-in of permutation graphs (compared to running time O(n5 ) of the algorithm for bipartite permutation graphs in [31]). A similar algorithm to compute the treewidth and the pathwidth for permutation graphs has been presented in [9]. For d ≥ 3, our algorithms for d-trapezoid graphs require an intersection model as part of the input. This is clearly a disadvantage although it is a quite natural assumption. On one hand, all four problems that we consider are NP-complete on cocomparability graphs [2, 36], hence there is no polynomial time algorithm for d-trapezoid graphs if the parameter d is unbounded, unless
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
4
P=NP. On the other hand, the recognition problem for d-trapezoid graphs is NP-complete for any fixed d ≥ 3 [35]. Thus, for d ≥ 3, to compute a d-trapezoid diagram, whenever the input graph is a d-trapezoid graph, means to solve an NP-complete problem. Fortunately, a d-trapezoid diagram as part of the input is not a necessary assumption to establish algorithms with polynomial running time. O(n5 R + n3 R3 ) time algorithms to compute the treewidth and minimum fill-in of a given asteroidal triple-free graph on n vertices with R minimal separators imply that the treewidth, pathwidth, minimum fill-in and minimum interval completion of a d-trapezoid graph can be computed in time O(n3d+3 ) without an intersection model as part of the input [23].
2 2.1
Preliminaries Preliminaries on treewidth, pathwidth and minimum fill-in
The concept of a chordal graph is fundamental for the treewidth and the minimum fill-in of graphs. Definition 1 A graph is chordal if it has no induced chordless cycle of length at least four. Chordal graphs (also called triangulated graphs) form a well-known class of graphs. For detailed information on chordal graphs and other special classes of graphs we refer to [11, 19]. (For more information on chordal graphs see also Subsection 2.3.) There are different ways to define the treewidth of a graph. The original definition by Robertson and Seymour uses the concept of a tree-decomposition. For more information on tree-decompositions the reader is referred to the survey paper [7]. In this paper we introduce the treewidth by means of triangulations. Definition 2 A triangulation of a graph G is a graph H with the same vertex set as G, such that G is a subgraph of H and H is chordal. We denote the maximum cardinality of a clique in a graph G by ω(G). Definition 3 The treewidth of a graph G, denoted by tw(G), is the minimum of ω(H) − 1 where H ranges over all triangulations of G. The pathwidth can be defined in terms of triangulations of a special kind. Definition 4 An interval graph is a graph of which the vertices can be put into one-to-one correspondence with closed intervals on the real line, such that two vertices are adjacent if and only if the corresponding intervals have a nonempty intersection.
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
5
Notice that every interval graph is chordal [19]. Definition 5 The pathwidth of a graph G, denoted by pw(G), is the minimum of ω(H) − 1 where H ranges over all triangulations of G which are interval graphs. Definition 6 A path-decomposition S of a graph G = (V, E) is a sequence of subsets of V , (X1 , . . . , Xr ), such that 1≤i≤r Xi = V , for all {v, w} ∈ E, there is an i, 1 ≤ i ≤ r, v, w ∈ Xi , and for all v ∈ V , there are lv , rv , such that for all integers j, 1 ≤ lv ≤ j ≤ rv ≤ r ⇔ v ∈ Xj . The width of path-decomposition (X1 , . . . , Xr ) is max1≤i≤r |Xi | − 1. The following lemma shows the equivalence of the above definition of pathwidth and the original one in terms of path-decompositions by Robertson and Seymour. For a proof see for example [21, Lemma 2.2.8]. Lemma 1 A graph G has a path-decomposition of width at most k if and only if there is a triangulation of G into an interval graph H such that ω(H) ≤ k + 1. The following characterization of interval graphs is due to Gilmore and Hoffman [18]. Theorem 2 G is an interval graph if and only if the maximal cliques of G can be ordered C1 , C2 , . . . , Ct so that for every vertex the maximal cliques containing it occur consecutively. Such an ordering of the maximal cliques is said to be a consecutive clique arrangement of G. By assigning to each vertex v ∈ V the interval [min{i | v ∈ Xi }, max{i | v ∈ Xi }], we directly get the following result. Lemma 3 Let (X1 , . . . , Xr ) be a path-decomposition of G = (V, E). The graph H = (V, F ), obtained by making each set Xi , 1 ≤ i ≤ r a clique, (i.e., for all v, w ∈ V, v 6= w: {v, w} ∈ F ⇔ ∃i : v, w ∈ Xi ), is an interval graph that contains G as a subgraph. The decision problems Treewidth and Pathwidth are NP-complete [2]. However, for constant k, graphs with treewidth or pathwidth at most k are recognizable in O(n) time [6, 8]. The large constants depending on k involved in these algorithms make them usually not practical. It is therefore of importance to find polynomial algorithms to compute the treewidth and the pathwidth for special classes of graphs which are as large as possible, where the treewidth (resp. pathwidth) of input graphs is not supposed to be bounded by a constant k. The aim of this paper is to present fast algorithms to compute the treewidth and the pathwidth as well as the minimum fill-in and the minimum interval graph completion on a relatively large parameterized class of graphs.
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
6
Definition 7 A fill-in of the graph G = (V, E) is a set F of edges of the complement of G such that H = (V, E ∪ F ) is chordal. The minimum fill-in of a graph G, denoted by mfi(G), is the minimum of |E(H)|−|E(G)| where H ranges over all triangulations of G. An interval graph completion of the graph G = (V, E) is a set F of edges of the complement of G such that H = (V, E ∪ F ) is an interval graph. The minimum interval graph completion of a graph G, denoted by mic(G), is the minimum of |E(H)| − |E(G)| where H ranges over all triangulations of G which are interval graphs. Hence solving the Minimum Fill-in (resp. Minimum Interval Graph Completion) problem on a graph G is equivalent to finding a triangulation H of G (such that H is an interval graph) that has as few edges as possible.
2.2
Preliminaries on minimal separators and triangulations
One of the main reasons why there exist fast algorithms for many problems when restricted to graphs with bounded treewidth, is the existence of vertex separators of bounded size. For designing efficient treewidth algorithms on special graph classes that do not have bounded treewidth, vertex separators of bounded size have been replaced by minimal separators (see, e.g., [9, 21]). Definition 8 Let G = (V, E) be a graph. A subset S ⊂ V is an a, b-separator for nonadjacent vertices a and b, if the removal of S separates a and b in distinct connected components. If no proper subset of the a, b-separator S is itself an a, bseparator then S is a minimal a, b-separator. A minimal separator S is a subset S ⊂ V such that S is a minimal a, b-separator for some nonadjacent vertices a and b. The following well-known lemma gives a useful characterization of minimal separators. Lemma 4 Let G = (V, E) be a graph and S ⊆ V . Let Ca and Cb be the components of G[V \ S], containing a and b respectively. Then S is a minimal a, b-separator of G if and only if every vertex of S has a neighbor in Ca and a neighbor in Cb . Using the characterization in Theorem 2, one can easily identify the minimal separators of an interval graph which has been shown in [23]. Lemma 5 Let A1 , A2 , . . . , Aq be a consecutive clique arrangement of an interval graph G. Then the minimal separators of G are the sets Ai ∩ Ai+1 , i ∈ {1, 2, . . . , q − 1}. Various types of triangulations are of importance in algorithms to compute the treewidth or the minimum fill-in for special graph classes.
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
7
Definition 9 A triangulation H of a graph G is a minimal triangulation of G if no proper subgraph of H is a triangulation of G. In 1976 Rose, Tarjan and Lueker have given the following characterization of minimal triangulations [30]. Theorem 6 Let H be a triangulation of a graph G. Then H is a minimal triangulation of G if and only if for all edges e ∈ E(H) \ E(G) the graph H − e is not chordal. Theorem 7 provides another characterization of minimal triangulations (see [23]). Definition 10 Let G = (V, E) be a graph. For any collection M of subsets of V , we denote by GM the graph obtained from G by adding edges between all pairs of nonadjacent vertices x and y of G for which an S ∈ M with {x, y} ⊆ S exists. We denote by Sep(G) the set of all minimal separators of G. Notice that any set S ∈ M is a clique in GM . Theorem 7 Let H be a triangulation of the graph G. Then H is a minimal triangulation of G if and only if H = GSep(H) . The following theorem is an immediate consequence of [21, Theorem 2.1.2], Theorem 8 Let H be a minimal triangulation of the graph G = (V, E). Then the following two conditions are satisfied. 1. If a and b are nonadjacent vertices in H then every minimal a, b-separator in H is also a minimal a, b-separator in G. 2. If S is a minimal separator in H and V (C) is the vertex set of a connected component C of H[V \ S] then G[V (C)] is a connected component of G[V \ S]. The following theorem of M¨ ohring in [26] considers asteroidal-triple free graphs, which form a graph class containing interval, permutation, trapezoid and cocomparability graphs. (For information on asteroidal triple-free graphs see [14].) Theorem 9 Any minimal triangulation of an asteroidal triple-free graph is an interval graph. Hence pw(G) = tw(G) and mfi(G) = mic(G) for each asteroidal triple-free graph. Any d-trapezoid graph is a cocomparability graph (see Section 3) and thus asteroidal triple-free. Corollary 10 Any minimal triangulation of an d-trapezoid graph is an interval graph. Hence pw(G) = tw(G) and mfi(G) = mic(G) for each d-trapezoid graph G. Therefore we may restrict ourselves to algorithms to compute the treewidth and the minimum fill-in for d-trapezoid graphs.
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
2.3
8
Preliminaries on chordal graphs and simplicial vertices
In 1961 Dirac established some of the fundamental structural properties of chordal graphs [15] (see also [19]). Definition 11 A vertex v of a graph G = (V, E) is simplicial if N [v] is a clique in G. Theorem 11 Let G = (V, E) be a graph. Then the following conditions are equivalent: (i) G is chordal. (ii) Every minimal separator of G is a clique. (iii) Every induced subgraph of G has a simplicial vertex. Theorem 12 Let G = (V, E) be a chordal graph and let S be a minimal separator of G. Then every component C of G[V \ S] contains a simplicial vertex of the graph G. The following lemma is of importance for the proof of our main structural theorem (Theorem 17). Lemma 13 Let G = (V, E) be a graph. Then no simplicial vertex of G is contained in a minimal separator of G. Furthermore no minimal triangulation H of G contains an edge e ∈ E(H) \ E(G) such that an endpoint of e is a simplicial vertex of G. Proof. Let S be a minimal a, b-separator of G and s ∈ S. Then s has a neighbor sa in Ca and a neighbor sb in Cb by Lemma 4. Clearly sa and sb are not adjacent. Hence s is not simplicial. Now assume that H is a minimal triangulation of G. Then H = GSep(H) by Theorem 7. Thus no edge incident to a simplicial vertex is added to obtain H from G, since Sep(H) ⊆ Sep(G) by Theorem 8 and since no simplicial vertex is contained in a minimal separator of G. 2
3
d-Trapezoid graphs
Flotow introduced d-trapezoid graphs in [16]. Definition 12 Let d be a positive integer. A d-trapezoid diagram of a graph G = (V, E) assigns to each vertex v of G a collection of d intervals I(v) = h[lvi , rvi ] : lvi , rvi ∈ {1, 2, . . . , 2n}, lvi < rvi , i ∈ {1, 2, . . . d}i
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
a
c
d
f
e
a
b
c
e
9
d
b
f
Figure 1: A 3-trapezoid graph G and a 3-trapezoid model D(G) such that for each i ∈ {1, 2, . . . d} and any pair of different vertices v, w ∈ V i i , rw ] have no endpoint in common. Furthermore, the intervals [lvi , rvi ] and [lw {v, w} ∈ E if and only if either there is an i ∈ {1, 2, . . . , d} such that [lvi , rvi ] i i , rw ] have nonempty intersection or there are i ∈ {2, 3, . . . , d} such that and [lw i−1 i−1 i i < rw and lw < rw < lvi < rvi . lvi−1 < rvi−1 < lw We use the following visualizing of a d-trapezoid diagram. Draw d parallel horizontal lines labeled D1 , D2 , . . . Dd from bottom to the top. Identify points 1, 2, . . . , 2n in unit distance from left to right on each of the horizontal lines. Then for any vertex v ∈ V we obtain a polygon Qv by drawing line segments between consecutive points in the chain lv1 , lv2 , . . . lvd , rvd , rvd−1 , . . . , rv1 , lv1 . The polygon Qv is said to be a d-trapezoid . Consequently {v, w} ∈ E if and only if Qv and Qw have nonempty intersection. (See Fig. 1 for an example.) Definition 13 A graph G is a d-trapezoid graph if it has a d-trapezoid diagram. The following theorem is a consequence of Definition 12 (see [16]). Theorem 14 The d-trapezoid graphs are exactly the cocomparability graphs of partially ordered sets of interval dimension at most d. Unfortunately, the problem ‘Given a partially ordered set P , decide whether the interval dimension of P is at most d’ is NP-complete for any fixed d ≥ 3 [35]. Hence for fixed d ≥ 3, to compute a d-trapezoid diagram of the given graph, if it is indeed a d-trapezoid graph, means to solve an NP-complete problem. Moreover, at present not even reasonable approximation algorithms for the interval dimension of a partially ordered set are known. Thus to assume for d ≥ 3 that a d-trapezoid diagram is part of the input is a strong assumption. Theorem 14 also shows that for any fixed d the d-trapezoid graphs form a subclass of the cocomparability graphs. Hence every d-trapezoid graph is asteroidal triplefree. Consequently as already mentioned in Corollary 10, the treewidth and pathwidth of a d-trapezoid graph coincide, and the minimum fill-in and the minimum interval graph completion of a d-trapezoid graph coincide. Details about the terminology used in Theorem 14 and the remarks above can be found in [34]. The definition of a d-trapezoid diagram implies that 1-trapezoid graphs and interval graphs coincide and that 2-trapezoid graphs and trapezoid graphs coin-
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
10
cide. Furthermore permutation graphs are exactly those 2-trapezoid graphs having a 2-trapezoid diagram satisfying rvi − lvi = 1 for all vertices v and i ∈ {1, 2}. For d = 2 we can drop the requirement that a 2-trapezoid diagram must be part of the input since there is an O(n2 ) recognition algorithm for trapezoid graphs that also computes a trapezoid model if the input graph is a trapezoid graph [25]. (Notice that interval graphs are of no interest to us since the four problems of this paper are easy for interval graphs.) Scanlines as a tool to represent all minimal separators of a graph have been used in various efficient algorithms to compute the treewidth or the minimum fill-in for special classes of intersection graphs, among them permutation, d-trapezoid, circle and circular-arc graphs [9, 20, 21, 24, 28]. Definition 14 Let G = (V, E) be a graph on n vertices with d-trapezoid diagram D(G). On each of the horizontal lines D1 , D2 , . . . , Dd of D(G), identify 2n + 1 unit distance apart points 0.5, 1.5, . . . , 2n + 0.5 from left to right, such that the point j is between the points j − 0.5 and j + 0.5 for all j ∈ {1, 2, . . . , 2n}. A scanline s of the d-trapezoid diagram D(G) is a sequence (s1 , s2 , . . . , sd ) of d scanpoints si ∈ {0.5, 1.5, . . . , 2n + 0.5}, i ∈ {1, 2, . . . , d}. In the d-trapezoid diagram D(G) we represent the scanpoint si as point on the horizontal line Di . The scanline s is represented by drawing a line segment between pairs of scanpoints on consecutive horizontal lines. Definition 15 Let D(G) be a d-trapezoid diagram. Let s1 and s2 be two different scanlines and let Qu and Qv be two different d-trapezoids of D(G). The scanline s1 is left of s2 if si1 ≤ si2 for all i ∈ {1, 2, . . . d}. Note that a scanline s1 , that is left of a scanline s2 , may share scanpoints with s2 . The d-trapezoid Qu is left of Qv if rui < lvi for all i ∈ {1, 2, . . . , d}. The d-trapezoid Qv is between the scanlines s1 and s2 if si1 < lvi < rvi < si2 for all i ∈ {1, 2, . . . , d}. The scanline s1 is between Qu and Qv if either rui < si1 < lvi , for all i ∈ {1, 2, . . . , d}, or rvi < si1 < lui , for all i ∈ {1, 2, . . . , d}. The following results extend corresponding ones for permutation graphs given in [9]. Some ideas of the proof of Theorem 15 will be reused in the proof of our main structural theorem in Section 4. Definition 16 Let s be a scanline of a d-trapezoid diagram D(G). We denote by S(s) the set of those vertices v of G for which s has nonempty intersection with the d-trapezoid Qv in D(G). Theorem 15 Let G be a d-trapezoid graph and let D(G) be a d-trapezoid diagram of G. For every minimal x, y-separator S of G there is a scanline s of D(G), which is between the d-trapezoids Qx and Qy , such that S = S(s). Proof. Let S be a minimal x, y-separator of G. Consider the d-trapezoid diagram D(G[V \ S]), obtained from D(G) by removing all d-trapezoids Qv with v ∈ S.
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
11
For each connected component C of G[V \ S], there is a generalized d-trapezoid i i := minz∈C lzi and rC := maxz∈C rzi , for all QC in D(G[V \ S]) defined by lC i ∈ {1, 2, . . . , d}. The generalized d-trapezoid contains all d-trapezoids Qz for which z is a vertex of C and QC has empty intersection with Qw for all w ∈ V \ (S ∪ C). Hence QC and QC 0 have empty intersection for any pair C and C 0 of different components of G[V \ S]. By the construction of the scanpoints in D(G), this implies that for any two different components of G[V \ S], there is a scanline s in D(G) between the generalized d-trapezoids QC and QC 0 . Now let Cx and Cy be the components of G[V \ S] containing x and y respectively. Without loss of generality we may assume that QCx is left of QCy in D(G[V \S]). We can choose a scanline s between QCx and QCy in D(G[V \S]) such that s does not intersect any generalized d-trapezoid QC of a component C of G[V \ S]. Hence for all d-trapezoids Qv that intersect the scanline s in D(G), v must be a vertex of S. This implies that S(s), i.e. the set of those vertices v of G for which s has nonempty intersection with Qv in D(G), is a subset of S. On the other hand, every vertex of S is adjacent to some vertex in Cx and to some vertex in Cy by Lemma 4. Hence Qv intersects the scanline s for every vertex v ∈ S, since Qv intersects a d-trapezoid, which is left of s, and a d-trapezoid, which is right of s. Hence S = S(s). 2 Corollary 16 The number of minimal separators of a d-trapezoid graph G on n ≥ 2 vertices is at most (2n − 3)d . To avoid confusion let us emphasize that a scanline depends on a d-trapezoid diagram. When we study scanlines we always assume that a fixed d-trapezoid diagram of the graph under consideration is given. Throughout the rest of the paper we assume that G = (V, E) is a d-trapezoid graph and that D(G) is a fixed d-trapezoid diagram of G.
4
Minimal triangulations of d-trapezoid graphs
The main structural result of this paper is a representation theorem for minimal triangulations of a d-trapezoid graph G in terms of scanlines of its d-trapezoid diagram D(G). The approach taken to prove this theorem differs completely from the techniques used to prove related theorems in previous work as e.g. [9, 20, 24]. Definition 17 Let D(G) be a d-trapezoid diagram of a graph G. A sequence of scanlines s0 , s1 , s2 , . . . , sr−1 , sr of D(G) is non-crossing if si is left of si+1 for each i ∈ {0, 1, . . . , r − 1}. We need some additional notations. Consider a d-trapezoid diagram D(G). We denote by sL the leftmost scanline in D(G), i.e., sL = (0.5, 0.5, . . . , 0.5), and by
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
12
sR the rightmost scanline in D(G), i.e., sR = (2n + 0.5, . . . , 2n + 0.5). For a non-crossing sequence of scanlines s0 , s1 , s2 , . . . , sr−1 , sr of D(G), we denote by Gs0 ,s1 ,...,sr the graph obtained from G by adding an edge between any pair of nonadjacent vertices u and v of G for which there is an i ∈ {0, 1, . . . , r} such that Qu and Qv intersect si in D(G). Definition 18 Let s and s0 be scanlines of D(G) such that s is left of s0 . Then V(s, s0 ) is the set of all vertices v for which Qv is either between the scanlines s and s0 or has a nonempty intersection with s or with s0 in D(G). Theorem 17 Let G = (V, E) be a d-trapezoid graph and let D(G) be a dtrapezoid diagram of G. Let H be any minimal triangulation of G and let Sep(H) be the set of all minimal separators of H. Then there is a non-crossing sequence of scanlines sL = s0 , s1 , s2 , . . . , sr−1 , sr = sR of D(G) for which (i) V(s0 , s1 ), V(s1 , s2 ), . . . , V(sr−1 , sr ) is a consecutive clique arrangement of the interval graph H, (ii) Sep(H) = {S(s1 ), S(s2 ), . . . , S(sr−1 )}, and (iii) H = Gs0 ,s1 ,...,sr . Proof. The main property is (i) which easily implies the other two. To see this note that (i) implies (ii) by Lemma 5. Furthermore Theorem 7 and property (ii) imply H = G{S(s1 ),S(s2 ),...,S(sr−1 )} . Thus the definition of Gs0 ,s1 ,...,sr immediately implies (iii). Hence it suffices to prove property (i). Let H be any minimal triangulation of the d-trapezoid graph G with dtrapezoid diagram D(G). By Corollary 10, H is an interval graph, and thus ˜ be the subgraph of H induced by the set of all simplicial vertices chordal. Let H ˜ are complete and we call them simplicial of H. Then all components of H cliques of H. Each simplicial clique A of H corresponds to a generalized di i := minz∈A lzi and rA := maxz∈A rzi , for all i ∈ trapezoid QA of D(G) with lA {1, 2, . . . , d}. Furthermore, all these generalized d-trapezoid QA have pairwise empty intersection (see the proof of Theorem 15). Let QA1 be the leftmost of all generalized d-trapezoids QA of the simplicial cliques A of H in the d-trapezoid diagram obtained from D(G) by removing all d-trapezoids Qv for which v is not simplicial in H. Claim 1: There is no d-trapezoid Qu and no a1 ∈ A1 such that Qu is left of Qa1 in D(G). Suppose not. Let a1 ∈ A1 and let Qu be a d-trapezoid that is left of Qa1 in D(G). Then u has no neighbor in A1 since A1 is a simplicial clique of H. Furthermore S ∗ = NH [A1 ] \ A1 is a minimal separator of H and A1 is a component of H[V \ S ∗ ], since A1 is a simplicial clique of H. (Here we denote by NG [V 0 ] the set of all vertices of the graph G = (V, E) that either belong to V 0 ⊆ V or have a neighbor in V 0 .)
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
13
Let x be a vertex of H such that S ∗ is a minimal x, a1 -separator of H. By Theorem 8, S ∗ is also a minimal x, a1 -separator of G and A1 is a component of G[V \ S ∗ ]. Consider the d-trapezoid diagram D(G[V \ S ∗ ]). Recall that A1 is a / S ∗ since u ∈ / NH [A1 ]. Let Cu be the component of G[V \ S ∗ ]. Notice that u ∈ ∗ component of G[V \ S ] containing u. Then the generalized d-trapezoid QCu is left of QA1 in D(G[V \ S ∗ ]) and thus in D(G), since Qu is left of Qa1 in D(G). By Theorem 8, Cu is also a component of H[V \ S ∗ ]. Hence, Theorem 12 implies that Cu contains a simplicial vertex of H and this contradicts the choice of A1 . This proves the claim. i + 0.5 for all i ∈ Now take as s1 the scanline of D(G) with si1 = rA 1 {1, 2, . . . , d}.
Claim 2: V(s0 , s1 ) is a maximal clique in H. NH [A1 ] is a maximal clique in H. Furthermore NG [A1 ] = A1 ∪ S(s1 ) by the choice of s1 . Hence V(s0 , s1 ) = NG [A1 ]. Finally Lemma 13 implies NG [A1 ] = NH [A1 ] and therefore V(s0 , s1 ) = NH [A1 ] is a maximal clique in H. This proves the claim. Now assume that we have constructed a non-crossing sequence of scanlines sL = s0 , s1 , s2 , . . . , sj−1 , j ≥ 2, of D(G) such that V(s0 , s1 ), V(s1 , s2 ), . . . , V(sj−2 , sj−1 ) are maximal cliques of H. We show how to find sj . Let Hj be the subgraph of H induced by the vertex set Vj that consists of all those vertices v for which the d-trapezoid Qv is not left of sj−1 in D(G). Clearly Hj is an interval graph. Claim 3: Every minimal separator of Hj is also a minimal separator of H. Let S be a minimal separator of the interval graph Hj . By assumption, V(sj−2 , sj−1 ) is a maximal clique of H. Hence Sj−1 = S(sj−1 ) is a clique. The construction of Hj implies NH [v] ∩ Vj ⊆ Sj−1 for all v ∈ V \ Vj . Hence it is impossible that there are two components of Hj [Vj \ S] that both contain vertices of Sj−1 . Imagine we take the components of Hj [Vj \ S] and we add all vertices of V \ Vj . Then we obtain the components of H[V \ S]. Now in H[V \ S] all vertices of V \ Vj either form a collection of new components (if Sj−1 ⊆ S) or they will be added to the unique component of Hj [Vj \ S] containing vertices of Sj−1 . In any case at most one component of Hj [Vj \ S] will be changed and that one will only be enlarged. Suppose S is a minimal a, b-separator of Hj . By Lemma 4, every vertex of S has a neighbor in the components Ca and Cb of Hj [Vj \ S]. When adding the vertices of V \ Vj to Hj [Vj \ S] this does not change, i.e. every vertex of S has a neighbor in the components Ca and Cb of H[V \ S]. Hence S is a minimal a, b-separator of H by Lemma 4. This proves the claim. Suppose Hj is not complete. Let H˜j be the subgraph of Hj induced by the set of all simplicial vertices of Hj . The components of H˜j are the simplicial cliques of Hj and each simplicial clique A of Hj corresponds to a generalized d-trapezoid
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
14
QA of D(G). Let QAj be the leftmost of all the generalized d-trapezoids QA of a simplicial clique A of Hj in the d-trapezoid diagram obtained from D(G) by removing all d-trapezoids Qv for which v is not simplicial in Hj . Claim 4: There is no u ∈ Vj and no aj ∈ Aj such that the d-trapezoid Qu is left of Qaj in D(G). This can be obtained by applying Claim 1 to Hj and Aj . i + 0.5 for all i ∈ Now take as sj the scanline of D(G) with sij = rA j {1, 2, . . . , d}. Notice that our construction ensures that sj−1 is left of sj and recall that Sj−1 is a clique of H.
Claim 5: V(sj−1 , sj ) is a maximal clique in H. Since Aj is a simplicial clique of Hj , we obtain NHj [aj ] = NHj [Aj ] for all aj ∈ Aj . By construction of sj , every vertex of Sj = S(sj ) has a neighbor in Aj . Hence Sj ⊆ NHj [Aj ]. Furthermore by Claim 4, every vertex of Sj−1 = S(sj−1 ) has a neighbor in Aj . Consequently NHj [Aj ] = Sj−1 ∪ Aj ∪ Sj = V(sj−1 , sj ) is a clique in Hj . Furthermore V(sj−1 , sj ) is a maximal clique in H since NHj [Aj ] = NH [Aj ]. This proves the claim. Finally consider the case that Hj is complete. Then we finish the construction by taking as sj the scanline sR of D(G). Clearly V(sj−1 , sj ) is a maximal clique of H. By now we have shown how to construct a non-crossing sequence of scanlines sL = s0 , s1 , s2 , . . . , sr−1 , sr = sR such that V(s0 , s1 ), V(s1 , s2 ), . . . , V(sr−1 , sr ) contains all maximal cliques of H. Clearly our construction guarantees that no maximal clique appears twice. Furthermore the definition of a d-trapezoid diagram and the definition of the sets V(s, s0 ) imply that for every vertex of H the maximal cliques containing it occur consecutively. Consequently V(s0 , s1 ), V(s1 , s2 ), . . . , V(sr−1 , sr ) is a consecutive clique arrangement of the interval graph H. 2 Our algorithms are based on the above representation theorem for minimal triangulations of d-trapezoid graphs. In fact algorithms obtained from Theorem 17 in a straightforward manner (by dynamic programming) would already run in polynomial time (roughly O(n3d )). However the tools that we develop in the next section allow us to exploit the information of the d-trapezoid diagram more cleverly. As a consequence we obtain significantly faster algorithms.
5
Small scanlines and dense sequences
The notion of a small scanline has been introduced in [9]. It is useful in a treewidth algorithm since a minimal separator S with |S| > k + 1 can not be made into a clique for obtaining a minimal triangulation H with ω(H) ≤ k.
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
15
Definition 19 Let D(G) be a d-trapezoid diagram. A scanline s of D(G) is k-small if it intersects with at most k + 1 d-trapezoids. Lemma 18 Any d-trapezoid diagram has O(nk d−1 ) k-small scanlines. If si and sj , i, j ∈ {1, 2, . . . d}, are endpoints of a k-small scanline s then |si − sj | ≤ 2(k + 1). Proof. Consider two parallel horizontal lines Di and Dj , i, j ∈ {1, 2, . . . d}, of the diagram. Let s be a scanline with endpoints si and sj on Di and Dj , respectively. d-Trapezoids do not have common endpoints in the diagram. Thus the number of d-trapezoids having empty intersection with the scanline s is at most |si − sj | min(si , sj ) − 1/2 2n − max(si , sj ) + 1/2 + =n− . 2 2 2 Hence the number of d-trapezoids intersecting the scanline s is at least 1/2 |si − sj |. Thus for any k-small scanline holds 1/2 |si − sj | ≤ k + 1 for each i, j ∈ 2 {1, 2, . . . d}. Hence there are O(nk d−1 ) k-small scanlines. Definition 20 Scanline s is a predecessor of scanline t in a d-trapezoid diagram if s is left of t and both have common endpoints on all horizontal lines except one. On this horizontal line (say Dj ) there is exactly one point of a d-trapezoid between the endpoints of s and t (i.e. tj = sj + 1). A non-crossing sequence of scanlines sL = s0 , s1 , s2 , . . . , sr−1 , sr = sR in a d-trapezoid diagram is said to be a dense sequence of scanlines if si is a predecessor of si+1 for each i ∈ {0, 1, . . . , r − 1}. The following definition is needed to describe the algorithm to compute the minimum fill-in of d-trapezoid graphs. Definition 21 Let D(G) be a d-trapezoid diagram of a graph G = (V, E). Let sL = s0 , s1 , s2 , . . . , sr−1 , sr = sR be a non-crossing sequence of scanlines of D(G). Then for all i ∈ {1, 2, . . . , r − 1}, we denote by first(si ) the set of those pairs {u, v} of nonadjacent vertices of G for which si is the leftmost scanline of the sequence that intersects both Qu and Qv . The following theorem justifies the correctness of our algorithms. Theorem 19 Let G = (V, E) be a d-trapezoid graph with a d-trapezoid diagram D(G). Then the following statements hold: n |V(si , si+1 )| − 1 : sL = s0 , s1 , s2 , . . . , ( i) tw(G) = pw(G) = min max i∈{0,1,...,r−1} o sr−1 , sr = sR non-crossing sequence of scanlines of D(G) .
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
16
(ii) If tw(G) ≤ k then there is a dense sequence of k-small scanlines sL = s0 , s1 , s2 , . . . , sr−1 , sr = sR of D(G) satisfying |V(si , si+1 )| − 1 ≤ k for all i ∈ {0, 1, . . . , r − 1}. n r−1 P
|first(si )| : sL = s0 , s1 , s2 , . . . , sr−1 , sr = sR o dense sequence of scanlines of D(G) .
(iii) mfi(G) = mic(G) = min
i=1
Proof. First note that tw(G) = pw(G) and mfi(G) = mic(G) for every dtrapezoid graph G by Corollary 10. Consider (i). Let sL = s0 , s1 , s2 , . . . , sr−1 , sr = sR be any non-crossing sequence of scanlines of D(G). The following convexity property is important. Let Qv be a d-trapezoid in D(G) such that si and sk both intersect Qv . Then i < j < k implies that sj also intersects Qv . By the definition of V(s, s0 ) and the convexity property, v ∈ V(si , si+1 ) and v ∈ V(sk , sk+1 ) implies v ∈ V(sj , sj+1 ) for all j ∈ {i + 1, i + 2, . . . , k − 1}. Therefore each vertex v ∈ V appears in the subsets V(si , si+1 ), V(si+1 , si+2 ), . . . , V(sk−1 , sk ) for some i, k with 0 ≤ i ≤ k ≤ r. Thus V(s0 , s1 ), V(s1 , s2 ), . . . , V(sr−1 , sr ) is a path-decomposition of G. Consequently tw(G) = pw(G) ≤
max
i=0,1,...,r−1
|V(si , si+1 )| − 1.
Now let H be a minimal triangulation of G with ω(H) − 1 = tw(G). By Theorem 17, there is a non-crossing sequence of scanlines sL = s0 , s1 , s2 , . . . , sr−1 , sr = sR of D(G) such that H = Gs0 ,s1 ,...,sr and V(s0 , s1 ), V(s1 , s2 ), . . . , V(sr−1 , sr ) is a consecutive clique arrangement of the interval graph H. Thus pw(G) = tw(G) = ω(H) − 1 = max0≤i≤r−1 (|V(si , si+1 )| − 1). This completes the proof of (i). Consider (ii). Let H be a minimal triangulation of G with ω(H) − 1 = tw(G) and let sL = s0 , s1 , s2 , . . . , sr−1 , sr = sR be a non-crossing sequence of scanlines of D(G) for which V(s0 , s1 ), V(s1 , s2 ), . . . , V(sr−1 , sr ) is a consecutive clique arrangement of H. Then each scanline si , i ∈ {1, 2, . . . , r − 1}, is k-small, since S(si ) ⊆ V(si , si+1 ) implies |S(si )| ≤ |V(si , si+1 )| ≤ tw(G) + 1 ≤ k + 1. (Trivially sL and sR are k-small for each positive integer k.) Therefore sL = s0 , s1 , s2 , . . . , sr−1 , sr = sR is a non-crossing sequence of k-small scanlines. Recall that each set V(si , si+1 ), i ∈ {0, 1, . . . , r − 1}, is a clique in H. Hence for any scanline s∗ between si and si+1 and any pair of d-trapezoids Qu and Qv that both intersect s∗ , the vertices u and v belong to V(si , si+1 ), thus they are adjacent in H. Consequently our particular non-crossing sequence of scanlines can be transformed into a dense sequence of scanlines by adding a suitable sequence of scanlines s∗i1 , s∗i2 , . . . , s∗i,qi between si and si+1 for all i ∈ {0, 1, . . . , r − 1}. Then |S(s∗il )| ≤ |V(si , si+1 )| ≤ k + 1. Hence each scanline s∗il added between si and si+1 is k-small. Thus we obtain a new sequence
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
17
sL = sˆ0 , sˆ1 , sˆ2 , . . . , sˆq−1 , sˆq = sR which is a dense sequence of k-small scanlines. Furthermore for every j ∈ {0, 1, . . . , q − 1}, V(ˆ sj , sˆj+1 ) ⊆ V(si , si+1 ) for some i ∈ {0, 1, . . . , r − 1} by the construction of the new sequence, implying |V(ˆ sj , sˆj+1 )| ≤ k + 1. This completes the proof of (ii). Consider (iii). Let sL = s0 , s1 , s2 , . . . , sr−1 , sr = sR be any dense sequence of scanlines of D(G). Hence si is a predecessor of si+1 for all i ∈ {0, 1, . . . , r − 1}. Therefore for all u, v ∈ V(sj , sj+1 ) with u and v nonadjacent in G, the dtrapezoids Qu and Qv either both intersect sj or both intersect sj+1 . Consequently there is a unique leftmost scanline si in sL = s0 , s1 , s2 , . . . , sr−1 , sr = sR that intersects both Qu and Qv , i.e. {u, v} ∈ first(si ) for exactly one i ∈ {0, 1, . . . , r − 1}. Consider the graph H = Gs0 ,s1 ,...,sr . We have seen that V(si , si+1 ) is a clique of H = Gs0 ,s1 ,...,sr for each i ∈ {0, 1, . . . , r − 1}. Recall that V(s0 , s1 ), V(s1 , s2 ), . . . , V(sr−1 , sr ) is a path-decomposition of G. Hence H = Gs0 ,s1 ,...,sr is a triangulation of G into an interval graph by Lemma 3 and Pr−1 Pr−1 |E(H)| − |E(G)| = i=1 |first(si )|. Consequently mic(G) ≤ i=1 |first(si )|. Now let H be a minimal triangulation of the graph G such that mic(G) = mfi(G) = |E(H)| − |E(G)|. By Theorem 17, there is a non-crossing sequence of scanlines sL = s0 , s1 , s2 , . . . , sr−1 , sr = sR of D(G) such that H = Gs0 ,s1 ,...,sr and V(s0 , s1 ), V(s1 , s2 ), . . . , V(sr−1 , sr ) is a consecutive clique arrangement of Pr−1 the interval graph H. Hence mic(G) = mfi(G) = i=1 |first(si )|. Analogously to (ii), the non-crossing sequence sL = s0 , s1 , s2 , . . . , sr−1 , sr = sR can be transformed into a dense sequence of scanlines Pp−1 sL = sˆ0 , sˆ1 , sˆ2 , . . . , si )|. 2 sˆp−1 , sˆp = sR of D(G) satisfying mic(G) = mfi(G) = i=1 |first(ˆ
6
Algorithms
In this section we present our two polynomial time algorithms to compute the treewidth and the pathwidth as well as the minimum fill-in and the minimum interval graph completion of a d-trapezoid graph that is given with a d-trapezoid diagram, d a fixed positive integer. Notice that for any input to one of the algorithms the constant d is equal to the number of horizontal lines in the given diagram.
6.1
Treewidth and pathwidth
We start with the algorithm to compute the treewidth and pathwidth. Let k be a positive integer. First we present a procedure that checks whether the treewidth of the given d-trapezoid graph does not exceed k. Construct a directed acyclic graph Wk (G) as follows. The vertices of the graph are the k-small scanlines of D(G). There is an arc from scanline s to t in Wk (G) if and only if
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
18
• the scanline s is a predecessor of the scanline t in D(G), and • |V(s, t)| ≤ k + 1. The next lemma follows immediately from Theorem 19 (i) and (ii). Lemma 20 G has treewidth at most k if and only if there is a directed path from sL to sR in Wk (G). Lemma 21 The graph Wk (G) has O(nk d−1 ) vertices and O(nk d−1 ) edges. Proof. The bound on the number of vertices is shown in Lemma 18. For each scanline s there are at most d scanlines t for which s is a predecessor. Hence the outdegree of a vertex is at most d. 2 Now we describe the procedure which determines if the treewidth of a dtrapezoid graph G given with a d-trapezoid diagram D(G) is at most k. Step 1 Construct the acyclic digraph Wk (G) as follows. Compute all k-small scanlines in D(G) and compute all ordered pairs of k-small scanlines s and t for which s is a predecessor of t and |V(s, t)| ≤ k + 1. Step 2 If there exists a path in Wk (G) from sL to sR , then report that the treewidth of G is at most k. If such a path does not exist, then report that the treewidth of G is larger than k. Lemma 22 The procedure can be implemented to run in time O(nk d−1 ). Proof. We describe any scanline s by the vector (s1 , s2 , . . . , sd ) of its scanpoints. The procedure processes in step 1 only those scanlines s = (s1 , s2 , . . . , sd ) satisfying s1 −2k−2 ≤ si ≤ s1 +2k+2 for all i ∈ {2, 3, . . . , d} (with obvious boundary conditions), since all k-small scanlines fulfill this condition by Lemma 18. We denote by A(s1 , s2 , . . . , sd ) the number of d-trapezoids that intersect the scanline s = (s1 , s2 , . . . , sd ) and we denote by B i (s1 , s2 , . . . , sd ), i ∈ {1, 2, . . . , d}, the number of d-trapezoids intersecting the scanline s = (s1 , s2 , . . . , sd ) or the scanline t = (s1 , s2 , . . . , si−1 , si + 1, si+1 , . . . , sd ). Thus s = (s1 , s2 , . . . , sd ) is k-small if and only if A(s1 , s2 , . . . , sd ) ≤ k + 1 and |V(s, t)| ≤ k + 1 if and only if B i (s1 , s2 , . . . , sd ) ≤ k + 1. Notice that A(0.5, 0.5, . . . , 0.5) = 0. All other values of A(s1 , s2 , . . . , sd ) and B i (s1 , s2 , . . . , sd ) are computed using the following rules. For all i ∈ {1, 2, . . . , d} holds (i) B i (s1 , s2 , . . . , sd ) = A(s1 , s2 , . . . , sd ) if the unique d-trapezoid with a point between the scanlines s = (s1 , s2 , . . . , sd ) and t = (s1 , s2 , . . . , si−1 , si + 1, si+1 , . . . , sd ) on the horizontal line Di intersects the scanline s, otherwise B i (s1 , s2 , . . . , sd ) = A(s1 , s2 , . . . , sd ) + 1.
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
19
(ii) A(s1 , s2 , . . . , si−1 , si + 1, si+1 , . . . sd ) = B i (s1 , s2 , . . . , sd ) if the unique dtrapezoid with a point between the scanlines s = (s1 , s2 , . . . , sd ) and t = (s1 , s2 , . . . , si−1 , si + 1, si+1 , . . . , sd ) on the horizontal line Di intersects t, otherwise A(s1 , s2 , . . . , sd ) = B i (s1 , s2 , . . . , sd ) − 1. During step 1 the procedure computes O(nk d−1 ) values of A(s1 , s2 , . . . , sd ) and O(nk d−1 ) values of B i (s1 , s2 , . . . , sd ). Clearly it can be checked in constant time whether the unique d-trapezoid with a point between the scanlines s = (s1 , s2 , . . . , sd ) and t = (s1 , s2 , . . . , si−1 , si + 1, si+1 , . . . , sd ) on the horizontal line Di , i ∈ {1, 2, . . . , d}, intersects s and t, respectively. Hence step 1 takes time O(nk d−1 ). Computing whether there is a directed path from sL to sR in Wk (G) takes O(nk d−1 ) time by a standard single source shortest-path algorithm in a directed acyclic graph. Hence the total procedure can be implemented to run in O(nk d−1 ) time. 2 Finally we show that the procedure can be used for obtaining an algorithm that computes the treewidth. Theorem 23 For each positive integer d, there is an O(n tw(G)d−1 ) algorithm to compute the treewidth and the pathwidth of a d-trapezoid graph G for which a d-trapezoid diagram D(G) is part of the input. Proof. The algorithm first computes a number L such that L/2 ≤ tw(G) ≤ L. This can be done, using the procedure described above O(log tw(G)) times, in overall time O(n tw(G)d−1 ), by calling the procedure for k = 1, 2, 4, 8, . . . until it reports ‘tw(G) ≤ k’ for the first time. Take this value of k as L and construct the directed graph WL (G). Then modify WL (G) as follows. Put weights on the arcs (s, t), saying how many vertices are in the corresponding vertex set V(s, t). Then search for a path from sL to sR , such that the maximum over the weights of arcs in the path is minimized. This maximum weight minus one gives the exact treewidth tw(G). A corresponding shortest-path algorithm for directed 2 acyclic graphs has running time O(n tw(G)d−1 ).
6.2
Minimum fill-in and interval graph completion
Now we show how to compute the minimum fill-in and the minimum interval graph completion of a d-trapezoid graph G with d-trapezoid diagram D(G). Our algorithm computes mfi(G) by solving a single source shortest-path problem on a suitable directed acyclic graph. f (G) as follows. The vertices of the Construct a directed acyclic graph W f (G) graph are the scanlines of D(G). There is an arc from scanline s to t in W if and only if the scanline s is a predecessor of t. The length of an arc from s to t is the number of pairs of d-trapezoids Qu and Qv in the diagram that have empty intersection, do not both intersect s but both intersect t.
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
20
Lemma 24 mfi(G) is equal to the length of a shortest directed path from sL to f (G). sR in W P Proof. By Theorem 19 (iii), mfi(G) is equal to the minimum of r−1 i=1 |first(si )|, where sL = s0 , s1 , s2 , . . . , sr−1 , sr = sR ranges over all dense sequences of scanf (G) are in one-to-one lines of D(G). The shortest paths from sL to sR in W correspondence to the dense sequences of scanlines of D(G). Finally the length of an arc from s to t is defined such that it is equal to |first(t)| if the dense 2 sequence is sL = s0 , . . . , s, t, . . . , sl = sR . This completes the proof. Similar to Lemma 21 one obtains the following. f (G) has O(nd ) vertices and O(nd ) edges. Lemma 25 The graph W Hence the algorithm that computes the minimum fill-in of a d-trapezoid graph G given with a d-trapezoid diagram D(G) is as follows. f (G). Compute the lengths of all arcs Step 1 Construct the acyclic digraph W f in W (G). f (G). Step 2 Compute the length of a shortest path from sL to sR in W Theorem 26 For each positive integer d, there is an O(nd ) algorithm to compute the minimum fill-in and the minimum interval graph completion of a given d-trapezoid graph G where a d-trapezoid diagram D(G) is part of the input. Proof. Again we describe any scanline s by the vector (s1 , s2 , . . . , sd ) of its scanpoints. For any scanline s = (s1 , s2 , . . . , sd ) we denote by L(s1 , s2 , . . . , sd ) the number of d-trapezoids that are left of the scanline s. In a preprocessing the algorithm computes L(s1 , s2 , . . . , sd ) for all scanlines s = (s1 , s2 , . . . , sd ) in the diagram. This can be done quite similar to step 1 of the procedure in the previous subsection. Clearly L(0.5, 0.5, . . . , 0.5) = 0. All other values of L(s1 , s2 , . . . , sd ) can be computed by the following rule. For all i ∈ {1, 2, . . . , d}, L(s1 , s2 , . . . , si−1 , si + 1, si+1 , . . . , sd ) = L(s1 , s2 , . . . , sd ) + 1 if the unique dtrapezoid with a point between the scanlines s = (s1 , s2 , . . . , sd ) and t = (s1 , s2 , . . . , si−1 , si +1, si+1 , . . . , sd ) on the horizontal line Di is left of t, otherwise L(s1 , s2 , . . . , si−1 , si +1, si+1 , . . . , sd ) = L(s1 , s2 , . . . , sd ). This preprocessing can be done in time O(nd ) since there are O(nd ) scanlines by Corollary 16. f (G). Consider an arc Then the algorithm computes the length of all arcs of W from s to t. First the unique d-trapezoid Qv with a point between the scanlines s = (s1 , s2 , . . . , sd ) and t = (s1 , s2 , . . . , si−1 , si +1, si+1 , . . . , sd ) is determined. If Qv intersects s then the length of the arc is 0. Otherwise the length is equal to the number of d-trapezoids that intersect s but not Qv . Hence the length of the arc is exactly L(lv1 − 0.5, lv2 − 0.5, . . . , lvd − 0.5) − L(s1 , s2 , . . . , sd ). Consequently f (G) can be constructed in time O(nd ). the directed acyclic graph W
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
21
f (G) can be done in time Computing a shortest path from sL to sR in W d O(n ) by a standard single source shortest-path algorithm in a directed acyclic 2 graph. Hence the overall running time of the algorithm is O(nd ). It is worth mentioning that the order of magnitude of the running time of our algorithm is equal to the order of magnitude of the number of scanlines in a dtrapezoid diagram. Hence improving our algorithm seems to require completely new ideas.
References [1] S. Arnborg, Efficient algorithms for combinatorial problems on graphs with bounded decomposability — A survey, BIT 25, 2 − 23, 1985. [2] S. Arnborg, D.G. Corneil and A. Proskurowski, Complexity of finding embeddings in a k-tree, SIAM Journal on Algebraic and Discrete Methods 8, 277 − 284, 1987. [3] S. Arnborg, J. Lagergren and D. Seese, Easy problems for tree-decomposable graphs, Journal of Algorithms 12, 308 − 340, 1991. [4] S. Arnborg and A. Proskurowski, Linear time algorithms for NP-hard problems restricted to partial k-trees, Discrete Applied Mathematics 23, 11 − 24, 1989. [5] H.L. Bodlaender, Dynamic programming algorithms on graphs with bounded treewidth, Proceedings of the 15th International Colloquium on Automata, Languages and Programming, 105−119, Springer-Verlag, Lecture Notes in Computer Science 317, 1988. [6] H.L. Bodlaender, A linear time algorithm for finding tree-decompositions of small treewidth, SIAM Journal on Computing 25, 1305 − 1317, 1996. [7] H.L. Bodlaender, A tourist guide through treewidth, Acta Cybernetica 11, 1 − 23, 1993. [8] H.L. Bodlaender and T. Kloks, Efficient and constructive algorithms for the pathwidth and treewidth of graphs, Journal of Algorithms 21, 358 − 402, 1996. [9] H. Bodlaender, T. Kloks and D. Kratsch, Treewidth and pathwidth of permutation graphs, SIAM Journal on Discrete Mathematics 8, 606 − 616, 1995. [10] H. Bodlaender and R.H. M¨ ohring, The pathwidth and treewidth of cographs, SIAM Journal on Discrete Mathematics 6, 181 − 188, 1993. [11] A. Brandst¨ adt, Special graph classes — a survey, Schriftenreihe des Fachbereichs Mathematik, SM-DU-199, Universit¨ at Duisburg Gesamthochschule, 1991. [12] M.S. Chang, Algorithms for maximum matching and minimum fill-in on chordal bipartite graphs, Proceedings of the 7th International Symposium Algorithms and Computation, 146 − 155, Springer-Verlag, Lecture Notes in Computer Science 1178, 1996. [13] D.G. Corneil, Y. Perl and L.K. Stewart, Cographs: recognition, applications and algorithms, Congressus Numerantium 43, 249 − 258, 1984.
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
22
[14] D.G. Corneil, S. Olariu and L. Stewart, Asteroidal triple-free graphs, SIAM Journal on Discrete Mathematics 10, 399 − 430, 1997. [15] G.A. Dirac, On rigid circuit graphs, Abhandlungen aus dem Mathematischen Seminar der Universit¨ at Hamburg 25, 71 − 76, 1961. [16] Flotow, C., On powers of m-trapezoid graphs, Discrete Applied Mathematics 63, 187 − 195, 1995. [17] R. Garbe, Tree-width and path-width of comparability graphs of interval orders, Proceedings of the 20th International Workshop on Graph-Theoretic Concepts in Computer Science, 26 − 37, Springer-Verlag, Lecture Notes in Computer Science 903, 1995. [18] P.C. Gilmore, A.J. Hoffman, A characterization of comparability graphs and interval graphs, Canadian Journal of Mathematics 16, 539 − 548, 1964. [19] M.C. Golumbic, Algorithmic Graph Theory and Perfect Graphs , Academic Press, New York, 1980. [20] T. Kloks, Treewidth of circle graphs, International Journal of Foundations of Computer Science 7, 111 − 120, 1996. [21] T. Kloks, Treewidth — Computations and Approximations, Springer-Verlag, Lecture Notes in Computer Science 842, 1994. [22] T. Kloks and D. Kratsch, Treewidth of chordal bipartite graphs, Journal of Algorithms 19, 266 − 281, 1995. [23] T. Kloks, D. Kratsch and J. Spinrad, On treewidth and minimum fill-in of asteroidal triple-free graphs, Theoretical Computer Science 175, 309 − 335, 1997. [24] T. Kloks, D. Kratsch and C.K.Wong, Minimum fill-in on circle and circular-arc graphs, Proceedings of the 23 International Colloquium on Automata, Languages and Programming, 256−267, Springer-Verlag, Lecture Notes in Computer Science 1099, 1996. [25] T.-H. Ma and J.P. Spinrad, On the 2-chain subgraph cover and related problems, Journal of Algorithms 17, 251 − 268, 1994. [26] R.H. M¨ ohring, Triangulating graphs without asteroidal triples, Discrete Applied Mathematics 64, 281 − 287, 1996. [27] A. Parra, Triangulating multitolerance graphs, Technical Report 392/1994, Technische Universit¨ at Berlin, Germany, 1994. [28] A. Parra and P. Scheffler, How to use the minimal separators of a graph for its chordal triangulation, Proceedings of the 22nd International Colloquium on Automata, Languages and Programming, 123 − 134, Springer-Verlag, Lecture Notes in Computer Science 944, 1995. [29] D.J. Rose, A graph-theoretic study of the numerical solution of sparse positive definite systems of linear equations, in: R.C. Reed, (ed.); Graph Theory and Computing, 183 − 217, Academic Press, New York, 1972. [30] D.J. Rose, R.E. Tarjan and G.S. Lueker, Algorithmic aspects of vertex elimination on graphs, SIAM Journal on Computing 5, 266 − 283, 1976.
L. Bodlaender et al., d-trapezoid graphs, JGAA, 2(5) 1–23 (1998)
23
[31] J. Spinrad, A. Brandst¨ adt and L. Stewart, Bipartite permutation graphs, Discrete Applied Mathematics 18, 279 − 292, 1987. [32] R. Sundaram, K. Sher Singh and C. Pandu Rangan, Treewidth of circular arc graphs, SIAM Journal on Discrete Mathematics 7, 647 − 655, 1994. [33] R.E. Tarjan, Decomposition by clique separators, Discrete Mathematics 55, 221− 232, 1985. [34] W.T. Trotter, Combinatorics and Partially Ordered Sets: Dimension Theory, The John Hopkins University Press, Baltimore, Maryland, 1992. [35] M. Yannakakis, The complexity of the partial order dimension problem, SIAM Journal on Algebraic and Discrete Methods 3, 351 − 358, 1982. [36] M. Yannakakis, Computing the minimum fill-in is NP-complete, SIAM Journal on Algebraic and Discrete Methods 2, 77 − 79, 1981.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 2, no. 6, pp. 1–22 (1998)
Memory Paging for Connectivity and Path Problems in Graphs Esteban Feuerstein Departamento de Computaci´ on Facultad de Ciencias Exactas y Naturales Universidad de Buenos Aires and Instituto de Ciencias Universidad de General Sarmiento Argentina.
[email protected]
Alberto Marchetti-Spaccamela Dipartimento di Informatica e Sistemistica Universit`a di Roma “La Sapienza” Italy
[email protected] Abstract We extend the Paging Problem to the case in which the items that are stored in the cache memory represent information about a graph. We propose on-line algorithms for two different connectivity problems in this context, for particular classes of graphs and under different cost assumptions. In the Path-paging problem we assume that the cache contains edges of the graph and queries to be answered are of the kind “report a path from i to j”; to answer the query it is necessary to have in memory all the edges of a path from i to j. In this case the answer to a query is not a single piece of information stored in memory. In the Connectivity problem the edges of the transitive closure of a given graph are stored in memory and we want to answer connectivity queries. In order to positively answer connectivity queries of the type “is i connected with j?”, it is possible to answer the query even if the cache does not contain the edge (i, j). Most of our algorithms are optimal and fairly simple.
Communicated by R. Tamassia: submitted October 1994; revised September 1998.
This work was partly supported by EC project DYNDATA under program KIT, by EC Esprit Long Term Research project ALCOM IT under contract 20244, by UBA projects EX070/J “Algoritmos eficientes para problemas online con aplicaciones” and EX209 “Mod´elos y T´ecnicas de Optimizaci´ on Combinatoria” and by Italian Ministry of Scientific Research Project 40% “Algoritmi, Modelli di Calcolo e Strutture Informative”. A preliminary version of this work has been presented at the Fourth International Symposium on Algorithms and Computation ISAAC’93, Hong Kong, December 1993.
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
1
2
Introduction
The input of an on-line problems is, in general, a sequence of requests each of which is to be served without knowing future requests. Such problems arise, for example, in memory management where an algorithm has to decide on-line which page of memory must be evicted from fast memory when a page fault occurs. Namely, in the Paging Problem [18], a fast memory (the cache) can contain at most a constant number of pages and a sequence of page requests is presented; if the requested page is in the cache, then the request can be answered with zero cost; otherwise, a page fault occurs and it is necessary to move the page from secondary memory to the cache paying a unit cost. The decision on which page to evict must be taken on-line, without knowing future requests. In this paper we study two applications of the paging problem to graph problems. The considered problems extend the paging problem to the case in which each piece of information, eventually combined with other pieces, can be used to infer information not directly present in the cache. As an example, in the Connectivity problem the edges of the transitive closure of a given graph are stored in memory and we want to answer connectivity queries. In order to positively answer connectivity queries of the type “is i connected with j?”, it is possible to answer the query even if the cache does not contain the edge (i, j); in fact it is sufficient that the cache contains a positive information about the connectivity of i and vertex h and of h and j, where h is any vertex. The other problem that we consider is the Path paging problem: we assume that the cache contains edges of a connected graph and queries to be answered are of the kind “report a path from i to j”; to answer the query it is necessary to have in memory all the edges of a path from i to j. In this case the answer to a query is not a single piece of information stored in memory. Note that there might be many possible paths and, therefore, many possible answers. In their seminal paper [18], Sleator and Tarjan introduced amortized analysis to analyze the performance of algorithms for on-line problems; they compare the cost of an on-line algorithm for answering a sequence of requests with the cost of the optimal algorithm that knows the whole sequence of requests. An algorithm is said to be c-competitive [12] if the cost afforded by it to serve any sequence of requests is at most c times the cost charged to the optimal algorithm plus a constant. Neither the constant c nor the additive constant depend on the particular input sequence. During the last years considerable attention has been devoted to competitive analysis of on-line algorithms, particularly to extend and generalize the Paging Problem. This includes the weighted version of the paging problem [17, 20], the problem of maintaining caches in a multiprocessor system [12], the k-server problem [7, 8, 10, 11, 13, 15]. All above extensions to the paging problem consider increasingly more complex models, but share essentially the same fundamental “individuality” property: in the case of paging, each request to a page of memory requires that page to be present in the cache; in the k-server problem one server must be present in one specified location to serve the request. The problems that we consider are a special case of the more general notion of Metrical Task Systems [6] that allows to model a great variety of on-line problems. However, the generality of that approach implies that the results that have been proved are rather negative results. In fact, competitive algorithms with small constant competitiveness coefficients have been found for different versions of the paging and the k- server problem [7, 8, 10, 11, 12, 13, 15, 17, 18, 20]. On the other side, a lower-bound on the competitiveness of any on-line algorithm for Metrical Task Systems has been proved that is linear in the number of different states [6]. For the problems considered in this paper, the number of states is exponential in the size of the cache. However, the competitiveness coefficients that we obtain are polynomial in the size of the cache. Besides their theoretical interest, the problems that we consider are motivated by the memory management problem of data structures for very large graphs (such that it is not possible to store in main memory neither the graph nor its transitive closure). We are interested in analyzing algorithms that use a small fast memory with the goal of reducing the number of accesses to the slow memory. We believe that the proposed algorithms might be useful in understanding and optimizing the cost of accessing secondary memory when dealing with very large graphs. Another possible motivation concerning communication in a network of processors will be discussed in section 4. We are not aware of previous work on this subject; however a considerable amount of work on related matters can be found in the literature. Borodin et al. [5] considered the paging problem in the case in
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
3
which the sequence of requests follows a pattern given by a previously known access graph. Nodine et al. [14] studied the speed-up that may be obtained using redundancy and efficient blocking in the case of searching in particular classes of graphs that are too large to fit in internal memory. The difference is that in our problem all queries refer to an underlying graph, but the sequence of requests does not follow any specified pattern. Attention has been also devoted [16, 19] to efficiently storing particular data structures in secondary memory in a dynamic environment, that is, when the underlying data structure is updated dynamically. Other related problems have been considered by Aggarwal et al. [1, 2, 3]. These works introduced different models of hierarchical memories and analyzed the behavior of algorithms for different problems in those models. Our problem is different from the cited works in the sense that we do not have to minimize the number of accesses to secondary memory necessary to solve a certain off-line problem but to answer in an on-line fashion an arbitrarily long sequence of queries. In section 2 the Path paging problem is defined and studied. We show that any on-line algorithm to be competitive for this problem against and adversary with cache of size k needs a cache of size at least b 34 k 2 − k2 + 1c. We also study this problem in the particular case of trees, giving lower and upper bounds for the competitiveness of deterministic and randomized algorithms. Depending on the cost model considered, lower and upper bounds match or differ only by a constant factor. In section 3 we consider the Connectivity problem. We show that any on-line algorithm must have a cache that is at least Ω(k 2 ) in order to be competitive against an adversary with a cache of size k; we also prove a lower bound of k for the competitiveness of any on line algorithm with any cache size against the same adversary. We also show a strategy for this problem that is a constant factor away from optimal. Section 4 presents optimal solutions to the connectivity problem in the particular case of connected graphs, that allows to model the service of requests in high-speed computer networks. Finally, conclusions and open problems are presented in section 5.
1.1
Competitive analysis
An on-line algorithm for a given problem is c-competitive [12] if the cost afforded by it to serve any sequence of requests is less than c times the cost charged to the optimal algorithm for that sequence plus a constant that does not depend on the chosen sequence. Let CA (σ) denote the cost afforded by algorithm A to serve an input sequence σ, and let OP T be the optimal off-line algorithm. Formally, we have the following definition: Definition 1.1 An on-line algorithm A is c-competitive if there exists a constant d such that for any input sequence σ, CA (σ) − c ∗ COP T (σ) ≤ d. If d = 0 then A is strongly c-competitive. The competitive ratio of algorithm A is the infimum over c such that A is c-competitive. As it is usually done in competitive analysis, we will compare on-line strategies with an adversary that must serve the same sequence of requests with his own cache, but who knows (in fact, who chooses) the entire request sequence in advance. Proving that the cost afforded by an on-line algorithm is no more than c times the adversary’s cost on the same sequence of requests implies that the on-line strategy is c-competitive. For the paging problem it has been shown [18] that a simple First In First Out (FIFO) rule is optimal, i.e. it obtains the best possible competitive ratio. In fact, assuming that the algorithm and the adversary have the same memory of size k, then FIFO achieves a competitive ratio of k; and k is also a lower bound. In the case of randomized strategies, different kinds of adversaries have been proposed. The most used adversary is the oblivious adversary that generates the input sequence of requests and then submits it to the on-line algorithm. Other possible adversaries include the adaptive-on-line and the adaptive-off-line adversaries [17]. In the following we will restrict our attention to the oblivious adversary. Note that deterministic and randomized lower-bounds for the competitive ratio of on-line algorithms for the Paging problem can be immediately extended to the problems considered in this paper; namely k is a lower bound for deterministic algorithms and Hk (the k-th harmonic number) is a lower bound for randomized algorithms against an oblivious adversary [9].
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
4
For many on-line problems, in particular paging problems, the performance of an on-line algorithm with respect to an adversary having less resources has been considered. This type of analysis can provide an insight on the behavior of the algorithm when the resources assigned to it may change. For example, K -competitive in [18, 17, 20] different strategies for the Paging problem have been proved to be K−k+1 when on-line algorithms are assigned a cache of size K ≥ k; it has also been proved that this value is optimal. In the following we denote by K the size of the on-line algorithm’s cache and by k that of the adversary’s; when they are equal we denote the size of both by k. Some of our proofs use the standard technique of the potential function [18], that is a function that maps every pair D of configurations of the cache of the on- line algorithm and of the adversary’s to a value Φ(D). In this model, the amortized cost of an operation is given by t + Φ(D0 ) − Φ(D), where t is the actual cost of the operation and D and D0 represent the configurations before and after the execution of the operation respectively. We will use the following lemma, whose standard proof is left to the reader. This or similar lemmas have been used in previous works on on-line algorithms (see for example [8]). Lemma 1.1 Let CADV and CALG denote the total costs charged respectively to an adversary and on-line algorithm ALG to serve a sequence of requests. Suppose that Φ, Φ ≥ 0, is a potential function with value Φ0 in the initial configuration such that 1. when the adversary makes a move, the increment in the potential is not more than α times the cost paid by the adversary, and 2. when the on-line algorithm serves a request, Φ decreases by at least β times the cost paid by the algorithm to serve the request Then CALG ≤ (α/β)CADV + Φ0 , and hence ALG is (α/β)-competitive.
1.2
Results of the paper
When an algorithm cannot answer a query with the information present in its fast memory, it must search for the information in secondary storage. It is reasonable to assume that it will search for a shortest path between the requested vertices. However, the on-line algorithm does not know which path will be more helpful for answering future queries. We consider three different cost models: 1. Full-cost model: when a path joining a and b is not present in cache, charge the algorithm the length (i.e. the number of edges) of a shortest path from a to b. 2. Partial-cost model: when a path joining a and b is not present in cache, charge the algorithm the number of edges it brings into the cache to have a path between the query vertices. 3. 0/1-cost model: when a path joining a and b is not present in cache, charge the algorithm a unit cost. Tables 1 and 2 present a summary of the results of the paper (Hk denotes the k-th harmonic number).
2
Path-paging
The Path-paging problem is defined as follows: given an undirected connected graph, a query Path(a, b), means “give a path joining vertices a and b”; we consider the case when a sequence of such queries must be answered in an on-line fashion: the i-th query must be answered before the following queries are presented. The goal is to minimize the number of accesses to secondary memory performed in order to serve a sequence of requests. We analyze the behavior of algorithms that use two levels of memory: a small and fast level (the cache) consisting of a constant number of edges and a secondary level of memory that allows to store the whole graph. The only stored information in the cache is a set of edges; no further information is stored.
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
5
Table 1: Summary of results - Path-paging problem Problem Lower bound for arbitrary graphs, K < 34 k 2 Upper bound for arbitrary graphs, K = 34 k 2 Lower bound for trees Upper bound for trees Lower bound for trees, randomized Upper bound for trees, randomized
Full cost unbounded d 34 k 2 e bk 2 /4c + 1 (k 2 + k)/2 k 2 ln k 2kHk
Partial cost unbounded d 34 k 2 e k k Hk 2Hk
0/1 cost unbounded k k k b ke c + 1 k
Table 2: Summary of results - Connectivity-paging and Link-paging problems Problem 2
Lower bound for arbitrary graphs, K < k2 − 3 k2 Lower bound for arbitrary graphs, any K 2 Upper bound for arbitrary graphs K ≈ k2 + k Lower bound for complete graphs (Link-Paging) Upper bound for complete graphs (Link-Paging)
53
4
+ O(k 3 )
unbounded k k2 2 +k K K−k+1 K K−k+1
An algorithm serves a query Path(a, b) without cost if its cache already contains all edges of some path connecting a and b. If such edges are not present, then a set of edges forming a shortest-path from a to b is provided to the on-line algorithm, and a cost is charged to it 1 . Clearly the problem makes sense only if the diameter of the graph (i.e. the maximum distance among all pairs of vertices) is bounded by the size of the cache.
2.1
Path-paging for arbitrary graphs
We first show that no on-line deterministic algorithm can be competitive unless the cache of the algorithm is sufficiently larger than the adversary’s cache; the bound holds in the case of arbitrary connected graphs and for all cost models. Theorem 2.1 No deterministic strategy for the Path-paging problem for arbitrary graphs with a cache of size K < b 34 k 2 − k2 + 1c can achieve a bounded competitive ratio against an adversary with cache size k, under all cost models. Proof: Consider a sequence of (K + 1)k requests to one-edge paths e11 , . . . , e1k , e21 , . . . , e2k , . . . , e(K+1)1 , . . . , e(K+1)k such that each subsequence ei1 , . . . , eik forms a path from vertex vi1 to vertex vi(k+1) (the graph corresponding to one such subsequence is depicted in figure 1 (a)). From now on we suppose k is odd, if k is even the proof is similar. Since the size of the on-line algorithm’s cache is K, after such a sequence there exists at least one i such that the on-line strategy has none of ei1 . . . eik in the cache. This holds whichever were the initial configurations of the on-line algorithm and that of the adversary. As the adversary knows the exact value of such i, he can serve the sequence of requests as follows (for simplicity of notation, we will denote all edges eij and vertices 1 We assume that on-line algorithms can control what kind of path to search for, and for this reason we assume that they look for shortest paths. In fact such paths provide the required information with a “minimum” use of the cache. Moreover, without this assumption, competitiveness results would be impossible. Note however that on-line algorithms have no way of knowing whether the retrieved information will be useful for future requests
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998) vi6
6
vi6
ei5 vi5
vi5
vi4
vi4
vi3
vi3
vi2
vi2
vi1
vi1
ei4 ei3 ei2 ei1
(a)
(b) Figure 1: Example for Theorem 2.1, with k = 5
vij as eˆj and vˆj respectively). The subsequence e11 . . . e1k . . . e(i−1)1 . . . e(i−1)k can be served in any way; for eˆ1 . . . eˆk the adversary puts each edge in a different position of the cache, so as to keep all edges of the subsequence. Let κ = k+1 2 . For the remaining queries of the sequence, the adversary pays for every query, caching all the edges to the same position of his cache, namely the position that contained edge vκ , vˆκ+1 ). eˆκ = (ˆ After the last query of the sequence the adversary may ask again for Path(ˆ vκ , vˆκ+1 ), and hence be ready to answer without paying the following queries: v1 , vˆk ), . . . , Path(ˆ v1 , vˆκ+2 ) Path(ˆ v1 , vˆk+1 ), Path(ˆ and then v3 , vˆk+1 ), . . . , Path(ˆ vκ , vˆk+1 ). Path(ˆ v2 , vˆk+1 ), Path(ˆ If, for each one of these queries, the on-line algorithm is provided a shortest path of the same length but disjoint from the path stored by the adversary and from previously requested paths (see figure 1 (b)), then we have that the total length of the requested paths is 1+
k X j=κ+1
j+
k−1 X
j=
j=κ
k−1 X 3 3 3 k 3 k+ +2 j = k2 − + 2 2 4 2 4 j=κ+1
Since the total size of the on-line algorithm’s cache is K < b 34 k 2 − k2 + 1c, then there will be always one query that can be answered by the adversary with no cost for which the on-line algorithm has to pay. The theorem follows. 2 We now analyze the behavior of the FIFO algorithm that, each time a new edge has to be brought into the cache, evicts the edge that has been present in the cache for the longest time. Theorem 2.2 For the Path-paging Problem on arbitrary graphs, with a cache of size d 34 k 2 e, and against an adversary with cache of size k, FIFO is: • d 43 k 2 e-competitive in the full-cost model • d 43 k 2 e-competitive in the partial-cost model
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
7
vi6 vi5 vi4 vi3 vi2
vi1
Figure 2: Example for Theorem 2.2, with k = 5 • k-competitive in the 0/1-cost model. Proof: Without loss of generality we assume that all queries in the input produce a fault to FIFO. We divide the sequence of queries in phases as follows: the first phase starts with the first query that implies a fault of FIFO, and a phase starting with query σi ends with query σj such that j is the minimum integer such that the paths referred in the queries {σi , σi+1 , . . . , σj+1 } require more than k edges to be answered. In other words, any subgraph of the underlying graph in which all the pairs referred in the queries of a phase are connected has strictly more than k edges. It is obvious that during a phase the adversary faults at least once, since it is not possible to answer the first query of each phase with the same set of edges that allows to answer all the queries of the previous phase. Hence the adversary’s amortized cost is at least 1 for each phase, in all cost models. Let S be the sum of the lengths of all the paths that produce a fault to FIFO during a phase. By showing that S is bounded by d 34 k 2 e, we prove the claim for the full and partial cost models. Note that, during a phase, at most k different requests can produce a fault for FIFO (each fault will provide the information corresponding to at least one edge of the adversary). This immediately implies the claim for the 0/1-cost model, as the cost of each request in that cost model is at most 1. We show that S is maximized for a particular sequence of requests that the adversary can construct whenever the edges of its cache form a simple path (an example of which is depicted in Figure 2, for k = 5). Let us suppose k is odd (the case in which k is even is similar and it is omitted), and, as let κ = k+1 2 . The adversary holds a simple path from v1 to vk+1 , and the queries are of the form Path(v1 , vj ), κ + 1 ≤ j ≤ k + 1 and Path(vj , vk+1 ), 2 ≤ j ≤ κ. In this case the total length of the requested paths (and therefore the maximum cost incurred by FIFO during a phase) is S=
k X j=κ
j+
k−1 X j=κ
j =k+2
k−1 X j=κ
j=
3 3 2 1 k + = d k 2 e. 4 4 4
We now show that the above example maximizes S over all possible sets of paths to be requested during a phase. Since all the connectivity information given by a cyclic graph is present in a spanning forest of the graph, without loss of generality we may suppose that the adversary has no cycles in its cache. Moreover, we assume that all the paths in the spanning forest are shortest paths in the underlying graph, and that the paths provided to FIFO are always disjoint from those of the adversary. This last assumption can only increase FIFO’s cost. We will first prove that, given that the adversary has a spanning forest, all queries refer to a vertex and its furthest leaf, and that no internal vertex appears in two different queries. Then we show that if
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
8
each tree of the spanning forest is a simple path then S is maximized, and finally that the best choice for the adversary is given by having only one connected component (that is, one simple path). Let d(x, y) be the distance between x and y. 1. All queries refer to a vertex and its furthest leaf. Suppose there is a query involving two internal vertices ni and nj . It is obvious that it could be substituted by a query involving one of the internal vertices (say ni ) and a leaf ` with d(ni , `) > d(ni , nj ). Moreover, any query of the form Path(n, `) may be replaced with a query Path(n, `0 ), where n is an internal vertex and `0 is the furthest leaf from n. 2. No internal vertex appears in two different queries. Suppose that there is an internal vertex n and two different leaves `1 and `2 such that the queries Path(n, `1 ) and Path(n, `2 ) appear in the input sequence, in that order. We consider two cases: • d(`1 , `2 ) ≥ d(n, `2 ). Clearly, by asking Path(`1 , `2 ) instead of Path(n, `2 ), we would obtain a sequence with at least the same S. This substitution is possible unless FIFO has already a path from `1 to `2 when Path(n, `2 ) is requested. But this would imply that the query Path(n, `2 ) would not produce a fault (because FIFO has also a path from n to `1 ). • d(`1 , `2 ) < d(n, `2 ). In this case n does not belong to the path from `1 to `2 . Since n is an internal vertex, there exists a leaf `3 such that d(`1 , `3 ) > d(`1 , n), d(`2 , `3 ) > d(`2 , n). Moreover, the sequence does not contain both requests Path(`1 , `3 ) and Path(`2 , `3 ) (otherwise, the last of the four paths to be requested would not produce a fault, a contradiction). Two different cases must be considered: – Path(`1 , `3 ) is not requested. If Path(n, `1 ) can be replaced by Path(`1 , `3 ) we are done. Otherwise, when Path(n, `1 ) is requested FIFO has already a path from `1 to `3 that does not pass through n. But then, after the request Path(n, `1 ) FIFO has a path from n to `3 . If before the request Path(n, `2 ) FIFO had also a path from `2 to `3 , the request Path(n, `2 ) would not produce a fault, a contradiction. Hence, FIFO had not a path from `2 to `3 and the request Path(n, `2 ) can be replaced by the request Path(`2 , `3 ). – Path(`1 , `3 ) is requested. If Path(n, `2 ) can be replaced by Path(`2 , `3 ) we are done. Otherwise, when Path(n, `2 ) is requested, FIFO has already a path from `2 to `3 that does not pass through n. Then either Path(`1 , `3 ) was requested before Path(n, `2 ) and therefore Path(n, `2 ) does not produce a fault (a contradiction), or Path(`1 , `3 ) will be requested after Path(n, `2 ) but it will not produce a fault (a contradiction). 3. One simple path maximizes S. Suppose that some tree T of the forest F the adversary has in its cache is not a simple path. Let `h , `i and `j be three leaves of T such that the path from `h to `i is a longest path of T . We show that there exists a tree T 0 for which the value S is larger. T 0 is obtained from T by eliminating the edge that connects `j to T and adding an edge from `j to either `h or `i . By case 2 above we can assume that there are no queries Path(n, `j ), but there could be one or more queries Path(`, `j ), where ` is a leaf different from `h , `i and `j . Note that either Path(`h , `j ) or Path(`i , `j ) is not shorter than the path from ` to `j . Therefore we can eliminate Path(`, `j ) replacing it with one of the other two queries. For a fixed `j , the adversary will never request both Path(`h , `j ) and Path(`i , `j ), because that would prevent him from asking Path(`h , `i ), that by hypothesis is the longest path of T . Therefore he will request only the longest of them, say Path(`h , `j ). But then T could be replaced with a different tree T 0 in which instead of `j there is a leaf `j 0 attached to `i , and all the queries Path(n, `i ) or Path(n, `j ) could be replaced by queries Path(n, `j 0 ) incrementing the overall length of the requested paths. Repeating this reasoning for T 0 we arrive to the conclusion that each connected component of F must be a path. But then, the best alternative for the adversary is to have only one path (of length k), for which he can ask one request of length k, two of length k − 1, two of length k − 2, and so on. This completes the proof of the theorem.
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998) y4
y3 y2 y1
9
y5 w
o
x
Figure 3: Example for Theorem 2.3 with k = 8, (o, w) is the edge requested at the beginning of the phase. 2 The proof of Theorem 2.1 is valid even assuming that the same path is provided to both the on-line algorithm and the adversary when they fault on the same query. If we eliminate this assumption, a stronger bound (that matches the upper bound of Theorem 2.2) can be obtained with a simpler proof by requesting paths Path(v1 , vk+1 ), Path(v1 , vk ), . . . , Path(v1 , vκ+1 ) and then Path(v2 , vk+1 ), Path(v3 , vk+1 ), . . . , Path(vκ , vk+1 ). These requests could be served by the adversary with a path from v1 to vk , while if the on-line algorithm is provided with disjoint paths, he would need a cache of size at least d 43 k 2 e to be competitive. Of course, for this we need to assume that the underlying graph contains all such disjoint paths.
2.2
Path-Paging for trees
In this section we show that if we restrict the input graph to be a tree then it is possible to improve the bounds given by Theorems 2.1 and 2.2. The improvement is due to the fact that, between each pair of vertices there is only one path; hence it is not necessary a cache of size quadratic with respect to the cache of the adversary for being able to “learn” the adversary’s configuration. 2.2.1
Full-cost model
For this cost model, we first prove the following lower bound. Theorem 2.3 No deterministic on-line strategy with cache size k for the Path-paging problem in trees under the full-cost model is c-competitive with c < bk 2 /4c + 1, against an adversary with cache of size k. Proof: For the sake of simplicity, we will prove the theorem only in the case k is even; if k is odd the proof is similar. Consider the following initial configuration of both the cache of the adversary and on-line algorithm A: there are k2 − 1 edges {(o, x1 ), (x1 , x2 ) . . . (x k −2 , x k −1 )} forming a path from vertex o to vertex x k −1 = x, 2 2 2 and k2 + 1 edges (o, y1 ) . . . (o, y k +1 ). The adversary may then ask for a path (consisting of a single edge) 2 between o and a vertex w such that w ∈ / {o, x1 . . . x k −1 , y1 . . . y k +1 } (see figure 3). 2
2
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
10
Among all the edges in the initial configuration and the newly requested edge (o, w), there is at least one edge missing to A, and hence there exists a request Path(x, z1 ), z1 ∈ {y1 . . . y k +1 } ∪{w} such that not 2 all the edges necessary for its answer are present in A’s cache. In order to answer this query the algorithm pays k/2 and must evict another edge; therefore there exists a request Path(x, z2 ), z2 ∈ {y1 . . . y k +1 }∪{w} 2 such that not all the edges necessary for its answer are present in A’s cache. In this way a sequence of k k k 2 queries Path(x, zi ), i = 1, 2, . . . , 2 are asked , making A pay 2 (the length of paths (y, zi )) at every query. Queries Path(x, w), Path(x, zi ), i = 1, 2, . . . , k2 form a phase; clearly A pays k 2 /4 + 1 in order to answer all queries of the phase. However the adversary can pay only 1 during the phase; in fact when edge (o, w) enters in the cache the adversary can keep the path (o, x), and the edges (o, yi ) i = 1, 2, . . . , k2 necessary to answer all queries Path(x, zi ) i = 1, 2, . . . , k2 with no cost, and hence the total cost for the adversary during the phase is 1 given by the cost for answering the first query of the phase. At the end of the phase, a similar phase can start if any edge (o, z) neither in A’s nor in the adversary’s cache is requested, yielding an arbitrarily long sequence in which the cost of A is at least k 2 /4 + 1 times the cost of the adversary. 2 The next theorem shows that FIFO is at most a constant factor away from optimal for this problem. Theorem 2.4 FIFO with cache size k is (k 2 + k)/2-competitive for the Path-paging problem for trees under the full-cost model against an adversary with cache size k. Proof: Consider the sequence of queries divided in phases, as in the proof of Theorem 2.2. The paths requested during a phase involve at most k edges, and the cost of the adversary is at least 1. Without loss of generality we assume that each query requires only one edge to be brought into the cache. In fact, suppose that in order to answer Path(a, b) two or more edges must be brought into the cache. Let (a, x1 ), (x1 , x2 ) . . . , (y, y 0 )(w1 , w2 )(w2 , w3 ), . . . , (z, z 0 ), (v1 , v2 ), (v2 , v3 ), . . . (vi , b) be the requested path and let (y, y 0 ) and (z, z 0 ) be the missing edges; if we replace query Path(a, b) with queries Path(a, y 0 ) and Path(a, b) then the total cost paid by FIFO is not smaller than the cost of answering only Path(a, b); note that this can be done without affecting the cost of future requests, and hence increasing the total cost paid by FIFO to process the sequence. Observe that if the phase consists of only one query then, obviously, the cost of FIFO is bounded by k; if there are two queries then the maximum cost is bounded by (k − 1) + k. In a similar way we have Pk that if the phase consists of h queries then the cost of FIFO is bounded by i=k−h+1 i; therefore the Pk 2 total cost during the phase is bounded by i=1 i, that is (k 2 + k)/2. It is easy to see that the above competitiveness ratio is tight for FIFO. Assume that the configuration of FIFO consists in a k-edge path from vertex v1 to vertex vk+1 , and such that the order in which the edges will be evicted is the reverse order of the indexes. This situation can be always forced by the adversary. Suppose that the next query is Path(vk+1 , vk+2 ), and that the adversary evicts edge (v1 , v2 ). The adversary may then ask for Path(vk , vk+2 ), Path(vk−1 , vk+2 ), . . . Path(v2 , vk+2 ). To make place for each new edge necessary to answer the query, FIFO will evict the edge necessary to answer the following one, and hence will have a fault at each query. The total cost for FIFO will hence be (k 2 + k)/2, while the adversary’s is only 1. The configuration at the end of this sequence of requests is similar to the initial one (up to renaming of the vertices), and hence the pattern can be repeated forever. If we consider randomized algorithms, it is possible to prove the following theorem. Theorem 2.5 Under the full-cost model and with a cache of size k, for sufficiently large k, no randomized on-line strategy for the Path-paging problem is better than Ω(k ln k)-competitive against an oblivious adversary with cache size k. Proof: The proof follows the approach developed in [9] of constructing a nemesis sequence for the on- line algorithm based on the possibility that an oblivious adversary has of knowing a probability distribution on the on-line’s cache. The sequence σ is random, and we show that for each constant d, in order to have (1) E[CA (σ)] − c ∗ E[CADV (σ)] < d,
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998) y3
y2 y1
11
y4 w
o
x
Figure 4: Example for Theorem 2.5 with k = 8, (o, w) is the edge requested at the beginning of the phase. c must be Ω(k ln k), where CA (σ) and CADV (σ) are the random variables denoting the costs charged to algorithm A and to the adversary, respectively, for serving the sequence σ. Assume the initial configuration in which both the adversary and A have in their caches the following set of edges: l edges {(o, x1 ), (x1 , x2 ) . . . (xl−1 , xl )} forming a path between vertex o and vertex x and k − l edges (o, y1 ) . . . (o, yk−l ) (the parameter l will be determined later). Consider a random sequence of queries composed by an arbitrarily large number of epochs; each epoch is defined as follows: the first query is Path(o, w), w ∈ / {x1 . . . xl } ∪ {y1 . . . yk−l }; in order to answer the query the adversary evicts edge (o, yj ), for some j ∈ {1 . . . k − l} uniformly chosen at random. The epoch proceeds with k − l − 1 subepochs, where each subepoch consists in zero or more requests to paths (x, yi ), i 6= j already requested in the epoch followed by a request to a path (x, yi0 ), i0 6= j not yet requested in the epoch. The requests of the first type will be done as many times as necessary till the probability that the on-line algorithm has exactly the edges needed to answer all the requests so far in the epoch is 1. This is always possible whenever the on-line algorithm achieves a bounded competitive ratio as the adversary can simulate the behavior of the on-line algorithm on the sequence of requests up to that moment, and all these requests cost nothing to the adversary. Upon completion of the epoch vertex w is “renamed” yj so as to always have again the initial configuration (see figure 4). The expected cost charged to the adversary in each epoch is 1 (in fact 1 is the exact cost). The cost of the algorithm is 1 for the first query of the epoch; in the full cost model each subsequent fault costs (l + 1). Without loss of generality we may suppose that edges belonging to the path that connects o and x will not be evicted by the on-line algorithm and that l lines of the cache are filled by the edges of the path (o, x). In fact, if A ever evicts during the epoch an edge of the path (o, x), it will surely fault in order to answer the following query. Therefore, the expected number of faults on the rest of the epoch depends on the probability that edges (o, yj ) are in the remaining part of the cache, of size k − l. Equivalently this number is one less than the expected number of faults for an epoch of the Paging problem with cache of size k − l (page yi corresponds to path Path(x, yi )). It has been proved in [9] (where epochs are called phases) that this number is greater than Hk−l−1 (where Hx denotes the x-th harmonic number). Hence the expected cost for the epoch is greater than 1 + (l + 1)(Hk−l−1 − 1). Turning to inequality 1, it follows that c, the competitiveness coefficient, must be greater or equal to the maximum value of the previous expression. Simple calculations show that the maximum value is
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
12
Ω(k ln k) and that, for k ≥ 4, the value is greater than k/2(ln(k) − 2.
2
In the following we will prove that the Marking algorithm (Marking, for short) is nearly optimal under the full-cost model. Marking has been originally proposed in [9] for the paging problem; we extend it to the path paging problem as follows. The algorithm maintains a set of marked edges. Initially the marked edges are exactly those that are present in the cache. The marks are updated after each request: when query Path(a, b) is requested all edges of the path are marked. If the requested path is completely present in cache, then nothing else is done. If edges in the cache do not allow to answer a query then there are two possibilities. Let x be the number of edges missing in the cache in order to complete the requested path. If there are at least x unmarked edges in the cache, then the algorithm evicts x edges that are randomly chosen among the unmarked ones to make place for the missing edges. If the number of unmarked edges is less than x then all marks except those assigned to edges of the current query are erased and then the previous case applies. Before proving the competitive ratio of Marking we need some preliminary definitions. Consider the sequence of requests divided in epochs. During an epoch, requests may involve three different kinds of edges: • marked edges, that are edges already used during the current epoch, • clean edges, that are edges that where not used during the current epoch nor in the previous one, • stale edges, that are edges that where used in the previous epoch but not during the current epoch. In a similar way, we can divide the requests in four types: • clean requests, that use clean and possibly marked edges, • stale requests, that use stale and possibly marked edges, • mixed requests, that use clean and stale edges, and possibly marked edges, and • marked requests, that use only marked edges. Without loss of generality we can suppose that there will not be requests of the last kind, as by definition Marking would answer them with no cost. It is easy to see that each epoch starts with a clean or a mixed request, that is, with a request that involves at least one clean edge. Lemma 2.6 The expected number of faults of Marking during an epoch is maximized if each query involves at most one clean or stale edge. Proof: Suppose a query q involves r > 1 stale or clean edges. We prove the lemma assuming that r = 2; by induction the proof can be easily extended to any other value of r. Let a and b denote the stale or clean edges of the query. Let A (B) denote the event that edge a (b) is in the cache; A (B) denotes the event that a (b) is not in the cache. The expected number of faults Fq for answering q is equal to the probability that at least one edge among a and b is not present in the cache. Hence we can write: Fq = Prob(A ∧ B) + Prob(A ∧ B) + Prob(A ∧ B). Let qa , qb be two queries obtained from q in such a way that qa (qb ) can be answered by including edge a and without edge b (respectively including b and not a) and let B 0 be the event that edge b is not in the cache after query qa has been answered. The expected number Fqa ,qb of faults for answering both queries qa and qb is equal to Fqa ,qb = Prob(A ∧ B) + Prob(A ∧ B) + Prob(B 0 ). The lemma follows by observing that Prob(B 0 ) ≥ Prob(A ∧ B) + Prob(A ∧ B) and, hence, Fqa ,qb ≥ Fq . 2
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
13
Theorem 2.7 Marking is 2kHk competitive for the Path-paging problem on trees under the full-cost model, against an adversary with cache size k. Proof: By lemma 2.6 we can suppose that each request involves only one clean or stale edge, and possibly some marked edges. This proof is similar to the proof of the competitiveness of Marking in [9]; for this reason we limit to give a sketch of the proof. The expected number of faults of Marking during the epoch is smaller than the number of faults it would have if all the clean requests of the epoch where done before any stale request. In such a case Marking has one fault for each clean request. Let c be the number of clean edges that are requested in the epoch, therefore, the number of faults for this type of requests is c. The probability of having a fault in a stale request is equal to the probability that the involved stale edge is not present in the cache. If we denote by s the current number of stale edges (that ranges from k to c + 1), this probability is sc . Hence, the expected number of faults of Marking during the epoch is less than c+
c c 1 1 1 c + + ...+ = c(1 + + + ... + ) = c(1 + Hk − Hc ) ≤ cHk k k−1 c+1 k k−1 c+1
As for the cost charged to the adversary, it can be proved in the same way as in [9] that it is at least c/2, half of the number of clean edges requested in the epoch. It follows that the ratio between the expected number of faults of Marking and the adversary is equal to 2Hk . In the full cost model, the maximum cost charged to Marking for a fault is k, while the minimum cost for a fault of the adversary is 1. Hence, if we consider the cost instead of the number of faults, we have that the cost of Marking is less than 2kHk times the cost of the adversary, that is, Marking is 2kHk competitive. 2 The two previous theorems assert that Marking is at most a factor of 4 away from optimality. 2.2.2
Partial-cost model
In this section we consider the partial-cost model, in which the cost charged for a fault is the number of missing edges that complete the requested path. In the following we propose a strongly competitive algorithm, based on the Least Recently Used (LRU) algorithm for the Paging Problem [18]. The LRU algorithm is defined as follows: when a fault occurs and new edges must be included in the cache LRU evicts the minimum number of edges that allows to include edges of the current query; the evicted edges are those that have not been used for the longest time (breaking ties arbitrarily). The strategy can be implemented in the following way: edges are ordered in such a way that if e precedes e0 then e0 has not been used for answering a query after e has been used. To answer a request Path(a, b) the algorithm works as follows: If a path P from a to b is present in cache then A.1 Reorder edges in the cache by placing ahead edges belonging to P while maintaining their relative order else B.1 Retrieve a path P from a to b. Let x be the number of edges of P not present in the cache B.2 Reorder edges in the cache by placing ahead edges belonging to P that are already in the cache (maintaining their relative order) and then remaining edges (maintaining their relative order) B.3 Evict the last x edges in the cache that do not belong to P B.4 Introduce the x new edges of P placing them ahead in the cache. Theorem 2.8 LRU is k-competitive for the Path-paging problem on trees under the partial-cost model, against an adversary with cache size k.
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
14
Proof: For every edge e of the tree let a[e] be an integer valued variable, in the range 1, . . . , k for all the edges present in the cache, such that the first edge in the cache (relative to the order maintained by LRU) has value k, the second one value k − 1 and so on; if e is not in the cache then we assume a[e] = 0. a[e] is the weight of e. Let us define the following potential function X (k − a[e]) Φ= e∈ADV
where ADV is the set of he adversary’s cache. We suppose that the adversary serves first each request, and then LRU serves it. The behavior of the potential function in the different situations is the following. The adversary serves the request Let z be the cost charged to the adversary (i.e. z new edges enter the adversary’s cache). The maximum possible increase in the potential occurs when all the z new edges are not present in LRU’s cache; in this case ∆Φ ≤ kz. LRU serves a request If LRU does not fault then there is no increase in the potential function; in fact there might be edges in both LRU and adversary’s cache that decrease their weight; however this decrease is equal or greater to the increase of the weights for edges that allow to answer the query (and that certainly belong to the adversary’s cache). If LRU faults then let y be the length of the path from a to b, x is the number of edges of that path that are not present in LRU’s cache. The modifications that LRU performs on the weights of the edges can be described as follows: B.2 Assign to the edges of the cache that are not in the path from a to b the values 1, . . . , k − (y − x) maintaining their relative order; assign values in the range k − (y − x) + 1, . . . , k to the edges of the cache that are in the path; B.3 for every edge e of the cache do a[e] := max(a[e] − x, 0); evict edges of the cache with weight equal to 0; B.4 bring into the cache the missing edges, arbitrarily assigning weights in the range k − x + 1, . . . , k. Step B.2 above increases the weight of (y − x) edges in the adversary’s cache and this increase is at least the decrease of edges in the adversary’s cache that are not part of the query path; therefore there is no increase in the potential due to this step. Since there are no more than (k − x) edges in the intersection of both caches before the execution of step B.3, then the increase of the potential function due to step B.3 is at most (k − x)x. Since the x new edges are placed ahead of LRU’s cache, then the change of the P potential function due to the insertion of the new edges (step B.4) is −(kx − x−1 i=1 i). Therefore the total modification of the potential function is at bounded by ∆Φ ≤ kx − x2 − kx +
x−1 X i=1
Lemma 1.1 implies that LRU is k-competitive.
i = −x2 +
(x − 1)x ≤ −x 2 2
In the sequel of this section we will show that the Marking algorithm achieves a competitive ratio of 2Hk by considering a particular kind of adversary. Let d(a, b) be the number of edges in the path connecting a and b. The restricted adversary, before every query Path(a, b) with d(a, b) > 1(from now on these kind of queries will be referred to as long queries), must request all the edges that form the path from a to b, in any order; let P(a, b) be such a sequence. This is not a real restriction; in fact the cost charged to the restricted adversary is exactly the same that it would be charged to a general adversary. Furthermore the cost charged to Marking is at least the same it would have to pay in a general sequence; in fact, in the partial-cost model, an algorithm is charged exactly the number of missing edges; hence the cost of Marking for answering all queries in P(a, b) and then Path(a, b) is at least the number of missing edges in Path(a, b) before the first edge of P(a, b) is requested.
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
15
Moreover, we assume a lazy adversary, (i.e. an adversary that does not evict any edge if all edges necessary to answer the current query are in the cache, and, when a fault occurs, evicts exactly the number of edges necessary to make place for the missing ones). It has been shown in [15] that this latter assumption can be done without loss of generality. As in the previous section, edges may be divided in marked, clean or stale, and requests in clean, stale, mixed and marked. The proof of the following lemma is trivial and it is omitted. Lemma 2.9 Each epoch starts with a clean request. Lemma 2.10 Every long query but the first one of an epoch is served by Marking with no cost. Proof: By definition of Marking and the kind of adversary we are considering, all edges that allow to answer a long query Path(a, b) but the first one of an epoch have been already marked and, hence, are in the cache. 2 Theorem 2.11 Marking is 2Hk competitive for the Path-paging problem under the partial-cost model, against an adversary with cache size k. Proof: By lemma 2.10 we can eliminate from the input sequence all long queries except the first one of each epoch; furthermore, since Marking does not pay for marked edges then we can eliminate from the input sequence all marked queries. Therefore we can assume that the sequence of requests of an epoch is as follows: c1 , . . . , ci , sc1 , . . . , scj , L, c11 , c12 , . . . , c1x1 , s11 , s12 , . . . , s1y1 , c21 , c22 , . . . , c2x2 , s21 , s22 , . . . , s2y2 , . . . where c1 . . . ci are requests to clean edges, sc1 . . . scj are requests to clean or stale edges, L is either empty or a long query involving edges c1 , . . . , ci , sc1 , . . . , scj and possibly some other stale edges (denoted s0 , s00 , s000 , . . . in the sequel) that have been requested in the final part of the previous epoch. Queries cnm and snm are clean and stale requests for one-edge paths, respectively. Since a marked edge is not evicted it follows that the cost charged to Marking for this sequence is less that the cost it would be charged for the sequence c1 , . . . , ci , sc1 , . . . , scj , s0 , s00 , s000 , . . . , c11 , c12 , . . . , c1x1 , s11 , s12 , . . . , s1y1 , c21 , . . . , c2x2 , s21 , . . . , s2y2 , . . . The rest of this proof is similar to the proof of the competitiveness of Marking for the full-cost model. The expected cost charged to Marking for the above input sequence is smaller than the cost it would be charged if all the clean edges of the sequence where requested before any request to a stale edge. In such a sequence Marking pays one for each clean edge and an expected cost for each stale request that is equal to the probability that the edge is not present in the cache. This probability is sc , where c is the number of clean edges requested so far and s is the current number of stale edges. Hence, the expected cost charged to Marking during the epoch is less than c+
c c 1 1 1 c + + ...+ = c(1 + + + ... + ) = c(1 + Hk − Hc ) ≤ cHk k k−1 c+1 k k−1 c+1
Following [9] it is possible to prove that the cost charged to the adversary is at least c/2, half of the number of clean edges requested in the epoch. This completes the proof of the 2Hk -competitiveness of Marking. 2 We recall that in [9] it has been proved that Hk is a lower bound for the competitive ratio of any algorithm for the Paging problem, and hence it is also a lower bound for the Path paging problem for trees under this cost model. Therefore the proposed algorithm is at most a factor of 2 from optimality.
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998) 2.2.3
16
0/1-Cost Model
If the 0/1-cost model is used, we can prove that LRU is k-competitive and, hence, optimal. Theorem 2.12 LRU and FIFO are k-competitive for the Path-paging problem on trees under the 0/1 cost model, against an adversary with cache size k. Proof: We prove the theorem for LRU omitting the analogous proof for FIFO. We will suppose that the adversary serves each request before LRU. An integer valued variable, in the range 1, . . . , k is associated to all edges present in the cache in the same way that was done in the proof of Theorem 2.8; if e is not in the cache then we assume a[e] = 0. Let us consider the following potential function Φ=
max
e∈L,e∈ADV /
a[e]
where L and ADV denote, respectively, the set of edges in LRU’s cache and in the adversary’s cache. The behavior of the potential function is as follows. The adversary answers the query Since 0 ≤ Φ ≤ k then clearly ∆Φ ≤ k. LRU answers the query Let us first consider the case when LRU faults. Since the adversary serves each request first then the edges that enter into LRU’s cache are all present in the adversary’s cache. Moreover, since LRU faults there must be at least one edge e such that e ∈ L, e ∈ / ADV , then the update of the array a, produces a decrease in the potential function, i.e. ∆Φ ≤ −1. On the other side, if LRU serves a request without a fault then ∆Φ ≤ 0. The theorem follows by applying Lemma 1.1. 2 Since k is a lower bound for the competitiveness of any deterministic algorithm it follows that LRU and FIFO are optimal. The following theorem provides a lower bound for randomized algorithms. Theorem 2.13 No randomized on-line strategy for the Path-paging problem on trees under the 0/1 cost model is c competitive against an adversary with cache size k with c < (b ke c + 1) (e is the base of the natural logarithm) even if oblivious adversaries are considered. Proof: Let A be any on-line algorithm; assume that before the first query is disclosed the adversary and A have the same set of edges in their caches. The input sequence is random and consists of an arbitrarily large number of rounds. The first request of each round asks a path of length l (the value of l will be determined later) that is disjoint from the set of edges present in both caches. To serve this request, the adversary evicts l randomly chosen edges; the round continues with k − l subrounds; each subround is defined as follows: first, all requests of previous subrounds of the round are repeated as shown in the proof of Theorem 2.5; then one of the k − l edges not evicted by the adversary is requested as one-edge path. The round terminates when all those k − l edges have been requested. The adversary’s cost during the round is 1, and after a round A’s and the adversary’s cache coincide and a new round can start. To complete the proof it is sufficient to show that the expected cost charged to A during a round is at least ke + 1. A pays 1 for the first request of the round. The expected cost paid by the algorithm for answering the queries of a subround is greater than the probability that, for each of the k − l subrounds, the requested edge is in the cache when it is requested for the first time during the round. The probability that the l . Therefore the expected first edge that is requested during the i-th subround is in A’s cache is k−i+1 cost for a round is at least: 1+
l l 1 1 1 l + + ...+ = 1 + l( + + ... + ) = 1 + l(Hk − Hl ) k k−1 l+1 k k−1 l+1
The maximum value of the above expression is 1 + theorem.
k e
(when l = ke ). This completes the proof of the 2
Recall that deterministic algorithms LRU and FIFO are k competitive in this case.
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
3
17
Connectivity-paging
In this section we consider the problem of answering (in an on-line way) queries about the connectivity of an arbitrary directed graph. We assume that the cache contains a subset of k pairs of vertices, together with the information whether the two vertices lie in the same connected component of the graph or not. In other words, the cache is a subset of edges of the transitive closure of the graph (which we suppose is stored in secondary storage). A pair (i, j) is called a yes-edge if i and j are in the same connected component, a no-edge otherwise. Both kinds of pairs will be referred to as edges when no confusion arises. We assume that no further information is stored in the cache. A query Connected(i, j) may be answered with no cost if there is a path in the cache containing at most one no-edge between i and j: if there is a path containing no no-edges, the answer to Connected(i, j) will be yes (pair (i, j) is called a deduction); conversely if there is a path containing one no-edge, the answer to the query will be negative (in this case we call pair (i, j) a no-deduction). Paths with more than one no-edge do not provide information to answer the connectivity query between i and j. If the cache does not contain a path between i and j with at most one no-edge then the query must be answered by accessing secondary memory. We require that after each query Connected(i, j), the information about the connectivity between i and j must be present in the cache; namely, the faulty query Connected(i, j) is answered by bringing into the cache edge (i, j): neither the algorithm nor the adversary are allowed to bring into the cache any other edge of the transitive closure. We assume that a constant cost is charged for each fault.
3.1
Lower bounds
Let f (k) be the maximum number of no-deductions that are consistent with a cache of size k. The value of f (k) is crucial in our analysis. In fact, we will show that no strategy can achieve a bounded competitiveness coefficient against an adversary with a cache of size k if its own cache is of size K < f (k); we will see that f (k) ' k 2 /2. Theorem 3.1 No deterministic on-line strategy for the Connectivity-paging problem on arbitrary graphs can be competitive against an adversary with cache size k if its own cache is of size K < f (k). Proof: Consider the sequence of (K + 1)k requests e11 . . . e1k . . . e(K+1)1 . . . e(K+1)k such that each subsequence ei1 . . . eik denotes a set of yes- and no-edges that allows exactly f (k) no-deductions. Since the memory of the on-line algorithm is K, after such a sequence there exists at least one i such that the on-line strategy has none of ei1 . . . eik in its cache. This holds whichever were the initial configurations of the on-line strategy and that of the adversary. Since the adversary knows the exact value of i, he can serve the sequence of request as follows: the subsequence e11 . . . e1k . . . e(i−1)1 . . . e(i−1)k can be served in any way. For ei1 . . . eik the adversary empties the cache to keep all the edges of the subsequence. For the remaining queries of the sequence, he pays for every query, caching all the edges to the same position of his cache, a position that contained some no-edge, say (x, y). After the last query of the sequence the adversary may ask again for Connected(x, y); after this query the adversary is able to answer a set f (k) different negative queries with no cost. Note that before answering Connected(x, y) the on-line algorithm has no edge of this set; since K < f (k), then there is always at least one no-edge absent from his cache. Therefore the algorithm has to pay for every query of an arbitrarily long sequence of queries for which the adversary pays nothing, yielding an unbounded relation between the costs. 2 Lemma 3.2 Given a cache of size k the maximum number of no-deductions is k2 −3 f (k) = 2
53 4 k + O(k 3 ). 2 1
1
This value is obtained when the yes-edges of the cache form l, l = k2 3 + 34 + O(k − 3 ), spanning trees, whose sizes differ at most in one unit, and there is a no-edge in the cache between each pair of spanning trees (see figure 5).
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
18
Figure 5: Two possible configurations for k = 12. The first one maximizes the number of possible no-deductions. Full lines represent yes- edges of the graph, while dashed lines represent no-edges. Proof: We suppose that the underlying graph contains subgraphs of the desired type. Let CC be a connected component. Given an initial configuration of the cache with any number of connected components we first obtain a sequence of configurations with non-decreasing number of no-deduction that has fixpoints in configurations of the claimed type, but possibly with a different number of connected components. The sequence is obtained by applying one of the following rules until the fixpoint is obtained. Without loss of generality we assume that at the beginning the initial configuration contains at least one no-edge (otherwise the number of no-deductions is zero). Transformation Rules 1. If there exists two CCs a and b such that there is not a no-edge between a vertex in a and a vertex in b, then merge a and b identifying one vertex x of a and one vertex y of b in a new vertex z. If this results in repeating the same no-edge (z, w), then replace one copy of the edge by a positive edge (z, v) where v is a new vertex. 2. If any CC is not a spanning tree then eliminate one positive edge that belongs to a cycle and add a positive edge between a vertex in the CC and a new vertex. 3. If there are two no-edges between the same pair of CCs then eliminate one no-edge and add a new yes-edge (x, y) where x is a vertex of one CC and y is a new vertex that was not previously in any CC. 4. If the difference of the number of positive edges belonging to a pair of CCs connected by a no-edge is greater than one then eliminate a positive edge from the bigger CC and add a positive edge to the smaller one. It is easy to see that rules 2,3 and 4 do not increase the number of possible no-deductions. As far as rule 1 is concerned we observe that all no-deductions that involve x and y are now possible with vertex z; moreover it might happen that new no-deductions become possible. When no rule can be applied, the configuration consists in a set of CCs whose number of edges (and vertices) differ in at most one. Notice that the number of CCs obtained at the fixpoint depends on the order in which rules are applied.
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
19
It remains to find the optimal size of the CCs as a function of k. It is sufficient to maximize the number of no-deductions possible as a function of the number of connected components varies. For example, Figure 5 shows two possible configurations for k = 12, one with 3 CCs and one 2 CCs. with l(l−1) ; each CC If there are l CCs then the number of no-edges in such a configuration will be 2 k−
l(l−1)
2 c + 1) or (b contains either (b l possible with a cache of size k is
f (k) = max l
k−
k−
l(l−1) 2
l
l(l−1) 2
l
c + 2) vertices. The maximum number of no-deductions !2 +1
5
k2 k3 l(l − 1) 4 = −3 + O(k 3 ) 2 2 2
The value of l that maximizes the value of f (k) is l ≈
k 2
1 3
+
3 4
+ o(1).
(2)
2
The second result of this section is a lower-bound on the competitive ratio of any on-line algorithm, with a cache of any size. Theorem 3.3 No on-line algorithm for the Connectivity paging problem for arbitrary graphs with any cache size can be c-competitive against an adversary with cache size k with c < k. Proof: Let h be the size of the algorithm’s cache; we assume that the underlying graph has at least h2+k vertices. Consider a configuration in which the adversary has k − 1 yes- edges forming a tree with vertex set T and the on-line algorithm has no edges joining vertices of T ; this is always possible using a suitable input sequence of queries analogously to the sequence exploited in the proof of Theorem 3.1. The rest of the input sequence is defined as follows: the adversary asks for a no-edge (x, j) where j belongs to the tree and x is neither in the adversary’s cache nor in the algorithm’s cache. After this query, k queries Connected(x, t), t ∈ T can be answered by the adversary with no cost. Since the on-line algorithm has no yes-edges connecting vertices in T , it will have a fault for each one of these k queries. Afterwards the input sequence continues analogously with query (y, j 0 ) where j 0 belongs to the tree and y is neither in the adversary’s cache nor in the algorithm’s cache; this pattern can be repeated an arbitrary number of times. The lower bound follows by observing that for each of these subsequences 1 and k are, respectively, the adversary’s and the algorithm’s costs. 2
3.2
An upper bound
In the following, we will prove an upper bound for the competitive ratio achieved by a variant of FIFO with a cache of size f (k) + k for the Connectivity-paging problem. The proposed algorithm maintains yes- and no-edges in separate parts of the cache, using the Firstin-first-out policy in each of them. Namely, the algorithm (that we call FIFO D ) has at every moment k positive edges and f (k) negative edges. We consider the following implementation of FIFOD : a value p(e) from 1 to k is associated with each positive edge e in the cache and a value n(e) from 1 to f (k) is associated with each negative edge in the cache. Whenever FIFOD has a fault on a positive (negative) edge, the values of p(e) (n(e)) are decreased for every e such that p(e) > 0 (n(e) > 0). The edge e such that p(e) (n(e)) becomes exactly 0 is the one evicted, and the arriving edge is given value k (f (k)). Let D(ADV ) denote the set of pairs of vertices such that the adversary may answer without paying a query about the connectivity of that pair in a certain configuration ADV of its cache. Proposition 3.4 Whenever FIFOD has a fault on a positive (negative) edge, there must be at least one edge e with p(e) > 0 (n(e) > 0) such that e ∈ / D(ADV ). Theorem 3.5 FIFOD with a cache of size f (k) + k is (f (k) + k)-competitive for the Connectivity-paging problem on arbitrary graphs against an adversary with cache size k.
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
20
Proof: The following potential function is used: Φ=
max
e∈D(ADV / )
{p(e)} +
max
{n(e)}
e∈D(ADV / )
We will suppose that the adversary serves each request first, and then it presents it to FIFOD . Again, we will analyze the behavior of the potential function in the cases where the adversary and FIFOD move. The adversary moves, evicting edge (i, j) Since Φ ≤ k + f (k), obviously ∆Φ ≤ k + f (k) FIFOD faults on request Connected(i, j) Note that in this case the entering edge (i, j) is deducible by the adversary (as the adversary serves each request first). The decrement in the value of p (n) for all the positive (negative) edges of FIFOD produces a decrement in the potential function whenever there was at least one edge e with p(e) ≥ 0 (n(e) ≥ 0), e ∈ / D(ADV ). By proposition 3.4 this is always the case, and hence ∆Φ ≤ −1. 2 By Lemma 1.1, FIFOD is f (k) + k-competitive.
4
Link paging
An important feature of high speed networks (e.g. ATM networks) is that the cost of establishing a communication channel between two vertices of the network depends on the reconfiguration of the network that is eventually necessary in order to establish the channel. Namely we assume a computer network in which all possible connections between pairs of vertices might occur, but at most k pairs of vertices are connected at the same instant. Communication requests are pairs of vertices to be connected, and one request is served with no cost if there is a path between the vertices in the current configuration of the k links; otherwise, both vertices are linked by switching one of the k physical links to connect the requested pair, and the cost is 1. We call this problem the Link-paging problem. An algorithm for the Connectivity-paging problem in the particular case in which the graph is complete is also an algorithm for this problem. K -competitive against adverIn the following we will prove that FIFO with a cache of size K is K−k+1 saries that use caches of size k ≤ K, and therefore optimal for the link paging problem. K -competitive for the Link-paging problem against adverTheorem 4.1 FIFO with cache size K is K−k+1 saries with cache size k ≤ K, and this is optimal.
Proof: An integer valued variable, in the range 1, . . . , K is associated with all edges present in the cache in the same way that was done in the proof of Theorem 2.8; if e is not in the cache then we assume a[e] = 0. Whenever FIFO has a fault a[e] is decreased for every edge in the cache and the evicted edge is the edge e such that a[e] becomes 0. The edge that is inserted into the cache in order to answer the query receives the value K. Note that edges in FIFO’s cache do not form a cycle; moreover without loss of generality we can assume that also the adversary’s cache does not contain a cycle (since if this occurs the cache contains at least one redundant edge). Let GF IF O = (VF IF O , EF IF O ) and GADV = (VADV , EADV ) be the graphs induced respectively by the set of edges in FIFO’s and the adversary’s caches. Let H be the multigraph union of GF IF O and GADV (where edges in both caches appear twice). Let C be the set defined by the following procedure: C := ∅; while there is a cycle in H do begin let e be the edge in FIFO’s cache belonging to a cycle such that a[e] is minimum; C := C ∪ {e}; remove the edge e from H end
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
21
C can be seen as the minimum-weight “feedback” edge set of H that consists only of edges in EF IF O . We consider the following potential function: X a[e]. Φ = kK − e∈C
When the adversary faults, ∆Φ ≤ K. This is true because the entering edge does not increase the potential function and the evicted edge can increase it by at most K. In order to show this latter fact, let e = (a, b) be the evicted edge, and suppose that e was part of x cycles of G. If x = 1, then the eviction of e eliminates only that cycle and hence ∆Φ ≤ K. If x > 1, then let C1 . . . Cx be those cycles, and suppose without loss of generality that C1 is the cycle whose minimum edge is maximum among the minimum edges of all the cycles. Then C1 is the last cycle that is eliminated by the above procedure. But then, each one of C2 . . . Cx is a cycle with e substituted by C1 − e, so the edges considered in the computation of the new potential function will be the same as before the eviction of e, except the one corresponding to C1 . The other thing to note is that if FIFO has a fault, then ∆Φ ≤ −K + k − 1. To see this, note that the entering edge is necessarily part of a cycle with only edges that are in the adversary’s cache, and, hence, it decreases the potential by K. Besides, note that |C| ≤ k, because each cycle contains at least one edge of EADV , and neither the adversary nor FIFO have redundant connections. Moreover if |C| = k then it follows that D(ADV ) ⊆ D(F IF O), where D(ADV ) and D(F IF O) denote the set of pairs that may be connected by the adversary and FIFO respectively. Therefore, the decrease of the weights of the other edges in FIFO’s cache produces an increase of the potential that is at most k − 1; in fact if FIFO faults, there are at most k − 1 edges in C. Hence ∆Φ ≤ −K + k − 1. By applying Lemma 2.1 the thesis follows. 2 As in the case of the general connectivity problem, it is interesting to note that LRU will not work for this problem.
5
Conclusions and open problems
In this paper we have studied two extensions of the Paging problem to graphs. We have shown that the competitiveness results that hold for the Paging problem become much worse if we assume that query answers are either a set of items that are constrained to form a path in an underlying graph or the connectivity information about a pair of vertices. Many open problems require further investigation. First of all it would be interesting to close the gaps between upper and lower bounds that do not match. Furthermore it would be interesting to extend Path-paging to directed and/or non-connected graphs, and to consider particular classes of graphs such as trees, forests or graphs with bounded diameter etc. A topic that deserves further study arises by noting that the lower bound of theorem 2.1 does not hold if we consider a different model in which at every fault on query Path(a, b) the on-line algorithm may bring into cache any set of edges and not necessarily a shortest path from a to b. A similar extension of the Connectivity-paging problem consists in considering algorithms that in response to a fault on query Connected(a, b) are not forced to bring to their cache the edge (a, b) of the transitive closure but may look for other edges that allow to answer the query. Note that the proof of the lower bound on the size of the cache in theorem 3.1 does not hold in this model. Acknowledgments: We would like to thank Giorgio Ausiello for useful discussions about this work, and Ricardo Baeza-Yates for computing the exact value of f (k) in Lemma 3.2. We also acknowledge anonymous referees for comments and observations that allowed us to improve the presentation.
References [1] A. Aggarwal, B. Alpern, A.K. Chandra and M. Snir, A model for hierarchical memory, Proc. 19th Annual ACM Symposium on Theory of Computing 305-314 (1987).
E. Feuerstein and A. Marchetti-Spaccamela, Paging for Graph Problems, JGAA, 2(6) 1–22 (1998)
22
[2] A. Aggarwal and A.K. Chandra, Virtual memory algorithms, Proc. 20th Annual ACM Symposium on Theory of Computing 173-185 (1988). [3] A. Aggarwal, A.K. Chandra and M. Snir, Hierarchical memory with block transfer, Proc. 28th. Annual Symposium on Foundations of Computer Science 204-216 (1987). [4] J.L. Bentley and C.C. McGeoch, Amortized analysis of self organizing sequential search heuristics, Comm. ACM 28(4) 404-411 (1985). [5] A. Borodin, Sandy Irani, P. Raghavan and B. Schieber, Competitive paging with locality of reference, Proc. 23rd Annual ACM Symposium on Theory of Computing 249-259 (1991). [6] A. Borodin, N. Linial, and M. Saks, An optimal online algorithm for metrical task systems, Proc. 19th Annual ACM Symposium on Theory of Computing 373-382 (1987). [7] M. Chrobak, H. Karloff, T. Payne, and S. Vishwanathan, New Results on server problems, Proc. 1st. Annual ACM-SIAM Symposium on Discrete Algorithms 291-300 (1990). [8] M. Chrobak and L. Larmore, An optimal online algorithm for k servers on trees, SIAM Journal on Computing 20 144- 148 (1991). [9] A. Fiat, R.M. Karp, M. Luby, L.A. McGeoch, D.D. Sleator and N.E. Young, Competitive paging algorithms, Journal of Algorithms 12 685-699 (1991). [10] A. Fiat, Y. Rabani and Y. Ravid, Competitive k- server algorithms, Proc. 31st. Annual Symposium on Foundations of Computer Science 454-463 (1990). [11] E.F. Grove, The harmonic online k-server algorithm is competitive, Proc. 23rd Annual ACM Symposium on Theory of Computing, 260-266, (1991). [12] A. Karlin, M. Manasse, L. Rudolph and D. Sleator, Competitive snoopy caching, Algorithmica 3 79-119 (1988). [13] E. Koutsoupias, C. Papadimitriou, On the k-server conjecture, Journal of the ACM 42(5), 971-983 (1995). [14] M. H. Nodine, M. T. Goodrich and J. S. Vitter, Blocking for external Graph Searching, Algorithmica 16(2), 181-214 (1996). [15] M.S. Manasse, L.A. McGeoch and D.D. Sleator, Competitive algorithms for server problems, Journal of Algorithms 11(2), 208-230 (1990). [16] M. Overmars, M. Smid, M. de Berg and M. van Kreveld, Maintaining range trees in secondary memory, part I: partitions, Acta Informatica 27 423-452 (1990). [17] P. Raghavan and M. Snir. Memory versus randomization in on-line algorithms, IBM Journal of Research and Development, 38(6):683–707, November 1994. [18] D. Sleator and R.E. Tarjan, Amortized efficiency of list update and paging algorithms, Comm. ACM 28 202-208 (1985). [19] M. Smid and P. van Emde Boas, Dynamic data structures on multiple storage media, a tutorial, Technical Report Universitat des Saarlandes a 15/90, (1990). [20] N. Young, On-line caching as cache size varies, Proc. 2nd. Annual ACM-SIAM Symposium on Discrete Algorithms 241-250 (1991).
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 2, no. 7, pp. 1–31 (1998)
New Lower Bounds For Orthogonal Drawings Therese C. Biedl School of Computer Science McGill University 3480 University Street #318 Montr´eal, Qu´ebec H3A 2A7, Canada
[email protected] Abstract An orthogonal drawing of a graph is an embedding of the graph in the two-dimensional grid such that edges are routed along grid-lines. In this paper we explore lower bounds for orthogonal graph drawings. We prove lower bounds on the number of bends and, when crossings are not allowed, also lower bounds on the size of the grid.
Communicated by D. Wagner: submitted July 1997; revised November 1998.
Some results of this paper were part of the author’s diploma thesis at TU Berlin under the supervision of Prof. R. M¨ ohring, and have been presented in an extended abstract at Graph Drawing ’95, Passau, Germany.
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
1
2
Introduction
A graph G = (V, E) is an abstract structure consisting of points (or vertices) V and connections (or edges) E. Such a structure is found in many industrial applications, such as networks, production schedules and diagrams. With the aid of graph drawing, a graph is displayed in visual form, and the underlying information can be understood easily. Many years of research have been spent on the development of graph drawing styles and graph drawing algorithms, see for example [8]. In this paper, we study orthogonal drawings, i.e., embeddings in the rectangular grid (see Section 2 for a precise definition). Many criteria are used to judge the quality of an orthogonal drawing, two of the most important ones are the area and the number of bends. Orthogonal drawings with vertices drawn as points exist only if every vertex in the graph has at most four incident edges. Such a graph is called a 4-graph, or more generally, a graph is called a ∆-graph if the maximum degree of the graph is at most ∆. In this paper we study only 4-graphs; lower bounds for graphs with larger degrees, specifically, lower bounds for the complete graph, have been studied in [6]. The question whether a graph can be embedded in a grid of prescribed size is NP-complete [9, 13]. Heuristics have been developed that are within a factor of O(log n) of the minimal area (see [16] for an overview). With respect to planar drawings of planar graphs, minimizing the number of bends is NP-complete [10], but if the combinatorial embedding and the outer-face is fixed (the graph has a fixed planar drawing), then the orthogonal drawing with the minimum number √ of bends can be found in O(n7/4 log n) time ([20] and [11]) and in linear time for 3-connected 3-graphs [18]. Another approach to orthogonal graph drawing is to develop simple heuristics and to prove worst-case bounds on the area and the number of bends. See farther below for an overview. The quality of such heuristics is measured by comparing them to lower bounds, i.e., to graphs that need at least a certain grid-size or at least a certain amount of bends in any orthogonal drawing. Some previous lower bounds have appeared in [12, 14, 19, 21, 22]. In this paper, we study, and in many cases improve, lower bounds for orthogonal drawings of 4-graphs and 3-graphs. Many heuristics have been tailored to some particular graph class, for example 3-connected planar 3-graphs [12]. To measure the quality of such an algorithm, one should use a lower bound graph that also falls into this class. Thus we study many graph classes, distinguishing them by the following parameters (see Section 2 for formal definitions of technical terms): • Degree of planarity: A graph can be planar or not. For a planar graph, there are three possibilities: An algorithm can draw the graph with crossings but using the fact that the graph is planar (non-planar drawing, see e.g. [15]), it can draw the graph without crossings (planar drawing), or it can draw the graph without crossings and exactly reflect the fixed planar drawing of the planar graph (plane drawing).
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
3
• Connectivity: Many heuristics are designed originally for graphs that are 2-connected or even 3-connected, and then extended to 1-connected graphs (e.g. [5, 12, 17]). In our study we include 4-connected graphs for the sake of completeness. • Degree of simplicity: Most heuristics consider only simple graphs. However, some lower bounds are easier to obtain by proving a lower bound for a graph with multiedges or loops, and then converting this graph into a simple graph by subdividing edges. We will thus include multigraphs and graphs with loops in our discussion. • Maximum degree: Some heuristics only work on graphs with maximum degree 3 (e.g. [1, 7, 12, 17]). We will thus study both 4-graphs and 3-graphs. In Table 1 we list the (to our knowledge) best upper bounds on the grid-size and the number of bends for simple graphs. We contrast these upper bounds with the lower bounds, which, if given without citation, will be proved in this paper. The paper is outlined as follows: After giving definitions in Section 2, we first prove lower bounds for non-planar drawings in Section 3 and for nonplanar drawings of planar graphs in Section 4. We continue with lower bounds for plane drawings in Section 5. Using the same graphs, but considering many planar drawings, we then obtain lower bounds for planar drawings in Section 6. Some of the more tedious proofs are deferred to the appendix.
2
Definitions
Let G = (V, E) be a graph with n vertices and m edges. G is called a ∆-graph if its maximum degree is at most ∆. By subdividing an edge e we understand that we delete e, add a new vertex (the subdivision vertex), and connect it with the two endpoints of e. G is called 1-connected if for any two vertices there exists a path between them. It is called c-connected, c ≥ 2, if for any c − 1 vertices v1 , . . . , vc−1 the graph remains 1-connected if these vertices are deleted. Menger’s theorem states that a graph is c-connected if and only if for every pair of vertices there exist c vertex-disjoint paths connecting them. The connectivity of a graph G is the maximum number c such that G is c-connected. A ∆-graph has connectivity at most ∆. Edges of the form (v, v) are not necessarily forbidden; such edges are called loops. It is also not necessarily forbidden that two vertices are connected by more than one edge; such edges are called multiple edges. Edges with multiplicity two, three and four are called double edge, triple edge, and quadruple edge, respectively. A graph without loops and multiple edges is called simple. A graph without loops is called a multigraph. We use the expression degree of simplicity as categorizing term for “simple graph”, “multigraph”, and “graph with loops”.
1-connected 2-connected 3-connected 1-connected 2-connected 3-connected
4-graphs 3-graphs
2
Non-planar drawing 2
0.76n area [17] 2n+2 bends [5] Ω(n2 ) area [22] 10 n bends 7 0.76n2 area [17] 2n+2 bends [5] Ω(n2 ) area [22] 5 n bends 3 0.76n2 area [17] 2n+2 bends [5] Ω(n2 ) area [22] 11 n bends 6
O(n log n) area [15] not analyzed Ω(n log n) area [14] 6 n bends 5 O(n log2 n) area [15] not analyzed Ω(n log n) area [14] 10 n bends 7 O(n log2 n) area [15] not analyzed Ω(n log n) area [14] 11 n bends 7
Upper bound Lower bound Upper bound Lower bound Upper bound Lower bound
d n+1 e×d n+1 e-grid [1] 2 2 n + 2 bends [1, 7, 17] 2 2 Ω(n ) area [22] n bends 3 n+1 d 2 e×d n+1 e-grid [1] 2 n + 2 bends [1, 7, 17] 2 2 Ω(n ) area [22] n bends 2 n+1 n+1 d 2 e×d 2 e-grid [1] n + 2 bends [1, 7] 2 Ω(n2 ) area [22] n + 1 bends [19] 2
O(n log2 n) area [15] not analyzed Ω(n log n) area [14] n bends 3 O(n log2 n) area [15] not analyzed Ω(n log n) area [14] n bends 2 2 O(n log n) area [15] not analyzed Ω(n log n) area [14] n + 1 bends [19] 2
( 32 n+1)×( 23 n+1)-grid [3] 4 n+4 bends [3, 12] 3 n ( 3 +1)×( n3 +1)-grid 4 n−2 bends 3
Plane drawing ( 23 n+1)×( 23 n+1)-grid [3] 4 n+4 bends [3, 12] 3 2 ( 3 n+1)×( 32 n+1)-grid 4 n+4 bends 3
n × n-grid [5] 2n+2 bends [5] n × n2 -grid 2 2n−6 bends n × n-grid [5] 2n+2 bends [5] n × n2 -grid 2 2n−6 bends
n × n-grid [5] 2n+2 bends [5] (n−1)×(n−1)-grid 2n−2 bends [21] 6 n × 65 n-grid [2] 5 12 n+2 bends [2] 5 ( 65 n− 11 )×( 65 n− 11 )-grid 5 5 12 22 n− bends 5 5
0.17n2 area [3]
0.17n2 area [3] + 3 bends [3] n ( 3 +1)×( n3 +1)-grid n bends 3 n n × -grid [12] 2 2 n + 1 bends [12] 2 n n × 2 -grid 2 n + 1 bends 2 6 n × 65 n-grid [2] 5 12 n+2 bends [2] 5 ( 23 n+1)×( 32 n+1)-grid 5 n − 1 bends 6
n + 3 bends [3] 3 n ( 6 +1)×( n6 +1)-grid n bends 3 n n × -grid [12] 2 2 n + 1 bends [12] 2 n 1 n 1 ( 4 + 2 )×( 4 + 2 )-grid n bends 2 n n × 2 -grid [12] 2 n + 1 bends [12] 2 ( n4 + 12 )×( n4 + 12 )-grid n + 1 bends [19] 2
n 3
4
Upper bound Lower bound Upper bound Lower bound Upper bound Lower bound
Planar graphs Planar drawing
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
Table 1: Overview of upper and lower bounds for simple graphs. All results without citation are proved in this paper.
Non-planar graphs
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
5
G is called planar if it has a planar drawing, i.e., a drawing in 2D without crossing. A planar drawing of a planar graph defines for every vertex v a circular clockwise ordering of the incident edges of v; the collection of these orderings is called a combinatorial embedding. A planar drawing splits the plane into components called faces; the unbounded component is called the outer-face. A combinatorial embedding of a planar graph defines a planar drawing of it, which is topologically unique except for the choice of the outer-face. We say that a planar graph has a fixed planar drawing if both a combinatorial embedding and an outer-face have been specified. An orthogonal drawing of G is an embedding of G in the two-dimensional rectangular grid. More precisely, every vertex is mapped to a grid-point, i.e., a point with integer coordinates. Every edge is mapped to a path of grid-segments connecting the two endpoints of the edge. A place where the route of an edge changes direction is called a bend. No two vertices may be mapped to the same point. No two edges may use the same grid-segment. No edge may pass through a grid-point of a non-incident vertex. No two bends may coincide. An orthogonal drawing is called planar if no routes of edges intersect. It is called plane if it is planar and reflects the fixed planar drawing of the input graph. To facilitate notation, we use the term non-planar drawing for a drawing that may or may not have crossings. If an orthogonal drawing can be enclosed by a box of width n1 and height n2 we call it a drawing with grid-size n1 × n2 and area n1 · n2 . The width is one less than the number of columns and the height is one less than the number of rows. Earlier, we proved the following theorem. Theorem 1 [4] Let Γ be an orthogonal drawing of a 4-graph G = (V, E) which has b bends, and uses r rows and c columns. Let |V | = n and |E| = m. Then (a) max{r, c} ≤ 12 b + 2n − m, and (b) r + c ≤ b + 2n − m.
3
Non-planar drawings
In this section we study lower bounds for non-planar orthogonal drawings. Specifically, we present new lower bounds on the number of bends. The area is lower-bounded by Ω(n2 ) [22], and we have not succeeded in improving the constant of this lower bound. To prove lower bounds on the number of bends, we describe for each case (depending on connectivity, degree of simplicity, and maximum degree) a class of graphs. These graphs are built by combining many copies of a small graph through subdividing edges, identifying vertices and adding edges. We first introduce these small graphs and study their lower bounds. Then we investigate how subdividing edges affects lower bounds. Finally, we define the graph classes and prove lower bounds.
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
3.1
6
Lower bounds for small graphs
We use the following small graphs: the loop L, the triple edge T , the quadruple edge Q, the complete graph on 4 vertices K4 , the 4-wheel W , the complete graph on 5 vertices K5 , and the octahedron O. See also Figure 1.
Figure 1: From left to right: L, T , Q, K4 , W , K5 , and O. We now prove lower bounds on the number of bends of the small graphs. Most of these lower bounds were known before, but the argument for their proof was “by exhaustively checking cases” [19]. Such an argument is dangerous, for example in the above paper Storer claimed that the graph in his Figure 9 requires 10 bends, but in fact it can be drawn with 8 bends as shown in Figure 2. Thus, we provide a formal (and tedious) proof for each of these graphs, which can be safely skipped on first reading. c a a
b
c
b
Figure 2: The graph by Storer [19], and an orthogonal drawing of it with 8 bends. Lemma 1 The following number of bends is required in any orthogonal drawing: L: 3 bends T : 4 bends Q: 8 bends K4 , W : 4 bends K5 , O: 12 bends Proof: In the following proofs, let n and m be the number of vertices and edges of the graph in question, and let Γ be an arbitrary, but fixed, orthogonal drawing of the graph. Denote by r, c, and b the number of rows, columns, and bends of Γ, respectively. For each graph, we first show a lower bound on r, or on r + c, usually with the following “cut-argument”: Let C be a column, let V≤ (C) be the vertices placed in C or in a column to the left of C, and let V> (C) be the vertices placed to the right of C. Any edge between V≤ (C) and V> (C) must cross the gap to the right of column C. Consequently, if the cut (V≤ (C), V> (C)) contains k edges, then there are at least k rows. Then we obtain a lower bound on b by applying Theorem 1. The individual claims are proved as follows:
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
7
L: The loop encloses at least one box of the grid, hence uses at least two rows and two columns. From Theorem 1(b), it follows that b ≥ r + c+ m− 2n ≥ 2 + 2 + 1 − 2 = 3. T : After possible rotation of Γ, the two vertices are placed in different columns. Let C be the left column containing a vertex. Then the cut (V≤ (C), V> (C)) contains 3 edges. So r ≥ 3, and from Theorem 1(a), it follows that b ≥ 2r + 2m − 4n ≥ 6 + 6 − 8 = 4. Q: After possible rotation of Γ, the two vertices are placed in different columns. Let C be the left column containing a vertex. Then the cut (V≤ (C), V> (C)) contains 4 edges. So r ≥ 4, and from Theorem 1(a), it follows that b ≥ 2r + 2m − 4n ≥ 8 + 8 − 8 = 8. K4 : Let C be the leftmost column containing vertices. If |V≤ (C)| ≥ 3, then there are at least three vertices placed in the column C, so r ≥ 3. If |V≤ (C)| ≤ 2, then there are at least three edges in the cut (V≤ (C), V> (C)), and again r ≥ 3. Applying the same argument to the topmost row containing vertices, we obtain c ≥ 3. By m = 2n−2, it follows from Theorem 1(b) that b ≥ r + c + m − 2n = 3 + 3 − 2 = 4. W : The proof is word by word the same as for K4 . O: Assume first that each column contains at most three vertices. Then, by scanning columns from left to right, we can find a column C such that 2 ≤ |V≤ (C)| ≤ 4. The cut (V≤ (C), V> (C)) contains at least six edges, so r ≥ 6. If there exists a column containing at least four vertices, then each row contains at most three vertices by n = 6. Thus we obtain c ≥ 6 with the same argument as before. Either way, by Theorem 1(a), b ≥ 2 max{r, c}+2m−4n ≥ 12+24−24 = 12. K5 : Since K5 is not planar, Γ has at least one crossing. Replace this crossing with a new vertex. We obtain an orthogonal drawing of some simple graph with six vertices where every vertex has degree 4. This drawing has the same number of bends as Γ. However, there exists only one simple graph with six vertices where every vertex has degree 4, namely, the octahedron. This graph needs 12 bends in any orthogonal drawing, so b ≥ 12. 2
3.2
Subdividing edges
To build large graphs, we subdivide edges of a small graph and then use the resulting vertices of degree 2 to connect many copies of this small graph by identifying vertices or adding edges. Thus, we now must study how subdividing edges affects a lower bound on the number of bends.
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
8
Lemma 2 If graph G needs at least b bends in any orthogonal drawing, and G0 results from subdividing one edge in G, then G0 needs at least b − 1 bends in any orthogonal drawing. Proof: Let Γ0 be an arbitrary orthogonal drawing of G0 , and assume that it has b0 bends. Removing the subdivision vertex, we obtain a drawing Γ of G. This drawing inherits all bends of Γ0 , and it may have one more bend at the point of the removed subdivision vertex. By the lower bound on G therefore b0 + 1 ≥ b, 2 or b0 ≥ b − 1.
3.3
Building large graph classes
In this section we give the definitions of the graph classes for lower bounds. For easier orientation among the excessive number of cases, we use the following classification scheme: The graphs in graph class N [∆, c, α] • have maximum degree ∆, ∆ ∈ {3, 4}, • are c-connected, c ∈ {1, 2, 3, 4}, and • have degree of simplicity α, i.e., they are simple, multigraphs, or may have loops if α = s, m and l, respectively. When talking of one particular graph of class N [∆, c, α] we append a parameter k which relates to the size, i.e., the number of vertices, of the graph. More precisely, the graph consists of k or 2k copies of one of the small graphs defined before. To avoid trivial cases, we will consider only graphs with k ≥ 3. The details of how to build each graph class are given below. To facilitate the description, we use the following notations. A δ-vertex is a vertex of degree δ. If there are k copies of a small graph, then they are numbered 1, . . . , k. If there are 2k copies, then they are numbered (1, 1), . . . , (k, 1), (1, 2), . . . , (k, 2). All additions are modulo k. N [4, 4, s](k): Take k copies of K4 . Connect two 3-vertices of copy i to two 3-vertices of copy i+1, i = 1, . . . , k. N [4, 3, s](k): Take 2k copies of Q. Subdivide three edges in each copy. Identify a 2-vertex of copy (i, 1) with a 2vertex of copy (i, 2), i = 1, . . . , k. Identify a 2-vertex of copy (i, j) with a 2-vertex of copy (i + 1, j), i = 1, . . . , k, j = 1, 2. N [4, 3, m](k): Take 2k copies of Q. Subdivide one edge once and one edge twice in each copy. Identify a 2-vertex of copy (i, 1) with a 2-vertex of copy (i, 2), i = 1, . . . , k. Identify a 2-vertex of copy (i, j) with a 2-vertex of copy (i + 1, j), i = 1, . . . , k, j = 1, 2.
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
9
N [4, 2, s](k): Take k copies of K5 . Subdivide two edges in each copy. Identify a 2-vertex of copy i with a 2-vertex of copy i + 1, i = 1, . . . , k. N [4, 2, m](k): Take k copies of Q. Subdivide two edges in each copy. Identify a 2-vertex of copy i with a 2-vertex of copy i + 1, i = 1, . . . , k. N [4, 2, l](k): Take k copies of L. Connect the vertex of copy i to the vertex of copy i + 1, i = 1, . . . , k. N [4, 1, s](k): Take k copies of K5 . Subdivide one edge in each copy. Connect the 2-vertex of copy i to the 2-vertex of copy i + 1, i = 1, . . . , k − 1. N [4, 1, m](k): Take k copies of Q. Subdivide one edge in each copy. Connect the 2-vertex of copy i to the 2-vertex of copy i + 1, i = 1, . . . , k − 1. N [3, 3, s](k): Take 2k copies of L. Subdivide the edge twice in each copy. Connect a 2-vertex of copy (i, 1) to a 2-vertex of copy (i, 2), i = 1, . . . , k. Connect a 2-vertex of copy (i, j) to a 2-vertex of copy (i + 1, j), i = 1, . . . , k, j = 1, 2. N [3, 2, s](k): Take k copies of T . Subdivide two edges in each copy. Connect a 2-vertex of copy i to a 2-vertex of copy i + 1, i = 1, . . . , k. N [3, 2, m](k): Take k copies of L. Subdivide the edge in each copy. Connect a 2-vertex of copy i to a 2-vertex of copy i + 1, i = 1, . . . , k. N [3, 1, s](k): Take k copies of K4 . Subdivide one edge in each copy. Add k − 2 vertices w2 , . . . , wk−1 . Connect the 2-vertex of copy 1 to w2 . Connect the 2-vertex of copy i to wi , i = 2, . . . , k − 1. Connect the 2-vertex of copy k to wk−1 . (This graph was presented first in [19].) N [3, 1, l](k): Take k copies of L. Add k − 2 vertices w2 , . . . , wk−1 . Connect the 2-vertex of copy 1 to w2 . Connect the 2-vertex of copy i to wi , i = 2, . . . , k − 1. Connect the 2-vertex of copy k to wk−1 . One immediately verifies the claims on the maximum degree and degree of simplicity. The claims on the connectivity will be proved for c = 2, 3, 4 in the appendix.
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
3.4
10
Lower bounds
Theorem 2 There exist lower bounds for the number of bends of non-planar orthogonal drawings as indicated below: Non-planar graphs Maximum degree ∆
Connectivity c
4-graph
4 3 2 1
3-graph
3 2 1
Degree of simplicity α Simple graph Multigraph Graph with loops n bends
n 2
10 7 n bends 5 2 3 n bends 11 6 n bends n 3 bends n 3 2 bends
+ 1 bends [19]
–1 bends 2n bends 7 3 n bends
– – 3n bends 3n bends
– n bends n bends
– – 3 2 n + 3 bends
10 7 n
Proof: For each case of maximum degree ∆, connectivity c and degree of simplicity α, we list in Table 2 the graph class used for the lower bound. (Note that for the cases (4, 1, l) and (3, 1, m) we use 2-connected graphs, which are also 1-connected.) This table, which contains the proof of the lower bound for each case, should be read as follows: For each graph class, we start with some small graph which has, say, nt vertices and needs at least bt bends in any orthogonal drawing by Lemma 1. We do some number d of subdivisions of edges in each copy; the small graph with subdivisions then has nd = nt + d vertices and needs at least bd = bt − d bends by Lemma 2. To build larger classes, we take q copies of the resulting small graph and add na vertices. To connect these copies and vertices, we add edges or identify vertices. Both operations cannot decrease the lower bound on the number of bends. If we identified i vertices per copy, then each copy now contributes ni = nd − 12 i vertices. The total number n of vertices therefore is qni + na , and the lower bound b on the number of bends is qbd . Reformulating the latter in terms of n yields the desired lower bound. 2 Remark: Note that we could have used class N [4, 3, s] to obtain the same lower bound for case (4, 3, m). We did not do this because N [4, 3, m](k) is planar while N [4, 3, s](k) is not; this will be exploited in the next section.
4A
hyphen signifies that no such graphs exist, at least not for n ≥ 5. [19] reported a lower bound of 11 n bends, but his proof is incorrect (see also 6 Figure 2). 6 A similar lower bound was proved by Papakostas and Tollis (private communication). 5 Storer
Graph class
(4, 4, s) (4, 3, s) (4, 3, m) (4, 2, s) (4, 2, m) (4, 2, l) (4, 1, s) (4, 1, m) (4, 1, l) (3, 3, s) (3, 2, s) (3, 2, m) (3, 1, s) (3, 1, m) (3, 1, l)
N [4, 4, s] N [4, 3, s] N [4, 3, m] N [4, 2, s] N [4, 2, m] N [4, 2, l] N [4, 1, s] N [4, 1, m] N [4, 2, l] N [3, 3, s] N [3, 2, s] N [3, 2, m] N [3, 1, s] N [3, 2, m] N [3, 1, l]
K4 Q Q K5 Q L K5 Q L L T L K4 L L
Npl [4, 4, s] Npl [4, 3, s] Npl [4, 2, s] Npl [4, 1, s]
W O O O
4 8 8 12 8 3 12 8 3 3 4 3 4 3 3
0 3 3 2 2 0 1 1 0 2 2 1 1 1 0
4 5 5 7 4 1 6 3 1 3 4 2 5 2 1
4 5 5 10 6 3 11 7 3 1 2 2 3 2 3
k 2k 2k k k k k k k 2k k k k k k
0 0 0 0 0 0 0 0 0 0 0 0 k−2 0 k−2
Final graph n b
0 3 3 2 2 0 0 0 0 0 0 0 0 0 0
4k 7k 7k 6k 3k k 6k 3k k 6k 4k 2k 6k−2 2k 2k−2
4k=n 10k= 10 7 n 10 10k= 7 n 10k= 53 n 6k=2n 3k=3n 11k= 11 6 n 7 7k= 3 n 3k=3n 2k= n3 2k= n2 2k=n 3k= n2 +1 2k=n 3k= 32 n+3
5k 15k 7k 7k
4k = 45 n 18k = 65 n 10k = 10 7 n 11 11k = 7 n
Non-planar drawings of planar graphs 5 4 0 4 4 k 0 0 6 12 3 9 9 2k 0 3 6 12 2 8 10 k 0 2 6 12 1 7 11 k 0 0
4 7 2 7 2
6 3 1 6 3 1 3 4 2 5 2 1 5 15 2
7 7
11
(4, 4, s) (4, 3, s) (4, 2, s) (4, 1, s)
4 2 2 5 2 1 5 2 1 1 2 1 4 1 1
Ident. i ni
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
Table 2: For the proof of Theorem 2 and 3.
Case (∆, c, α)
Non-planar drawings Small graph Subdivide Build nt b t d nd b d q na
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
4
12
Non-planar drawings of planar graphs
In this section we study lower bounds for non-planar drawings of planar graphs. The interest in such drawings arises from the fact that every planar graph can be drawn with O(n log2 n) area if crossings are allowed [15], whereas both nonplanar graphs and planar drawings of planar graphs may require Ω(n2 ) area ([22] and Section 6). The lower bound for the area of non-planar drawings of planar graphs is Ω(n log n) [14]. We did not improve on this lower bound, but study here lower bounds on the number of bends. For the most part, we use the graphs defined in Section 3.3. As can be seen from the drawings, these graphs are planar, with the exception of N [4, c, s](k), c = 1, 2, 3, 4. We now define four graph-classes Npl [4, c, s](k), of c-connected simple planar 4-graphs, using the 4-wheel W and the octahedron O. Npl [4, 4, s](k): Take k copies of W . Connect two 3-vertices of copy i to two 3-vertices of copy i + 1, i = 1, . . . , k. Npl [4, 3, s](k): Take 2k copies of O. Subdivide three edges on one face of each copy. Identify a 2-vertex of copy (i, 1) with a 2-vertex of copy (i, 2), i = 1, . . . , k. Identify a 2vertex of copy (i, j) with a 2-vertex of copy (i + 1, j), i = 1, . . . , k, j = 1, 2. Npl [4, 2, s](k): Take k copies of O. Subdivide two edges on one face of each copy. Identify a 2-vertex of copy i with a 2-vertex of copy i + 1, i = 1, . . . , k. Npl [4, 1, s](k): Take k copies of O. Subdivide one edge of each copy. Connect the 2-vertex of copy i with the 2-vertex of copy i + 1, i = 1, . . . , k − 1. One immediately verifies that these are indeed simple planar 4-graphs. The claims on the connectivity will be proved for c = 2, 3, 4 in the appendix. Theorem 3 There exist lower bounds for the number of bends of non-planar orthogonal drawings of planar graphs as indicated below: Non-planar drawings of planar graphs Maximum degree ∆
Connectivity c
4-graph
4 3 2 1
3-graph
3 2 1
Degree of simplicity α Simple graph Multigraph Graph with loops
n 2
4 5 n bends 6 5 n bends 10 7 n bends 11 7 n bends n 3 bends n 2 bends
+ 1 bends [19]
– bends 2n bends 7 3 n bends
– – 3n bends 3n bends
– n bends n bends
– – 3 2 n + 3 bends
10 7 n
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
13
Proof: For all graphs except the simple 4-graphs, the lower bound is given by the same graph class as in Theorem 2 and has been proved there. For the simple 4-graphs, the proof is done in Table 2, which has to be read as explained in the proof of Theorem 2. 2
5
Plane drawings of planar graphs
In some algorithms for planar orthogonal drawings, e.g. [12, 20], the output planar orthogonal drawing exactly reflects the input planar drawing, i.e., the combinatorial embedding and the outer-face. In this section we prove lower bounds for such plane orthogonal drawings.
5.1
Definition of graph classes
We define new graphs for lower bounds for plane drawings, using the same classification scheme as before after replacing “N ” by “P ”. Thus, P [∆, c, α] is a class of planar c-connected ∆-graphs with degree of simplicity α. We again use a parameter k that relates to the size of the graph: P [∆, c, α](k) consists of k edge-disjoint cycles C1 , . . . , Ck , which are connected to each other by identifying vertices or adding edges. To explain the fixed planar drawing of the graph, we need some terminology. Let e be an edge and let C and C 0 be circles. In a planar drawing, removing the closed Jordan curve defined by C splits the plane into two open regions, one bounded and one unbounded. Edge e is called inside circle C if all interior points of the open Jordan curve representing e are in the bounded open region thus defined by C. In particular, the endpoints of e, but not e itself, may belong to C. Circle C 0 is called inside circle C if all edges of C 0 are inside C. We say that k cycles C1 , . . . , Ck are stacked if Ci is inside Ci+1 , i = 1, . . . , k − 1. We fix the combinatorial embedding and outer-face of P [∆, c, α](k) such that the cycles C1 , . . . , Ck are stacked. To facilitate the notations for the definitions, let an l-cycle be a cycle with l vertices. If Ci is an l-cycle, then denote its vertices as v1i , . . . , vli in clockwise order around the cycle. P [4, 4, s](k): C1 and Ck are 4-cycles. C2 , . . . , Ck−1 are 8-cycles. Identify vertices v11 , v21 , v31 , v41 with vertices v12 , v32 , v52 , v72 . Identify vertices v2i , v4i , v6i , v8i with vertices v1i+1 , v3i+1 , v5i+1 , v7i+1 , i = 2, . . . , k−2. Identify vertices v2k−1 , v4k−1 , v6k−1 , v8k−1 with vertices v1k , v2k , v3k , v4k . We have n = 4k−4 and m = 2n. P [4, 3, s](k): C1 and Ck are 3-cycles. C2 , . . . , Ck−1 are 6-cycles. Identify vertices v11 , v21 , v31 with vertices v12 , v32 , v52 . Identify vertices v2i , v4i , v6i with vertices v1i+1 , v3i+1 , v5i+1 , i = 2, . . . , k−2. Identify vertices v2k−1 , v4k−1 , v6k−1 with vertices v1k , v2k , v3k . We have n = 3k − 3 and m = 2n.
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
14
P [4, 3, m](k): Take a copy of P [4, 3, s](k−2). Subdivide two edges of C1 and add a double edge inside C1 . Subdivide two edges of Ck−2 and add a double edge such that Ck−2 is inside it. We have n = 3k − 5 and m = 2n. P [4, 2, s](k): Take a copy of P [4, 2, m](k) defined below. Subdivide one edge of C1 and one edge of Ck . We have n = 2k and m = 2n − 2. (This graph was presented first in [21].) P [4, 2, m](k): C1 and Ck are 2-cycles. C2 , . . . , Ck−2 are 4-cycles. Identify vertices v11 , v21 with vertices v12 , v32 . Identify vertices v2i , v4i with vertices v1i+1 , v3i+1 , i = 2, . . . , k − 2. Identify vertices v2k−1 , v4k−1 with vertices v1k , v2k . We have n = 2k − 2 and m = 2n. (This graph was presented first in [21].) P [4, 2, l](k): Take a copy of P [4, 2, s](k − 2). Add a loop inside C1 at the 2-vertex of C1 . Add a loop at the 2-vertex of Ck−2 such that Ck−2 is inside it. We have n = 2k − 4 and m = 2n. P [4, 1, m](k): Take a copy of P [4, 1, l](k − 2) defined below. Subdivide C1 twice and add a double edge inside C1 . Subdivide Ck−2 twice and add a double edge such that Ck−2 is inside it. We have n = k + 1 and m = 2n. P [4, 1, l](k): C1 and Ck are 1-cycles. C2 , . . . , Ck−2 are 2-cycles. Identify v11 with vertex v12 . Identify v2i with vertex v1i+1 , i = 2, . . . , k − 2. Identify vertex v2k−1 with v1k . We have n = k − 1 and m = 2n. P [4, 1, s](k): This graph class is defined only for k = 3l. C1 , C4 , . . . , C3l−2 are 3-cycles. C2 , C5 , . . . , C3l−1 are 4-cycles. C3 , C6 , . . . , C3l are 3-cycles. Identify vertices v13i−2 , v33i−2 with vertices v13i−1 , v33i−1 , i = 1, . . . , l. Identify vertices v23i−1 , v43i−1 with vertices v13i , v33i , i = 1, . . . , l. Identify vertex v23i with vertex v23i+1 , i = 1, . . . , l − 1. We have n = 53 k + 1 and m = 2n − 2. P [3, 3, s](k): C1 and Ck are 3-cycles. C2 , . . . , Ck−1 are 6-cycles. Connect vertices v11 , v21 , v31 with vertices v12 , v32 , v52 . Connect vertices v2i , v4i , v6i with vertices v1i+1 , v3i+1 , v5i+1 , i = 2, . . . , k −2. Connect vertices v2k−1 , v4k−1 , v6k−1 with vertices v1k , v2k , v3k . We have n = 6k − 6 and m = 32 n.
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
15
P [3, 2, s](k): Take a copy of P [3, 2, m](k) defined below. Subdivide one edge of C1 and one edge of Ck . We have n = 4k − 2 and m = 32 n − 1. P [3, 2, m](k): C1 and Ck are 2-cycles. C2 , . . . , Ck−2 are 4-cycles. Connect vertices v11 , v21 with vertices v12 , v32 . Connect vertices v2i , v4i with vertices v1i+1 , v3i+1 , i = 2, . . . , k − 2. Connect vertices v2k−1 , v4k−1 with vertices v1k , v2k . We have n = 4k − 4 and m = 32 n. P [3, 1, m](k): Take a copy of P [3, 1, l](k) defined below. Subdivide the edge of C1 and the edge of Ck . We have n = 2k and m = 32 n − 1. P [3, 1, l](k): C1 and Ck are 1-cycles. C2 , . . . , Ck−2 are 2-cycles. Connect v11 with vertex v12 . Connect v2i with vertex v1i+1 , i = 2, . . . , k − 2. Connect vertex v2k−1 with v1k . We have n = 2k − 2 and m = 32 n. P [3, 1, s](k): This graph class is defined only for k = 2l. C1 , . . . , Ck are 3-cycles. Connect vertices v12i−1 , v32i−1 with vertices v12i , v32i , i = 1, . . . , l. Connect vertex v22i with vertex v22i+1 , i = 1, . . . , l − 1. We have n = 3k and m = 32 n − 1. One immediately verifies the claims on planarity, maximum degree and degree of simplicity. The claims on the connectivity will be proved for c = 2, 3, 4 in the appendix.
5.2
Lower bounds
Lemma 3 If an orthogonal planar drawing Γ of a graph with n vertices and m edges contains k stacked cycles, then it has at least 2k rows, 2k columns, and 4k + m − 2n bends. Proof: Let C1 , . . . , Ck be the k stacked cycles. Pick a point p in Γ which is not on a grid-line and inside cycle C1 . When traversing the horizontal ray starting at p and proceeding towards +∞, we must cross all k stacked cycles. Because p is not on a grid-line, the horizontal line through p does not intersect any gridpoints, therefore we must cross at least k edges. To accommodate these edges, there must be at least k columns to the right of p. See Figure 3. Similarly, there must be at least k columns to the left of p, and at least k rows above and k rows below p. This proves the claim on the rows and columns. The claim on the number of bends is then a reformulation of Theorem 1(b). 2
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
16
Ck C2 C1
≥ k edges
Figure 3: Going from inside C1 to outside Ck we cross all stacked cycles. Since the fixed planar drawing of P [∆, c, α](k) contains k stacked cycles, we obtain immediately the following corollary. Corollary 4 For any combination of ∆, c, α, k for which P [∆, c, α](k) is defined, P [∆, c, α](k) needs a (2k − 1) × (2k − 1)-grid and 4k + m − 2n bends in any plane orthogonal drawing. Theorem 4 There exist lower bounds for plane orthogonal drawings as indicated below, with the first entry in each cell being a lower bound on the grid-size, and the second entry being a lower bound on the number of bends: Plane drawings of planar graphs maximum degree ∆
c
4-graph
4
Simple graph
3 2 1 3-graph
3 2 1
Degree of simplicity α Multigraph Graph with loops
( n2 +1)×( n2 +1) n+4 bends 2 ( 3 n+1)×( 23 n+1) 4 3 n+4 bends (n−1)×(n−1) 2n−2 bends [21] 6 11 ( 65 n− 11 5 )×( 5 n− 5 ) 12 22 5 n− 5 bends
– – 2 7 ( 3 n+ 3 )×( 23 n+ 73 ) 10 7 n bends (*) (n+1)×(n+1) 2n+4 bends [21] (2n−3)×(2n−3) 4n−4 bends
– – – – (n+3)×(n+3) 3n bends (*) (2n+1)×(2n+1) 4n+4 bends
( n3 +1)×( n3 +1) n 3 bends (*) n n 2×2 n 2 +1 bends ( 23 n−1)×( 23 n−1) 5 6 n−1 bends
– – n ( 2 +1)×( n2 +1) n bends (*) (n−1)×(n−1) 3 2 n−1 bends
– – – (n+1)×(n+1) 3 2 n+4 bends
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
Graphs P [4, 4, s] P [4, 3, s] P [4, 3, m] P [4, 2, s] P [4, 2, m] P [4, 2, l] P [4, 1, s] P [4, 1, m] P [4, 1, l] P [3, 3, s] P [3, 2, s] P [3, 2, m] P [3, 1, s] P [3, 1, m] P [3, 1, l]
n 4k − 4 3k − 3 3k − 5 2k 2k − 2 2k − 4 5 3k + 1 k+1 k−1 6k − 6 4k − 2 4k − 4 3k 2k 2k − 2
k 1 4n + 1 3n + 1 3n + 1 2n 1 2n + 1 2n + 3 5n −
1 1 5 3
1 2 3 5
n−1 n+1 1 6n + 1 1 1 4n + 2 1 4n + 1 1 3n 1 2n 1 2n + 1
2k − 1 1 2n + 1 2 3n + 1 2 7 3n + 3 n−1 n+1 n+3 6 11 5n − 5 2n − 3 2n + 1 n 3 +1 1 2n 1 2n + 1 2 3n − 1 n−1 n+1
m 2n 2n (*) 2n − 2 2n (*) 2n − 2 2n 2n (*) 3 n 2 −1 (*) 3 n 2 −1 3 2n − 1 3 2n
m − 2n 0 0 (*) −2 0 (*) −2 0 0 (*) − 12 n − 1 (*) − 12 n − 1 − 12 n − 1 − 12 n
17 b n+4 4 3n + 4 (*) 2n − 2 2n + 4 (*) 12 22 5 n− 5 4n − 4 4n + 4 (*) n 2 +1 (*) 5 n 6 −1 3 2n − 1 3 2n + 4
Table 3: For the proof of Theorem 4. Proof: The results marked (*) are identical to the claims of Theorem 3 and have been proved in Theorem 2. For all other cases, the lower bounds follow from reformulating Corollary 4 in terms of the number of vertices. This is done in Table 3. We list for all defined graph classes the number of vertices n and reformulate k in terms of n. This yields the lower bound of 2k − 1 on the width and height by Corollary 4. Then, if needed, we list m relative to n, and m − 2n, which allows us to compute the lower bound of the number of bends b = 4k + m − 2n. 2 Remark: One might think that the lower bound for simple 3-connected 4graphs could be improved from 43 n + 4 bends to 10 7 n by using class N [4, 3, s]. However, this is not true because N [4, 3, s](k) is not planar; we could only use graph Npl [4, 3, s](k), but the lower bound of 65 n bends for this graph is not better than the lower bound of 43 n + 4 shown above.
6
Planar drawings of planar graphs
To the author’s knowledge no research has been done into lower bounds for planar orthogonal drawings when we can choose the combinatorial embedding of the graph. We provide such results here. Our main contribution are lower bounds on the grid-size; we prove lower bounds on the number of bends as well,
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
18
but these are frequently not better than the ones known for non-planar drawings of planar graphs (Theorem 3). The difficulty in proving lower bounds for planar drawings lies in the fact that possible combinatorial embeddings and outer-faces of the graph have to be tested. We deal with this by using graph classes that have only one possible combinatorial embedding, up to renaming of vertices. For 4-connected and 3-connected planar graphs, the combinatorial embedding is unique. For the 2-connected planar graphs without loops defined in Section 5.1, one can show that the combinatorial embedding is also unique up to renaming of vertices. Unfortunately, the combinatorial embedding is not unique for our graph classes that have loops or are not 2-connected. For this reason, we will use 2-connected graphs without loops to obtain lower bounds for 1-connected graphs and graphs with loops. In fact, a weaker property than uniqueness of the combinatorial embedding will suffice for our lower bound argument. This property is detailed in the following lemma. Lemma 5 If ∆, c, α, k is a combination for which P [∆, c, α](k) is defined, and if k ≥ 3, c ≥ 2 and α 6= l, then for any planar drawing of P [∆, c, α](k) there exists some i, 1 ≤ i < k, such that the cycles C1 , . . . , Ci are stacked, and the cycles Ck , Ck−1 , . . . , Ci+1 are stacked. Proof: For c = 2 this will be proved in the appendix. For c ≥ 3 the combinatorial embedding is unique, thus in any planar drawing the outer-face F must be a face in the drawing of Section 5.1. One verifies that there are only three possibilities for F : It can be C1 , it can be Ck , or it can be composed of edges of two cycles Ci and Ci+1 , i ∈ {1, . . . , k − 1} and (for ∆ = 3) edges that were added to connect Ci and Ci+1 . See also Figure 4. In the first case, set i = 1; in the second case, set i = k − 1, and in the third case, use Ci as defined. One verifies the claim. 2 C1
Ck
Ck
C1
Ci C1
Ci+1 Ck
Figure 4: Three possibilities for the outer-face: it can be C1 , it can be Ck , or it can be incident to two cycles Ci and Ci+1 . Shown here is P [4, 3, s](7). To obtain a slightly stronger lower bound, we will use only those graphs P [∆, c, α](k) for which k is odd.
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
19
Lemma 6 If ∆, c, α, k is a combination for which P [∆, c, α](k) is defined, and if k ≥ 3 is odd, c ≥ 2 and α 6= l, then P [∆, c, α](k) needs a k × k-grid and at least 4k + m − 2n − (∆ − 2)c bends in any planar orthogonal drawing. Proof: Let 1 ≤ i < k be such that the cycles C1 , . . . , Ci and Ck , . . . , Ci+1 are stacked (Lemma 5). Let G1 be the graph induced by the vertices in C1 , . . . , Ci and let G2 be the graph induced by the vertices in Ci+1 , . . . , Ck . Ci
Ci
Ci+1
Ci+1
G1 G1
G2
G2
Figure 5: Graph G1 consists of stacked cycles C1 , . . . , Ci and G2 consists of stacked cycles Ck , . . . , Ci+1 . Shown here is P [4, 2, m](9) with i = 5 and P [3, 2, m](7) with i = 4. Let n1 , m1 , n2 , m2 be the number of vertices and edges of G1 and G2 , respectively. Graph G1 has i stacked cycles and hence needs 2i rows, 2i columns and 4i + m1 − 2n1 bends by Lemma 3. Graph G2 has k − i stacked cycles and hence needs 2(k − i) rows, 2(k − i) columns and 4(k − i) + m2 − 2n2 bends by Lemma 3. For the claim on the grid-size, observe that max{i, k − i} ≥ d k2 e = k+1 2 since k is odd, so at least one of G1 and G2 needs k + 1 rows and k + 1 columns, and thus width and height k. For the claim on the number of bends, we distinguish by the maximum degree ∆. If ∆ = 4, then Ci and Ci+1 were connected by identifying at most c vertices, so n1 + n2 ≤ n + c, m1 + m2 = m, and the number of bends is at least 4i + m1 − 2n1 + 4(k − i) + m2 − 2n2 ≥ 4k + m − 2n − 2c = 4k + m − 2n − (∆ − 2)c. If ∆ = 3, then Ci and Ci+1 were connected by adding c edges, so n1 + n2 = n and m1 + m2 = m − c, and the number of bends is at least 4i + m1 − 2n1 + 4(k − i) + m2 − 2n2 = 4k + m − c − 2n = 4k + m − 2n − (∆ − 2)c. Either way, the second claim follows.
2
Theorem 5 There exist lower bounds for plane orthogonal drawings as indicated below, with the first entry in each cell being a lower bound on the grid-size, and the second entry being a lower bound on the number of bends:
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
20
Planar drawings of planar graphs Maximum degree ∆ 4-graph
c 4 3 2 1
3-graph
3 2 1
Simple graph ( n4 +1)×( n4 +1) n − 4 bends n ( 3 +1)×( n3 +1) 4 3 n − 2 bends n n 2×2 2n − 6 bends n n 2×2 2n − 6 bends
Degree of simplicity Multigraph – – n 5 ( 3 + 3 )×( n3 + 53 ) 10 7 n bends (*) ( n2 +1)×( n2 +1) 2n bends ( n2 +1)×( n2 +1) 7 3 n bends (*)
α Graph with loops – – – – ( n2 +1)×( n2 +1) 3n bends (*) ( n2 +1)×( n2 +1) 3n bends (*)
( n6 +1)×( n6 +1) n 3 bends (*) n 1 ( 4 + 2 )×( n4 + 12 ) n 2 bends (*) n 1 ( 4 + 2 )×( n4 + 12 ) n 2 + 1 bends (*)
– – ( n4 +1)×( n4 +1) n+1 bends (*) ( n4 +1)×( n4 +1) n bends (*)
– – – – ( n4 +1)×( n4 +1) 3 2 n+3 bends (*)
Proof: The results marked (*) are identical to the claims of Theorem 3 and have been proved in Theorem 2. For all other cases, the lower bounds follow from reformulating Lemma 6 for an appropriate graph class in terms of the number of vertices. For each case of maximum degree ∆, connectivity c and degree of simplicity α, we list in Table 4 the used graph class P [∆0 , c0 , α0 ](k). For each graph class P [∆0 , c0 , α0 ](k), we list k, which is the lower bound on the width and height by Lemma 6, and which we computed relative to n already in Table 3. Where needed, we then compute 4k and m − 2n; the latter is again taken from the proof of Theorem 4. Finally we compute (∆0 − 2)c0 ; note that here we have to take the parameters of the graph class used for the lower bound, not the parameters of the case under consideration. Combining these values, we get b = 4k + m − 2n − (∆0 − 2)c0 , which is the lower bound on the number of bends by Lemma 6. 2
7
Remarks and open problems
In this paper we studied lower bounds on the grid-size and the number of bends for orthogonal drawings. We provided lower bounds for various graph classes, depending on degree of planarity, maximum degree, connectivity, and degree of simplicity. In most cases, we gave lower bounds for the first time or considerably improved previous ones. Not for all graph classes do there exist specialized algorithms, thus not all lower bounds can be compared to upper bounds. As far as algorithms do exist, the upper bounds and lower bounds are generally very close for plane drawings
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
Case (∆, c, α) (4, 4, s) (4, 3, s) (4, 3, m) (4, 2, s) (4, 2, m) (4, 2, l) (4, 1, s) (4, 1, m) (4, 1, l) (3, 3, s) (3, 2, s) (3, 2, m) (3, 1, s) (3, 1, m) (3, 1, l)
Graph class P [4, 4, s] P [4, 3, s] P [4, 3, m] P [4, 2, s] P [4, 2, m] P [4, 2, m] P [4, 2, s] P [4, 2, m] P [4, 2, m] P [3, 3, s] P [3, 2, s] P [3, 2, m] P [3, 2, s] P [3, 2, m] P [3, 2, m]
Grid-size k 1 4n + 1 1 3n + 1 1 5 3n + 3 1 2n 1 n 2 +1 1 2n + 1 1 2n 1 2n + 1 1 2n + 1 1 6n + 1 1 1 4n + 2 1 4n + 1 1 1 4n + 2 1 4n + 1 1 4n + 1
4k n+4 4 3n + 4 (*) 2n 2n + 4 (*) 2n (*) (*) (*) (*) (*) (*) (*) (*)
Bends m − 2n (∆0 −2)c0 0 8 0 6 (*) (*) −2 4 0 4 (*) (*) −2 4 (*) (*) (*) (*) (*) (*) (*) (*) (*) (*) (*) (*) (*) (*) (*) (*)
21
b n−4 4 3n − 2 (*) 2n − 6 2n (*) 2n − 6 (*) (*) (*) (*) (*) (*) (*) (*)
Table 4: For the proof of Theorem 5. (with the exception mentioned below). For planar drawings, the upper and lower bounds are close with respect to the number of bends, but do not match with respect to the grid-size. Our conjecture is here that the upper bounds should be improved, as most algorithms do not change the embedding of the planar graphs, or not by much. Finally, much work remains to be done for non-planar drawings, in particular with respect to improving the lower bound on the area. Some remaining open problems are the following: • For which classes can the lower bounds be improved? In particular, are there better lower bounds for planar drawings of 1-connected graphs? Are there better lower bounds on the area of non-planar drawings? • We verified that the presented graph classes indeed have an orthogonal drawing which matches the lower bounds, up to a small additive constant, with two exceptions: – We did not find a drawing of N [4, 4, s](k) with less than 32 n bends, or a drawing of Npl [4, 4, s](k) with less than 65 n bends, and conjecture that these numbers are the correct lower bound on the number of bends. How can this be shown?
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
22
– The lower bound on the grid-size for planar orthogonal drawings is computed by taking the maximum of the two subgraphs defined by the two sets of stacked cycles. However, this disregards that both subgraphs need grid-space. Intuitively, one would think that if one subgraph needs 2i rows and columns, and the other subgraph needs 2k − 2i rows and columns, then, to place the drawings next to each other, one needs at least 2k rows or columns, thus yielding a lower bound of roughly a k × 2k-grid. This agrees with our experience of trying to draw the planar graphs while changing the outer-face. However, to prove this lower bound, one would have to show that each subgraph “almost completely” fills its grid in any drawing. What is the appropriate definition of “almost completely”, and how can this be shown? • No algorithms are known that use the fact that a graph is 4-connected. No algorithms are known for non-planar 3-connected graphs. Certainly, drawings of such graphs can be obtained by applying an algorithm for graphs of lower connectivity, but could the upper bounds be improved with specialized algorithms for graphs of high connectivity? • Are there better upper bounds for plane drawings of 1-connected 3-graphs? The algorithm by Kant [12] does not work, as it may change the combinatorial embedding. (This can be seen already from the fact that Kant’s algorithm achieves n2 + 1 bends, while the lower bound for plane drawings of 3-graphs is 56 n − 1 bends.) The cited upper bound results from an algorithm for 4-graphs [2], and can thus likely be improved. • The algorithm by Leiserson [15] creates small non-planar drawings of planar graphs, but has not been analyzed with respect to the constants involved in the area, and with respect to the number of bends. Is there an algorithm that draws every planar graph in O(n log2 n) area (preferably with small constant) and with at most 11 7 n bends?
References [1] T. Biedl. Improved orthogonal drawings of 3-graphs. In 8th Can. Conf. Comp. Geometry, volume 5 of International Informatics Series, pages 295–299. Carleton University Press, 1996. [2] T. Biedl. Optimal orthogonal drawings of connected plane graphs. In 8th Can. Conf. Comp. Geometry, volume 5 of International Informatics Series, pages 306– 311. Carleton University Press, 1996. [3] T. Biedl. Optimal orthogonal drawings of triconnected plane graphs. In R. Karlsson and A. Lingas, editors, 5th Scandinavian Workshop on Algorithms Theory, volume 1095 of Lecture Notes in Computer Science, pages 333–344. SpringerVerlag, 1996. [4] T. Biedl. Relating bends and size in orthogonal graph drawings. Information Processing Letters, 65(2):111–115, 1998.
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
23
[5] T. Biedl and G. Kant. A better heuristic for orthogonal graph drawings. Computational Geometry: Theory and Applications, 9:159–180, 1998. [6] T. Biedl and M. Kaufmann. Area-efficient static and incremental graph drawings. In 5th European Symposium on Algorithms, volume 1284 of Lecture Notes in Computer Science, pages 37–52. Springer-Verlag, 1997. [7] T. Calamoneri and R. Petreschi. An efficient orthogonal grid drawing algorithm for cubic graphs. In 1st Intl. Conference Computing and Combinatorics, volume 959 of Lecture Notes in Computer Science, pages 31–40. Springer-Verlag, 1995. [8] G. Di Battista, P. Eades, R. Tamassia, and I. Tollis. Graph Drawing: Algorithms for Geometric Representations of Graphs. Prentice-Hall, 1998. [9] M. Formann and F. Wagner. The VLSI layout problem in various embedding models. In Graph-theoretic Concepts in Computer Science: International Workshop WG, volume 484 of Lecture Notes in Computer Science, pages 130–139. Springer-Verlag, 1991. [10] A. Garg and R. Tamassia. On the computational complexity of upward and rectilinear planarity testing. In R. Tamassia and I. Tollis, editors. DIMACS International Workshop, Graph Drawing 94, volume 894 of Lecture Notes in Computer Science, pages 286–297. Springer-Verlag, 1995. [11] A. Garg and R. Tamassia. A new minimum cost flow algorithm with applications to graph drawing. In S. North, editor. Symposium on Graph Drawing 96, volume 1190 of Lecture Notes in Computer Science, pages 201–216. Springer-Verlag, 1997. [12] G. Kant. Drawing planar graphs using the canonical ordering. Algorithmica, 16:4–32, 1996. [13] M. Kramer and J. van Leeuwen. The complexity of wire routing and finding minimum area layouts for arbitrary VLSI circuits. In F. Preparata, editor, Advances in Computing Research, volume 2: VLSI Theory, pages 129–146. JAI Press, Reading, MA, 1984. [14] F.T. Leighton. New lower bound techniques for VLSI. Math. Systems Theory, 17:47–70, 1984. [15] C. Leiserson. Area-efficient graph layouts (for VLSI). In 21st IEEE Symposium on Foundations of Computer Science, pages 270–281, 1980. [16] T. Lengauer. Combinatorial Algorithms for Integrated Circuit Layout. Teubner/Wiley & Sons, Stuttgart/Chicester, 1990. [17] A. Papakostas and I. Tollis. Algorithms for area-efficient orthogonal drawings. Computational Geometry: Theory and Applications, 9:83–110, 1998. [18] Md. S. Rahman, S. Nakano, and T. Nishizeki. A linear algorithm for bend-optimal orthogonal drawings of triconnected cubic plane graphs. To appear in J. Graph Algorithms Appl. A preliminary version can be found in G. DiBattista, editor. Symposium on Graph Drawing 97, volume 1353 of Lecture Notes in Computer Science, pages 99–110. Springer-Verlag, 1998. [19] J. Storer. On minimal node-cost planar embeddings. Networks, pages 181–212, 1984. [20] R. Tamassia. On embedding a graph in the grid with the minimum number of bends. SIAM J. Computing, 16(3):421–444, 1987. [21] R. Tamassia, I. Tollis, and J. Vitter. Lower bounds for planar orthogonal drawings. Information Processing Letters, 39:35–40, 1991. [22] L. Valiant. Universality considerations in VLSI circuits. IEEE Trans. on Computers, C-30(2):135–140, 1981.
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
A
24
Connectivity-proofs
We now prove the claims on the connectivity for c = 2, 3, 4. To limit the excessive number of cases, we restrict the attention to the simple graphs, and leave the rest to the reader. We use the following notations: Two paths P1 and P2 will be called fully vertex-disjoint if no vertex belongs to both P1 and P2 , and weakly vertex-disjoint if P1 and P2 may begin or end at the same vertex, but are otherwise vertexdisjoint.
A.1 A.1.1
Graphs N[∆, c, α](k) and Npl [∆, c, α](k) 4-connectivity
Lemma 7 N [4, 4, s](k) is 4-connected for all k ≥ 2. Proof: Recall that N [4, 4, s](k) was built using k copies K41 , . . . , K4k of K4 . Let the four vertices of K4i be v1i , v2i , v3i and v4i , named such that the added edges are (v2i , v1i+1 ) and (v4i , v3i+1 ), i = 1, . . . , k (addition is modulo k). See Figure 6(a). Let w1 and w2 be two arbitrary vertices of N [4, 4, s](k). We will show that there are four weakly vertex-disjoint paths from w1 to w2 ; this proves the claim by Menger’s theorem. By symmetry we may assume that w1 belongs to K41 . Let l be such that w2 belongs to K4l . If l > 1, then define the following four fully vertex-disjoint paths connecting the four vertices of K41 with the four vertices of K4l (see Figure 6(a)): • v21 − v12 − v22 − v13 − . . . − v2l−1 − v1l , • v41 − v32 − v42 − v33 − . . . − v4l−1 − v3l , • v11 − v2k − v1k − v2k−1 − . . . − v1l+1 − v2l , and • v31 − v4k − v3k − v4k−1 − . . . − v3l+1 − v4l ,
v11 v21
v1l
v2l
v11 v21
v31 v41
v3l v4l
v31 v41
(a)
(b)
Figure 6: N [4, 4, s](k) is 4-connected: (a) Four fully vertex-disjoint paths can be found between K41 and K4l , and (b) N [4, 4, s](k), k ≥ 2 contains a subdivision of K5 . For each of these paths, vertex w1 either is its endpoint in K41 , or is incident to its endpoint in K41 , and w2 either is its endpoint in K4l or incident to the
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
25
endpoint in K4l . Thus, the four paths can be completed to four weakly vertexdisjoint paths connecting w1 and w2 . If l = 1, then for k ≥ 2 N [4, 4, s](k) contains a subdivision of K5 such that each vertex in K11 is mapped to a vertex of K5 . See Figure 6(b). Four weakly vertex-disjoint paths exist between any two vertices in a K5 , and therefore also 2 between any two vertices in K41 . Lemma 8 Npl [4, 4, s](k) is 4-connected for k ≥ 2. Proof: The proof the same as the proof of the above lemma, except that the 4-wheel W plays the role of K4 and the octahedron O plays the role of K5 . Recall that Npl [4, 4, s](k) was built using k copies W 1 , . . . , W k of W . Let the five vertices of W i be v1i , . . . , v5i , named such that the added edges are (v2i , v1i+1 ) and (v4i , v3i+1 ), i = 1, . . . , k (addition is modulo k). See Figure 7(a). Let w1 and w2 be two arbitrary vertices of Npl [4, 4, s](k). We will show that there are four weakly vertex-disjoint paths from w1 to w2 ; this proves the claim by Menger’s theorem. By symmetry we may assume that w1 belongs to W 1 . Let l be such that w2 belongs to W l . If l > 1, then define the same four fully vertex-disjoint paths between W 1 and W l as in the proof of Lemma 7; see also Figure 7. Every vertex in W can be connected to the four vertices of degree 3 with four weakly vertex-disjoint paths. Thus, the four paths above can be completed to four weakly vertexdisjoint paths connecting w1 and w2 . If l = 1, then for k ≥ 2 Npl [4, 4, s](k) contains a subdivision of the octahedron O such that every vertex of W 1 is mapped to a vertex of O. See Figure 7(b). Because the octahedron is a triangulated planar graph without a separating triangle, it is 4-connected. Thus four weakly vertex-disjoint paths exist between any two vertices in an octahedron, and therefore also between any two vertices 2 in W 1 .
v11 v21
v1l
v2l
v11 v21
v31 v41
v3l v4l
v31 v41
v15
(a)
(b)
Figure 7: Npl [4, 4, s](k) is 4-connected: (a) Four vertex-disjoint paths can be found between W 1 and W l , and (b) Npl [4, 4, s](k), k ≥ 2 contains a subdivision of the octahedron.
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998) A.1.2
26
3-connectivity
Lemma 9 N [4, 3, s](k) is 3-connected for k ≥ 3. Proof: In Figure 8(a) we show the k-prism Pk which has 2k vertices. This graph is 3-connected for k ≥ 3, because it is the graph of a convex polyhedron (see also Figure 10). N [4, 3, s](k) can be derived from Pk as follows: Subdivide all edges of Pk and replace each original vertex with a quadruple edge with three edges subdivided.
p1,1
p1,2
p1,3
p1,4
p2,1
p2,2
p2,3
p2,4
(a)
(b)
(c)
Figure 8: (a) The k-prism (k = 4 in this example). (b) By subdividing the edges of a k-prism, and (c) substituting a subdivided quadruple edge for each vertex of the k-prism, we obtain N [4, 3, s](k). This graph contains a subdivision of the k-prism. Let w1 and w2 be two arbitrary vertices of N [4, 3, s](k). We will show that there are three weakly vertex-disjoint paths from w1 to w2 ; this proves the claim by Menger’s theorem. Let pi,j be the vertex in the ith row and jth column of Pk as shown in Figure 8(a). Let Qi,j be the subdivided quadruple edge that replaces pi,j in N [4, 3, s](k). Assume first that w1 and w2 belong to different copies of the subdivided quadruple edge, say w1 belongs to Qi1 ,j1 and w2 belongs to Qi2 ,j2 . There are three weakly vertex-disjoint paths from pi1 ,j1 to pi2 ,j2 in Pk because Pk is 3connected. These paths can be transformed to three fully vertex-disjoint paths in N [4, 3, s](k) between the three subdivision vertices of Qi1 ,j1 and the three subdivision vertices of Qi2 ,j2 , because N [4, 3, s](k) contains a subdivision of the k-prism (see Figure 8(c) and Figure 9). From every vertex in Qi,j we can find three weakly vertex-disjoint paths to the three subdivision-vertices of Qi,j , therefore we can complete the paths to three weakly vertex-disjoint paths connecting w1 and w2 . Now assume that w1 and w2 belong to the same copy of the subdivided quadruple edge. If one of w1 or w2 is a subdivision vertex, then it also belongs to some other copy of a subdivided quadruple edge and we are done by the above case. So w1 and w2 are the original vertices of the quadruple edge, and hence connected by three (actually, four) weakly vertex-disjoint paths within the quadruple edge. 2
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
27
Figure 9: For any two vertices, we can find three weakly vertex-disjoint paths in the k-prism, and therefore also three fully vertex-disjoint paths in N [4, 3, s](k). The proof that Npl [4, 3, s](k) is 3-connected for k ≥ 2 is identical to the above proof, except that octahedron replaces the quadruple edge. We leave the details to the reader. Lemma 10 N [3, 3, s](k) is 3-connected for k ≥ 3. Proof: In Figure 10 we show a polyhedron, the graph of which is the k-prism. Cutting off each corner of this polyhedron, we obtain a polyhedron the graph of which is N [3, 3, s](k), so this graph is triconnected. 2
Figure 10: By cutting off the corners of the k-prism, we obtain the polyhedron of N [3, 3, s](k). A.1.3
2-connectivity
Lemma 11 N [4, 2, s](k) , Npl [4, 2, s](k), and N [3, 2, s](k) are 2-connected for k ≥ 2. Proof: As shown in Figure 11, these graphs are Hamiltonian, i.e., they have a simple cycle with n vertices. Any Hamiltonian graph is 2-connected. 2
Figure 11: N [4, 2, s](k), Npl [4, 2, s](k), and N [3, 2, s](k) are Hamiltonian.
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
A.2
28
Graphs P [∆, c, α](k)
Lemma 12 P [4, c, s](k), c = 3, 4 is c-connected for k ≥ 3. Proof: Recall that P [4, c, s](k), c = 3, 4 consists of k stacked cycles C1 , . . . , Ck and that vertex vjp is the jth vertex in clockwise order of cycle Ci . As a first step, define a path connecting vj1 with vjk , j = 1, . . . , c as k−2 k−1 k−1 2 2 3 3 4 − v2j =v2j−1 − v2j =v2j−1 − . . . v2j =v2j−1 − v2j =vjk . vj1 =v2j−1
See also Figure 12. These c fully vertex-disjoint paths will be called spirals.
Figure 12: The spirals of P [4, 4, s](6) and P [4, 3, s](5). Next, we show that for any vertex w and any spiral S that does not contain w, there are four weakly vertex-disjoint paths from w to a vertex in S. Let w belong to cycle Ci ; since every vertex belongs to two cycles and by k ≥ 3 we can choose i such that 1 < i < k. Two neighbors of w are on Ci−1 , thus we can find two weakly vertex-disjoint paths from w to a vertex in S ∩ Ci−1 using edges of Ci−1 . Two neighbors of w are on Ci+1 , thus we can find two weakly vertex-disjoint paths from w to a vertex in S ∩ Ci+1 using edges of Ci+1 . See Figure 13.
w w S
S
Figure 13: Any vertex w not in S has four weakly vertex-disjoint paths to a vertex in S. Let w1 , . . . , wc−1 be c − 1 arbitrary vertices of P [4, c, s](k). We will show that the graph that results from removing these vertices is connected, hence P [4, c, s](k) is c-connected.
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
29
Since c − 1 vertices are removed, but there are c spirals, at least one spiral, say S, remains intact. Let w be an arbitrary vertex 6= w1 , . . . , wc−1 . Then either w ∈ S, or there were four weakly vertex-disjoint paths from w to a vertex in S in P [4, c, s](k). By c ≤ 4, and because no vertex in S is removed, one of these paths remains intact after removing w1 , . . . , wc−1 , so w is connected to a vertex in S. Thus, all vertices in the remaining graph are either in S, or connected to S, and S itself is connected, so the remaining graph is connected. 2 Lemma 13 P [3, 3, s](k) is 3-connected for k ≥ 2. Proof: The proof is the same as in Lemma 12 with two exceptions: (a) The spirals are defined differently, because Ci and Ci+1 are now connected by added edges rather than identified vertices. (b) For any vertex w and any spiral S with w 6∈ S, there are only three weakly vertex-disjoint paths from w to vertices in S. These paths use the cycle Ci containing w, and either Ci+1 or Ci−1 (whichever one contains a neighbor of w). See Figure 14. 2
w
S Figure 14: The new definition of spirals, and the three vertex-disjoint paths from w to vertices in spiral S. Lemma 14 P [4, 2, s](k) and P [3, 2, s](k) are 2-connected for k ≥ 2. Proof: As shown in Figure 15, these graphs are Hamiltonian. Any Hamiltonian graph is 2-connected. 2
Figure 15: P [4, 2, s](k) and P [3, 2, s](k) are Hamiltonian.
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
B
30
Many stacked cycles
In this section, we prove Lemma 5 for the case c = 2, i.e., we prove that in any planar drawing of P [∆, 2, α](k), α 6= l, k ≥ 3, there exists an i, 1 ≤ i < k such that the cycles C1 , . . . , Ci and the cycles Ck , . . . , Ci+1 are stacked. We do this in detail for P [4, 2, m](k), k ≥ 3, and then sketch the proof for the other graph classes. Recall that P [4, 2, m](k) consists of k cycles C1 , . . . , Ck , where C1 and Ck have length 2 while all other cycles have length 4. In the original planar drawing, these cycles were stacked, i.e., all edges of Ci were inside Ci+1 , i = 1, . . . , k − 1. Let from now on an arbitrary planar drawing of P [4, 2, m](k) be fixed. We will use the notion of outside: An edge is outside a cycle C if it is not an edge of C and not inside C. A cycle C 0 is outside a cycle C if all edges of C 0 are outside C. Claim 1 For 1 ≤ i < k, Ci is either inside or outside Ci+1 . Proof: Assume to the contrary that there exists an i such that some edges of Ci are inside Ci+1 and some are outside Ci+1 . By k ≥ 3, we have i > 1 or i + 1 < k. We assume the former, the other case is proved similarly using cycle Ci+2 . So assume i > 1, thus Ci is a 4-cycle with vertices v1i , v2i , v3i , v4i ; vertices v2i and v4i also belong to Ci+1 . Because we have a planar drawing, and some edges of Ci are inside and some are outside Ci+1 , one vertex of Ci which is not in Ci+1 , say v1i , must be inside Ci+1 , and the other such vertex v3i must be outside Ci+1 . By i > 1, vertices v1i and v3i both belong to Ci−1 and are thus connected with a path P using only edges of Ci−1 . This path thus leads from inside Ci+1 (at v1i ) to outside Ci+1 (at v3i ). Because Ci+1 and Ci−1 are vertex-disjoint, this path must cross Ci+1 at an edge, a contradiction to planarity. See Figure 16(a). 2 Claim 2 For 1 < i < k, either Ci+1 or of Ci−1 must be inside Ci . Proof: Let v1i , . . . , v4i be the four vertices of Ci . Assume that Ci+1 and Ci−1 are both not inside Ci , so they are both outside Ci by Claim 1. In the induced planar drawing of the subgraph consisting of Ci , Ci−1 and Ci+1 , cycle Ci then is a face. Add an extra vertex v5 inside this face and connect it to the vertices of Ci . Thus, using edges of the three circles, we obtain a planar drawing of K5 , a contradiction. See Figure 16(b). 2 Now we are ready to prove the main claim for P [4, 2, m](k), k ≥ 3. Lemma 15 In any planar drawing of P [4, 2, m](k), k ≥ 3, there exists an i, 1 ≤ i < k, such that the cycles C1 , . . . , Ci are stacked, and the cycles Ck , Ck−1 , . . . , Ci+1 are stacked. Proof: Let i be the smallest integer for which not all edges of Ci are inside Ci+1 ; i = k − 1 if no such integer exists. Thus, the cycles C1 , . . . , Ci are stacked.
T. Biedl., New Lower Bounds, JGAA, 2(7) 1–31 (1998)
31
Ci v3i v2i
Ci+1
?
v2i
v3i
v5
P Ci
v1i
v1i
v4i v4i (a)
part of Ci−1
part of Ci+1 (b)
Figure 16: (a) Edges of Ci cannot be both inside Ci+1 and outside Ci+1 , otherwise cycle Ci−1 would cause a crossing. (b) One of Ci−1 and Ci+1 must be inside Ci , otherwise there would be a planar drawing of a K5 . If i = k − 1 then nothing is left to prove. If i < k − 1, then not all edges of Ci are inside Ci+1 , so Ci is not inside Ci+1 , so by Claim 1 Ci is outside Ci+1 . By Claim 2, therefore Ci+2 must be inside Ci+1 , which means that Ci+1 is outside Ci+2 . Applying induction, one shows that for j = i + 1, . . . , k − 1, Cj is outside 2 Cj+1 ; thus the cycles Ck , . . . , Ci+1 are stacked. Lemma 16 In any planar drawing of P [3, 2, m](k), k ≥ 3, there exists an i, 1 ≤ i < k, such that the cycles C1 , . . . , Ci are stacked, and the cycles Ck , Ck−1 , . . . , Ci+1 are stacked. Proof: The proof is similar to the one of the previous lemma; we will only sketch an outline here. Claim 1 holds by planarity because Ci and Ci+1 are vertex-disjoint. Claim 2 holds because otherwise we could again construct a planar drawing of K5 . Exactly as in the proof of Lemma 15 we can thus find the integer i. 2 Lemma 17 In any planar drawing of P [4, 2, s](k) and P [3, 2, s](k), k ≥ 3, there exists an i, 1 ≤ i < k, such that the cycles C1 , . . . , Ci are stacked, and the cycles Ck , Ck−1 , . . . , Ci+1 are stacked. Proof: These simple graphs are obtained by subdividing two edges of the corresponding multigraph. For any planar drawing of the simple graph, we can remove the subdivision vertices and obtain a planar drawing of the multigraph; the claim thus holds by the above lemmas. 2
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 2, no. 8, pp. 1–21 (1998)
Rectangle-visibility Layouts of Unions and Products of Trees Alice M. Dean Department of Mathematics and Computer Science Skidmore College http://www.skidmore.edu/∼adean
[email protected]
Joan P. Hutchinson Department of Mathematics and Computer Science Macalester College http://www.macalester.edu/∼hutchinson/
[email protected] Abstract The paper considers representations of unions and products of trees as rectangle-visibility graphs (abbreviated RVGs), i.e., graphs whose vertices are rectangles in the plane, with adjacency determined by horizontal and vertical visibility. Our main results are that the union of any tree (or forest) with a depth-1 tree is an RVG, and that the union of two depth-2 trees and the union of a depth-3 tree with a matching are subgraphs of RVGs. We also show that the cartesian product of two forests is an RVG.
Communicated by J. S. B. Mitchell: submitted January 1998; revised September 1998.
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
1
2
Introduction
In this paper we study aspects of the question of how to represent a graph in the plane as a rectangle-visibility graph (RVG for short). In such a representation the vertices are drawn as rectangles with horizontal and vertical sides, and two vertices are adjacent if and only if their rectangles can be connected by a horizontal or vertical band of positive width that intersects no other rectangle. We call such a representation an RVG layout of the graph. Shermer [11] has shown that it is NP-complete to determine if a graph is an RVG, and so it is of interest to determine classes of graphs that are and are not RVGs. There is now a considerable body of research on RVGs; for results and applications see [5, 6, 3, 4, 2] and others. The focus of this paper is those graphs whose edges can be partitioned into particular types of trees (or forests); we say then that the graph is the union of these trees. An RVG is seen to be the union of two planar graphs (i.e., has thickness at most two) by considering the vertical and horizontal edges in its layout, and so the union of two trees is potentially an RVG. In addition to being planar, a tree has a natural representation as a bar-visibility graph (or BVG), in which each vertex is represented by a horizontal bar, and two bars are adjacent if they can be connected by a vertical band of positive width that intersects no other bar; BVGs are well understood and can be recognized in polynomial time [12, 13]. The horizontal and vertical edges of an RVG decompose it into a union of two BVGs . This leads to the question of when a union of two BVGs is an RVG; our question is when the union of two trees is an RVG. The union of two trees has at most 2n − 2 edges, when the union has n vertices, and this edge-bound is well below the bound of 6n − 20 edges for general RVGs [5, 6]; however, in the same papers it is shown that for each n ≥ 9 and m ≥ 35 there is a thickness-2 graph with n vertices and m edges that is not an RVG. The union of two trees has clique number at most 4, and it is possible to lay out K8 as an RVG; however, again it is not hard to construct graphs with clique number 4 and at most 2n − 2 edges that are not RVGs. Since a planar graph is an RVG [13] and has arboricity at most 3 [9] (i.e., it is the union of three or fewer forests), one might hope that a union of two trees might be “nearly planar,” and thus be an RVG. In [10] it is shown that a union of three trees can have thickness greater than 2, and more recently Bjorling-Sachs and Shermer [1] have constructed an example showing that the union of two trees needn’t be an RVG. In [2] certain types of unions of trees, as well as certain classes of k-trees, are shown to be RVGs. Here we look at classes of tree-unions that are described primarily by the depth of one or both of the component trees, i.e., by the maximum distance from vertex to root in each tree. For instance, the example of [10] shows that the union of three depth-2 trees need not have thickness 2. Our main results are that the union of any tree (or forest) with a depth-1 tree is an RVG, and that the union of two depth-2 trees and the union of a depth-3 tree with a matching are subgraphs of RVGs. We also show that the cartesian product of two forests is an RVG.
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
2
3
Background and definitions
Throughout the paper we use terminology established in [12, 13] for bar-visibility graphs, and in [3, 4, 2] and others for rectangle-visibility graphs. We call a graph G a bar-visibility graph (BVG for short) if its vertices can be represented by closed horizontal line segments in the plane, nonintersecting except possibly at endpoints, in such a way that two vertices are adjacent if and only if there is a vertical visibility band joining the corresponding segments. By a visibility band we mean a nondegenerate rectangle, with opposite sides subsets of the two segments, and intersecting no other segments. Such a collection of segments is called a BVG layout of G. BVGs are easily seen to be planar graphs and have been characterized as those planar graphs having a planar embedding with all cut-points lying on a common face [12, 13]. It is also easy to see that any tree (or forest) is a BVG; in a standard tree layout, choose a root for the tree and represent it by a horizontal line segment, and represent each remaining vertex as a segment lying below the segment representing its parent; for forests put BVG layouts for the component trees side by side. A graph G is called a rectangle-visibility graph (RVG for short) if its vertices can be represented by closed rectangles in the plane that have horizontal and vertical sides and are pairwise disjoint except possibly along their boundaries, in such a way that two vertices are adjacent if and only if there is a vertical or horizontal band of visibility joining the two rectangles. BVGs are easily seen to be a subclass of RVGs, by fattening the horizontal segments of a BVG layout into rectangles, and staggering them vertically to avoid any horizontal visibilities; Wismath [13] has shown that every planar graph is an RVG. By partitioning the edges of an RVG according to horizontal and vertical visibilities, it is clear that every RVG has thickness at most 2; in other words, its edges can be partitioned into two sets, each of which induces a planar graph. More generally, the thickness of a graph G, denoted θ(G), is the least number of sets into which its edges can be partitioned so that each set induces a planar subgraph of G. By results of [3, 4, 5, 6] it is known that not every thickness-2 graph is an RVG. An RVG (resp., BVG) layout is called noncollinear if no two rectangles have collinear sides (resp., no two segments have endpoints with the same xcoordinate). A graph having such a layout is called a noncollinear RVG (resp., noncollinear BVG), or NCRVG (resp., NCBVG) for short. In [8] a characterization of NCBVGs is given that shows them to be a strict subclass of BVGs; in [3, 4] it is shown that NCRVGs form a strict subclass of RVGs. A graph G is called a weak RVG (resp., BVG) if it is a subgraph of an RVG (resp., BVG); in other words, G has a layout in which every edge corresponds to a visibility band, but there may also be visibility bands that correspond to edges not in G. Thus RVGs (resp., BVGs) comprise a subclass of weak RVGs (resp., weak BVGs). In [13, 12] it is shown that the class containment is strict for BVGs, and in [3, 4] it is shown to be strict for RVGs. It is easy to see that the standard BVG layout described above for trees
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
4
can be constructed in a noncollinear manner, and that such a layout can be modified to give an NCRVG layout for any tree or forest. In what follows we will make use of a special form of such a layout, which we call a “standard diagonal arrangement.” In laying out a tree T , we represent each vertex of T as a rectangle (or square) contained in a rectangular area; for contrast we call these rectangular areas “boxes” and will indicate how and where to place the (vertex-) rectangles in a suitable box or subbox. If a vertex v is represented as a rectangle R, we typically represent its children as squares lying in a (square) box S below or to the right of R (although there will be some exceptions to this scheme). We choose a positive integer d so that T is a subtree of a d-ary tree, and we subdivide S into d2 subboxes. We represent the children of v as squares, each a strict subsquare of one of the d boxes along the main diagonal. Thus we retain noncollinearity and v can see between any two of its children. Such an arrangement is called a “standard diagonal arrangement” (abbreviated SDA) of the children of v. Figure 1 shows an SDA layout of a depth-2 tree, in which depth-1 vertices lie below the root, and depth-2 vertices lie to the right of their depth-1 parents.
root R
depth-1
depth-2
Figure 1: SDA layout of a depth-2 tree We make several observations about the SDA. First, such an arrangement induces both a vertical and a horizontal ordering of the children of v. Second, if all descendants of the root are arranged in SDAs below or to the right of their parent, then all vertices in the layout retain both east- and south-visibility, meaning there are regions in which they see nothing to the east and nothing to the south. Third, note that if the children of a vertex v are in an SDA in a
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
5
box S below the rectangle representing v, then a child can be moved vertically up or down in S without altering its visibility to v and without altering its horizontal ordering as a child of v (of course moving it may cause it to become horizontally visible to other vertices). An analogous observation holds if v sees its children in an SDA to its right. If the layout is such that each vertex sees its children in an SDA to its south (resp., east), then we call the layout a standard vertical NCRVG tree layout (resp., standard horizontal NCRVG tree layout). These standard layouts are extended to forests by laying out each component southeast of the previous one. Throughout we use lower-case letters to refer to vertices and upper-case letters for the rectangles representing those vertices and for the surrounding boxes; for example, we use X to denote the rectangle representing the vertex x, placed within a box A. If A and B are disjoint boxes with the same dimensions, and S is a subbox of A, then by the “box in B corresponding to S” we mean the subbox T of B that has the same dimensions as S and the same relative position in B as S has in A. We sometimes use subscripts to indicate the depth of a vertex in a tree. For example, if T is a d-ary tree with root r, then we typically denote the children of r by xi , and the children of xi by xi,j , where the indices i, j run from 1 to d. The results in this paper are primarily concerned with graphs that are combinations of certain types of trees, particularly unions and products of trees. By the union of two graphs, G1 ∪ G2 , we mean the graph G with V (G) = V (G1 ) ∪ V (G2 ) and E(G) = E(G1 ) ∪ E(G2 ). The sets V (G1 ) and V (G2 ) (resp., E(G1 ) and E(G2 )) may or may not have elements in common. In contrast, we say that a graph G can be decomposed into the subgraphs G1 and G2 if V (G) = V (G1 ) = V (G2 ) and E(G) is the disjoint union of E(G1 ) and E(G2 ). Note that if G can be decomposed into G1 and G2 then G = G1 ∪ G2 , but the converse need not hold. The cartesian product (or simply product) of the graphs G1 and G2 , denoted G1 × G2 , is the graph with vertex set V (G1 × G2 ) = V (G1 ) × V (G2 ) and with vertices (u1 , u2 ) and (v1 , v2 ) adjacent if either u1 = v1 and (u2 , v2 ) ∈ E(G2 ) or u2 = v2 and (u1 , v1 ) ∈ E(G1 ). By analogy with the product of a subset of the x-axis with a subset of the y-axis, a horizontal (resp., vertical) edge of G1 ×G2 is one that connects vertices with the same G2 -coordinate (resp., G1 -coordinate). The n-dimensional hypercube, denoted Qn , is defined recursively as a cartesian product: Q1 = K2 , the complete 2-vertex graph, and Qn+1 = Qn × Q1 , for n ≥ 1. A caterpillar is a tree containing a simple path P such that every vertex not on P is distance one from P . A caterpillar forest is a forest in which every component is a caterpillar. In [2] it is shown that if a graph G is a union of two caterpillar forests, then G is an NCRVG. The proof uses the fact that a BVG layout of a caterpillar forest can be projected onto an interval graph in which no more than two intervals have common intersection; the cartesian product of the two interval graphs gives an NCRVG layout of G. Theorem 1 (The Caterpillar theorem [2]) If G is the union of two caterpillar
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
6
forests, then G is a noncollinear rectangle-visibility graph.
3
Unions with depth-1 trees and forests
In this section we consider the union of two trees, one of which has depth 1. By the Caterpillar Theorem of [2], the union of two caterpillar forests is an NCRVG and thus so is the union of two depth-1 trees. Even more, the union of two forests, each forest with all components being depth-1 trees, is an NCRVG. We show now that not only does the union of any forest with a depth-1 tree have a weak RVG layout, but also the union of any forest with as many as three trees of depth 1 has a weak layout. In contrast we show that the union of five trees, four of which have depth 1, need not be weakly representable. The main result of this section is that any forest union a depth-1 tree is an NCRVG. Proposition 1 If a graph G is a union of a forest and one, two, or three depth-1 trees, then G is a weak RVG. Proof: Denote the forest by F , and denote the depth-1 trees by Ti , with roots ri , 1 ≤ i ≤ 3. We claim we may assume that F does not contain any of the ri vertices, but does contain all other vertices of G: For each vertex x not in F and x 6= ri for any i, add x to F as an isolated vertex. Then, for each i > 0 such that ri ∈ F , remove ri and any incident edges from F, and add those edges to Ti . Then F and the trees Ti still have the properties given in the proposition. Lay out F with the standard vertical NCRVG layout; in this layout each rectangle is east-, south-, and west-visible. Then place long rectangles Ri to represent ri , i > 0, along the entire west, south, and east borders, respectively. Thus each Ri , for i > 0, sees every other rectangle in the layout, and hence all the vertices and edges of G are represented, giving a weak representation of G as claimed. 2 Proposition 2 A graph that is the union of a forest and four depth-1 trees need not be a weak RVG. Proof: In [DH1, DH2] it is shown that K5,9 , though of thickness-2, does not have a weak RVG representation. That graph is the union of five depth-1 trees. 2 The layout of Prop. 1 can be improved to give a noncollinear layout when G is the union of a forest and a single depth-1 tree. Theorem 2 The union of a forest and a depth-one tree is an NCRVG. Proof: Suppose G = F ∪ T , where F is a forest and T is a depth-1 tree. Let r be the root of one component of F and r1 the root of T ; as shown in the proof of Prop. 1 we may assume F contains all the vertices of G, except for r1 . Lay out F with the standard vertical NCRVG layout, with all vertices represented by squares and r represented at the top by a square R so that all squares in
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
7
the representation lie below R or (for components not containing r) southeast of R. Next, make a duplicate, horizontal NCRVG layout of F , using the same square R to represent r, with all squares in the same component as r duplicated to the right of R, and with all other components of F represented by duplicate squares NE of R. Thus each vertex of G is currently represented twice, except for r, which is represented once, and r1 , which is not yet represented. In the end a rectangle R1 , representing r1 , will be placed along the left-hand (western) border of the whole array. The general plan is to place squares visible to R1 below R and those invisible to R1 to the right of other squares in F that will block them from R1 , as described below. For each child xi of r, choose either the representing square below R or to the right of R, according as xi is or is not adjacent to r1 in T . Then delete the unused square, to the right or below R, and delete the squares representing descendants of xi to the right of or below R, respectively. That is, there are two potential positions for a square representing xi . Choose one of these and erase the other and all its descendants from the layout. If Xi is below (respectively, to the right of) R, then place a horizontal (respectively, vertical) NCRVG layout of its descendants to its right (resp., beneath it); place the new layout to the right of (resp., below) the entire current configuration. Thus, for each i, the descendants of xi are still represented twice in the full layout. Then continue this process for each grandchild xi,j of r and then for each descendant of r. For each descendant d of r, there are two choices for its placement, one with west-visibility and one with visibility blocked to the west. And when a choice is made, two potential locations for each descendant of d are found, one with west-visibility and one with that visibility blocked. Once the component of F containing r is completed, the same procedure is carried out for all vertices in a second component of F and then for each component of F . At the end, a long rectangle R1 is placed to the left of the entire configuration, extended to see R if r and r1 are adjacent, and the noncollinear layout is complete. The layout process is illustrated in Figure 2, in which solid rectangles represent final positions, and dashed rectangles represent rejected potential positions. 2 We do not know in general about the possibility of a noncollinear representation of a tree union two depth-1 trees or even of a weak representation of a tree union a depth-2 tree; in the next section we turn to the question of the union of two depth-2 trees.
4
Unions with depth-2 trees
In this section we show that the union of two depth-2 trees is always a weak RVG and, if the two trees have the same root, then it is an RVG. If the roots are different, the weak RVG result follows from a modification of the proof of the Caterpillar Theorem of [2], as shown in Prop. 3 below; to achieve the nonweak RVG result when the roots are the same, a different approach is needed, as shown in Thm. 3.
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
8
7
3 6
1
2 1 3
4 5 6 7
2 4
8
8
5
2 3 6 4 5 6 7
5
Figure 2: NCRVG layout for a union of a forest and a depth-one tree
Proposition 3 If a graph G is the union of two depth-2 trees with different roots, then G is a weak RVG. Proof: Let G = T0 ∪ T1 , where, for i = 0, 1, Ti is a depth-2 tree with root ri , and r0 6= r1 . Then for i = 0, 1 we define Fi = Ti \ ri , so that Fi is a depth-1 forest. We add to Fi , as isolated vertices, any vertices of G \ ri not already in Fi , thus keeping Fi a depth-1 forest (note that now r1−i ∈ Fi ). As a final adjustment to the Fi graphs, we remove from F1 any edges that already appear in F0 , so that F0 and F1 become edge-disjoint forests. We begin by representing F0 as an interval graph on the positive x-axis with each depth-1 vertex of F0 represented by a proper subinterval of its parent’s interval. In addition we arrange the interval graph on the axis so that the intervals representing the depth-1 tree containing r1 are leftmost. We then delete the interval representing r1 from the interval representation of F0 . Next we perform an analogous process, representing F1 along the positive y-axis, with the intervals representing the depth-1 tree containing r0 lowest in the layout; we then delete r0 from the interval representation of F1 . We now take the cartesian product of the intervals for F0 and F1 to form rectangles in the first quadrant, non-intersecting since the forests are edge-disjoint. We draw a rectangle, below the x-axis (resp., left of the y-axis) and extending the full extent of the layout, label it R0 (resp., R1 ), and if r0 is adjacent to r1 , extend R0 leftward to see R1 . The adjacencies of the trees in F0 (resp., F1 ) are represented vertically (resp., horizontally). The projection of a T0 -level-2 rectangle on the x-axis is a proper subinterval of its parent’s projection; hence R0 is visible to all its T0 -children. In addition, R0 sees all the vertices to which it is adjacent in T1 , since they are the closest to the x-axis. Similarly, all adjacencies with r1 are represented, and
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
9
so the configuration is a weak layout of G. The construction is illustrated in Figure 3. 2
6
2
6 3
7
4 7
8
3 2
4 R1 = 8
1
4 5
6
7 3
2 5 5 R 0= 1 2
4
5
3
6
7
Figure 3: Weak RVG layout for a union of two depth-2 trees with different roots If, using the notation of the proof of Prop. 3, r0 = r1 , we can get an RVG layout G, but the proof is more involved. Theorem 3 If a graph G is the union of two depth-2 trees with a common root, then G is an RVG. Proof: Let G = T0 ∪ T1 , where T0 and T1 are depth-2 trees with common root r. We direct the edges of each tree from parent to child and color the edges of T0 and T1 , red and blue, respectively (if e ∈ T0 ∩ T1 , color e red). Let D1 be the induced graph on V (D1 ) = {v ∈ G|v is depth-1 in T0 or T1 (or both)}. Then D1 is a 2-edge-colored digraph with the following properties. First, there can be no monochromatic directed path of length 2 or more in D1 ; otherwise the second vertex on the path would have depth-1 and depth-2 in the same tree. Second, no vertex of D1 can have more than one incoming edge: two incoming edges of the same color are forbidden since each Ti is a tree, and two incoming edges of different colors would mean the vertex is level-2 in both trees, hence not in D1 . Thus each (undirected) connected component of D1 is either a tree (of arbitrary depth) or a collection of vertex-disjoint trees (also of arbitrary depth) whose roots are joined in a cycle (which must be even). We begin the layout of G by specifying how to lay out each component of D1 so that, for every pair of vertices in the component, there is an empty rectangular region that is west-visible from one vertex and south-visible from the other (we say the pair has southwest visibility). For a component that is a tree T with root rT , we lay out T (but not in the standard vertical SDA format). First we represent rT as a wide rectangle RT
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
10
and place the depth-1 vertices in an SDA below RT ; each pair of vertices thus laid out has southwest visibility. We repeat this process for the children of each vertex v having depth-1 in T , first shifting all rectangles positioned southeast of v southwards to create space for an SDA of v’s children below v and northwest of all these shifted rectangles; southwest visibility of pairs is thus maintained. We continue this process for the children of the vertices at each level of T , until the entire tree is laid out, maintaining southwest visibility of pairs as we proceed. We call the resulting NCRVG layout a southwest-visible layout of T . Note that, in addition to each pair of vertices having southwest visibility, each individual vertex sees nothing to its south, west, or east. Suppose next that a component C of D1 consists of a cycle v1 , v2 , ..., vk , v1 , together with vertex-disjoint trees, Tvi rooted at vi , for i = 1, ..., k. We lay out each Tvi in a southwest-visible configuration as described above, with the total layout of Tvi contained in a box Bi . We adjust the proportions of the Bi boxes so that they are all squares of the same size, and then we set them along the main diagonal of a k × k square, with B1 at the upper left and Bk at the lower right, so that no rectangle in Bi sees any rectangle in Bj if i 6= j. We then modify this configuration to include the cycle; thus far we have an NCRVG layout, but we will give up noncollinearity in this step. Let the rectangle representing vertex vi of the cycle be labeled Vi . First extend the right side of V1 beyond the left side of Vk but not as far as the right side of Vk , so that it sees all the other Vi rectangles to its south. Then extend the right sides of V2 , ..., Vk−1 so that they are collinear and are half-way between the left side of Vk and the right side of V1 . This is a (collinear) southwest-visible layout of the component C, and as before, in addition to each pair of vertices having southwest visibility, each individual vertex sees nothing to its south, west, or east. Once each component Ci (where Ci = C or T as described above) is given a southwest-visible layout as described above, with component Ci ’s layout contained in a rectangular region Ei , we adjust the proportions of the boxes Ei so that they are all squares of the same size, and we set them in an SDA along the main diagonal of a larger square box E. The entire configuration is a southwestvisible RVG layout of D1 . The construction guarantees that, in addition to each pair of vertices having southwest-visibility, each individual vertex sees nothing to its south, west, or east. It is now a simple matter to add rectangles representing the remaining vertices of G to the layout. With the exception of the common root r, any vertex not in D1 is depth-2 in either T0 or T1 , or in both, and hence a child of either one or two vertices in D1 . For each pair v 6= w, with v, w ∈ D1 , we represent their common children in an SDA in the left half of the rectangular region that is south-visible to one and west-visible to the other. To handle the vertices not in D1 that have exactly one parent in D1 we use a rectangular region F below the current layout contained in E and having the same size as E. For each v ∈ D1 , we locate the rectangle Fv in F that corresponds to v’s rectangle in E, and we place those vertices, not in D1 , that are children only of v in an SDA in the right half of the rectangle Fv . Thus E contains all the vertices that are depth-1 in either tree, plus those depth-2 vertices that have two level-1 parents;
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
11
the latter are blocked to the east by one of their parents, and are seen to the south from the left half of the other parent. The box F below E contains no depth-1 vertices; each depth-2 vertex in F is seen to the south from the right half of its (unique) parent in E. Hence we can represent the final vertex, namely the common root r of T0 and T1 , by a rectangle R that lies to the right of E and extends the entire length of E; R sees only the vertices of D1 , as it should. Figure 4 illustrates the layout process for a particular graph G, showing G, the subgraph D1 , and the final RVG layout for G. All the above operations preserve an RVG layout at every stage, and so the proof is complete. 2
1
G
2
r 3 1
7
4 5 6 7
6 5
1 2
8 9
r
7 3
3 9
D1 6
2
8
8
4
Figure 4: RVG layout for a union of two depth-2 trees with a common root If, in the proof of Thm. 3, D1 contains no cycles, then a noncollinear layout is obtained. Prop. 3 and Thm. 3 together imply the following. Corollary 1 If G is the union of two depth-2 trees, then G is a weak RVG. Note that the proof of Thm. 3 is easily modified to give an alternate proof of Prop. 3, by putting a second root along the west side of the layout. Furthermore, by putting a third root along the south side of the layout, we get a weak representation of the union of two depth-2 trees and a depth-1 tree (recall from Thm. 2 that the union of one depth-2 tree with a depth-1 tree is an NCRVG). Corollary 2 If G = T1 ∪ T2 ∪ T3 , where T1 and T2 are depth-2 trees and T3 is a depth-1 tree, then G is a weak RVG. Aside from the above results, we do not know in general about the possibility of representing a tree union a depth-2 tree. In [1] it is shown that the union of
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
12
two depth-3 trees need not be an RVG. In the next section we show that the union of a depth-3 tree with a matching is a weak RVG.
5
Unions of depth-3 trees and matchings
In this section our primary focus is on unions involving depth-3 trees. By Thm. 2 the union of a depth-3 tree with a depth-1 tree is an NCRVG. It is not known if the union of a depth-3 tree with a depth-2 tree is an RVG, but the result of [1] says that the union of two depth-3 trees need not be an RVG. Here we try to enlarge the class of RVGs that are unions with depth-3 trees by considering unions of trees with matchings, especially the union of a depth-3 tree with a matching. By the Caterpillar Theorem, the union of a depth-1 forest and a matching is an NCRVG since both are caterpillar forests. By Thm. 3 the union of a depth-2 tree and a matching is an RVG since the matching can be extended to a depth-2 tree using the same root as the given tree; one corollary of the main result of this section, Theorem 4, is that this union is an NCRVG. We obtain some additional NCRVG results on special unions of trees with matchings; however, the main theorem is that the union of a depth-3 tree and a matching is a weak RVG. To introduce some new techniques involving the use of SDAs, here is a first result. Proposition 4 Suppose G is the union of a tree T with root r and a matching M such that (x, y) ∈ M implies distT (x, r) = distT (y, r). Then G is an NCRVG. Proof: Suppose T is a subtree of a d-ary tree with root r and depth p. We use a standard NCBVG layout for T , then expanding it to be formed by rectangles as follows. Use a collection of p + 1 disjoint, congruent square boxes, placed in the plane, one above the other. Label these A0 , A1 , ..., Ap from top to bottom, and let the root r be represented by the square R that equals A0 . Then represent the children of r as an SDA in box A1 . If X is a square in A1 , representing vertex x, then represent its children as an SDA in the square corresponding to X in A2 , and do this for each child of the root. Repeat this process for each vertex in each level of the tree T . Suppose vertices x and y, both at distance i from r in T , are joined in the matching M . These vertices are represented by squares X and Y in box Ai , lying in subboxes along the diagonal; suppose X lies above and to the left of Y . Then Y can be shifted vertically upwards until it sees X and no other vertex to its left. Y still sees its parent above and its children below, and sees no additional vertex. 2 Note that such vertical shifting can also allow matchings between a child of vertex x with y when the corresponding rectangle X lies above and to the left of Y , but in this case such a simple shift does not work to match a child of Y with
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
13
X. Some results, similar to Prop. 4, will follow from our main result, which we turn to now. Theorem 4 If G is a union of a depth-3 tree T and a matching M , then G is a weak RVG. Proof: We lay out G using a collection of seven boxes: a rectangle R to represent the root r of T , and six disjoint, congruent square boxes, labeled A through F , alphabetically in the order they are used. Choose a positive integer d so that T is a subtree of a d-ary tree. The vertices of T are labeled r, xi , xi,j , and xi,j,k , 1 ≤ i, j, k ≤ d, as described in Section 2. The layout process of the proof is illustrated in Figure 5, in which T is a subtree of a ternary tree; for ease of viewing, the rectangles are not drawn to scale. Its root r is adjacent to three vertices x1 , x2 , and x3 , each themselves with three additional level-2 neighbors (children). Of these x1,1 , x1,2 , x1,3 , x2,1 , and x2,2 are adjacent to two leaves each, x3,1 to three, and the rest are leaves themselves. The matching M joins the following pairs of vertices of T : {x1 , x2,1 }, {x2 , x1,1 }, {x3,2 , x3,3 }, {x3 , x2,1,1 }, {x2,3 , x2,1,2 }, and {x3,1 , x1,2,1 }. The final position of each rectangle is shown in black outline; a shaded rectangle represents an initial position from which the rectangle is later moved.
X1
X2
X3 R
A
D
E
B
C
F
Figure 5: Weak RVG layout for a union of a depth-3 tree and a matching In general we place the level-1 children of r to its right in an SDA in the box A. In particular, if we divide A into d2 subboxes labeled Ai,j , 1 ≤ i, j ≤ d, then Xi is a square occupying the middle third of Ai,i (that is, the middle third in each dimension). The level-2 children of a level-1 vertex xi will lie in box B. We begin by choosing the box Bi in B that corresponds to the square Xi in A.
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
14
We place the children of xi in an SDA in the lower-right quadrant of Bi , each occupying the middle third of a square on the diagonal of this quadrant. Hence all edges from xi to its children correspond to visibility lines running vertically down from the right half of the square Xi . The level-3 children of a level-2 vertex xi,j lie in box C, in an SDA in the subbox Ci,j of C corresponding to the square Xi,j , and again each occupies the middle third of a square on the diagonal. Note that due to the one-third sizing, each square now lies in the middle third of a subbox with enough perimeter room so that another square of the same size or a whole SDA of another same-sized square can be fit into any side of the same subbox. Thus we have laid out the entire depth-3 tree; see Figure 5. Next we modify (in seven steps) this layout to add in the visibilities corresponding to the edges of the matching. Note that originally and through step 4 we maintain a noncollinear RVG layout, but the layout may become weak in step 5. Step 1: Matching two level-1 vertices. Suppose xi is matched with xj with i < j. First we shift the square Xj vertically upwards so that the top of Xj lies halfway up the height of Xi ; thus Xj sees Xi to its left, protrudes below Xi , but fits within the original box Ai,j so that Xj gains no additional visibilities. Both Xi and Xj maintain east-visibility. Before this shift, for k > j, Aj,k was a subbox of A with visibility to both Xj and Xk ; we refer to “Aj,k translated” or Atj,k to mean the new subbox of A that after the vertical shift of Xj lies to right of Xj and above Xk . Atj,k will be used in the next step. Step 2: Matching a level-1 and level-2 vertex. First consider a matching between a child xi,k of xi with a level-1 vertex xj , where i < j. Let A∗i,j denote the middle third subbox of Ai,j or of Ati,j if Xi was translated in step 1 (in the latter case xi was matched with some xi0 , where i0 < i). We use the upperleft quadrant of the box A∗i,j . Find the rectangle Xi,k lying in the lower-right quadrant of Bi , and move it into the corresponding position in the upper-left quadrant of A∗i,j . Then Xi sees Xi,k to its east, and Xj sees Xi,k vertically. We must also move the children of xi,k so that they retain visibility to their parent, and we move them into box D from their position in box C as follows. Let hi,k be the horizontal strip east of (the newly relocated) Xi,k , intersected with D. The children of xi,k currently form an SDA in a subbox of C. Move this SDA up vertically until these rectangles all lie within hi,k . Xi,k now sees its children to the east, and we repeat the above process for each child of each xi that is matched with a level-1 vertex xj with i < j. Suppose next that xi is matched with a child xj,k of some xj , where i < j. Then, as above, move the rectangle Xj,k from the lower-right quadrant of Bj into the corresponding position in the same quadrant of A∗i,j , and vertically move the box containing its children in C into D so that they are directly to the right of Xj,k . In summary, each A∗i,j , with i < j, contains at most two squares, a child of xi matched with xj in the upper-left quadrant, and either a child of xj matched
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
15
with xi in the lower-right quadrant or the level-1 vertex xj matched with xi in the lower half. Note also that the rectangles in C ∪ D retain their original horizontal ordering from box C. Also, if xi has more than one child matched with different level-1 vertices, then Xi sees them all either to the east in the same relative vertical order that they held before being moved or north in the same horizontal order as before. Note that by initially laying out a tree in a zigzag pattern, these ideas can be used to prove the following. Proposition 5 Suppose G is the union of a tree T with root r and a matching M such that (x, y) ∈ M implies that either distT (x, r) = distT (y, r) or that distT (x, r) = 2k − 1 and distT (y, r) = 2k for some integer k (and the values of k may vary). Then G is an NCRVG. In other words, edges of the matching join vertices at the same level or at alternate adjacent levels; a similar result holds when all matching edges are between levels 2k and 2k+1. Step 3: Matching two level-2 vertices. Suppose xi,j is matched with xk,m with (i, j) lexicographically less than (k, m); note that both vertices are still in their original position in box B. First shrink the SDA containing xi,j ’s children in C by half in both dimensions and move this SDA into the top half of its previous position, clearing the bottom half of the box. Next move the square Xk,m vertically upwards so that the top of Xk,m lies halfway up the height of Xi,j (as in step 1) so that Xk,m sees Xi,j to its left and protrudes below Xi,j , but sees nothing more to its left. Finally, move the SDA containing Xk,m ’s children vertically upwards in C until it is directly to the right of Xk,m . These operations preserve an NCRVG layout. The proof so far can be used to give the following. Proposition 6 The union of a depth-2 tree and a matching is an NCRVG. Step 4: Matching a level-1 vertex with a level-3 vertex. Suppose we must match xi with xj,k,m (where possibly i = j). Suppose first that the rectangle Xj,k has not been moved outside of box B. Then move Xj,k,m horizontally until it is entirely below the left-hand half of Xi . Either this area was empty or, if i = j, contained rectangles only below the right-hand half of Xi . Then Xj,k,m sees its parent and Xi , but it blocks no visibilities nor introduces any new ones. Otherwise Xj,k has been moved to the right of, say, Xi0 . We consider two cases according as xj,k is or is not a child of xi0 . In the former case the square Xj,k lies in (and is the only square in) the upper-left quadrant of a subbox A∗i0 ,j of A, and the square Xj,k can be expanded leftwards until it almost reaches the left boundary of the subbox A∗i0 ,j (= Ai0 ,j or Ati0 ,j ). Thus this new rectangle enters a vertical band v, free of all other rectangles and wide enough to contain an SDA of d level-3 vertices. Place Xj,k,m within the band v so that it sees Xj,k vertically and Xi horizontally in the top third of Xi ’s horizontal band of visibility. In the latter case Xj,k lies in the lower-right quadrant of A∗i0 ,j and
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
16
can be extended downward into a horizontal band h, similarly free of all other rectangles and high enough to contain an SDA of d level-3 vertices. Place Xj,k,m within h so that it sees Xj,k horizontally and Xi vertically in its leftmost third. Note that we may put several level-3 children of xj,k , staggered in the bands h and v and positioned so that all desired visibilities and nonvisibilities are maintained. Step 5: Matching a level-2 vertex with a level-3 vertex. If vertex xi,j is matched with vertex xk,m,n , then (i, j) 6= (k, m) (but possibly i = k) and Xi,j is in its original position in box B. If Xk,m,n is still in box C (when Xk,m is unmatched or matched with another level-2 vertex), then we move Xk,m,n horizontally until it is above or below the left-hand half of Xi,j ; thus it is placed in a subbox of B in the same horizontal band as Xk,m and in the same vertical band as Xi,j . This subbox was previously empty, but if (k, m) < (i, j), the layout becomes weak since Xk,m,n sees Xi vertically. (Xk,m and its SDA of children may have been shifted or its SDA of children may have been contracted if Xk,m was matched with another level-2 vertex, but this does not matter.) If Xk,m,n has been moved into box D because its parent Xk,m has been matched with a level-1 vertex, then we will use box E, the square box congruent to and to the right of D, to contain Xi,j (and all level-2 vertices that are matched with level-3 vertices in D). Let Ei be the subbox of E corresponding to Xi in A. Form d2 subboxes along the diagonal of the upper-left quadrant of Ei and place Xi,j in the middle third of the j’th subbox down the diagonal (this is the subbox corresponding to its subbox in the lower-right quadrant of Bi ). Xi will now see Xi,j to the east (but Xi,j does not yet see Xk,m,n ); Xi may also see other children in this direction in subboxes Ai,j or Ati,j , j > i, and in Ei , but they will each be placed along the diagonal of their enclosing subbox so that Xi sees these children vertically in the same order in which it initially saw them horizontally below in B. Xi sees the rest of its children vertically in boxes A and B. Next all the (matched and unmatched) children of xi,j must be moved. First put all children of xi,j back in their original SDA in C. Then move this SDA vertically upward into D until it lies within the horizontal band west of Xi,j and east of Xi . Due to spacing between rectangles, this SDA does not block visibility between Xi and Xi,j , but the layout may have become weak, if it wasn’t already. All unmatched children of xi,j are now in their proper positions as is a child that was matched with xi . Let vi,j be the vertical band extending above and below Xi,j in boxes E and F , the latter box below E and to the east of C. All other matched children of Xi,j , and also Xk,m,n , will be placed appropriately in vi,j as follows. If a child xi,j,p of xi,j was matched with xq , q 6= i, (and so previously had been moved horizontally into box B), then let Di be the box in D corresponding to Xi (and now containing all of Xi,j ’s children in its upper-left quadrant). We move xi,j,p from its position within the upper-left quadrant of Di to the corresponding position in the upper-left quadrant of Ei , and then move it vertically (within vi,j ) until it is contained in the lower half of the (empty) horizontal band
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
17
east of Xq . Then Xq sees Xi,j,p to its east from its lower half, Xi,j sees Xi,j,p (and any other such children) in the vertical band vi,j . If several children of xi,j are matched with different xk ’s, they are staggered in vi,j so that visibility to Xi,j is maintained. If a child xi,j,p of xi,j had previously been matched with a level-2 vertex xq,r (by a prior application of this case), then Xi,j was in B when this match occurred, and Xi,j,p was in C. Thus Xq,r was left in its original position, and Xi,j,p was moved into B to see Xq,r vertically. Move Xi,j,p from its position in the upper-left quadrant of Di to the corresponding position in the upper-left quadrant of Ei and then move it downwards (within vi,j ) until it is within the horizontal band east of the lower third of Xq,r (so that visibility is not blocked by Xq,r ’s children). Note that Xi,j,p has been moved into the box F . Again if several children of xi,j are matched with different xq,r ’s, they are staggered in vi,j so that visibility to Xi,j is maintained and no two of these children see each other. Finally we are ready to move Xk,m,n horizontally into the right-most part of the band vi,j so that it sees Xi,j vertically and obstructs no visibility of Xi,j with its children. Xk,m,n still sees its parent horizontally in A or in E. Because of the “middle-third” construction of the vertices in the original tree layout, Xk,m,n sees none of the children of Xi,j , although it might be collinear with the right-most child of Xi,j . Step 6: Matching two level-3 vertices. Note that all unmatched level-3 vertices lie in C or D; there may also be matched level-3 vertices in these boxes. The vertical ordering of the level-3 vertices in C ∪ D may have been permuted, but their horizontal ordering is unchanged. Furthermore, they all see their parents horizontally. To match two of these level-3 vertices, take the leftmost one and move it right until it sees the other vertically. Step 7: Matching the root with another vertex. Observe that all level-1 vertices and unmatched level-2 vertices are east-visible. All unmatched level-3 vertices are either in C or D, and they are east-visible except when their parent lies in E. We move the root r and represent it now by a rectangle to the right of the entire layout, extending from top to bottom of the layout. Then r sees all its children. If r is matched with a level-3 vertex Xi,j,k in D whose parent Xi,j lies in E, then we move Xi,j,k horizontally into the upper-right quadrant of Ei . Note that moving r introduces many extraneous visibilities. 2 We do not know if the results of Theorem 4 are best possible, meaning that we do not know whether the union of a depth-4 tree and a matching or the union of a depth-3 tree and a depth-2 tree is an RVG, though by the results of [1] the union of two depth-3 trees is not necessarily an RVG. The example of [1] does have a weak RVG representation and so we also wonder if unions of depth-4 trees have a weak representation. Clearly there are other unions of trees to be studied; for example, the case of caterpillar trees suggests that a breadth-first analysis might be as fruitful as the depth-oriented one we have pursued here.
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
6
18
Cartesian Products
In this section we give results on thickness and rectangle-visibility for cartesian products of graphs. Our two main results are that the thickness of a product is bounded above by the sum of the thicknesses of the factors (and this is best possible), and that the product of two BVGs is an RVG. From the latter we conclude that the product of two forests is an RVG. We also generalize the second result to products of what we call “left-right-bar-visibility” graphs with certain paths and cycles. We apply these results to conclude that several classes of graphs are RVGs. We first give several results on the thickness of product graphs. If G is the product of two planar graphs, then the horizontal and vertical edges partition G into two planar graphs. More generally, if G1 and G2 are two arbitrary graphs and G = G1 × G2 , then the horizontal edges of G can be partitioned into θ(G1 ) planar graphs, and likewise the vertical edges of G can be partitioned into θ(G2 ) planar graphs. We have thus proved the following: Proposition 7 If G is the product of two planar graphs, then θ(G) ≤ 2. Proposition 8 If G = G1 × G2 , then θ(G) ≤ θ(G1 ) + θ(G2 ). P Q Corollary 3 If G = (Gi ), then θ(G) ≤ θ(Gi ). The graphs Pn × K2 and Cn × K2 (where Pn and Cn are, resp., the path and cycle on n vertices) show that equality need not hold in Prop. 7. On the other hand, if G is planar and contains K4 , equality is achieved by G× K2 , since G × K2 contains a K5 minor. The hypercube graphs provide a useful class of examples to demonstrate that the bounds in Prop. 8 can always be achieved, and that they also can always be made strict, for any two thicknesses θ1 and θ2 . Kleinert [7] has shown that the thickness of the hypercubes is given by the formula θ(Qn ) = d(n + 1)/4e. Given any two thicknesses, θ1 and θ2 , we can achieve the upper bound in Prop. 8 by taking Gi = Q4θi −1 , for i = 1, 2. On the other hand, to get strict inequality we take Gi = Q4θi −4 , in which case θ(G1 × G2 ) = θ1 + θ2 − 1. It follows from Proposition 7 that the product of two trees has thickness at most two. In the next proposition we show that the product of two BVGs is an RVG, and so the product of two trees is an RVG. Proposition 9 If the graphs G and H are both BVGs, then G × H is an RVG. Analogous statements hold if G and H are noncollinear or weak BVGs. Proof: Assume we have BVG layouts of G and H using horizontal bars with left and right endpoints in the interval [0, 1]; without loss of generality, we assume that in each layout the bars have distinct y-coordinates. Number the vertices of G and H in order of their bars in each case from bottom to top, i = 1, ..., nG and j = 1, ..., nH ; the bars themselves will be denoted BG (i) and BH (j). We give an RVG layout for G × H in the region [0, 2nG ] × [0, 2nH ], so that the rectangle
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
19
R(i, j) lies in the region [2i − 1, 2i] × [2j − 1, 2j]. The top, bottom, left and right coordinates (indicated by t, b, l, r, respectively) of R(i, j), i = 1, ..., nG , j = 1, ..., nH , are as follows: t[R(i, j)] = 2j − 1 + r[BG (i)] b[R(i, j)] = 2j − 1 + l[BG (i)] l[R(i, j)] = 2i − 1 + l[BH (j)] r[R(i, j)] = 2i − 1 + r[BH (j)] Looking vertically in this layout we see |V (G)| copies of H, each in a different column, and similarly |V (H)| copies of G when looking horizontally. It is easy to see that R(i, j) sees R(i0 , j 0 ) if and only if either i = i0 and BH (j) sees BH (j 0 ) in the BVG layout of H, or j = j 0 and BG (i) sees BG (i0 ) in the BVG layout of G. The construction is illustrated in Figure 6. It is also clear that this construction preserves noncollinearity and weakness. 2 G 2 1 G 2
G 2 1
1
H32
2,3
1,3
G 2
1
2,2
1,2
1
2,1
1,1
H 3
2
H 3 1
2
1
Figure 6: RVG layout of G × H, for BVGs G and H
Corollary 4 If G is the product of two trees or forests, then G is an NCRVG. Although the focus of this paper is combinations of trees, we note that since the p-dimensional hypercube Qp is a BVG for p = 1, ..., 3, we can apply Prop. 9 to get that Qp is an RVG for p = 1, ..., 6. Corollary 5 The hypercube graphs Qn , for n = 1, ..., 6, are RVGs. Q3 is actually a BVG, since it is a 2-connected planar graph. It is known that the hypercubes of thickness 2 are Q4 , ..., Q7 [7]. A bipartite RVG has e ≤ 4v − 12 [3, 4], and it follows from results in [8] that a bipartite NCRVG has e ≤ 2n − 2; hence Q7 cannot be an NCRVG but could be an RVG. It is not known if Q7 is an RVG.
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
20
In the proof of Prop. 9 we can get a somewhat stronger result if the two BVG layouts have an additional property. A left-right bar-visibility layout of a graph G, abbreviated LRBVG layout, is a BVG layout of G using horizontal bars contained in a rectangular region [a, b] × [c, d], such that each bar has either left endpoint a or right endpoint b (these bars are called left and right bars, respectively). Examples of LRBVGs include all paths and cycles. It is easy to see that if G is an LRBVG, then G is outerplanar, i.e., it has a planar embedding in which all vertices lie on the outer face. The proofs of the following propositions concerning LRBVGs are fairly straightforward, and are omitted. Proposition 10 If G and H are BVGs, and at least one of G and H is an LRBVG, then G × H × P2 is an RVG. Corollary 6 If G and H are both LRBVGs, then G × H × K is an RVG, for K = P2 , P3 , P4 , or C4 . If Q3 were an LRBVG, then it would follow from Cor. 6 that Q7 is an RVG, but this is not the case: It is well known that a graph G is outerplanar if and only if it does not contain a subgraph homeomorphic to K4 or K2,3 . Since Q3 contains a homeomorph of K2,3 , it is not outerplanar, hence not an LRBVG.
A. Dean and J. Hutchinson, RVG Layouts, JGAA, 2(8) 1–21 (1998)
21
References [1] I. Bjorling-Sachs and T. Shermer, personal communication, 1996. [2] P. Bose, A. Dean, J. Hutchinson, and T. Shermer, On Rectangle Visibility Graphs, Lecture Notes in Computer Science #1190 (S. North, ed.), Springer-Verlag, Berlin, 25–44, 1997. [3] A. Dean and J. Hutchinson, Rectangle-visibility representations of bipartite graphs, Discrete Applied Mathematics, 75:9–25, 1997. [4] A. Dean and J. Hutchinson, Rectangle-visibility representations of bipartite graphs (extended abstract), Lecture Notes in Computer Science #894 (R. Tamassia and I.G. Tollis, eds.), Springer-Verlag, Berlin, 159–166, 1995. [5] J. Hutchinson, T. Shermer, and A. Vince, On representations of some thickness-two graphs, Computational Geometry: Theory and Applications, to appear. [6] J. Hutchinson, T. Shermer, and A. Vince, On representations of some thickness-two graphs (extended abstract), Lecture Notes in Computer Science #1027, (F. Brandenburg, ed.), Springer-Verlag, Berlin, 324–332, 1995. [7] M. Kleinert, Die Dicke des n-dimensionalen W¨ urfel-Graphen, J. Comb. Theory, 3:10–15, 1967. [8] F. Luccio, S. Mazzone, and C. Wong, A note on visibility graphs, Discrete Mathematics, 64:209–219, 1987. [9] C. Nash-Williams, Decomposition of finite graphs into forests, J. London Math. Soc., 39:12, 1964. [10] L. Pyber Problem C.23, Contests in Higher Mathematics, Milk´ os Schweitzer Competitions 1962-1991, (G.J. Sz´ekely, ed.), Springer, Berlin, 42, 1996. [11] T. Shermer, On rectangle visibility graphs III. external visibility and complexity, Proc. 8th Canad. Conf. Comput. Geom., Carleton University Press, Ottawa, 234–239, 1996. [12] R. Tamassia and I.G. Tollis, A unified approach to visibility representations of planar graphs, Discrete and Computational Geometry, 1:321–341, 1986. [13] S. Wismath, Characterizing bar line-of-sight graphs, Proc. 1st Symp. Comp. Geom., ACM, 147–152, 1985.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 3, no. 1, pp. 1–18 (1999)
Edge-Coloring and f -Coloring for Various Classes of Graphs Xiao Zhou Graduate School of Information Sciences Tohoku University Aoba-yama 05, Sendai 980-8579, Japan
[email protected]
Takao Nishizeki Graduate School of Information Sciences Tohoku University Aoba-yama 05, Sendai 980-8579, Japan
[email protected] In an ordinary edge-coloring of a graph each color appears at each vertex at most once. An f -coloring is a generalized edge-coloring in which each color appears at each vertex v at most f (v) times where f (v) is a positive integer assigned to v. This paper gives efficient sequential and parallel algorithms to find ordinary edge-colorings and f -colorings for various classes of graphs such as bipartite graphs, planar graphs, and graphs having fixed degeneracy, tree-width, genus, arboricity, unicyclic index or thickness.
Communicated by M. Kaufmann: submitted October 1997; revised September 14, 1998.
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
1
2
Introduction
This paper deals with a simple graph G which has no multiple edges or selfloops. An edge-coloring of a graph G is to color all the edges of G so that no two adjacent edges are colored with the same color. The minimum number of colors needed for an edge-coloring is called the chromatic index of G and denoted by χ0 (G). In this paper the maximum degree of a graph G is denoted by ∆(G) or simply by ∆. Vizing showed that χ0 (G) = ∆ or ∆ + 1 for any simple graph G [10, 30]. The edge-coloring problem is to find an edge-coloring of G with χ0 (G) colors. Let f be a function which assigns a positive integer f (v) to each vertex v ∈ V . Then an f -coloring of G is to color all the edges of G so that, for each vertex v ∈ V , at most f (v) edges incident to v are colored with the same color. Thus an f -coloring of G is a decomposition of G to edge-disjoint spanning subgraphs in each of which vertex degrees are bounded above by f . An ordinary edge-coloring is a special case of an f -coloring for which f (v) = 1 for every vertex v ∈ V . The minimum number of colors needed for an f -coloring is called the f -chromatic index of G and denoted by χ0f (G). The f -coloring problem is to find an f -coloring of G with χ0f (G) colors. Let ∆f (G) = maxv∈V dd(v)/f (v)e where d(v) is the degree of vertex v, then χ0f (G) = ∆f or ∆f + 1 for any simple graph G [13]. The edge-coloring and f -coloring have applications to scheduling problems like the file transfer problem in a computer network [5, 24, 25]. In the model a vertex of a graph G represents a computer, and an edge does a file which one wishes to transfer between the two computers corresponding to its ends. The integer f (v) is the number of communication ports available at a computer v. The edges colored with the same color represent files that can be transferred in the network simultaneously. Thus an f -coloring of G with χ0f (G) colors corresponds to a scheduling of file transfers with the minimum finishing time. Since the ordinary edge-coloring problem is NP-complete [15], the f -coloring problem is also NP-complete in general. Therefore it is very unlikely that there exists an exact algorithm which solves the ordinary edge-coloring problem or the f -coloring problem in polynomial time. However, the following approximate algorithms are known. Any simple graph G can be edge-colored with ∆ + 1 colors in polynomial time [27, 29]; the best known algorithm takes time √ O(min{n∆ log n, m n log n}) [12], where we denote by n the number of the vertices and m the number of the edges in G. Furthermore, the proof in [13] immediately yields an approximate algorithm to f -color any simple graph with ∆f + 1 colors in time O(mn). On the other hand, exact algorithms to edge-color G with χ0 (G) colors are known for restricted classes of graphs as follows: (a) an O(m log n)-time algorithm for bipartite graphs [6, 11]; (b) a linear-time algorithm for planar graphs of ∆ ≥ 19 [4]; (c) an O(n log n)-time algorithm for planar graphs of ∆ ≥ 9 [3]; (d) an O(n2 )-time algorithm for planar graphs of ∆ ≥ 8 [12, 27]; (e) a linear-time algorithm for series-parallel multigraphs [34]; and (f) a linear-time algorithm for partial k-trees [32].
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
3
Concerning parallel edge-coloring algorithms, NC parallel exact algorithms have been obtained only for a few restricted classes of graphs such as bipartite graphs [20], series-parallel simple graphs [2], series-parallel multigraphs [35], partial ktrees [32] and planar graphs with maximum degree ∆ ≥ 9 [3, 4]. However, NC parallel approximate algorithms to edge-color G with ∆+ 1 colors have not been known so far except for the case when ∆ is small [18]. On the other hand, no efficient exact algorithms for the f -coloring problem have been obtained even for restricted classes of graphs. In this paper we consider various classes of graphs specified by invariants like the degeneracy. The degeneracy s(G) of a graph G is the minimum number s such that G can be reduced to an empty graph by the successive deletion of vertices with degree at most s [1]. Clearly the degeneracy has a favorable implication on the vertex-coloring: any graph G can be vertex-colored with at most s(G) + 1 colors [9, 22, 23, 28]. On the other hand, Vizing [16, 31] showed that the degeneracy has a surprising implication on the edge-coloring: χ0 (G) = ∆(G) if ∆(G) ≥ 2s(G). Thus Vizing gave a lower bound on ∆(G) for χ0 (G) = ∆(G) to hold true. In this paper we express such a lower bound in terms of various other graph-invariants like tree-width, arboricity, unicyclic index, thickness, and genus. It is rather straightforward to derive from Vizing’s proof an O(mn) algorithm for edge-coloring a graph G with ∆(G) colors if ∆(G) ≥ 2s(G). We give more efficient sequential and NC parallel algorithms to edge-color a graph G whose maximum degree ∆(G) is roughly larger than twice the lower bounds, say ∆(G) ≥ 4s(G). Our sequential algorithm takes time O(n log n) if s(G) is bounded and ∆(G) ≥ 4s(G). We next give a simple but useful transformation of a graph G to a new graph Gf such that an ordinary edge-coloring of Gf immediately induces an f -coloring of the original graph G with the same number of colors. Using the transformation, we finally give efficient sequential and NC parallel algorithms to f -color various classes of graphs with large ∆(G). In the paper the parallel computation model we use is a concurrent-read exclusivewrite parallel random access machine (CREW PRAM). An early version of the paper was presented at [33].
2
Preliminary
In this section we define terminology and observe relationships between various graph invariants. A graph with vertex set V and edge set E is denoted by G = (V, E). The vertex set and the edge set of a graph G is often denoted by V (G) and E(G), respectively. We denote the number of vertices in G by n(G) or simply n, and denote the number of edges in G by m(G) or simply m. We say that a graph G is trivial if m(G) = 0. The degree of v in G is denoted by d(v, G) or simply by d(v). We denote by ∆(G) the maximum degree of vertices of G and by δ(G) the minimum degree. The graph obtained from G by deleting all vertices in V 0 ⊆ V (G) is denoted by G − V 0 . The graph obtained from G by deleting all edges in E 0 ⊆ E(G) is denoted by G − E 0 .
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
4
We then define various invariants of graphs. Let s be a positive integer. A graph G is s-degenerate if the vertices of G can be ordered v1 , v2 , · · ·, vn so that d(vi , Gi ) ≤ s for each i, 1 ≤ i ≤ n, where Gi = G − {v1 , v2 , · · · , vi−1 } [1, 9, 22, 23]. Thus G is s-degenerate if and only if G can be reduced to a trivial graph by the successive removal of vertices having degree at most s. The degeneracy s(G) of G is the minimum integer s for which G is s-degenerate. The degeneracy s(G) is also called the Szekeres-Wilf number [28]. The degeneracy of a graph can be computed in linear time [23]. Every planar graph G has a vertex of degree at most five, that is, δ(G) ≤ 5 [1, 27], and hence s(G) ≤ 5.
(1)
Obviously any graph G can be vertex-colored with at most s(G) + 1 colors [9, 22, 23, 28]. Vizing showed that χ0 (G) = ∆(G) if ∆(G) ≥ 2s(G) [16, 31]. A graph G = (V, E) is a k-tree if either it is a complete graph on k vertices or it has a vertex v ∈ V whose neighbors induce a clique of size k and G − {v} is again a k-tree. A graph is a partial k-tree if it is a subgraph of a k-tree [32]. The tree-width k(G) of graph G is the minimum integer k such that G is a partial k-tree. Clearly s(G) ≤ k(G). (2) The arboricity a(G) of a graph G is the minimum number of edge-disjoint forests into which G can be decomposed. Nash-Williams [26] proved that a(G) = maxH⊆G dm(H)/(n(H) − 1)e, where H runs over all nontrivial subgraphs of G. We have a(G) ≤ s(G), (3) because any subgraph H of G is s(G)-degenerate and hence m(H) ≤ s(G)(n(H) −1) and m(H)/(n(H) − 1) ≤ s(G). Furthermore, if G is planar, then a(G) ≤ 3,
(4)
because m(H) ≤ 3n(H) − 3 for any nontrivial subgraph H of G. We now introduce a rather unfamiliar invariant a0 (G) which we call the unicyclic index of a graph G: a0 (G) is the minimum number of edge-disjoint unicyclic graphs, that is, graphs with at most one cycle, into which G can be decomposed. Since a forest is a unicyclic graph and a unicyclic graph can be decomposed to one or two forests, we have a0 (G) ≤ a(G) ≤ 2a0 (G).
(5)
The thickness θ(G) of a graph G is the minimum number of edge-disjoint planar subgraphs into which G can be decomposed. Clearly θ(G) ≤ a0 (G) ≤ a(G) ≤ 3θ(G)
(6)
since every unicyclic graph is planar and every planar graph can be decomposed into at most three edge-disjoint forests [8].
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
5
The genus g(G) of a graph G is the minimum number of handles which must be added to a sphere so that G can be embedded on the resulting surface. Of course, g(G) = 0 if and only if G is planar. It is known [14, 17] that if g(G) ≥ 1 then k j p (7) δ(G) ≤ 5 + 48g(G) + 1 /2 . Furthermore any subgraph H of G satisfies g(H) ≤ g(G). Therefore, if g(G) ≥ 1 then k j p (8) s(G) ≤ 5 + 48g(G) + 1 /2 . One can observe that the following upper bound holds on the minimum degree. Lemma 1 The following (a)–(c) hold for any nontrivial graph G: (a) δ(G) ≤ 2a(G) − 1 [8]; (b) δ(G) ≤ 2a0 (G); and (c) if a0 (G) is bounded and U = {u ∈ V | d(u, G) ≤ 2a0 (G)}, then |U | ≥ n/(2a0 (G) + 1) and hence |U | = Θ(n). Proof: (a) One may assume that G has no isolated vertices. Let n0 be the number of vertices v of G such that 1 ≤ d(v) ≤ 2a(G) − 1. Then clearly n0 + 2a(G)(n − n0 ) ≤ 2m. On the other hand, G can be decomposed into a(G) edge-disjoint forests, and any forest has at most n − 1 edges. Therefore m ≤ a(G)(n−1). Thus n0 ≥ 2a(G)/(2a(G)−1) > 1, and hence δ(G) ≤ 2a(G)−1. (b) and (c) Since every vertex in V − U has degree ≥ 2a0 (G) + 1, we have 0 (2a (G) + 1)(n − |U |) ≤ 2m. Since any unicyclic graph has at most n edges, we have m ≤ a0 (G)n. Thus we have |U | ≥ n/(2a0 (G) + 1). Hence U 6= φ and 2 δ(G) ≤ 2a0 (G). If a0 (G) is bounded, then |U | = Θ(n). By Lemma 1 and Eqs. (1), (2), (4)–(6) and (8) we can immediately derive the following upper bounds on s(G) in terms of k(G), a(G), a0 (G), θ(G) and g(G). Note that a(H) ≤ a(G), a0 (H) ≤ a0 (G), θ(H) ≤ θ(G) and g(H) ≤ g(G) for any subgraph H of G. Lemma 2 The following (a) – (f) hold: (a) s(G) ≤ k(G); (b) s(G) ≤ 2a(G) − 1; (c) s(G) ≤ 2a0 (G); (d) s(G) ≤ j 6θ(G) − 1; k p (e) s(G) ≤ 5 + 48g(G) + 1 /2 if g(G) ≥ 1; and (f) s(G) ≤ 5 if G is planar. The relationships among these graph-invariants are illustrated in Figure 1.
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999) k(G) 2a(G) − 1
O
6
p g(G)
2a0 (G) hhhh hhhQ s(G)
3θ(G)
hhhh hh a(G)
a0 (G)
θ(G) Figure 1: Relationships among graph-invariants.
3
Chromatic Index
By the classical Vizing’s theorem, χ0 (G) = ∆ or ∆ + 1 for any simple graph G [10, 30]. Vizing also showed that χ0 (G) = ∆ if ∆ ≥ 2s(G). In this section we give various lower bounds on ∆(G) for χ0 (G) = ∆(G) to hold true, expressed in terms of various invariants such as k(G), a(G), a0 (G), θ(G) and g(G). For vertices u and v, we denote by d∗u (v) the number of v’s neighbors, other than u, having degree ∆(G). An edge (u, v) ∈ E is eliminable if either d(u) + d∗u (v) ≤ ∆(G) or d(v) + d∗v (u) ≤ ∆(G) [27, 29]. The following lemma is an expression of a classical result on “critical graphs,” called “Vizing’s adjacency lemma” (see, for example, [10, 27, 29]). In other words, the edges that are excluded in a critical graph by the adacency lemma are eliminable. Note that the definition is not symmetric with u and v. Lemma 3 If (u, v) is an eliminable edge of a simple graph G and χ0 (G − (u, v)) ≤ ∆(G), then χ0 (G) = ∆(G). Thus, if we remove an eliminable edge (u, v) and can color the remaining graph G − (u, v) with ∆(G) colors, then the obtained coloring can be extended to the edge (u, v) without using more colors. Vizing [31] obtained the following two theorems. We give proofs for them, which yield an O(mn) algorithm to edge-color G with ∆ colors if ∆(G) ≥ 2s(G), as we will show in the succeeding section. Theorem 1 [31] Any nontrivial graph G has an eliminable edge if ∆(G) ≥ 2s(G). Proof: Let U = {u ∈ V (G) | d(u, G) ≤ s(G)}. Then U 6= φ because the definition of the degeneracy implies that G has at least one vertex of degree
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
7
≤ s(G). Furthermore V −U 6= φ since ∆ ≥ 2s(G) > s(G) and hence the vertices of degree ∆ are not contained in U . Thus H = G − U is not empty and s(H) ≤ s(G). Therefore H has a vertex v of degree ≤ s(G). Since s(G) + 1 ≤ d(v, G) and d(v, H) ≤ s(G), G has an edge (u, v) joining v and a vertex u ∈ U . Since u ∈ U , d(u) ≤ s(G) < 2s(G) ≤ ∆. Thus none of v’s neighbors in U has degree ∆, and hence d∗u (v) ≤ d(v, H) ≤ s(G). Therefore d(u) + d∗u (v) ≤ 2s(G) ≤ ∆, and hence edge (u, v) is eliminable. 2 Theorem 2 [31] χ0 (G) = ∆(G) if ∆(G) ≥ 2s(G). Proof: Assume that G is a nontrivial graph with ∆(G) ≥ 2s(G). Then by Theorem 1 G has an eliminable edge e1 . Let G1 = G − {e1}, then s(G1 ) ≤ s(G). If ∆(G1 ) = ∆(G), then G1 has an eliminable edge e2 . Thus there exists a sequence of edges e1 , e2 , · · · , ej such that (i) ∆(Gj ) = ∆(G) − 1 where Gj = G − {e1 , e2 , · · · , ej }; and (ii) every edge ei , 1 ≤ i ≤ j, is eliminable in Gi−1 = G − {e1 , e2 , · · · , ei−1 }. By the classical Vizing’s theorem [10], χ0 (Gj ) ≤ ∆(Gj ) + 1 = ∆(G). Therefore, 2 applying Lemma 3 repeatedly, we have χ0 (G) = ∆(G). A minor of a graph G is a graph obtained from G by repeated deletions and contractions of edges. We say that a class G of graphs is minor closed if any minor of G belongs to G for every graph G ∈ G. A classical result of Mader [7, 21] implies that every graph G in any minor closed class G has a degeneracy bounded by a constant h(G), that is, s(G) ≤ h(G), where h(G) is a constant depending on the class G. For example, h(G) = 5 for the class G of planar graphs. Thus we have the following corollary from Theorem 2 and Lemma 2. Corollary 1 χ0 (G) = ∆(G) if one of the following (a) – (g) holds: (a) G belongs to a minor closed class G and ∆(G) ≥ 2h(G); (b) ∆(G) ≥ 2k(G) [32]; (c) ∆(G) ≥ 4a(G) − 2; (d) ∆(G) ≥ 4a0 (G); (e) ∆(G) ≥ 12θ(G) − 2; (f) g(G) ≥ 1 and ∆(G) ≥ 2
k j p 5 + 48g(G) + 1 /2 ; and
(g) G is planar and ∆(G) ≥ 10. A result better than Corollary 1(g) is known [10, 27]: χ0 (G) = ∆(G) if G is planar and ∆(G) ≥ 8.
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
4
8
Finding Edge-Colorings
The proofs of Theorems 1 and 2 yield an exact algorithm to edge-color a graph G with ∆ colors if ∆(G) ≥ 2s(G). However, the algorithm takes O(mn) time, since it repeats operations of “shifting a fan sequence” and “switching an alternating path” O(m) times and each operation takes O(n) time [27]. In this section we give a more efficient exact algorithm of complexity O(n log n) for the case where a0 (G) is bounded and ∆(G) is large: ∆(G) ≥ 4a0 (G). Remember that a0 (G) ≤ s(G). Furthermore we give an NC parallel exact algorithm for this case. Our algorithms first decompose a given graph G of large maximum degree to several edge-disjoint subgraphs of small maximum degrees by using Zhou, Nakano and Nishizeki’s algorithm [32], and then find edge-colorings of the subgraphs by using Chrobak and Nishizeki’s algorithm (for planar graphs) [3], and finally superimpose the edge-colorings of subgraphs to obtain an edge-coloring of G. The main result of this section is the following. Theorem 3 If the unicyclic index a0 (G) is bounded and ∆(G) ≥ 4a0 (G), then graph G can be edge-colored by ∆(G) colors in O(n log n) sequential time or in O(log3 n) parallel time with O(n log3 n) operations. By Lemma 2 and Eqs.(2)–(6) we have the following corollary. Corollary 2 Graph G can be edge-colored by ∆(G) colors in O(n log n) sequential time or in O(log3 n) parallel time with O(n log3 n) operations if one of the following (a) – (g) holds: (a) G belongs to a minor closed class G and ∆(G) ≥ 4h(G); (b) a(G) is bounded and ∆(G) ≥ 4a(G); (c) s(G) is bounded and ∆(G) ≥ 4s(G); (d) k(G) is bounded and ∆(G) ≥ 4k(G); (e) θ(G) is bounded and ∆(G) ≥ 12θ(G); k j p (f) g(G) ≥ 1 is bounded and ∆(G) ≥ 4 5 + 48g(G) + 1 /2 ; and (g) G is planar and ∆(G) ≥ 12. Zhou et al. [32] obtained a result stronger than Corollary 2(d): a linear-time sequential and an optimal parallel edge-coloring algorithm for any graphs with bounded k(G), i.e., partial k-trees. In the remaining of this section we prove Theorem 3. We use Chrobak and Nishizeki’s algorithm [3] which edge-colors a planar graph G of ∆(G) ≥ 9 by ∆ colors in O(n log n) sequential time or in O(log3 n) parallel time with O(n log3 n) operations and hence is stronger than Corollary 2(g). Their algorithm relies on the following fact: any planar connected graph G has Θ(n) eliminable edges if ∆(G) ≥ 9 [3]. We have the following lemma on graphs which are not always planar.
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
9
Lemma 4 If G is a connected graph, ∆(G) is bounded and ∆(G) ≥ 4a0 (G), then G has Θ(n) eliminable edges. Proof: Let U = {u ∈ V (G) | d(u, G) ≤ 2a0 (G)}, then U 6= φ because by Lemma 1(b) δ(G) ≤ 2a0 (G). Furthermore V − U 6= φ since ∆(G) ≥ 4a0 (G) > 2a0 (G). Therefore the graph H obtained from G by deleting all the vertices in U is not empty. Let W = {w ∈ V (H) | d(w, H) ≤ 2a0 (G)}, and let E 0 be the set of edges (u, v) ∈ E(G) such that u ∈ U and v ∈ U ∪ W . Then it suffices to prove the following (i) and (ii): (i) each edge (u, v) ∈ E 0 is eliminable; and (ii) the number of edges in E 0 is Θ(n). We first prove (i). Let (u, v) be an arbitrary edge in E 0 . Since u ∈ U , d(u) ≤ 2a0 (G) < ∆. On the other hand d∗u (v) ≤ 2a0 (G): if v ∈ U then d∗u (v) ≤ d(v, G) ≤ 2a0 (G); and if v ∈ W then d∗u (v) ≤ d(v, H) ≤ 2a0 (G) since none of v’s neighbors in U has degree ∆. Therefore d(u) + d∗u (v) ≤ 4a0 (G) ≤ ∆, and hence edge (u, v) is eliminable. We next prove (ii). Since at least one edge in E 0 is incident to each vertex in W , we have (9) |E 0 | ≥ |W |. By applying Lemma 1(c) to graph H we have |W | ≥
n(H) . 2a0 (H) + 1
(10)
Since a0 (H) ≤ a0 (G) and n(H) = n − |U |, we have |W | ≥ If |U | is small, say |U | ≤
2∆−1 2∆+1 n,
|E 0 | ≥ ≥
n − |U | . 2a0 (G) + 1
(11)
then by Eqs. (9) and (11) we have 1 (n − |U |) 2a0 (G) + 1 2 n, 0 (2a (G) + 1)(2∆ + 1)
and hence |E 0 | = Θ(n) since both ∆(G) and a0 (G) are bounded. Thus it suffices to verify |E 0 | = Θ(n) for the case when |U | > 2∆−1 2∆+1 n, that is, n − |U | <
2 n. 2∆ + 1
(12)
Edges in E(G) − E 0 either join two vertices in W or are incident to vertices in V −U −W . The number of former edges is at most a0 (G)|W |, and the number of latter edges is at most ∆(n − |U | − |W |). Therefore we have |E 0 | ≥ =
m − a0 (G)|W | − ∆(n − |U | − |W |) m − ∆(n − |U |) + (∆ − a0 (G))|W |.
(13)
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
10
Since G is connected, m ≥ n − 1. Therefore by Eqs. (11), (12) and (13) we have |E 0 | ≥ = > =
∆ − a0 (G) (n − |U |) 2a0 (G) + 1 a0 (G)(2∆ + 1) (n − |U |) n−1− 2a0 (G) + 1 2a0 (G) n n−1− 0 2a (G) + 1 1 n − 1. 0 2a (G) + 1 n − 1 − ∆(n − |U |) +
Thus |E 0 | = Θ(n) since a0 (G) is bounded.
2
Lemma 4 implies that if G is a connected planar graph, ∆(G) is bounded and ∆(G) ≥ 12 then G has Θ(n) eliminable edges. Thus Lemma 4 does not implies the fact proved by Chrobak and Nishizeki [3], but is a kind of generalization of the fact for (not always planar) graphs. Chrobak and Nishizeki’s algorithm [3] correctly edge-colors any (not always planar) graph G with ∆ colors if ∆ is bounded and G has Θ(n) eliminable edges. Therefore by Lemma 4 we have the following lemma. Lemma 5 If ∆(G) is bounded and ∆(G) ≥ 4a0 (G), then G can be edge-colored by ∆(G) colors in O(n log n) sequential time or in O(log3 n) parallel time with O(n log3 n) operations. By Lemma 5, in order to prove Theorem 3, it suffices to give an algorithm to edge-color G with ∆ colors only for the case in which ∆ is not bounded, say ∆ ≥ 8s(G)(> 4a0 (G)). Chrobak and Nishizeki’s algorithm [3] uses Chrobak and Yung’s algorithm [4] for the case in which ∆ is large, say ∆ ≥ 19. However, the algorithm in [4] works only for planar graphs with ∆ ≥ 19. Our idea is to decompose (not always planar) graph G of large maximum degree into several edge-disjoint subgraphs G1 , G2 , · · · , Gj of small maximum degrees ∆(Gi ) Pj 0 such that ∆(G) = i=1 ∆(Gi ) and 4s(G) ≤ χ (Gi ) = ∆(Gi ) < 8s(G) for each i, and hence an edge-coloring of G with ∆(G) colors can be obtained simply by superimposing edge-colorings of Gi with ∆(Gi ) colors. Note that the edge-coloring of Gi can be found within the required time bounds as shown in Lemma 5 since ∆(Gi ) is bounded. Let c be a bounded positive integer, and let E1 , E2 , · · · , Ej be a partition of E. Denote by Gi = G[Ei ] the subgraph of G induced by the edge set Ei . We say that E1 , E2 , · · · , Ej is a (∆, c)-partition of E if Gi = G[Ei ], 1 ≤ i ≤ j, satisfies Pj (i) ∆(G) = i=1 ∆(Gi ); and (ii) ∆(Gi ) = c for each i, 1 ≤ i ≤ j − 1, and c ≤ ∆(Gj ) < 2c. Clearly s(Gi ) ≤ s(G) for each i, 1 ≤ i ≤ j. Theorem 2 implies that χ0 (G) = ∆(G) since ∆(G) ≥ 8s(G) > 2s(G). Choose c = 4s(G), then ∆(Gi ) ≥ c =
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
11
4s(G) > 2s(Gi ) and hence χ0 (Gi ) = ∆(Gi ) for each i, 1 ≤ i ≤ j. Since ∆(Gi ) < 2c = 8s(G) ≤ 16a0 (G) = O(1) by Lemma 2, ∆(Gi ) is bounded for 1 ≤ i ≤ j. Furthermore ∆(Gi ) ≥ 4s(G) ≥ 4s(Gi ) ≥ 4a0 (Gi ) by Eqs. (3) and (5). Therefore by Lemma 5 one can find an edge-coloring of Gi with ∆(Gi ) colors in the claimed time. Since ∆(G) =
j X
∆(Gi ),
i=1
edge-colorings of Gi with ∆(Gi ) colors, 1 ≤ i ≤ j, can be immediately superimposed to an edge-coloring of G with ∆(G) colors. Zhou et al. [32] obtained the following result on the (∆, c)-partition. Lemma 6 If ∆(G) ≥ 2c ≥ 8s(G), then a (∆, c)-partition of E can be found in linear sequential time or in O(log n) parallel time with O(n) operations. Thus we have the following algorithm to edge-color a graph G such that a0 (G) is bounded and ∆(G) ≥ 4a0 (G). EDGE-COLOR(G); { assume that a0 (G) is bounded and ∆(G) ≥ 4a0 (G) } begin if ∆(G) < 8s(G) then {∆(G) is bounded } 1.
edge-color G with ∆(G) colors by Lemma 5; else {∆(G) ≥ 8s(G)} begin
2.
find a (∆, 4s(G))-partition E1 , E2 , · · · Ej of E(G);
3.
for i := 1 to j do edge-color of Gi with ∆(Gi ) colors where Gi = G[Ei ];
4.
extend these optimal edge-colorings of G1 , G2 , · · · , Gj to an optimal edge-coloring of G with ∆(G) colors end end;
We are now ready to prove Theorem 3. Proof of Theorem 3: By Lemmas 5 and 6 clearly the algorithm above correctly finds an edge-coloring of a graph G with ∆ colors. Therefore it suffices
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
12
to prove the complexities. By Lemma 6 line 2 can be done in linear time or optimally in parallel. By Lemma 5 line 1 can be done in O(n log n) sequential time or in O(log3 n) parallel time with O(n log3 n) operations, since ∆(G) < 8s(G) ≤ 16a0 (G) = O(1). At line 3, for each i, 1 ≤ i ≤ j, by Lemma 5 one can find an edge-coloring of Gi with ∆(Gi ) colors in O(n(Gi ) log n(Gi )) sequential time or in O(log3 n(Gi )) parallel time with O(n(Gi ) log3 n(Gi )) operations. Since Gi = G[Ei ], n(Gi ) ≤ 2|Ei |. Therefore j X i=1
n(Gi ) ≤ 2
j X
|Ei | = 2|E|.
i=1
Since the unicyclic index a0 (G) is bounded, |E| = O(n). Thus line 3 can be totally done in O(n log n) sequential time or in O(log3 n) parallel time with P O(n log3 n) operations. At line 4, since ∆(G) = ji=1 ∆(Gi ), one can immediately superimpose these edge-colorings of G1 , G2 , · · · , Gj to an edge-coloring of G with ∆(G) colors. Thus the algorithm spends O(n log n) sequential time in 2 total or in O(log3 n) parallel time with O(n log3 n) operations. It should be noted that the algorithm EDGE-COLOR does not need to know an actual decomposition of G into a(G) unicyclic subgraphs.
5
f -Coloring
In this section we give efficient sequential and NC parallel algorithms for the f -coloring problem on various classes of graphs. We first show that the f -coloring problem on a graph G can be reduced to the edge-coloring problem on a new graph Gf defined below. We may assume without loss of generality that f (v) ≤ d(v) for each v ∈ V . For each vertex v ∈ V , replace v with f (v) copies v1 , v2 , · · · , vf (v) , and attach the d(v) edges incident with v to the copies; attach dd(v)/f (v)e or bd(v)/f (v)c edges to each copy vi , 1 ≤ i ≤ f (v). Let Gf be the resulting graph. It should be noted that the construction of Gf is not unique. Figure 2 illustrates G and an example of Gf , where the number next to vertex v is f (v). Since an edge-coloring of Gf immediately induces an f -coloring of G with the same number of colors, we have χ0f (G) ≤ χ0 (Gf ).
(14)
However, Eq. (14) does not always hold in equality. For example, χ0f (G) = 2 for a graph G in Figure 2(a) as indicated by solid and dotted lines, but χ0 (Gf ) = 3 for the graph Gf in Figure 2(b) as indicated by thin, thick and dotted lines. Clearly ∆(Gf ) = ∆f (G) = maxv∈V dd(v)/f (v)e. If G is a simple graph, then Gf is also a simple graph and hence χ0 (Gf ) ≤ ∆(Gf ) + 1 = ∆f (G) + 1. Thus an edge-coloring of Gf with χ0 (Gf ) colors does not always induce an f -coloring of G with χ0f (G) colors, but induces a near-optimal f -coloring of G with at most ∆f (G) + 1 colors.
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
13
1 1
1
1
1
2
3 1
2
2 1
1
1
1 (a) G
(b) G f
Figure 2: Transformation from G to Gf . The number of P edges in Gf is equal to that of G, but the number of vertices of Gf increases to v∈V f (v) (≤ 2m). Furthermore one can easily observe that the following lemmas hold. Lemma 7 For a graph G there exists Gf such that (a) Gf is bipartite if G is bipartite; (b) Gf is planar if G is planar; (c) g(Gf ) ≤ g(G); (d) s(Gf ) ≤ s(G); (e) a(Gf ) ≤ a(G); (f) a0 (Gf ) ≤ a0 (G); and (g) θ(Gf ) ≤ θ(G). Lemma 8 Let G be a class of graphs which are closed under the transformation above, that is, any Gf is contained in G for every G ∈ G, and let α and β be real numbers. Then the following (a) and (b) hold. (a) If there exists a sequential algorithm to edge-color any graph G0 ∈ G by α∆(G0 ) + β colors in polynomial time T (m(G0 ) + n(G0 )), then there exists a sequential algorithm to f -color any graph G ∈ G by α∆f (G) + β colors in O(T (m(G) + n(G))) time. (b) If there exists a parallel algorithm to edge-color any graph G0 ∈ G by α∆(G0 ) + β colors in polylogarithmic parallel time T (m(G0 ) + n(G0 )) with polynomial operations P (m(G0 ) + n(G0 )), then there exists a parallel algorithm to f -color any graph G ∈ G by α∆f (G) + β colors in O(T (m(G) + n(G))) parallel time with O(P (m(G) + n(G))) operations.
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
14
Proof: (a) Let G be a graph in G. One can construct Gf from G in linear time. Using the assumed algorithm, one can find an ordinary edge-coloring of Gf with α∆(Gf )+ β colors in T (m(Gf )+ n(Gf )) time. The edge-coloring of Gf immediately induces an f -coloring of G with α∆(Gf ) + β = α∆f (G) + β colors. By the construction of Gf we have m(Gf ) = m(G) and n(Gf ) ≤ 2m(G) + n(G) and hence m(Gf ) + n(Gf ) ≤ 3m(G) + n(G). Since the function T is polynomial, T (m(Gf )+n(Gf )) = O(T (m(G)+n(G))). Thus an f -coloring of G can be found in O(T (m(G) + n(G))) time in total. (b) Similarly, Gf can be easily constructed from G in O(log(m(G) + n(G))) parallel time with O(m(G) + n(G)) operations. 2 It is known that χ0 (G) = ∆(G) if G is a bipartite graph [19] and that χ (G) = ∆(G) if G is a planar graph with ∆(G) ≥ 8 [10, 27]. Therefore, by Theorem 2, Corollary 1 and Lemmas 7, 8, we have the following theorem. 0
Theorem 4 χ0f (G) = ∆f (G) if one of the following (a)–(i) holds: (a) G belongs to a minor closed class G and ∆f (G) ≥ 2h(G); (b) G is bipartite [13]; (c) ∆f (G) ≥ 2s(G); (d) G is a partial k-tree and ∆f (G) ≥ 2k; (e) ∆f (G) ≥ 4a(G) − 2; (f) ∆f (G) ≥ 4a0 (G); (g) ∆f (G) ≥ 12θ(G) − 2; j k p (h) g(G) ≥ 1 and ∆f (G) ≥ 2 5 + 48g(G) + 1 /2 ; and (i) G is planar and ∆f (G) ≥ 8. Proof: Proofs of (a), (b), (c), (e), (f), (g) and (i) are immediate. If G is a partial k-tree, then Gf is not always a partial k-tree, but s(G) ≤ k. Therefore (d) above is an immediate consequence of (c). If g(G) ≥ 1 and j k p ∆f (G) ≥ 2 5 + 48g(G) + 1 /2 , then ∆f (G) = ∆(Gf ) ≥ 12 and hence χ0f (G) ≤ χ0 (Gf ) = ∆(Gf ) = ∆f (G) even 2 if g(Gf ) = 0. Thus (h) follows. By Theorem 3, Corollary 2, Lemmas 7, 8 and the algorithms in [3, 6, 12], we have the following results. Theorem 5 (a) Any graph √ G can be f -colored by at most ∆f (G)+ 1 colors in O(min{m∆f log n, m m log n}) time. (b) Any bipartite graph G can be f -colored by ∆f (G) colors in O(m log n) time.
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
15
(c) Graph G can be f -colored by ∆f (G) colors in O(n log n) time if one of the following (i) – (viii) holds: (i) G belongs to a minor closed class G and ∆f (G) ≥ 4h(G); (ii) a0 (G) is bounded and ∆f (G) ≥ 4a0 (G); (iii) a(G) is bounded and ∆f (G) ≥ 4a(G); (iv) s(G) is bounded and ∆f (G) ≥ 4s(G); (v) k(G) is bounded and ∆f (G) ≥ 4k(G); (vi) θ(G) is bounded and ∆f (G) ≥ 12θ(G); j k p (vii) g(G) ≥ 1 is bounded and ∆f (G) ≥ 4 5 + 48g(G) + 1 /2 ; and (viii) G is planar and ∆f (G) ≥ 9. Proof: (a) The algorithm in [12] edge-colors Gf with ∆(Gf ) + 1 colors in time p O(min{mf ∆f log nf , mf mf log nf }), where mf is the number of edges and nf the number of vertices in Gf . Since mf = O(m), nf = O(m + n) and ∆(Gf ) = ∆f (G), the claim holds. (b) Gf is also bipartite. The algorithm in [6] edge-colors a bipartite graph Gf with ∆(Gf ) colors in time O(mf log nf ). Thus the claim holds similarly as (a). (c) Similar to (b). Note that s(G) h(G), a0 (G) ≤ a(G) k ≤ s(G) ≤ k(G), j ≤ p 2 a(G) ≤ 3θ(G), and a(G) ≤ s(G) ≤ 5 + 48g(G) + 1 /2 . Theorem 6 (a) Any bipartite graph G can be f -colored by ∆f (G) colors in O(log3 n) parallel time with O(m) operations. (b) Graph G can be f -colored by ∆f (G) colors in O(log3 n) parallel time with O(n log3 n) operations if one of the following (i) – (viii) holds: (i) G belongs to a minor closed class G and ∆f (G) ≥ 4h(G); (ii) a0 (G) is bounded and ∆f (G) ≥ 4a0 (G); (iii) a(G) is bounded and ∆f (G) ≥ 4a(G); (iv) s(G) is bounded and ∆f (G) ≥ 4s(G); (v) k(G) is bounded and ∆f (G) ≥ 4k(G); (vi) θ(G) is bounded and ∆f (G) ≥ 12θ(G); j k p (vii) g(G) ≥ 1 is bounded and ∆f (G) ≥ 4 5 + 48g(G) + 1 /2 ; and (viii) G is planar and ∆f (G) ≥ 9.
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
16
Proof: (a) Gf is also bipartite. The algorithm in [20] edge-colors Gf with ∆(Gf ) colors in O(log3 nf ) parallel time with O(mf ) operations. Since mf = O(m), nf = O(m + n) and ∆(Gf ) = ∆f (G), the claim holds. (b) Similar to (a). 2 It should be noted that the algorithms in Theorems 5.4 and 5.5 do not need to know an actual embedding or a decomposition related to an invariant.
6
Conclusion
In this paper we first gave efficient sequential and NC parallel algorithms to edge-color graph G with ∆(G) colors if a0 (G) is bounded and ∆(G) ≥ 4a0 (G), where a0 (G) is the unicyclic index of G. Our algorithms are based on the following two algorithms: the edge-coloring algorithm (for planar graphs) by Chrobak and Nishizeki [3], and the algorithm for decomposing a graph of large maximum degree to edge-disjoint subgraphs of small maximum degrees by Zhou, Nakano and Nishizeki [32]. We next introduced a simple but useful reduction of an f -coloring to an ordinary edge-coloring, and derived various sufficient conditions for χ0f (G) = ∆f (G) to hold true. Using the reduction, we finally gave efficient sequential and NC parallel f -coloring algorithms.
Acknowledgments We would like to thank Dr. Hitoshi Suzuki and Dr. Shin-ichi Nakano for helpful comments and discussions. This research is partly supported by Grant in Aid for Scientific Research of the Ministry of Education, Science, and Culture of Japan under a grant number: General Research (C) 07650408.
References [1] M. Behzad, G. Chartrand, and L. Lesniak-Foster. Graphs and Digraphs. Pindle, Weber & Schmidt, Boston, 1979. [2] Y. Caspi and E. Dekel. Edge coloring series parallel graphs. Journal of Algorithms, 18:296–321, 1995. [3] M. Chrobak and T. Nishizeki. Improved edge-coloring algorithms for planar graphs. Journal of Algorithms, 11:102–116, 1990. [4] M. Chrobak and M. Yung. Fast algorithms for edge-coloring planar graphs. Journal of Algorithms, 10:35–51, 1989. [5] E. G. Coffman, J. M. R. Garey, D. S. Johnson, and A. S. LaPaugh. Scheduling file transfers. SIAM J. Comput., 14(3):744–780, 1985. [6] R. Cole and J. Hopcroft. On edge coloring bipartite graphs. SIAM J. Comput., 11:540–546, 1982.
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
17
[7] R. Diestel. Graph Theory, Springer, New York, 1997. [8] A.M. Dean and J.P. Hutchinson. Relations among embedding parameters for graphs. In Graph Theory, Combinatorics, and Applications, (Eds.) Y. Alavi, G. Chartrand, O.R. Ollermann, and A.J. schwenk. John Wiley and Sons, 287–296, 1991. [9] P. Erd¨ os and A. Hajnal. On chromatic number of graphs and set-systems. Acta. Math. Acad. Sci. Hungar., 17:61–99, 1966. [10] S. Fiorini and R. J. Wilson. Edge-Colourings of Graphs. Pitman, London, 1977. [11] H. N. Gabow and O. Kariv. Algorithms for edge-coloring bipartite graphs. SIAM J. Comput., 11:117–129, 1982. [12] H. N. Gabow, T. Nishizeki, O. Kariv, D. Leven, and O. Terada. Algorithms for edge-coloring graphs. Technical Report TRECIS-8501, Tohoku Univ., 1985. [13] S. L. Hakimi and O. Kariv. On a generalization of edge-coloring in graphs. Journal of Graph Theory, 10:139–154, 1986. [14] P. J. Heawood. Map color theorems. Quart. J. Math., 24:332–338, 1890. [15] I. Holyer. The NP-completeness of edge-colouring. SIAM J. Comput., 10:718–720, 1981. [16] T. Jensen and B. Toft. Graph Coloring Problems. John Wiley & Sons, New York, 1995. [17] P. C. Kainen. Some recent results in topolgical graph theory. In Proceedings of the Captial Conference on Graph Theory and Combinatorics, SpringerVerlag, Lecture Notes in Mathematics, volume 406, pages 76–200, 1974. [18] H. J. Karloff and D. B. Shmoys. Efficient parallel algorithms for edgecoloring problems. Journal of Algorithms, 8:39–52, 1987. ¨ [19] D. K¨ onig. Uber graphen und iher anwendung auf determinantentheorie und mengenlehre. Math. Ann., 77:453–465, 1916. [20] G. F. Lev, N. Pippenger, and L. G. Valliant. A fast parallel algorithm for routing in permutation networks. IEEE Transactions on Computers, C-30, 2:93–100, 1981. [21] W. Mader. Homomorphieeigenschaften und mittlere Kantendichte von Graphen. Math. Ann., 174, pp. 265–268, 1967. [22] D. Matula. A min-max theorem for graphs with application to graph coloring. SIAM Rev., 10:481–482, 1968.
X. Zhou et al., Edge-Coloring and f -Coloring, JGAA, 3(1) 1–18 (1999)
18
[23] D. Matula and L. Beck. Smallest-last ordering and clustering and graph coloring algorithms. JACM, 30:417–427, 1983. [24] S. Nakano and T. Nishizeki. Scheduling file transfers under port and channel constraints. Int. J. Found. of Comput. Sci., 4(2):101–115, 1993. [25] S. Nakano, T. Nishizeki, and N. Saito. On the f -coloring of multigraphs. IEEE Transactions on Circuits and Systems, CAS-35, 3:345–353, 1988. [26] C. S. J. A. Nash-Williams. Edge-disjoint spanning trees of finite graphs. J. London Math. Soc., 36:445–450, 1961. [27] T. Nishizeki and N. Chiba. Planar Graphs: Theory and Algorithms. NorthHolland, Amsterdam, 1988. [28] G. Szekeres and H. Wilf. An inequality for the chromatic number of a graph. J. Combinatorial Theory, 4:1–3, 1968. [29] O. Terada and T. Nishizeki. Approximate algorithms for the edge-coloring of graphs. Trans. Inst. of Electronics and Communication Eng. of Japan, J65-D, 11(4):1382–1389, 1982. [30] V. G. Vizing. On an estimate of the chromatic class of a p-graph (in Russian). Metody Discret Analiz., 3:25–30, 1964. [31] V. G. Vizing. Critical graphs with given chromatic class (in Russian). Metody Discret. Analiz., 5:9–17, 1965. [32] X. Zhou, S. Nakano, and T. Nishizeki. Edge-coloring partial k-trees. Journal of Algorithms, 21:598–617, 1996. [33] X. Zhou and T. Nishizeki. Edge-coloring and f -coloring for various classes of graphs. In Proc. of the Fifth International Symposium on Algorithms and Computation, Lect. Notes in Computer Science, Springer-Verlag, volume 834, pages 199–207, 1994. [34] X. Zhou, H. Suzuki, and T. Nishizeki. A linear algorithm for edge-coloring series-parallel multigraphs. Journal of Algorithms, 20:174–201, 1996. [35] X. Zhou, H. Suzuki, and T. Nishizeki. An NCparallel algorithm for edgecoloring series-parallel multigraphs. Journal of Algorithms, 23:359–374, 1997.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 3, no. 2, pp. 1–23 (1999)
Experimental Comparison of Graph Drawing Algorithms for Cubic Graphs Tiziana Calamoneri
Simone Jannelli
Rossella Petreschi
Dipartimento di Scienze dell’Informazione Universit´a di Roma “La Sapienza” { calamo,petreschi }@dsi.uniroma1.it Abstract We report on the results of an experimental study in which we have compared the performances of three algorithms for drawing general cubic graphs on the bidimensional orthogonal grid. The comparison works on 18,000 randomly generated graphs with up to 300 vertices and analyzes the number of bends and crossings, the area, the edge length and the running time.
Communicated by R. Tamassia: submitted May 1997; revised May 1999.
The first author is supported by the Italian Research Council – CNR.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999)
1
2
Introduction
An orthogonal grid drawing of a graph is a drawing such that the edges are polygonal chains consisting of horizontal and vertical segments and the vertices have integer coordinates. The graphs that admit such a drawing must have maximum degree 4. Among these graphs, cubic graphs (i.e. regular graphs of degree 3) and at most cubic graphs (i.e. graphs having bounded degree 3), constitute interesting and complex classes of graphs, despite their apparent simplicity. Indeed, cubic graphs are a natural model for a large number of real systems that interest many scientific fields such as Psychology, Probability, Economy, Physics, Geometry, and Computer Science. More in detail, some concrete examples are the study of the interaction of quantistic charged particles of high energy [4] and the study of flowgraphs to design hierarchical software metrics [21], see Figs. 1 and 2.
x1(t1)
y1(t1)
x(t) y(t)
x2(t2) y2(t2)
Figure 1: Interaction between two particles. Furthermore, cubic graphs have been widely studied by many researchers, since they seem to be a threshold class of graphs, in the sense that they are the simplest graphs for which several fundamental problems are as difficult as in the general case [5, 14]. Several results on orthogonal drawing of cubic graphs have been presented [2, 6, 7, 11, 17, 18, 19, 20, 22]. However, none of the cited papers provides experimental results, although the interest in experimentally testing the performance of graph drawing algorithms has increased in the last years [8, 9, 10, 15, 16]. This paper tries to bridge this gap by presenting an experimental comparison of three orthogonal drawing algorithms for cubic graphs. The three selected algorithms are as follows: the first one, by Biedl and Kant [2], is a specialization of an algorithm for graphs with bounded degree 4; the second and third ones, by Calamoneri and Petreschi [6] and by Papakostas and Tollis [19], respectively, are specifically designed for cubic graphs.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999)
3
b
c a
Figure 2: From a flowgraph to the underlying (undirected) cubic graph.
We have chosen these algorithms because they are homogeneous with respect to the input, the output and the leading idea. In particular, in our experimentation, no restriction on the input is required: neither planarity nor biconnectivity, nor a preliminary layout. This is the main reason why we have decided not to include in our experimentation algorithms such as those presented in [3, 17, 22], which deal with planar and/or triconnected graphs only. For what concerns the output, it is accepted to be non plane, even if the input graph is planar. The chosen algorithms add one vertex at a time according to an st-numbering [13]; therefore, the algorithm described in [20] has not been considered because it works on pairs of vertices. All the algorithms first work on biconnected components and then splice the drawings of the components to form a drawing of the entire graph. Thus, the results of our experiments are reported in two series of diagrams, one for biconnected graphs and the other for simply connected graphs. Observe that the algorithm by Biedl and Kant is the only algorithm, among the chosen ones, not to be explicitly designed for cubic graphs. We have included this algorithm in the experimentation also to check if designing a drawing algo-
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999)
4
rithm specifically for cubic graphs can improve its performance. The answer to this question is discussed in Section 5. Finally, the chosen algorithms achieve the best theoretical results known in the literature for a general at most cubic graph in minimizing the area, the total number of bends and the running time. The rest of this paper is organized as follows: in Section 2, some basic definitions are given. In Section 3, the three analyzed drawing algorithms are sketched outlining the similarities and underlining the differences. Section 4 contains the results of the experiments (summarized in twelve diagrams) and a comparative analysis of the performance of the algorithms. Finally, in Section 5, we show drawings of the same graph generated by the three algorithms and offer concluding remarks.
2
Basic Definitions
In this section we introduce some preliminary concepts related to the topics dealt in this paper. Definition 1 Let G = (V, E) be a graph, n = |V | and m = |E|. An orthogonal drawing of G is a drawing of G in the plane such that all edges are drawn as sequences of horizontal and vertical segments. The edges are not allowed to overlap for any distance (although a vertical segment may cross a horizontal one). In addition, the edges cannot cross vertices that are not their extremes. A point where the drawing of an edge changes its direction is called a bend of this edge. This drawing is said to be a drawing in the (rectangular) grid if all vertices and bends are at integer coordinates. In the following the four directions on the grid with respect to each vertex are distinguished and a direction is called free with respect to a vertex if no edge is present on it. Definition 2 Let k be a non negative integer. A k-bend drawing of a graph G is a grid drawing of G in which every edge contains at most k bends. Definition 3 [1] Let G be a connected graph. A vertex a is said to be an articulation vertex of G if there exist vertices v and w such that v, w and a are distinct, and every path between v and w contains vertex a. A connected graph G is said to be biconnected if for every distinct triplet of vertices v, w, a, there exists a path between v and w and not containing a. Thus, a connected graph is biconnected if and only if it has no articulation vertex. Observe that a nontrivial biconnected graph cannot have any vertex of degree 1. When we deal with biconnected graphs, we will assume that the input graph is cubic. Indeed, if it is at most cubic, we can first eliminate each vertex of degree 2 by merging its incident edges. After drawing the resulting cubic
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999)
i
i
i
i
x
j
5
x
j
j
j
Figure 3: Transformation from biconnected at most cubic graph to cubic graph and vice-versa.
graph, we can reinsert a vertex of degree 2 adjacent to vertices i and j by simply placing a “dot” along the drawing of edge (i, j) (see Fig. 3). Definition 4 [13] Given any edge {s, t} of a biconnected graph G = (V, E), a function g : V → {1, 2, . . . , n} is called an st-numbering if the following conditions hold: • g(u) 6= g(v) for u 6= v • g(s) = 1 • g(t) = |V | = n • for every v ∈ V − {s, t} there are vertices u and w such that g(u) < g(v) < g(w) and {u, v}, {w, v} ∈ E. From now on, we shall refer to the vertices of a biconnected st-numbered cubic graph G = (V, E) by their st-numbers.
3
The Algorithms Under Evaluation
In order to make this paper self-contained, we shall briefly describe the three algorithms we compare in the following and we will refer to them by means of the first letters of their authors, i.e. BK[2], CP[6] and PT[19], respectively. To make easier the reading of this section, we deal only with the key aspects of the algorithms and we skip technical details. Furthermore, we present the common characteristics and the differences between the algorithms. • The input of these algorithms is a general simple loopless at most cubic graph G (neither planarity nor 2- or 3-connectivity are required). Since
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999)
6
n
Figure 4: Insertion of vertex n in Algorithm PT.
Algorithm PT is presented in [19] only for biconnected graphs, in our comparisons we added to PT a second phase able to handle separated biconnected components and to splice them. Namely, we utilize the procedure detailed by Algorithm CP to assemble the biconnected components. • In order to obtain better upper bounds for the optimization functions, the algorithms do not guarantee the output to be plane even if the input is planar. Actually, Algorithm BK has a behavior different from the other two since it gets a plane drawing if a plane layout of G is given as input. For the sake of uniformity, we have not considered this case. • With respect to the number of bends per edge, all three algorithms reach a constant value, either 1 or 2. In particular, the output of algorithm CP is exactly a 1-bend drawing of G; the output of PT is 1-bend except at most one edge incident to n (Fig. 4) while the output of BK is 2-bend. Notice that the introduction of 2 bends per edge arises from the fact that this algorithm has been designed for graphs with bounded degree 4. • Both Algorithm CP and PT use the concept of movement of bends, already introduced in [18]. The movement of a bend consists of moving a vertex k along an edge in order to change its free directions (Fig. 5). This has also the effect of changing the position of a bend, while the total number of bends stays the same. In Algorithm CP it is possible to change the free directions of a vertex also through a rotation. This operation does not guarantee the invariance of the number of bends; in Fig. 6 a possible rotation is shown. • All the algorithms divide the input graph into its biconnected components and run a pre-processing phase computing an st-numbering. Then, one by one, each biconnected component is drawn; finally, the whole drawing of the graph is obtained by connecting the drawings of the different components.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999)
k
7
k
j i
j i
Figure 5: Movement of a bend.
k k
i
j
j
i
Figure 6: Rotation of a vertex.
• The basic idea of the first phase consists of adding the vertices to the drawing one at a time ordered according to an st-numbering. This construction is made for each biconnected component and it is based on the existence, in an st-numbered graph, of edges {1, 2}, {n − 1, n} and, for each vertex j (where j 6= 1, n), of edges {j, i} and {j, l} such that i < j < l. Let G k = (Vk , Ek ) be the subgraph induced by the first k vertices in the stnumbering (Vk = {1, 2, . . . , k}) and Dk a drawing for G k . During the k-th step, vertex k and the edges {i, k}, with i < k, are added to Dk−1 . Each author has his/her own rules to lay vertex k out, and they constitute the main reason of the difference between the three algorithms. In particular, Algorithm BK, at each step, associates with a free direction of k an edge incident to k that will be drawn in a successive step (Fig. 7). Algorithms CP and PT draw k in such a way that at least one and at most two edges do not introduce any bend. • The final difference we want to highlight is the addition of vertex n to Dn−1 . Algorithm CP places vertex n and its edges on the grid as a comb graph (Fig. 8) after having possibly operated a rotation or a movement of some bends. Beside the comb graph, Algorithm PT must accept also the configuration of Fig. 4 for n because this algorithm does not provide any rotation.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999)
8
2
1
Figure 7: Insertion of vertices 1 and 2 in Algorithm BK.
n
Figure 8: A comb graph.
Finally, in Algorithm BK the addition of vertex n induces the drawing of the last three edges dotted in the previous steps. Then, the insertion of n and its edges induces a comb graph-like structure in which the teeth are not connected to the n’s adjacent vertices but to their dotted edges. • The second phase of the algorithms deals with general at most cubic graphs and uses a decomposition into biconnected components. The common idea is to draw separately each component and then to join the drawings of the components through their connections. In this step, both Algorithms BK and CP work in a recursive way, but they use different methods. The main difference is that in BK the bridges (separating edges) are removed, while in CP the articulation vertices are deleted. This difference is reflected in the way the biconnected components are later spliced together. Indeed, in BK only edges whose endpoints are already drawn must be added, but this requires that at least one of these endpoints be on the boundary of the drawing of its biconnected component. In CP the articulation vertices and their incident edges are added and no constraint is required for their adjacent vertices. However, some directions towards the boundary of the current drawing are always left free (either directly, or after a movement of a bend, or after a rotation). We conclude this section summarizing the worst-case theoretical results achieved by the three algorithms.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999)
9
• Regarding the area of the drawing, for BK it is ( n2 + 2) × (n − 2) if the input is biconnected and 34 n × 34 n otherwise. In CP and PT the area is n2 × n2 and ( n2 + 1) × n2 , respectively, both for biconnected and simply connected graphs. • Regarding the total number of bends, Algorithm BK achieves n + 1 and n for biconnected and simply connected graphs, respectively. In Algorithm CP the bound is n2 + 1 in the biconnected case and it is improved by 1 in the connected case. Finally, Algorithm PT draws a graph with at most n 2 + 3 bends. • CP constructs a 1-bend drawing PT constructs a 2-bend drawing except for one edge with two bends, and BK constructs a 2-bend drawing. • All three algorithms run in linear time. Notice that for BK we have indicated better bounds than those reported in [2] since we consider only almost cubic graphs.
4
Analysis of the Experimental Results
4.1
Performance Indicators
The experiments provide a detailed quantitative evaluation of the performance of the three algorithms, both from an “aesthetic” point of view (area, number of crossings, number of bends, edge length) and from a computational one. Namely, the considered performance indicators for each algorithm are: • Area: area of the smallest rectangle with horizontal and vertical sides covering the drawing; • Bends: total number of bends; • Crossings: total number of edge-crossings; • MaxEdgeLen: maximum length of any edge; • TotalEdgeLen: total edge length; • Time: CPU time (measured in milliseconds) to compute the geometry of the drawing, including the st-numbering computation but excluding both the graph generation time and the time for drawing on screen. The resolution is 0.2 ms. Observe that we do not consider MaxEdgeBends (maximum number of bends on any edge) because of the discussed theoretical results of the algorithms.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999) 10
4.2
Experimental Setting
In order to compare the performance of the three algorithms outlined in Section 3, we have tested them on 18,000 randomly generated graphs with with number of vertices in the range 10 . . . 300. The results of the experimentation are presented in graphical form and reported in Figs. 10–21. We produced the statistics by grouping the graphs by number of vertices. We decided not to group the graphs by the number of edges since all at most cubic graphs are sparse and all our sample graphs have more or less the same number of edges for the same number of vertices. Therefore, data points in the diagrams are averages over 300 graphs with the same number of vertices. Moreover, we give two separate series of diagrams, one for biconnected graphs and one for simply connected graphs. Biconnected graphs were generated by adding, one at a time, an edge between two randomly chosen vertices with degree less than three. The generation procedure ends when the graph becomes connected and the number m of inserted edges is such that 2.75n/2 ≤ m ≤ 3n/2. At the end of the procedure, if the graph is biconnected it is added to the experimental suite, otherwise it is discarded. Observe that this naive method to impose biconnectivity is not computationally expensive because almost all at most cubic graphs with more than 2.75n/2 edges are biconnected. Simply connected graphs were generated by merging biconnected components: the number of biconnected components is randomly chosen in the range 2 . . . n/20 and, accordingly, their size is randomly decided. The biconnected components are generated using the previous procedure and then they are merged together avoiding the creation of cycles.
4.3
Implementation
The algorithms have been implemented in C and have been run on a computer with a Pentium MMX 166 MHz processor. A technical problem faced during the implementation of all three algorithms is the maintenance of the vertex coordinates during the incremental construction of the drawing. Indeed, when adding a new row or column to the drawing to accommodate the placement of the next vertex, the coordinates of many vertices and bends may need to be updated. This implies that it is not possible to compute the final coordinates of each vertex as it is added to the drawing. By representing the “virtual” coordinates by means of two sorted lists, this problem is reduced to the problem of maintaining order in a list, for which an optimal linear-time solution using sophisticated techniques is given by Dietz and Sleator [12]. In our implementation we have opted instead for a simple lineartime method that experimentally works very well but that is not guaranteed to always give correct results, although it never failed in our experimentations. Our method uses temporary floating-point coordinates for the vertices during
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999) 11 the execution of the algorithm. Namely, consider the insertion of a new vertex k on a new row (column) between the rows (columns) where its two adjacent vertices i and j lie. W.l.o.g., suppose that yj < yi (xj < xi ) and let yb (xb ) be the first occupied row (column) in the range [yj , yi ] ([xj , xi ]) after yj (xj ). This is the value immediately following yj (xj ) in the sorted list of y (x) coordinates. We assign to vertex k y- (x-)coordinate equal to the average of yj and yb (xj and xb ) and update the sorted list by inserting yk (xk ) is after yj (xj ) and before yb (xb ). At the end of the construction of the drawing we transform the temporary floating-point coordinates into final integer coordinates in linear time, with a simple prefix sum algorithm. The above algorithm may yield incorrect results if there is a long succession of vertices k1 , . . . , ks with the following property: • k1 lies between i and j; • kr (r = 2, . . . , s) lies between kr−1 and i. For typical processors, errors occur if s ≥ 36, an event that never occurred in our experiments. Another minor problem was that our implementation of Algorithm PT failed on some input graphs. This is due to the fact that the original description of the algorithm does not mention how to deal with certain special cases (see Fig. 9). i
k
j
Figure 9: Example of ignored configuration in Algorithm PT.
4.4
Analysis
In this section, we discuss the results of the experiments and analyze in detail the various performance indicators. • The observed practical behavior of the algorithms is consistent with their theoretical properties. Actually, the experimental results for some performance indicators, such as the number of bends for connected graphs, are slightly better than the theoretical worst-case bounds.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999) 12 • There is no significant difference between the results for biconnected and simply connected graphs on the area, maximum edge length and running time. On the contrary, there is a wide gap between the results for connected and biconnected graphs on the number of bends, the number of crossings and the total edge length. Justifications of this behavior are given in the following. • From a computational point of view, drawing cubic graphs is a well solved problem: even the slowest algorithm takes only 6.8 ms to draw the largest graphs (300 vertices). We now discuss in detail each performance indicator. • Area: (Figs. 10 and 11) Algorithm PT yields average area very close to the theoretical bound of n2 /4 + o(n2 ), both in the connected and in the biconnected case. The area of drawings computed by Algorithm BK is n2 /2 both in the connected and biconnected case. But, while this value matches the theoretical value of the area for biconnected graphs, it is slightly better than 9n2 /16, which is the theoretical bound for connected graphs. This suggests that the configurations leading to the larger theoretical value for the area in the connected case are rare. Finally, since Algorithm CP tries to draw vertices without adding new bends and therefore without adding new rows and columns, it reaches a slightly better area bound (about n2 /4.88 instead of n2 /4) both in the connected and in the biconnected case. • Bends: (Figs. 12 and 13) For what concerns the total number of bends, it is clear from the diagrams that all three algorithms generate fewer bends in the simply connected case than in the biconnected one. Namely, BK generates a total number of bends that is close to n for biconnected graphs and close to n/1.25 for connected graphs. Algorithm PT approaches n/2 and n/2.5 in the biconnected and connected case, respectively. Algorithm CP works better from this point of view, since it generates about n/2.44 and n/3 bends if the input graph is biconnected and connected, respectively. Also, the ratio between the averages of the numbers of bends in the biconnected and connected case is about 1.22 in all algorithms: the better results in the biconnected case can be justified by the lower number of edges on average. • Crossings: (Figs. 14 and 15) The total number of crossings does not appear to be an increasing function of the number of vertices because the number of crossings is highly random. Since edges connecting the biconnected components are always drawn without crossings, their number
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999) 13
40000 35000 30000 25000 20000 15000 10000 5000 0 Area
10 20 30
40 50
60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300
Number of vertices BK
PT
CP
Figure 10: Area versus number of vertices for simply connected graphs.
40000 35000 30000 25000 20000 15000 10000 5000 0 Area
10 20 30
40 50
60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300
Number of vertices BK
PT
CP
Figure 11: Area versus number of vertices for biconnected graphs.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999) 14
240
200
160
120
80
40
0 number of bends
10
20
30
40
50
60
70
80
90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300
number of vertices BK
PT
CP
Figure 12: Total number of bends versus number of vertices for simply connected graphs. 320 280 240 200 160 120 80 40 0 number of bends
10
20
30
40
50
60
70
80
90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300
number of vertices BK
PT
CP
Figure 13: Total number of bends versus number of vertices for biconnected graphs.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999) 15
1000 800 600 400 200 0 number of crossings
10
20
30
40
50
60
70
80
90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300
number of vertices BK
PT
CP
Figure 14: Crossings versus number of vertices for simply connected graphs. 5000 4800 4600 4400 4200 4000 3800 3600 3400 3200 3000 2800 2600 2400 2200 2000 1800 1600 1400 1200 1000 800 600 400 200 0
number of crossings
A A 10
20
BK
30
40
50
60
70
80
90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300
number of vertices PT
CP
Figure 15: Crossings versus number of vertices for biconnected graphs.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999) 16
400
300
200
100
0 Max Edge Length
10
20
30
40
50
60
70
80
90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300
number of vertices BK
PT
CP
Figure 16: Maximum edge length versus number of vertices for simply connected graphs.
400
300
200
100
0 Max Edge Length
10
20
30
40
50
60
70
80
90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300
number of vertices BK
PT
CP
Figure 17: Maximum edge length versus number of vertices for biconnected graphs.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999) 17
14000 12000 10000 8000 6000 4000 2000 0
Total Edge 10 20 Length BK
30
40
50
60
70
PT
80
CP
90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300
number of vertices
Figure 18: Total edge length versus number of vertices for simply connected graphs. 26000 24000 22000 20000 18000 16000 14000 12000 10000 8000 6000 4000 2000 0
Total Edge Length
10
BK
20
30
40
50
PT
60
70
80
CP
90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300
number of vertices
Figure 19: Total edge length versus number of vertices for biconnected graphs.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999) 18
7 6
5
4
3
2
1 0 10
20
30
40
50
60
70
80
computational time
90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300
number of vertices
BK
PT
CP
Figure 20: Computational time (in ms) versus number of vertices for simply connected graphs. 7 6
5
4
3
2
1 0 10
computational time BK
20
30
40
50
60
70
80
90 100 110 120 130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300
number of vertices PT
CP
Figure 21: Computational time (in ms) versus number of vertices for biconnected graphs.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999) 19 is consistently smaller when the graphs are simply connected rather than when they are biconnected. The average values in the biconnected case are n2 /33, n2/25.8 and n2 /17.6 for Algorithms BK, CP and PT, respectively. The good result of BK can be explained as a consequence of the fact that it is designed to support the drawing of planar graphs without crossings, and therefore its number of crossings is lower, to the detriment of the area. • MaxEdgeLen: (Figs. 16 and 17) and TotEdgeLen: (Figs. 18 and 19) The experimental values of the maximum edge length are 1.4n, 0.5n and 0.6n in the connected case and 1.36n, 0.77n and 0.88n in the biconnected case for Algorithms BK, CP and PT, respectively. The values of the total edge length are 1/4n2 , 1/13n2 and 1/12n2 in the connected case and 2/7n2, 1/6n2 and 1/5n2 in the biconnected case for Algorithms BK, CP and PT, respectively. We have no theoretical bounds to compare these results to, but we observe that all the algorithms have considerably worse performance in the biconnected case. This is because when two biconnected components are merged, some edges are lengthened and influence these performance indicators. • Computational time: (Figs. 20 and 21) All three algorithms are very fast: PT runs in n/54 and n/50 ms on connected and biconnected graphs, respectively; BK and CP need n/48(n/47) and n/47(n/44) ms to draw an n vertex connected and biconnected cubic graph, respectively.
5
Conclusions
Following the trend of comparing the theoretical properties of graph drawing algorithms with experimental results and of estimating performance indicators, in this paper we analyze three algorithms for constructing orthogonal grid drawings of cubic graphs. The main conclusion of our work is that this problem is well solved both from a theoretical and an experimental point of view. Analyzing more in detail the results of the experimentation, we see that the best algorithm depends on the criteria used. If the most important objective is either the area or the maximum number of bends or the edge length, the best algorithm is CP. According to the computational time PT beats the other two. A partial justification of why BK performs best only regarding the number of crossings lies in its goals: to draw graphs with maximum degree 4 and to focus on planar graphs. To conclude, we give an example of the layouts produced by the three algorithms by running them on the graph of Fig. 22. Figs. 23, 24 and 25 show the drawings generated by Algorithms BK, CP and PT, respectively.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999) 20
Figure 22: A graph with 30 vertices.
Figure 23: Graph of Fig. 22 drawn by Algorithm BK.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999) 21
Figure 24: Graph of Fig 22 drawn by Algorithm CP.
Figure 25: Graph of Fig 22 drawn by Algorithm PT.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999) 22
References [1] A. Aho, J. K. Hopcroft, and J. D. Ullman. The design and analysis of computer algorithms. Addison Wesley, Reading, MA, 1973. [2] T. Biedl, and G. Kant. A Better Heuristic for Orthogonal Graph Drawings. Comput. Geom. Theory Appl., 9:159–180, 1998. Also in Proc. European Symposium on Algorithms (ESA ’94), Lectures Notes in Computer Science 855, Springer-Verlag, pages 24–35, 1994. [3] T. Biedl. Optimal plane orthogonal drawings for triconnected graphs. In Proc. Scandinavian Workshop on Algorithm Theory (SWAT’96), Lectures Notes in Computer Science 1097, Springer-Verlag, pages 333–344, 1996. [4] J.D. Bjorken, and S.D. Drell. Relativistic Quantum Fields. Mc-Graw Hill, New York, 1965. [5] T. Calamoneri. Does Cubicity Help to Solve Problems? Ph.D. Thesis, University of Rome “La Sapienza”,XI-2-97, 1997. [6] T. Calamoneri, and R. Petreschi. An Efficient Orthogonal Grid Drawing Algorithm for Cubic Graphs. In Proc. First Annual International Conference on Computing and Combinatorics (COCOON ’95), Lectures Notes in Computer Science 959, Springer-Verlag, pages 31–40, 1995. [7] T. Calamoneri, and R. Petreschi. Orthogonal Drawing Cubic Graphs in Parallel. J. Parallel and Distr. Comput., 55:94–108, 1998. [8] G. Di Battista, A. Garg, G. Liotta, R. Tamassia, E. Tassinari, and F. Vargiu. An Experimental Comparison of Three Graph Drawing Algorithms. In ACM Symposium on Computational Geometry, ACM, pages 306–315, 1995. [9] G. Di Battista, A. Garg, G. Liotta, R. Tamassia, E. Tassinari, and F. Vargiu. An Experimental Comparison of Four Graph Drawing Algorithms. Comp. Geom., 7(5-6):303–325, 1997. [10] G. Di Battista, A. Garg, G. Liotta, A. Parise, R. Tamassia, and E. Tassinari. Drawing Directed Acyclic Graphs: An Experimental Study. In Proc. Graph Drawing (GD’96), Lectures Notes in Computer Science 1190, SpringerVerlag, pages 76–91, 1996. [11] G. Di Battista, G. Liotta, and F. Vargiu. Spirality and Optimal Orthogonal Drawings. SIAM J. Comput., 27(6):1764–1811, 1998. [12] P. F. Dietz, and D. D. Sleator. Two algorithms for maintaining order in a list. In Proc. 19th ACM Symp. on Theor. Comp. Sci. (STOC ’87), 2, pages 436–441, 1976.
T. Calamoneri et al., Experimental Comparison..., JGAA, 3(2) 1–23 (1999) 23 [13] S. Even, and R. E. Tarjan. Computing an st-numbering. Theoret. Comp. Sci., 365–372, 1987. [14] R. Greenlaw, and R. Petreschi. Cubic graphs. ACM Computing Surveys, 27 (4):471–495, 1995. [15] M. Himsolt. Comparing and evaluating layout algorithms within GraphEd. J. Visual Lang. Comput. (special issue on Graph Visualization), 6(3):255273, 1995. [16] S. Jones, P. Eades, A. Moran, N. Ward, G. Delott, and R. Tamassia. A note on planar graph drawing algorithms. Tech. Rep. 216, Department of Computer Science, University of Queensland, 1991. [17] G. Kant. Drawing Planar Graphs Using the canonical ordering. In Proc. 33th Ann. IEEE Symp. on Found. of Comp. Science (FOCS ’92), pages 101–110, 1992. Also in Algorithmica - Special Issue on Graph Drawing, 16: 4–32, 1996. [18] Y. Liu, P. Marchioro, and R. Petreschi. At most single bend embedding of cubic graphs. Tech. Rep. SI 92/01 Dept. of Comp. Science University of Rome “La Sapienza”, 1992. Also in Applied Mathematics (Chin. Journ.), 9/B/2,127–142, 1994. [19] A. Papakostas, and I.G. Tollis. Improved Algorithms and Bounds for Orthogonal Drawings. In Proc.Graph Drawing (GD’94), Lectures Notes in Computer Science 894, Springer-Verlag, pages 40–51, 1994. [20] A. Papakostas, and I.G. Tollis. Algorithms for Area-Efficient Orthogonal Drawings. Comput. Geom. Theory Appl., 9:83–110, 1998. [21] R.E. Prather. Design and Analysis of Hierarchical Software Metrics. ACM Computing Surveys, 27 (4):497–518, 1995. [22] M. S. Rahman, S. Nakano, and T. Nishizeki. A Linear-Time Algorithm for Orthogonal Drawings of Triconnected Cubic Plane Graphs with the Minimum Number of Bends. In Proc. Graph Drawing (GD’97), Lectures Notes in Computer Science 1353, Springer-Verlag , pages 99–110, 1997.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 3, no. 3, pp. 1–27 (1999)
Subgraph Isomorphism in Planar Graphs and Related Problems David Eppstein Department of Information and Computer Science University of California, Irvine http://www.ics.uci.edu/∼eppstein/
[email protected] Abstract We solve the subgraph isomorphism problem in planar graphs in linear time, for any pattern of constant size. Our results are based on a technique of partitioning the planar graph into pieces of small tree-width, and applying dynamic programming within each piece. The same methods can be used to solve other planar graph problems including connectivity, diameter, girth, induced subgraph isomorphism, and shortest paths.
Communicated by Roberto Tamassia: submitted December 1995, revised November 1999.
Work supported in part by NSF grant CCR-9258355 and by matching funds from Xerox Corp.
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
1
2
Introduction
Subgraph isomorphism is an important and very general form of exact pattern matching. Subgraph isomorphism is a common generalization of many important graph problems including finding Hamiltonian paths, cliques, matchings, girth, and shortest paths. Variations of subgraph isomorphism have also been used to model such varied practical problems as molecular structure comparison [2], integrated circuit testing [10], microprogrammed controller optimization [26], prior-art avoidance in genetic evolution of circuits [33], analysis of Chinese ideographs [27], robot motion planning [34], semantic network retrieval [36], and polyhedral object recognition [44]. In the subgraph isomorphism problem, given a “text” G and a “pattern” H, one must either detect an occurrence of H as a subgraph of G, or list all occurrences. For certain choices of G and H there can be exponentially many occurrences, so listing all occurrences can not be solved in subexponential time. Further, the decision problem is NP-complete. However for any fixed pattern H with ` vertices, both the enumeration and decision problems can easily be solved in polynomial O(n` ) time, and for some patterns an even better bound might be possible. Thus one is led to the problem of determining the algorithmic complexity of subgraph isomorphism for a fixed pattern. Here we consider the special case in which G (and therefore H) are planar graphs, a restriction naturally occurring in many applications. We show that for any fixed pattern, planar subgraph isomorphism can be solved in linear time. Our results extend to some other problems including vertex connectivity, induced subgraph isomorphism and shortest paths. Our algorithm uses a graph decomposition method similar to one used by Baker [6] to approximate various NP-complete problems on planar graphs. Her method involves removing vertices from the graph leaving a disjoint collection of subgraphs of small tree-width; in contrast we find a collection of non-disjoint subgraphs of small tree-width covering the neighborhood of every vertex. We assume throughout that all planar graphs are simple, so that the number of edges is at most O(n); this simplifies our time bounds as we need not include the dependence on this number. The only problems for which this assumption makes a difference are induced subgraph isomorphism, h-clustering, and edge connectivity; for those, one can assume without loss of generality that the graph has bounded edge multiplicity, so again m = O(n).
2
New Results
We prove the following results. The time dependence on H is omitted from these bounds. In general it is exponential (necessarily so, unless P=NP, since planar subgraph isomorphism is NP-complete) but see Theorem 3 for situations in which it can be improved. • We can test whether any fixed pattern H is a subgraph of a planar graph G, or count the number of occurrences of H as a subgraph of G, in time O(n).
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
3
• If connected pattern H has k occurrences as a subgraph of a planar graph G, we can list all occurrences in time O(n + k). If H is 3-connected, then k = O(n) [16], and we can list all occurrences in time O(n). • We can count the number of induced subgraphs of a planar graph G isomorphic to any fixed connected pattern H in time O(n), and if there are k occurrences we can list them in time O(n + k). • For any planar graph G for which we know a constant bound on the diameter, we can compute the exact diameter in time O(n). • For any constant h we can solve the h-clustering and connected h-clustering problems [30] in planar graphs in time O(n). • For any planar graph G for which we know a constant bound on the girth, we can compute the exact girth in time O(n). The same bound holds if instead of girth we ask for the shortest separating cycle or for the shortest nonfacial cycle in a given plane embedding of the graph. • For any planar graph G, we can compute the vertex connectivity and edge connectivity of G in time O(n). (For planar multigraphs, we can test k-edge-connectivity for any fixed k in time O(n).) • For any planar graph G and any constant `, we construct in time O(n) a linear-space routing data structure which can test for any pair of vertices whether their distance is at most `, and if so find a shortest path between them, in time O(log n).
3
Related Work
For general subgraph isomorphism, nothing better than the naive exponential O(n|H| ) bound is known. Plehn and Voigt [41] give an algorithm √ for subgraph O(|H|) O( |H|) n (since imisomorphism which in planar graphs takes time |H| √
proved by Alon et al. [1] to 2O(|H|) nO( |H|) ), but this is still much larger than the linear bound we achieve. Several papers have studied planar subgraph isomorphism with restricted patterns. It has long been known that if the pattern H is either K3 or K4 , then there can be at most O(n) instances of H as a subgraph of a planar graph G, and that these instances can be listed in linear time [7, 28, 40], a fact which has been used in algorithms to test connectivity [35], to approximate maximum independent sets [7], and to test inscribability [14]. Linear time and instance bounds for K3 and K4 can be shown to follow solely from the sparsity properties of planar graphs [12, 13], and similar methods also generalize to problems of finding K2,2 and other complete bipartite subgraphs [12, 17]. Richards [42] gives O(n log n) algorithms for finding C5 and C6 subgraphs in planar graphs, and leaves open the question for larger cycle lengths; Alon et al. [1] gave O(n log n) deterministic and O(n) randomized algorithms for larger cycles. In [16], we
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
4
showed how to list all cycles of a given fixed length in outerplanar graphs, in linear time (see also [37, 38, 39, 45] for similar variants of outerplanar subgraph isomorphism). We used our outerplanar cycle result to find any wheel of a given fixed size in planar graphs, in linear time. Itai and Rodeh [28] discuss the problem of finding the girth of a general graph, or equivalently that of finding short cycles. The problem of finding cycles in planar graphs was discussed above. Fellows and Langston [20] discuss the related problem of finding a path or cycle longer than some given length in a general graph, which they solve in linear time for a given fixed length bound. The planar dual to the shortest separating cycle problem has been related by Bayer and Eisenbud [8] to the Clifford index of certain algebraic curves. Our results here generalize and unify this collection of previously isolated results, and also give improved dependence on the pattern size in certain cases. Recently we were able to characterize the graphs that can occur at most O(n) times as a subgraph isomorph in an n-vertex planar graph: they are exactly the 3-connected planar graphs [16]. However our proof does not lead to an efficient algorithm for 3-connected planar subgraph isomorphism. In this paper we use different techniques which do not depend on high-order connectivity. Laumond [35] gave a linear time algorithm for finding the vertex connectivity of maximal planar graphs. Eppstein et al. [19] give an O(n) time algorithm for testing k-edge-connectivity for k ≤ 4 and k-vertex-connectivity for k ≤ 3. For general graphs, testing k-edge-connectivity for fixed k takes time O(m + n log n) [25]. 4-vertex-connectivity in general graphs can be tested in time O(nα(n) + m) [29]. However planar graphs can be as much as 5-vertexconnected, and nothing even close to linear was known for testing planar 5connectivity. Our shortest path data structure combines our methods of bounded treewidth decomposition with a separator-based divide and conquer technique due to Frederickson [21]. Obviously all pairs shortest paths can be computed in time O(nm) after which the queries we describe can be answered in time O(1), but some faster algorithms are known for approximate planar shortest paths [23, 24, 31]. Our data structure answers shortest path queries exactly, in less preprocessing time than the other known results, but can only find paths of constant length. A final note of caution is in order. One should not be confused by the superficial similarity between the subgraph isomorphism problems posed here and the graph minor problems studied extensively by Robertson, Seymour, and others [43]. One can recognize path subgraphs by minor testing, but such tricks do not work for most other subgraph isomorphism problems. The absence of a fixed minor imposes severe structural constraints on a graph, whereas this is much less the case when a fixed subgraph is not present. Although minor testing can be done in time polynomial in the text graph size, the constant factors are typically much higher than those for our subgraph isomorphism algorithm.
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
A
5
G { A, F, G, H } F
H { A, F, H, M }
B
E
{ A, E, F, M }
{ F, H, K, M }
{ A, D, E, M }
{ H, K, L, M }
K L
C { A, C, D, E }
D
M
{ A, B, C, E }
Figure 1: Tree decomposition of a planar graph.
4
Bounded Tree-Width Subgraph Isomorphism
As a subroutine, we need to perform subgraph isomorphism testing in graphs of bounded tree-width. This can be done by a standard dynamic programming technique [9, 46]. The exact statement of the problem we solve is complicated by the requirement that we count or list each subgraph isomorph exactly once. For simplicity, we state the bounds for this problem with one parameter measuring both the tree-width of the text and the size of the pattern. Definition 1 A tree decomposition of a graph G consists of a tree T , in which each node N ∈ T has a label L(N ) ⊂ V (G), such that the set of tree nodes whose labels contain any particular vertex of G forms a contiguous subtree of T , and such that any edge of G connects two vertices belonging to the same label L(N ) for at least one node N of T . The width of the tree decomposition is one less than the size of the largest label set in T . The tree-width of G is the minimum width of any tree decomposition of G. We can assume without loss of generality (by splitting high-degree nodes into multiple nodes with the same label) that each node in T has at most three neighbors and that there are O(n) nodes in the tree. We will assign our tree decomposition an arbitrary orientation, by rooting it at one of its leaves, so that T becomes a binary tree. Figure 1 shows a planar graph, with a tree decomposition of width three. In fact, the graph shown has no tree decomposition of width two, so its tree-width is three. Define the subtree rooted at a node N to consist of N and all its descendants. Each such subtree is associated with an induced subgraph of G, having vertices contained in labels of nodes in the subtree.
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
6
y
A
G F F
H
H
B
K E
x
K L
C
D
M
M
Figure 2: Partial isomorph of a pentagon in the induced subgraph associated with node {F, H, K, M }, and corresponding partial isomorph boundary mapping the pentagon to G0N . Lemma 1 The subtree rooted at N provides a tree decomposition of the associated induced subgraph of G. Proof: The only property of a tree decomposition that does not follow immediately is the requirement that each edge connect two vertices contained in the label of some node. Since this is true of G and T , any induced subgraph edge (u, v) must have {u, v} ⊂ L(N 0 ) for some N 0 , but N 0 may not be a descendant of N . However, if not, u belongs to both L(N 0 ) and (by assumption) L(N 00 ) where N 00 is a descendant of N . Therefore, by contiguity, u ∈ L(N ), and similarly v ∈ L(N ), so in this case (u, v) still both belong to the label of at least one node in the subtree. 2 Lemma 2 Assume we are given graph G with n vertices along with a tree decomposition T of G with width w. Let S be a subset of the vertices of G, and let H be a fixed graph with at most w vertices. Then in time 2O(w log w) n we can count all isomorphs of H in G that include some vertex in S. We can list all such isomorphs in time 2O(w log w) n + O(kw), where k denotes the number of isomorphs and the term kw represents the total output size. Proof: We perform dynamic programming in tree T . Let a partial isomorph at a node N of the tree be an isomorphism between an induced subgraph H 0 of the pattern H and the induced subgraph of G associated with the subtree rooted at N . We let G0N be formed by adding two additional vertices x, y to the subgraph of G induced by vertex set L(N ). We connect each of the two additional vertices
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
7
to all vertices in L(n), and each of the two additional vertices also is given a self-loop. Then from any partial isomorph at N we can derive a graph homomorphism from all of H to G0 , which is one-to-one on vertices in L(N ), maps the rest of H 0 to x, and maps H − H 0 to y. Let a partial isomorph boundary be such a map; Figure 2 illustrates a partial isomorph and the corresponding boundary. Since a partial isomorph boundary consists of a map from a set of at most w objects to a set of at most w + 3 objects, there are at most w w+3 = 2O(w log w) possible partial isomorph boundaries for a given node. Suppose that node N has children N1 and N2 We say that two partial isomorph boundaries B : H 7→ G0N and B1 : H 7→ G0N1 are consistent if the following conditions all hold: • For each vertex v ∈ H, if B(v) ∈ L(N1 ) or B1 (v) ∈ L(N ), then B(v) = B1 (v). • For each vertex v ∈ H, if B(v) 6= x then B1 (v) ∈ L(N ) ∪ {y}. • At least one vertex v ∈ H has B1 (v) 6∈ L(N ) ∪ {y}. We say that two partial isomorph boundaries B1 : H 7→ G0N1 and B2 : H 7→ G0N2 form a compatible triple with B if the following conditions both hold: • B1 and B2 are both consistent with B. • For each v with B(v) = x, exactly one of B1 (v) and B2 (v) is equal to y. For each partial isomorph boundary B : H 7→ G0N , let X1 (B) be the number of partial isomorphs which give rise to that boundary, and include a vertex of S. Let X2 (B) be the number of partial isomorphs which give rise to that boundary, and do not include a vertex of S. These values can be computed in a bottom-up fashion as follows: • If there is no v for which B(v) = x, then all partial isomorphs having boundary B involve only vertices in L(N ), and can be enumerated by brute force in time 2O(w log w) . • Otherwise, we initialize X1 (B) and X2 (B) to zero. Then, for each partial boundary B1 that is consistent with B, and such that there is no v with B(v) = x and B1 (v) = y, we increment X1 (B) by X1 (B1 ) and increment X2 (B) by X2 (B1 ). Finally, for each compatible triple B, B1 , B2 we increment X1 (B) by X1 (B1 ) · X1 (B2 ) + X1 (B1 ) · X2 (B2 ) + X2 (B1 ) · X1 (B2 ) and increment X2 (B) by X2 (B1 ) · X2 (B2 ). The total time for testing all triples for compatibility and performing the above computation is O(w 3(w+3)+1 = 2O(w log w) . At the root node of the tree, we compute the number of isomorphs involving S simply by summing the values X2 (B) over all partial isomorph boundaries for which B(v) 6= y for all v. 2
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
8
Lemma 3 Assume we are given graph G with n vertices along with a tree decomposition T of G with width w. Let S be a subset of the vertices of G, and let H be a fixed graph with at most w vertices. Then we can list all isomorphs of H in G that include some vertex in S in time 2O(w log w) n + O(kw), where k denotes the number of isomorphs and the term kw represents the total output size. Proof: We first follow the above dynamic programming procedure, to compute the values X1 and X2 for each partial isomorph boundary. We then compute top-down in the tree the set of pairs (B, X) where B is a partial isomorph boundary and X is either X1 or X2 , such that the value X(B) contributes to the final count of subgraph isomorphs. These pairs can be identified as the ones such that X(B) was included in the computation of some pair higher in the tree that has been previously identified as contributing to the total, and that caused a nonzero increment in this computation. Finally, we compute bottom-up again, listing for each contributing pair (B, X) the partial subgraph isomorphs counted in the value X(B). This step can be performed by mimicking the initial computation of X(B) described in the previous lemma, restricted to the boundaries known to contribute to the overall total, replacing each increment by a concatenation of lists, and replacing each multiplication with the construction of partial isomorphs from a Cartesian product of two previously-computed lists. The number of steps for this computation is proportional to the number of steps in the previous algorithm, together with the added time for each combination of a pair of partial isomorphs. Each such combination can be charged to a subgraph isomorph included in the output, and each output isomorph is formed by a binary tree of combinations that takes O(w) time to perform, so the total added time is O(kw). 2 The same dynamic programming techniques also lead to similar results for counting or listing induced subgraphs isomorphic to H. To do this, we need only modify the algorithms above to restrict attention to partial isomorph boundaries B : H 7→ G0N in which all edges between vertices of L(N ) are covered by the image of some edge in H.
5
Neighborhood Covers
We have seen above that we can perform subgraph isomorphism quickly in graphs of bounded tree-width. The connection with planar graphs is the following: Lemma 4 (Baker [6]) Let planar graph G have a rooted spanning tree T in which the longest path has length `. Then a tree decomposition of G with width at most 3` can be found in time O(`n). Proof: Without loss of generality (by adding edges if necessary) we can assume G is embedded in the plane with all faces triangles (including the outer face).
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
9
A { A,B,C }
{A
}
,B ,C ,D
,D ,C
}
{A
D
{ A,D,E,F } }
{A
,C
,E
E
{A ,B ,C ,D
F
G
G}
,F
{A
,E,
C,D
,B,
{A
,D
{ A,C,D, E,F,G }
}
,C,
D,F ,G
}
{ A,B,C,G } B
C
Figure 3: Triangulated planar graph, with depth two tree T rooted at A (shown by heavy solid lines), and tree decomposition with nodes corresponding to faces of the graph and edges complementary to T . Form a tree with one node per triangle, and an edge connecting any two nodes whenever the corresponding triangles share an edge that is not in T (Figure 3). Label each node with the set of vertices on the paths connecting each corner of the triangle to the root of the tree. Then each edge’s endpoints are part of some label set (namely, the sets of the two triangles containing the edge), and the labels containing any vertex form a contiguous subtree (namely, the path of triangles connecting the two triangles containing the edge from the vertex to its parent, and any other triangles enclosed in the embedding by this path). Therefore, this gives us a tree decomposition of G. The number of nodes in any label set is at most 3` + 1, so the width of the decomposition is at most 3`. 2 In particular, any planar graph with diameter D has tree-width O(D). If an isomorph of a connected pattern H uses vertex v in G, it is contained in the portion of G within distance |H| of v. By Lemma 4 this |H|-neighborhood of v has tree-width at most 3|H|. Therefore we can cover G by the collection of all such neighborhoods, and use Lemma 3 to find the copies of H within each neighborhood. However such a cover is not efficient: the total size of all subgraphs is O(n2 ), so this would give us a subgraph isomorphism algorithm with quadratic runtime. We speed this up to linear by using more efficient covers. Awerbuch et al. [3, 5] have introduced the very similar concept of a neighborhood cover, which is a covering of a graph by a collection of subgraphs, with the properties that the neighborhood of every vertex is contained in some subgraph, and that every subgraph has small diameter. They showed that for any (possibly nonplanar) graph, and any given value w, there is a w-neighborhood cover in which the diameter of each subgraph is O(w log n), and in which the
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
10
total size of all subgraphs is O(m log n); such a cover can be computed in time O(m log n + n log2 n) [4]. Because of Lemma 4, such a neighborhood cover is also almost exactly what we want to speed up our subgraph isomorphism algorithm. However there are two problems. First, the size and construction time of neighborhood covers are higher than we want (albeit only by polylogarithmic factors). Second, and more importantly, the diameter of each subgraph is logarithmic, so we are unable to use dynamic programming directly in the subgraphs of the cover. We would instead be forced to use some additional techniques such as separator-based divide and conquer, introducing more unwanted logarithmic factors. Instead, we use a technique similar to that of Baker [6] to form a cover that has the properties we want directly: any connected w-vertex subgraph of G is included in some member of the cover, and each vertex of G is included in few members of the cover (so the total size of the cover is O(n)). Unlike the techniques cited above, the diameter of the subgraphs will not be bounded, however we will still be able to use Lemma 4 on an auxiliary graph to show that each covering subgraph has tree-width O(w). Because of the exponential dependence of our overall algorithms on the tree-width of the covering subgraphs, we concentrate our efforts on reducing this width as much as possible, at the expense of increasing the total size of the cover by an O(w) factor over the minimum possible. Lemma 5 Let G be a planar graph, and w be a given integer parameter. Then we can find a collection of subgraphs Gi and a partition of the vertices of G into subsets Si with the following properties: • Every vertex of G is included in at most w subgraphs Gi . • We can find a tree decomposition of each subgraph Gi with tree-width at most 3w − 1. • If H is a connected w-vertex subgraph of G, and i is the smallest value for which H ∩ Si is nonempty, then H is a subgraph of Gi but is not a subgraph of any Gj with j > i. • The total time for performing the partition and computing the tree decompositions is O(w 2 n). Proof: We choose an arbitrary starting vertex v0 , and let Si consist of the vertices atSdistance i from v0 . We then let Gi be the graph induced by the i+w−1 vertex set j=i Sj , as shown in Figure 4. Clearly, the sets Si form a partition of the vertices of G, and each vertex is in at most w subgraphs Gi . Then for i = 0, Gi consists of the vertices at distance at most w − 1 from v0 , so by applying Lemma 4 to its breadth first spanning tree we can find a tree decomposition with width at most 3(w − 1). To show that each Gi with i > 0 has low tree-width, form an auxiliary graph G0i from G by collapsing into a single supervertex all the vertices at distance less than i from v0 , and deleting
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
11
S0 S1 S2 S3 S4 S5 S6 S7 S8 S9 S10
Figure 4: Planar graph with breadth first spanning tree (heavy edges), partition into layers Si , subgraph Gi (for w = 3, i = 5), and minor G0i (with large supervertex and contracted breadth first spanning tree). all the vertices with distance at least i + w. G0i is a minor of the planar graph G and is therefore also planar. Then similarly collapsing a breadth first spanning tree of G gives a spanning tree of G0i with depth at most w, so G0i has a tree decomposition with width at most 3w, in which each node of the decomposition includes the collapsed supervertex in its label. Gi is formed by deleting this supervertex from G0i , so we can form a tree decomposition of Gi with width at most 3w − 1 by removing the supervertex from the decomposition of G0i . Next, we need to show that any connected subgraph H of G with |H| ≤ w is contained in Gi , where i is the smallest value such that H ∩ Si 6= ∅. But Gi is formed from G simply by removing the sets Sj where j < i or j ≥ i + w. No Sj with j < i can contain a vertex of H, or else i would have been smaller. And no Sj with j ≥ i + w can contain a vertex v of H, or else we could find a path of length at most i + w − 1 from v0 to v by concatenating a path in H from some vertex vi ∈ Si ∩ H to v (which has length at most |H| − 1 ≤ w − 1) with the breadth first tree path from v0 to vi (which has length i), contradicting the placement of v in Sj . Therefore, none of the vertices that were deleted from G can belong to H, so H remains a subgraph of Gi . Finally, the condition that H can not be a subgraph for Gj where j > i is clearly true, since no such Gj can include any vertex of Si . The time bound is dominated by the time tree decompositions P to perform theP O(wGi ) = wO( Gi ) = w(wn). 2 on the graphs G0i , which by Lemma 4 is
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
6
12
The Subgraph Isomorphism Algorithm
We first describe the result for the special case of connected patterns. Theorem 1 We can count the isomorphs or induced isomorphs of a given connected pattern H, having w vertices, in a planar text graph G with n vertices, in time 2O(w log w) n. If there are k such isomorphs we can list them all in time 2O(w log w) n + O(wk). Proof: The algorithm consists of the following steps: 1. Apply the method of Lemma 5 to find a partition of the vertices into sets Si associated with graphs Gi having low width tree decompositions. 2. For each i ≥ 0, count or list the subgraph isomorphs of H in Gi that involve at least one vertex of Si , using the algorithm of Lemma 2 or Lemma 3 respectively. 3. Sum all the counts or concatenate the lists, to get a count or list of the isomorphs in G. By Lemma 5, each isomorph of H in G occurs in exactly one way as an isomorph in Hi that involves at least one vertex of Si , so the algorithm produces the correct total count or list. The time for the first step is O(w 2 n), and the time forP the last step is O(n), both dominated by the time for the second step which is 2O(w log w)|Gi | + O(ki w), where the 2O(w log w) factor arises by plugging the 3w − 1 treewidth bound of LemmaP5 into the P analysis in Lemmas 2 and 3. This can be simplified to 2O(w log w)( |Gi |) + O( ki w) = 2O(w log w) · O(wn) + 2 O(kw) = 2O(w log w)n + O(kw). The method so far requires that the pattern be connected. We now describe a general method for handling disconnected patterns. The technique will let us count the number of matching patterns, after which some sort of separatorbased divide and conquer can likely be used to find an instance of a matching pattern, but we have been unable to extend this technique to the problem of listing all subgraph isomorphs of a disconnected pattern. Theorem 2 We can count the isomorphs of any (possibly disconnected) pattern H having at most w of vertices, in a planar text graph G with n vertices, in time 2O(w log w) n. Proof: Let #G (H) denote the number of isomorphs of H in G. Rather than counting the isomorphs of a single pattern, we count the isomorphs of all planar graphs having at most w vertices. There are only 2O(w) such graphs [47], so this factor does not change the overall form of our time bound. We order these graphs by the number of connected components, so that when we are processing a particular graph H we can assume we already know the values of #G (H 0 ) for every H 0 with fewer components. Our algorithm them performs the following steps on each graph H:
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
13
1. If H is connected, compute #G(H) using the algorithm of Theorem 1. 0 00 2. Otherwise, let H be the disjoint union P of two subgraphs H and H , and 0 00 let #G(H) = #G(H ) · #G (H ) − ki #G(Hi ), where the sum is over all graphs Hi with fewer components than H, and ki denotes the number of different ways Hi can be formed as the union of H1 and H2 .
The product #G (H 0 ) · #G(H 00 ) counts the number of ways of mapping H and H 00 are isomorphically mapped but their instances into G such that both H 0P may overlap. The term ki #G (Hi ) corrects for these overlaps by subtracting the number of overlapped occurrences of each possible type. The coefficients ki may be computed by brute force enumeration of all possible ways of marking a vertex of Hi as coming from H 0 , H 00 , or both, combined with a planar graph isomorphism algorithm, in time 2O(w) . Therefore, the overall time taken in the second step of the algorithm is 2O(w) , independent of n, and the total time is dominated by the first step, in which we apply Theorem 1 2 to 2O(w) connected graphs, taking time 2O(w log w) n.
7
Further Improvements
For certain patterns, such as the wheels, our results can be further improved to reduce the time dependence on |H|. Let diam(H) denote the diameter of H (i.e., the longest distance between any two nodes), and let Kx (H) denote the maximum number of connected components that can be formed by removing at most x nodes from H. Note that if the diameter diam(H) is small, we can use that value instead of |H| in our neighborhood cover of G, reducing the tree-width of the subgraphs Gi to O(diam(H)). Lemma 6 Let H be a given pattern graph, and N be a node of a tree decomposition of graph G. Then there are at most 2K|L(N)| (H)+|L(N)| log(|H|+1) different possible partial isomorph boundaries B : H 7→ G0N (as defined in the proof of Lemma 2). Proof: The map B can be defined by specifying which (if any) vertex of H maps to each vertex in L(N ) (using log(|H| + 1) bits per vertex of L(N ) to specify this information) and also specifying which of the remaining vertices in H map to the vertex x in G0N and which ones map to the vertex y. However, it is not possible for the boundary to come from an actual subgraph isomorphism unless each connected component of H \ B −1 (L(N )) is mapped consistently either to x or to y, since any path from x to y must pass through a vertex of L(N ). So, to finish specifying the boundary, we need only add this single bit of information per component of H \ B −1 (L(N )), and by definition there are at 2 most K|L(N)| (H) such components. As a consequence, the analysis in Lemma 2 can be tightened to show that the dynamic program takes time 2O(KO(diam(H)) (H)+diam(H) log |H|) n.
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
14
Lemma 7 Suppose that planar graph H is Hamiltonian, or is 3-connected, or is connected and has bounded degree. Then for any set S of vertices of H, H −S has O(|S|) connected components. Proof: For Hamiltonian graphs and bounded degree graphs this is straightforward. For 3-connected graphs, assume without loss of generality that no edge can be added to H connecting two vertices in S; then each component of H − S must occupy a distinct face in the planar embedding of S induced by the unique embedding of H. 2 Theorem 3 If a given pattern H is Hamiltonian, 3-connected, or connected of bounded degree, we can count the isomorphs of H in a planar text graph G with n vertices in time 2O(diam(H) log |H|) n. Proof: The proof consists simply of plugging the improved analysis of Lemma 6 into the algorithm of Theorem 1. 2 For instance we can count the isomorphs of a wheel Wk in a planar text graph G with n vertices, in time O(nk O(1) ). In fact in this case it is not difficult to come up with an O(nk 2 ) algorithm: Theorem 4 We can count the isomorphs of any wheel Wk in a planar text graph G with n vertices in time O(nk 2 ). Proof: For each vertex v, we count the number of cycles of length k in the neighbors of v. The sum of the sizes of all neighborhoods in G is O(n). Each neighborhood has treewidth at most 2 by Lemma 4. Any partial isomorphism of a k-cycle in a node N of this decomposition can only consist of a single path of at most k − 1 vertices, which starts and ends at some two of the at most three vertices in L(N ) and may or may not involve the third vertex; therefore we need only keep track of O(k) different partial isomorph boundaries at each node. A careful analysis of the steps in the algorithm of Lemma 2 then shows that the most expensive step (finding compatible triples) can be performed in 2 time O(k 2 ) per node, giving an overall running time of O(k 2 n).
8
Variations and Applications
We now describe briefly how to use our subgraph isomorphism algorithm to solve certain other related graph problems. For instance, we can find the girth (shortest cycle), or smallest nonfacial cycle (for some particular embedding) simply by searching for isomorphs of small cycles: Theorem 5 We can find the girth g of any planar graph G, or find a smallest nonfacial cycle C for an embedded planar graph, in time 2O(g log g) n or 2O(|C| log |C|) n respectively.
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
15
Proof: We test for each integer i = 3, 4, 5 . . . whether there is a cycle (or nonfacial cycle) of length i. To test if there is a nonfacial cycle, we count the total number of cycles of length i in the graph andPsubtract the number of faces of length i. The total time for this procedure is i≤g 2O(i log i) n = 2O(g log g) n. For the nonfacial cycle problem, once the length of the cycle is known, we can find a single such cycle by performing our subgraph isomorph listing algorithm, stopping once k + 1 cycles are generated, where k = O(n) is the number of faces of the given length. By radix sorting the list of cycles (in lexicographic order by their sequences of vertex indices) we can then test in linear time which of the generated cycles are nonfacial. 2 Theorem 6 We can find a shortest separating cycle C in a planar graph, in time 2O(|C| log |C|) n. Proof: We describe how to test for the existence of a separating cycle of length i; the shortest such cycle can then be found by a sequential search similar to the computation of the girth. We first modify the construction of the graphs Gi in Lemma 5, by including in Gi not only all the vertices in layers Si through Si+w−1 but also a single supervertex for each connected component of the graph induced by the vertices in layers Sj , j ≥ i + w, and a supervertex for the (single) connected component of the vertices in layers Sj , j < i. Then a cycle that uses only vertices in layers Si through Si+w−1 (and does not use any of the supervertices) is separating in the modified Gi if and only if the corresponding cycle is separating in G. Note that the added supervertices only add one level to the breadth first search tree of Gi and hence the tree-width is still O(w). Then we need merely modify the dynamic program of Lemma 2, to use a definition of a partial isomorph boundary that, in addition to the map B : H 7→ G0N , specifies which of the remaining unmapped vertices of G0N are in each of the two subsets of G separated by the cycle, enforcing the requirement that no vertex in one subset be adjacent to a vertex in the other subset. This modification multiplies the number of boundaries by 2O(w) , but this increase is 2 swamped by the 2O(w log w ) terms from our previous analysis. We next consider the application of our techniques to certain graph clustering problems. Definition 2 (Keil and Brecht [30]) The h-clustering problem is that of approximating the maximum clique by finding a set of h vertices inducing as many edges as possible. The connected h-clustering problem adds the restriction that the induced subgraph be connected. Keil and Brecht [30] study these problems, and show that even though cliques are easy to find in planar graphs [40], the connected h-clustering problem is NPcomplete for planar graphs. See [32] for approximate h-clustering algorithms in general graphs.
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
16
Figure 5: An embedded planar graph G, the vertex connectivity substitute graph G0 (with edges drawn as heavy curves), and the edge connectivity substitute graph G00 . Theorem 7 For any h we can solve the planar h-clustering and connected hclustering problems in time 2O(h log h) n. Proof: We simply to test subgraph isomorphism for all possible planar graphs on h vertices, and return the subgraph isomorph with the most edges. 2 We now describe two applications to connectivity that, unlike the previous applications, are linear without an exponential dependence on a separate parameter. The vertex connectivity of G is the minimum number of vertices such that their deletion leaves a disconnected subgraph. Since every planar graph has a vertex of degree at most five, the vertex connectivity is at most five. We now use a method of Nishizeki (personal communication) to transform the vertex connectivity problem into one of finding short cycles, similar to those discussed at the start of this section. We choose some plane embedding of G, and construct a new graph G0 having n + f vertices: the n original vertices of G and f new face-vertices corresponding to the faces of G. We place an edge in G0 between an original vertex and a face-vertex whenever the corresponding vertex and face are incident in G. Then G0 is a bipartite plane-embedded graph. This construction is illustrated in the center of Figure 5. Lemma 8 Any minimal set S ⊂ G of vertices the deletion of which would disconnect G corresponds to a cycle C ⊂ G0 of the same original vertices and an equal number of face-vertices in G0 , such that G0 \C has at least two connected components each containing at least one original vertex. Conversely if C is any cycle such that G0 \ C has at least two connected components each containing at least one original vertex, then the original vertices in C form a cutset in G.
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
17
Proof: Let A be a connected component of G \ S, let GA be formed from G by contracting A into a supervertex, and let S 0 be the set of faces and vertices adjacent to the contracted supervertex. Then (since it is just the neighborhood of a vertex) S 0 has the structure of a cycle in G0 , and separates A from G\{A∪S}. If S is minimal, then it must consist of exactly the original vertices in S 0 . The converse is immediate, since no edge in the embedding of G can cross a face or vertex in C. 2 Theorem 8 We can compute the vertex connectivity of a planar graph in O(n) time. Proof: We can assume without loss of generality that G is two-connected, so the graph G0 described in Lemma 8 has no multiple adjacencies. We form G0 as above and find the shortest cycle in G0 that separates two original vertices. As with the shortest separating cycle problem (Theorem 6) this can be done by a slight modification to our dynamic programming method that decorates the dynamic programming states with O(1) bits of additional information regarding the separated vertices. Since any planar graph has a vertex of degree at most five by Euler’s formula, the shortest cycle in G0 must have length at most ten, so the algorithm takes time O(n). 2 The edge connectivity of a graph is similarly defined as the minimum number of edges the removal of which disconnects the graph. For simple graphs, this can again be at most five but for multigraphs it can be higher. Theorem 9 We can compute the edge connectivity of a simple planar graph in O(n) time. Proof: Assume without loss of generality that G is two-edge-connected. Embed G, and form a graph G00 by subdividing each edge of G and connecting the resulting subdivision points to new vertices in each adjacent face; this construction is illustrated in the right of Figure 5. Then G00 is a planar graph with n original vertices, e edge-vertices on each edge of G, and f face-vertices in each face of G, so its total complexity is O(n). By the assumption of twoedge-connectivity, G00 is simple. One can use an argument similar to the one in Lemma 8, in which we delete a cutset from G, contract a connected component, and examine the neighborhood in G of the contracted supervertex, to show that G is k-edge-connected iff there is no cycle of fewer than 2k edge- and face-vertices in G00, which separates two original vertices. As before, the degree bound on a planar graph imposes a limit of ten on the length of the shortest such cycle, and as before this cycle can be found by a minor modification to our dynamic programming algorithm. 2 The same methods extend easily enough to multigraphs, but now the edge connectivity can not be bounded a priori, so we need to include the connectivity in our time bound. Theorem 10 For any fixed k, we can test k-edge-connectivity of a planar multigraph in time 2O(k log k) n.
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
18
Proof: Without loss of generality, the multiplicity of any edge is at most k, as higher multiplicities can not improve the overall connectivity. After the edge subdivision step in the construction of G00 , the resulting graph is a simple planar graph with O(kn) vertices, after which we can proceed as in the remainder of Theorem 9. 2
9
Shortest Path Data Structure
We next describe a technique for finding shortest paths in planar graphs. Let a parameter ` be given (typically, a fixed constant). We wish to test, for any two vertices u and v, whether there is a path from u to v of distance at most `, and if so return the shortest such path. Since we wish to use an amount of space independent of `, we need a variant of Lemma 5 in which the total size of the subgraphs is not so large. Lemma 9 Let G be a planar graph, and w be a given integer parameter. Then we can find a collection of subgraphs Gi and a partition of the vertices of G into subsets Si with the following properties: • Every vertex of G is included in at most two subgraphs Gi . • We can find a tree decomposition of each subgraph Gi with tree-width O(w). • Gi contains the `-neighborhood of every vertex in Si . • The total time for performing the partition and computing the tree decompositions is O(wn). Proof: As in Lemma 5, we compute the distances of each vertex from some arbitrary starting vertex v0 . We then let Si consist of those vertices with distance at least 2iw and at most (2i + 2)w − 1 from v0 , and we let Gi be the graph induced by the set of vertices with distances at least (2i − 1)w and at most (2i + 3)w − 1 from v0 . The proof that these graphs have treewidth O(w) and that each Gi contains the `-neighborhood of Si is essentially the same as that of Lemma 5. 2 As before, by introducing dummy nodes, we can assume without loss of generality that each node in the tree decomposition of Gi has at most three neighbors. We warm up with a data structure for our shortest path queries that uses more space than necessary, but for which queries are very fast. Theorem 11 Given a planar graph G, and any value `, we can in time and space O(`n log n) build a data structure that can, given a query pair of vertices, either return the distance between the pair or determine that the distance is greater than `, in time O(`) per query.
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
19
Proof: By performing the decomposition of Lemma 9 we can assume without loss of generality that we have a tree decomposition T for G of width O(`). As with any tree, we can find a node N the removal of which disconnects T into subtrees of size at most |T |/2. Our primary data structure consists of the distances d(x, z) from each vertex x ∈ G to each vertex z ∈ L(N ), together with a recursively constructed data structure in each subtree. To answer a query pair x, y where the two vertices belong to different subtrees of T , we can simply try each of the O(D) values d(x, z) + d(z, y) where z ranges over all the members of L(N ). To answer a query where the two vertices belong to the same subtree, we can use the recursively defined structure in that subtree. It remains to show how we quickly determine which node N is eventually used to answer each query. To do this, define the level of a node to be the stage in the recursive subdivision process at which the node was chosen, and define the superior of a node N to be the node chosen at the next earlier level in the subtree containing N . The links from a node to its superior define a tree structure T 0 different from the original decomposition tree T . Further, define the home node of a vertex v to be the node with the earliest level with v ∈ L(N ). Note that, because of the requirements that the labels containing v are contiguous, the home node is uniquely defined. Then, the node to be used in answering a query pair x, y is simply the least common ancestor in T 0 of the home nodes of x and y. 2 To return the actual shortest path, rather than simply the distance between a pair of nodes, we can store a single-source shortest path tree for each member of L(N ), and return the path in the tree for the member of L(N ) giving the smallest distance. We next show how to reduce the space to linear, at the expense of increasing the query time. Theorem 12 Given a planar graph G, and any value `, we can build a data structure of size O(`n) that can, given a query pair of vertices, either return the distance between the pair or determine that the distance is greater than `, in time O(`2 log n) per query. Proof: As above, we can assume G has a tree decomposition of width O(`), which we assume has the form of a rooted binary tree. Define levels in this tree and home nodes of vertices as above, except that we terminate the recursive subdivision process when we reach subtrees with fewer than ` nodes (which we call small subtrees). If the node labels containing a vertex v belong only to nodes in a small subtree S, then v does not have a home node, instead we say that S is v’s home subtree. Define a pair of nodes in T to be related if there is no node between them with an earlier level than both. Then, each node N is related to O(1) nodes at each level: one node at an earlier level than N , and at most one node in each later level in each of the at most three subtrees formed by removing N from T . Therefore, there are O(n/`) pairs of related nodes.
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
20
Our data structure then consists of the matrix of distances from vertices in L(N1 ) to vertices in L(N2 ), for each pair N 1, N 2 of related nodes. The space for this data structure is O(n`). It can either be built as a subset of the data structure of Theorem 11, in time O(n` log n), or bottom-up (using hierarchical clustering techniques of Frederickson [22] to construct the level structure in T , and then computing each distance matrix from two previously-computed distance matrices in time O(`3 )) in total time O(n`2 ); we omit the details. To answer a query, we form chains of related pairs connecting the home nodes (or small subtrees) of the query vertices to their common ancestor in T 0 . The levels of the nodes in these two chains becomes earlier at each step towards the common ancestor, so the total number of pairs in the chain is O(log n). We then build a graph, in which we include an edge between each pair of vertices in the labels of a related pair of nodes, labeled with the distance stored in the matrix for that pair. We also include in that graph the edges of G belonging to the small subtrees containing the query vertices, if they belong to small subtrees. The query can then be answered by finding a shortest path in this graph, which 2 has O(` log n + `2 ) vertices and O(`2 log n) edges. The following theorem on computing diameter improves the naive O(n2 ) bound for all pairs shortest paths when the diameter is small. Note that diameter is not a subgraph isomorphism problem but it succumbs to similar techniques. Theorem 13 We can compute the diameter D of a planar graph G, in time O(2O(D log D) n). Proof: We begin by performing a breadth first search from an arbitrary vertex. This will produce a tree of height at most D, so by Lemma 4 we can find a tree decomposition of width O(D), which as usual we can assume has the form of a rooted binary tree. We first perform a bottom-up sweep of this tree to compute for every node N the distances between every pair of vertices in L(N ), in the graph associated with the subtree rooted at N . These O(D2 ) distances can be found by combining the distance matrices of the two children of N , in time O(D3 ), so this phase takes time O(D3 n). We then sweep the decomposition top down, computing for every node N the distances between every pair of vertices in L(N ), in the whole graph G. The first pass correctly computed these distances at the root of the tree, and at any other node N the distances can be computed by combining the distance matrices of the parent of N (previously computed in the top-down sweep) and its two children (computed in the bottom-up sweep), again in time O(D3 ) per node. We finally sweep through the tree decomposition bottom up, keeping at each node N a subset S of the vertices seen so far in the subtree rooted at N , together with the distances from each member of S to each member of L(N ). When we process a node N , we perform the following steps: 1. Let the set S for node N consist of the union of the corresponding sets S1 and S2 for its children N1 and N2 , together with L(N ).
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
21
2. Compute the distances from each member of S to each member of L(N ), by combining the previously computed distances to L(N1 ) or L(N2 ) with the distances within L(N1 ) ∪ L(N2 ). 3. Compute the distance between each pair of nodes x, y where x ∈ S1 \L(N ) and y ∈ S2 \ L(N ), by testing the distances through all O(D) possible intermediate nodes in L(N ). 4. Radix sort the members of S according to the lexicographic ordering of their O(D)-tuples of distances to L(N ), and eliminate all but one member for each distinct tuple. The value returned as the diameter is then the maximum of the distances from S to L(N ) computed in the second step, and the distances of pairs x, y comuted in the third step If any eliminated member x of a tuple belongs to a diametral pair x, y, where y is not in the subgraph associated with N , then the uneliminated member x0 with the same tuple would have the same distance to y, and would form another diametral pair. Therefore, the algorithm above will correctly find and report a diametral pair. The number of distinct O(D)-tuples of integers in the range from 0 to D is 2O(D log D) , hence this gives a bound on the size of each set S. The time to compute distances between pairs x, y is O(D) times the square of this quantity, 2 which is still 2O(D log D) .
10
Other Graph Families
Our results for planar graphs use the assumption of planarity in two ways. First, in the bound relating tree-width to diameter (Lemma 4), the proof is based on the existence of a planar embedding of the graph, and in fact there is no similar bound in general for nonplanar graphs; for instance the complete graph Kn has diameter one but tree-width n − 1. Second, in the cover of G by low-treewidth subgraphs described in Lemma 5, we needed the fact that planar graphs are closed under minors to show that the graph G0i is planar, allowing us to apply Lemma 4 to it. This naturally raises the question, for which other minor-closed graph families can we prove a bound relating diameter to tree-width, similar to Lemma 4? Such a result would then let us apply our subgraph isomorphism techniques unchanged to any such families. In the conference version of this paper [18], we announced an exact characterization of these families, which are detailed in a separate journal paper [15] and which we now summarize: Definition 3 Define a family F of graphs to have the diameter-treewidth property if there is some function f(D) such that every graph in F with diameter at most D has treewidth at most f(D).
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
22
Figure 6: The graph on the left is an apex graph; the topmost vertex is one of the possible choices for its apex. The graph on the right is not an apex graph. Definition 4 An apex graph is a graph G such that for some vertex v (the apex), G \ {v} is planar (Figure 6). Theorem 14 ([15]) Let F be a minor-closed family of graphs. Then F has the diameter-treewidth property iff F does not contain all apex graphs. Corollary 1 Let F be a minor-closed family of graphs, such that some apex graph is not in F . Let H be a fixed graph in F . Then there is a linear time algorithm for testing whether H is a subgraph of a given graph G ∈ F. Note that the bound on tree-width from Theorem 14 is much higher than the linear bound in Lemma 4, so the dependence on |H| of the time bound of the algorithm implied by Corollary 1 is much greater than in our planar graph algorithms. However, for certain important minor-closed graph families (such as bounded genus graphs) we were able to prove a better dependence of tree-width on diameter [15], leading to less impractical algorithms.
11
Conclusions and Open Problems
We have shown how to solve planar subgraph isomorphism for any pattern in time O(n). We have also solved certain related problems in similar time bounds. A number of generalizations of the problem remain open: • We have shown that we can solve planar subgraph isomorphism even for disconnected patterns in time O(n). Can we list all occurrences of a disconnected pattern in time O(n + k)? • Bui and Peck [11] describe an algorithm for finding the smallest set of edges partitioning a planar graph into two sets of vertices with specified
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
23
sizes; if the edge set has bounded size their algorithm has cubic running time. Can we use our methods to find such a partition more quickly? • It seems possible that the recently discovered randomized coloring technique of Alon et al. [1] can improve the dependence on the size of the pattern from 2O(w log w) to 2O(w) , but only for the decision problem of subgraph isomorphism. Can we achieve similar improvements for the counting and listing versions of the subgraph isomorphism problem?
Acknowledgements The author wishes to thank Sandy Irani, George Lueker, and the anonymous referees, for helpful comments on drafts of this paper.
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
24
References [1] N. Alon, R. Yuster, and U. Zwick. Color-coding. J. Assoc. Comput. Mach. 42(4):844–856, July 1995. [2] P. J. Artymiuk, P. A. Bath, H. M. Grindley, C. A. Pepperrell, A. R. Poirrette, D. W. Rice, D. A. Thorner, D. J. Wild, P. Willett, F. H. Allen, and R. Taylor. Similarity searching in databases of three-dimensional molecules and macromolecules. J. Chemical Information and Computer Sciences 32:617–630, 1992. [3] B. Awerbuch, B. Berger, L. Cowen, and D. Peleg. Low-diameter graph decomposition is in NC. 3rd Scand. Worksh. Algorithm Theory (SWAT), vol. 621, pp. 83–93. Springer-Verlag Lecture Notes in Computer Science, 1992. [4] B. Awerbuch, B. Berger, L. Cowen, and D. Peleg. Near-linear time construction of sparse neighborhood covers. SIAM J. Computing 28(1):263– 277, 1998. [5] B. Awerbuch and D. Peleg. Sparse partitions. Proc. 31st IEEE Symp. Foundations of Computer Science, pp. 503–513, 1990. [6] B. S. Baker. Approximation algorithms for NP-complete problems on planar graphs. J. Assoc. Comput. Mach. 41:153–180, 1994. [7] R. Bar-Yehuda and S. Even. On approximating a vertex cover for planar graphs. Proc. 14th Symp. Theory of Computing, pp. 303–309. Assoc. Comput. Mach., 1982. [8] D. Bayer and D. Eisenbud. Graph curves. Advances in Math. 86:1–40, 1991. [9] M. W. Bern, E. L. Lawler, and A. L. Wong. Linear-time computation of optimal subgraphs of decomposable graphs. J. Algorithms 8:216–235, 1987. [10] A. D. Brown and P. R. Thomas. Goal-oriented subgraph isomorphism technique for IC device recognition. IEE Proceedings I (Solid-State and Electron Devices) 135:141–150, 1988. [11] T. N. Bui and A. Peck. Partitioning planar graphs. SIAM J. Computing 21:203–215, 1992. [12] N. Chiba and T. Nishizeki. Arboricity and subgraph listing algorithms. SIAM J. Computing 14:210–223, 1985. [13] M. Chrobak and D. Eppstein. Planar orientations with low out-degree and compaction of adjacency matrices. Theoretical Computer Science 86:243– 266, 1991.
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
25
[14] M. B. Dillencourt and W. D. Smith. A linear-time algorithm for testing the inscribability of trivalent polyhedra. Proc. 8th Symp. Computational Geometry, pp. 177–185. Assoc. Comput. Mach., 1992. [15] D. Eppstein. Diameter and treewidth in minor-closed graph families. To appear in Algorithmica, math.CO/9907126. [16] D. Eppstein. Connectivity, graph minors, and subgraph multiplicity. J. Graph Theory 17:409–416, 1993. [17] D. Eppstein. Arboricity and bipartite subgraph listing algorithms. Information Processing Letters 51:207–211, 1994. [18] D. Eppstein. Subgraph isomorphism in planar graphs and related problems. Proc. 6th Symp. Discrete Algorithms, pp. 632–640. Assoc. Comput. Mach. and Soc. Industrial & Applied Math., 1995. [19] D. Eppstein, Z. Galil, G. F. Italiano, and T. H. Spencer. Separator based sparsification II: edge and vertex connectivity. SIAM J. Computing 28(1):341–381, 1999. [20] M. R. Fellows and M. A. Langston. On search, decision and the efficiency of polynomial-time algorithms. Proc. 21st Symp. Theory of Computing, pp. 501–512. Assoc. Comput. Mach., 1989. [21] G. N. Frederickson. Fast algorithms for shortest paths in planar graphs, with applications. SIAM J. Computing 16:1004–1022, 1987. [22] G. N. Frederickson. Ambivalent data structures for dynamic 2-edgeconnectivity and k smallest spanning trees. SIAM J. Comput. 26(2):484– 538, April 1997. [23] G. N. Frederickson and R. Janardan. Efficient message routing in planar networks. SIAM J. Computing 18:843–857, 1989. [24] G. N. Frederickson and R. Janardan. Space-efficient message routing in c-decomposable networks. SIAM J. Computing 19:14–30, 1990. [25] H. N. Gabow. A matroid approach to finding edge connectivity and packing arborescences. J. Computer & System Sciences 50:259–273, 1995. [26] A. Guha. Optimizing codes for concurrent fault detection in microprogrammed controllers. Proc. Int. Conf. Computer Design: VLSI in Computers and Processors (ICCD ’87), pp. 486–489. Inst. Electrical & Electronics Engineers, 1987. [27] D. Hong, Y. Wu, and X. Ding. An ARG representation for Chinese characters and a radical extraction based on the representation. Proc. 9th Int. Conf. Pattern Recognition, vol. 2, pp. 920–922. Inst. Electrical & Electronics Engineers, 1988.
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
26
[28] A. Itai and M. Rodeh. Finding a minimum circuit in a graph. SIAM J. Computing 7:413–423, 1978. [29] A. Kanevsky, R. Tamassia, G. Di Battista, and J. Chen. On-line maintenance of the four-connected components of a graph. Proc. 32nd IEEE Symp. Foundations of Computer Science, pp. 793–801, 1991. [30] J. M. Keil and T. B. Brecht. The complexity of clustering in planar graphs. J. Combinatorial Mathematics and Combinatorial Computing 9:155–159, 1991. [31] P. N. Klein and S. Sairam. Fully dynamic approximation schemes for shortest path problems in planar graphs. Algorithmica 22(3):235–249, November 1998. [32] G. Kortsarz and D. Peleg. On choosing a dense subgraph. Proc. 34th Symp. Foundations of Computer Science, pp. 692–703. Inst. Electrical & Electronics Engineers, 1993. [33] J. R. Koza, F. H. Bennett, III, and O. Stiffelman. Genetic programming as a Darwinian invention machine. Proc. 2nd Worksh. Genetic Programming (EuroGP ’99). Springer-Verlag, Lecture Notes in Computer Science 1598, 1999, http://www.genetic-programming.com/EUROGP99.ps. [34] S. Y. T. Lang and A. K. C. Wong. A sensor model registration technique for mobile robot localization. Proc. Int. Symp. Intelligent Control, pp. 298–305. Inst. Electrical & Electronics Engineers, 1991. [35] J.-P. Laumond. Connectivity of plane triangulations. Information Processing Letters 34:87–96, 1990. [36] R. Levinson. Pattern associativity and the retrieval of semantic networks. Computers and Mathematics with Applications 23:573–600, 1992. [37] A. Lingas. Subgraph isomorphism for biconnected outerplanar graphs in cubic time. Theoretical Computer Science 63:295–302, 1989. [38] A. Lingas and A. Proskurowski. On parallel complexity of the subgraph homeomorphism and the subgraph isomorphism problem for classes of planar graphs. Theoretical Computer Science 68:155–173, 1989. [39] A. Lingas and M. M. Syslo. A polynomial-time algorithm for subgraph isomorphism of two-connected series-parallel graphs. Proc. 15th Int. Colloq. Automata, Languages and Programming, pp. 394–409. Springer-Verlag, Lecture Notes in Computer Science 317, 1988. [40] C. H. Papadimitriou and M. Yannakakis. The clique problem for planar graphs. Information Processing Letters 13:131–133, 1981.
D. Eppstein, Planar Subgraph Isomorphism, JGAA, 3(3) 1–27 (1999)
27
[41] J. Plehn and B. Voigt. Finding minimally weighted subgraphs. Proc. 16th Int. Worksh. Graph-Theoretic Concepts in Computer Science, pp. 18–29. Springer-Verlag, Lecture Notes in Computer Science 484, 1991. [42] D. Richards. Finding short cycles in planar graphs using separators. J. Algorithms 7:382–394, 1986. [43] N. Robertson and P. D. Seymour. Graph Structure Theory: Proc. Joint Summer Res. Conf. Graph Minors. Contemporary Mathematics 147. Amer. Math. Soc., 1991. [44] T. Stahs and F. M. Wahl. Recognition of polyhedral objects under perspective views. Computers and Artificial Intelligence 11:155–172, 1992. [45] M. M. Syslo. The subgraph isomorphism problem for outerplanar graphs. Theoretical Computer Science 17:91–97, 1982. [46] K. Takamizawa, T. Nishizeki, and N. Saito. Linear-time computability of combinatorial problems on series-parallel graphs. J. Assoc. Comput. Mach. 29:623–641, 1982. [47] G. Tur´ an. On the succinct representation of graphs. Discrete Applied Mathematics 8(3):289–294, 1984.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 3, no. 4, pp. 1-2 (1999)
New Trends in Graph Drawing Special Issue on Selected Papers from the 1997 Symposium on Graph Drawing Guest Editors’ Introduction Giuseppe Di Battista Dipartimento di Informatica e Automazione Universit`a degli Studi di Roma Tre via della Vasca Navale 79, 00146 Roma, Italy
[email protected]
Petra Mutzel Institut f¨ ur Computergraphik Technische Universit¨at Wien Karlsplatz 13/186, 1040 Wien, Austria
[email protected]
Di Battista and Mutzel, Guest Editors’ Introduction, JGAA, 3(4) 1-2 (1999) 2 This Special Issue is devoted to selected papers from the 1997 Symposium on Graph Drawing, held in Rome, Italy, on September 18–20, 1997. The Graph Drawing field is a continual source of interesting problems and general methodologies that have both theoretical depth and impact on real-life applications. Among the “hot” topics in the area, we consider the following especially intriguing: (i) drawing large graphs by means of clustering techniques, (ii) visualizing graphs in 3D, and (iii) finding linear-time solutions to problems usually tackled by computationally expensive flow techniques. These topics are addressed in the collection of selected papers of this Special Issue. Drawing large graphs is important for several applications. A promising approach to the problem is the one of grouping the vertices and the edges into clusters and of allowing the user to visualize the graph selecting her/his favorite “abstraction level”. In the selected level, some clusters will be collapsed into single vertices, while some other clusters will be explicitly drawn, with the constraint that the vertices belonging to the same cluster are placed close to each other. Eades, Feng, and Nagamochi propose an algorithm for efficiently constructing clustered drawings with several guarantees on the aesthetic quality of the result. The problem of constructing orthogonal drawings of plane graphs with the minimum number of bends is usually tackled in terms of a flow problem. Such a method yields algorithms whose time complexity is nonlinear in the number of vertices. Rahman, Nakano, and Nishizeki propose an innovative method that allows to produce in linear time optimal orthogonal drawings for a fairly large class of plane graphs. Research in 3D graph drawing is attracting increasing attention. In fact, low-price high-performance 3D graphic workstations are becoming widely available. Also, 3D graph drawing offers interesting perspectives to the sophisticated demand of visualization coming from new graphical user interfaces. The paper by Biedl, Shermer, Whitesides, and Wismath studies 3D drawings of graphs with vertices represented by boxes. It proposes new construction methods and offers bounds that can become reference points in the field. The paper by Papakostas and Tollis is based on a realistic interactive setting, where vertices arrive and enter the drawing on-line. The presented algorithms have very good behavior in terms of the volume occupied by the drawing and of the number of bends along the edges. Finally, we wish to thank all the referees. They gave a fundamental contribution to the preparation of this Special Issue.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 3, no. 4, pp. 3–29 (1999)
Drawing Clustered Graphs on an Orthogonal Grid Peter Eades Department of Computer Science and Software Engineering University of Newcastle http://www.cs.newcastle.edu.au/
Qingwen Feng Tom Sawyer Software http://www.tomsawyer.com/
Hiroshi Nagamochi Department of Applied Mathematics and Physics Kyoto University http://www.kyoto-u.ac.jp/ Abstract Clustered graphs are graphs with recursive clustering structures over the vertices. For graphical representation, the clustering structure is represented by a simple region that contains the drawing of all the vertices which belong to that cluster. In this paper, we present an algorithm which produces planar drawings of clustered graphs in a convention known as orthogonal grid rectangular cluster drawings. If the input graph has n vertices, then the algorithm produces in O(n) time a drawing with O(n2 ) area and at most 3 bends in each edge. This result is as good as existing results for classical planar graphs. Further, we show that our algorithm is optimal in terms of the number of bends per edge. Communicated by Giuseppe Di Battista and Petra Mutzel. Submitted: May 1998. Revised: December 1998 and April 1999. This work was supported by a research grant from the Australian Research Council and a grant from the Kyoto University Foundation. The work was partially carried out while the second and third authors were visiting the University of Newcastle. Authors’ email addresses:
[email protected],
[email protected],
[email protected].
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
1
4
Introduction
Graphs are commonly used to model relational information in computing. Many software systems need a graph drawing function. Examples include CASE tools [50], management information systems [22], software visualization tools [49], and VLSI design tools [20]. Graph drawing algorithms aim to produce drawings which are easy to read and easy to remember. Many graph drawing algorithms have been designed, analyzed, tested and used in visualization systems [7]. With increasing complexity of the information that we want to visualize, more structures are needed on top of the classical graph model. Clustered graphs are graphs with recursive clustering structures (see Figure 1). This type of clustering structure appears in many structured diagrams [20, 26, 28, 38]. Drawing algorithms for clustered graphs are difficult. Heuristic methods for drawing similar structures have been developed by Sugiyama and Misue [30, 39], North [31], and by Madden et al. [25]. Algorithms for constructing straight-line drawings of clustered graphs are given in [9, 10, 15]; note, however, that straightline drawings of clustered graphs can require exponential area [15]. In this paper, we present a linear time algorithm which produces planar drawings of clustered graphs in a convention called “orthogonal grid rectangular cluster drawings”. We apply a technique to order the clusters of the graph recursively, and we use a “visibility representation” for directed graphs to produce our drawings.
Queensland Victoria Deakin
JCU
Brisbane UQ
QUT Griffith
Melbourne
LaTrobe NSW
MU
Monash
Ncle
UNE
Sydney
SU
Figure 1: An example of a clustered graph.
UTS
UNSW
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
5
8 7
8
6 7
5
6
4
5 3
4
3
2 2 1 1
(a)
(b)
Figure 2: (a) A planar graph. (b) A visibility representation of the graph. The orthogonal grid drawing convention appears in a number of applications, such as VLSI circuit design [27, 29, 47, 48] and diagrammatic interfaces for relational information systems [1, 42, 32, 35, 40]. Under the orthogonal grid drawing convention, minimizing the number of bends and minimizing the area are the main criteria both for diagram readability and for VLSI design applications. For classical graphs, several basic results regarding planar orthogonal grid drawings have appeared in the literature. It has been shown by Valiant [48] that any planar graph of degree at most 4 admits a planar orthogonal grid drawing with area O(n2 ); further, there are graphs which need quadratic area. Tamassia [41] presented an O(n2 log n) time algorithm that computes a planar orthogonal grid drawing with a given planar embedding so that the number of bends is minimized. Garg and Tamassia [19] have shown that if the planar embedding is not given, then the problem is NP-hard. Several linear time algorithms for planar orthogonal grid drawings of classical graphs have been developed. Tamassia and Tollis [44, 45] have presented an algorithm that outputs drawings with O(n2 ) area, where n is the number of the vertices of the graph. If the graph is biconnected, then there are at most 2n + 4 bends in the drawing; otherwise, there are at most 2.4n + 2 bends. Further, there are at most 4 bends in each edge. If the graph is biconnected, then all but 2 edges have at most 2 bends. Kant [23, 24] has presented an algorithm which improves the result of Tamassia and Tollis in some cases. For triconnected graphs, Kant’s algorithm draws on an n × n grid with at most 2 bends per
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
6
edge (if n > 6), and the total number of bends is no more than d3n/2e + 4. If the graph is connected with degree at most 3, then the algorithm draws on an bn/2c × bn/2c grid with at most 2 bends in each edge and no more than bn/2c + 1 bends in total. Even and Granot [11] have presented an algorithm such that for any planar graph with degree at most 4, the drawing has O(n2 ) area, and there are at most 3 bends in each edge. Lower bounds on the area and the number of bends for planar orthogonal drawings of graphs have been presented by Tamassia, Tollis and Vitter [46], and by Biedl [4]. Another useful representation for planar graphs is the visibility representation [36, 43]. Figure 2 shows a planar graph and a visibility representation of the graph. Visibility representation is related to orthogonal drawing in that it is often used as a basis for constructing an orthogonal drawing. Several orthogonal drawing algorithms [11, 44, 45] first construct a visibility representation of the graph, then transform it to an orthogonal drawing. In Section 3, we present an algorithm for planar drawing of clustered graphs using the same approach. Given an n vertex clustered graph of maximum degree 4, our algorithm produces in O(n) time an orthogonal grid rectangular cluster drawing with O(n2 ) area and with at most 3 bends in each edge. This result is as good as the results for classical planar graphs [11, 24, 45]. Further, Section 4 presents a class of graphs each of which has a set of Ω(n) edges each of which require at least 3 bends; thus there is no algorithm that can improve on the worst case performance of our algorithm with respect to the number of bends per edge. A byproduct of our method is a visibility algorithm for clustered graphs; given an n vertex clustered graph (with no limit on the degree), the algorithm produces a visibility representation where the clusters are represented by rectangles. A clustered graph, together with the visibility representation and orthogonal drawing produced by our algorithm, is in Figure 3. Section 5 concludes with some extensions of our work and some open problems.
2
Terminology
A clustered graph C = (G, T ) consists of an undirected graph G = (V, A) and a rooted tree T = (V, A) such that the leaves of T are exactly the vertices of G. For a node ν in T , let chl(ν) denote the set of children of ν, and pa(ν) denote the parent of ν (if ν is not the root). Each node ν of T represents a cluster V (ν) of the vertices of G that are leaves of the subtree rooted at ν. The subgraph of G induced by V (ν) is denoted by G(ν). Note that tree T describes an inclusion relation between clusters. If a node ν 0 is a descendant of a node ν in the tree T , then we say the cluster of ν 0 is a sub-cluster of ν. In a drawing of a clustered graph C = (G, T ), graph G is drawn as points and curves as usual. For each node ν of T , the cluster is drawn as simple closed region R that contains the drawing of G(ν), such that: (1) the regions for all sub-clusters of ν are completely contained in the interior
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
7
of R; (2) the regions for all other clusters are completely contained in the exterior of R; (3) if there is an edge e between two vertices of V (ν) then the drawing of e is completely contained in R. We say that the drawing of edge e and region R have an edge-region crossing
00111100 000 111 000 111 0011
111 000
00111100
0110 1010 10
00111100 000 111 000 111 1100 11001100 1100 1100 1100 0011
(a) (b)
111 000
00111100
0011 00111100
00111100
000 111 11001100 00 111 110011001100 000 0011
(c)
Figure 3: (a) A clustered graph, (b) The visibility representation output by our algorithm, and (c) The orthogonal drawing output by our algorithm.
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
8
if the drawing of e crosses the boundary of R more than once. A drawing of a clustered graph is c-planar if there are no edge crossings or edge-region crossings. If a clustered graph C has a c-planar drawing then we say that it is c-planar. A clustered graph C = (G, T ) is a connected clustered graph if each cluster induces a connected subgraph of G. The following results from [14, 16] characterize c-planarity in a way which can be exploited by our drawing algorithms. Theorem 1 A connected clustered graph C = (G, T ) is c-planar if and only if the graph G is planar and there exists a planar drawing D of G, such that for each node ν of T , all the vertices and edges of G − G(ν) are in the external face of the drawing of G(ν). Let C1 = (G1 , T1 ) and C2 = (G2 , T2 ) be two clustered graphs such that T1 is a subtree of T2 and for each node ν of T1 , G1 (ν) is a subgraph of G2 (ν). We say that C1 is a sub-clustered-graph of C2 . Theorem 2 A clustered graph C = (G, T ) is c-planar if and only if it is a sub-clustered graph of a connected and c-planar clustered graph. From Theorem 2, we can assume that we are given a connected clustered graph when drawing a c-planar clustered graph. For each vertex u, a doublylinked list A(u) of edges around u is given; the edges in A(u) appear around u in the order of the list in the embedding. In the rest of the paper, we further assume that in a clustered graph C = (G, T ), every non-leaf node of tree T has at least two children. Hence the size of T = (V, A) is O(|V| + |A|) = O(n). Our techniques use the concept of planar st-graphs [2]. A planar st-graph is a planar directed graph with one source s and one sink t, such that both the source and the sink above can be embedded on the boundary of the same face, say the external face.
3
Orthogonal Drawings for C-planar Clustered Graphs
An orthogonal grid rectangular cluster drawing (OGRC drawing) of a clustered graph maps the graph onto a grid, where edges are drawn as sequences of horizontal and vertical segments, vertices are drawn on grid points, and region boundaries for clusters are drawn as rectangles. Figure 1 is derived from an OGRC drawing. In this section, we present an algorithm that produces a cplanar OGRC drawing for a given c-planar clustered graph C = (G, T ) in which each vertex of G has degree at most 4 in G. The drawing has O(n2 ) area, and at most 3 bends in each edge. The algorithm works in linear time, and consists of three phases: (1) visibility representation;
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
9
(2) orthogonalization; (3) bend reduction. It is clear that OGRC drawings are restricted to clustered graphs in which each vertex of G has degree at most 4 in G; however, the visibility representation (phase 1) can be constructed for any c-planar clustered graph. We treat the three phases in turn.
3.1
Visibility Representation
A visibility representation Γ for a planar st-graph G maps each vertex v into a horizontal segment Γ(v), and each edge e into a vertical segment Γ(e) such that: (1) Segments Γ(u) and Γ(v) are disjoint for distinct vertices u and v. (2) If e = (u, v), then the segment Γ(e) has its bottom endpoint on Γ(u), its top endpoint on Γ(v) and does not intersect any other segment. A visibility representation of a clustered graph C = (G, T ) consists of a visibility representation of G as well as an isothetic rectangle for each node ν of T , such that the rectangles satisfy the same constraints as the regions for clusters as given in Section 2. An example is in Figure 3(b). The first phase of our algorithm produces a visibility representation of the input clustered graph. The input clustered graph is enhanced by adding some dummy vertices and edges; this makes a classical graph. A visibility drawing of this classical graph is made; the horizontal lines connecting two horizontal bars (where each horizontal bar represents a dummy vertex) become the horizontal sides of the cluster rectangles, and the vertical lines representing the dummy edges become the vertical sides of the rectangles. The visibility phase has the following steps: 1. Triangulate an input clustered graph C = (G, T ), and compute a specific kind of st-numbering, called a “c-st numbering”. 2. Find specific kinds of facial triangles, called “support triangles” for each cluster in the triangulated graph; intuitively, these form the left and right boundaries for each cluster. 3. Extend the original graph C = (G, T ) with dummy vertices and edges. 4. Extend the c-st numbering. 5. Find a constrained visibility drawing, and replace the dummy vertices and edges with rectangles.
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
10
Our method depends critically on the constrained visibility algorithm of Di Battista, Tamassia and Tollis [3]; this is reviewed and extended slightly in the following subsection. Then we describe each of the steps above in turn. The algorithm described by the steps above produces a visibility representation of the input clustered graph, and does not require that the input graph has maximum degree 4. However, for Section 3.2, the input must be restricted to maximum degree four, and some alignment constraints must be used to limit the number of edge bends in the final drawing. These alignment constraints are described in subsection 3.1.7. Some remarks on the construction of the visibility representation are in subsection 3.1.8. 3.1.1
Constrained visibility drawings
The Constrained Visibility algorithm described in [3] takes as inputs a planar st-graph G and a set Π of paths in G, and it produces a visibility drawing of G so that the x-coordinates of Γ(e) and Γ(e0 ) are the same whenever e and e0 are the edges in the same path in Π. The set Π is restricted to “non-crossing paths” in the following sense. Two paths π1 and π2 of G are said to be non-crossing if they are edge disjoint and do not cross at common vertices, that is, there is no vertex v of G with edges e1 , e2 , e3 and e4 incident in this clockwise order around v, such that e1 and e3 are in π1 and e2 and e4 are in π2 . For each vertex u in G, the original algorithm Constrained Visibility of [3] chooses the y-coordinate of Γ(u) to be the length of the longest directed path from s to u in G. In fact, we can vary the original algorithm to use a topological order λ of an st-graph G as an additional input of Constrained Visibility: the y-coordinate of Γ(u) is λ(u) for each u ∈ V . Looking at it in a different way, we apply Constrained Visibility to the graph obtained by inserting λ(v) − λ(u) − 1 new vertices in each directed edge (u, v), regarding the resulting paths as part of the set of non-crossing paths. This variation is important for some of the details below. In our algorithm, the y coordinates of the vertices are the “c-st numbers” of the vertices, a specific kind of topological order, as defined in the next subsection. 3.1.2
Computing a c-st numbering
When transforming the clustered graph to a planar st-graph, we need to consider the clustering structure so that the visibility representation that we produce respects the clustering constraints. This is achieved by computing an st-numbering of the vertices of G such that the vertices that belong to the same cluster are numbered consecutively. We call this numbering c-st numbering. The c-st numbers are used for the y-coordinates of vertices; the consecutiveness ensures that the vertices of each cluster occupy a vertical range. In this paper, a c-st numbering λ : V → {1, 2, . . . , n} of an n vertex clustered graph may have the same
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
11
number assigned to more than one vertex, as long as it does not violate the property that a vertex u(6= s, t) is adjacent to two neighbors v and w such that λ(v) < λ(u) < λ(w). Lemma 1 [9, 10] Suppose that C = (G, T ) is a connected c-planar clustered graph, and G is triangulated. Then a c-st numbering of C can be found in O(n) time. Proof: The algorithm for obtaining a c-st numbering is complex and given fully in [9, 10]; here we briefly sketch the main thrust of the algorithm. For a cluster ν ∈ V, let G∗ (ν) be the (classical) graph obtained from G(ν) by shrinking each child cluster V (ν 0 ), for each ν 0 ∈ chl(ν), to a single vertex. An st numbering of G∗(ρ), where ρ is the root of the cluster tree T , can be computed in linear time using the algorithm of Even and Tarjan [13]. Now suppose that ν is a child of the root. In this case, we need to augment G∗(ν) (with vertices and edges from G∗ (ρ), ρ ∈ chl(ν)) and apply the algorithm recursively to the augmented graph. Using the order of the children ν of ρ given by the st numbering of G∗(ρ), together with the c-st numberings of each V (ν) provided by recursion, one can obtain a c-st numbering of the complete clustered graph. 2 With this c-st numbering, we transform a clustered graph into a planar st-graph by applying directions for edges of G according to the c-st numbering. 3.1.3
Find support triangles for each cluster
Next we show how to obtain the 4 bounding sides of the rectangle for a cluster ν. To do this, we need some further terminology. We say that an edge is an outward edge (resp., inward edge) of a cluster ν if its tail (resp., head) is inside the cluster and its head (resp., tail) is outside the cluster. As preprocessing, we introduce two new edges (s∗ , s) and (t, t∗) with new vertices s∗ and t∗ outside of G so that each cluster ν has an outward edge and an inward edge. Then we triangulate the graph, as shown in Figure 4, introducing two edges between s∗ and t∗ ; the use of these new edges is described later. The resulting graph G∗ is clearly a planar st-graph with source s∗ and sink t∗ . Note that an outward edge for a cluster ν may well be an outward edge for several clusters, and in fact the sum of the number of outward edges for cluster ν over all clusters ν may be quadratic. We are aiming for a linear time algorithm; to this end we identify a linear number of outward edges with which we can form a rectangle for each cluster. Let L+ (ν) and R+ (ν) denote the leftmost outward edge and the rightmost outward edge of a cluster ν ∈ V respectively in G∗ (it is possible that L+ (ν) = R+ (ν)). Similarly, L− (ν) and R− (ν) denote the leftmost inward edge and the rightmost inward edge of ν respectively. Identifying the edges L− (ν), L+ (ν), R− (ν) and R+ (ν) helps to define new dummy edges that will form the four bounding sides of the rectangle for a cluster ν. There are at most four of these edges for each cluster, so that the
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
12
t*
t
G
s
s* Figure 4: Extending G to G∗ . total number of them is linear. The main difficulty is ensuring that the time required to identify the edges is linear; the remainder of this subsection presents the algorithm for this. Note that for each node ν in T , L− (ν) and L+ (ν) are contained in the same facial triangle in G∗ , since G∗ is triangulated. Similarly, R− (ν) and R+ (ν) are in the same facial triangle in G∗ . A facial triangle which contains L− (ν) and L+ (ν) (or R− (ν) and R+ (ν)) for a cluster ν is a support triangle of ν. Any node ν in T has exactly two support triangles (one on its left, and one on its right), where the added edges incident to s∗ or t∗ ensure the existence of support triangles of the root cluster of G. The support triangles are used to compute the edges L− (ν), L+ (ν), R− (ν) and R+ (ν) for all nodes ν in T . Firstly, however, we must show how to compute the support triangles. Let c(u, v) denote the least common ancestor of two nodes u and v in T . After O(n) time preprocessing, c(u, v) can be found in O(1) time [21, 37]. Suppose that τ = (u1 , u2 , u3) is a facial triangle with directed edges e1 = (u1 , u2 ), e2 = (u2 , u3 ) and e3 = (u1 , u3). If ν is a cluster such that u2 ∈ V (ν) and {u1 , u3 } ∩ V (ν) = ∅ then τ is a support triangle of ν; see Figure 5(a). It is easy to see that τ is a support triangle for all clusters ν on the path from u2 to µ = min{c(u1 , u2 ), c(u2 , u3 )} in T , where the minimum means to take the lower node in T among the two; see Figure 5(b). Thus the following algorithm can be used to identify the support triangles of each cluster:
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
root
T
u3
e1 u1
µ
e2
e3 τ
13
u2 cluster ν
u1 (a)
u3
u2 (b)
Figure 5: Computing support triangles. 1. Pre-process tree T to prepare for computing c(u, v) for any pair u, v of vertices of G. 2. For each facial triangle τ = (u1 , u2 , u3 ) of G with directed edges e1 = (u1 , u2 ), e2 = (u2 , u3 ) and e3 = (u1 , u3 ): (a) compute µ = min{c(u1 , u2 ), c(u2 , u3 )} (b) Traverse T from u2 toward the root. Stop the traversal if we reach µ, or if we encounter a node for which a support triangle has been assigned. At each node ν traversed (except for the final node), we assign τ as a support triangle for ν. From [21, 37], steps 1 and 2(a) take linear time. For step 2(b), note that since each cluster has two support triangles, each node of T is visited at most twice. Thus the total running time is O(|T |), that is, linear. Given the support triangles, it is easy to compute the edges L− (ν), L+ (ν), − R (ν) and R+ (ν). For each cluster ν, L− (ν) = e1 and L+ (ν) = e2 if e2 = (u2 , u3 ) is clockwise next to e1 = (u1 , u2 ) around u2 ; R− (ν) = e1 and R+ (ν) = e2 otherwise. Clearly, the entire running time is O(|V|), that is, O(n). 3.1.4
Extending the graph with dummy vertices and edges
The next step in the algorithm is to modify G(ν) in G∗ recursively from top to bottom of the tree T , using the edges L− (ν), L+ (ν), R−(ν) and R+ (ν). The head and tail of a directed edge e are denoted by head(e) and tail(e) respectively.
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
14
For each cluster ν, we add four dummy vertices `d(ν), `u(ν), rd(ν) and ru(ν), then add six new edges (see Figure 6): (tail(L− (ν)), `d(ν)), (`d(ν), `u(ν)), (`u(ν), head(L+ (ν))), (tail(R− (ν)), rd(ν)), (rd(ν), ru(ν)) and (ru(ν), head(R+(ν))). The pairs (`d(ν), `u(ν)), (rd(ν), ru(ν)), (`d(ν), rd(ν)) and (`u(ν), ru(ν)) represent the four sides of a rectangle for ν in the final drawing of the clustered graph. In T we place these dummy vertices as children of ν which will be new leaves.
R +( ν )
L+ ( ν )
G (ν )
L- ( ν )
ru ( ν )
lu ( ν )
G (ν )
R- ( ν)
ld ( ν )
rd ( ν )
Figure 6: Modify G(ν), adding dummy vertices to represent the rectangle. We modify every subgraph G(ν) recursively as above, obtaining an extended graph F that includes the dummy vertices for the rectangles. It can be easily verified that the leftmost outward edge of a cluster does not change during the modification for the following reasons. (i) The edge L+ (ν) cannot be R− (ν 0 ) for any other cluster ν 0 (since the graph G∗ is triangulated). (ii) Since we apply the transformation from top to bottom, adding new edge (`u(ν), head(L+ (ν)) to G(ν) does not affect the definition of L+ (ν 0 ), L− (ν 0 ) or R− (ν 0 ) for any other cluster ν 0 which is not an ancestor of ν. Similarly we do not have to recompute the rightmost outward, leftmost inward and rightmost inward edges of a cluster during the modification. It follows that the above modification can be completed in O(n) time.
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
15
The resulting graph F is clearly a planar st-graph. It is trivial to add the dummy vertices to T to make an extended cluster tree T ∗ ; this gives an extended clustered graph C ∗ = (F, T ∗ ). Since we add 4 dummy vertices and 6 dummy edges for every node of T , F has O(n) vertices and edges. 3.1.5
Extending the c-st numbering
We extend the c-st numbering λ in C to a c-st numbering λ0 in C ∗ such that, for each cluster ν: (i) vertices in V (ν) ∪ {`u(ν), `d(ν), ru(ν), rd(ν)} are numbered by λ0 consecutively, and (ii) λ0 (`d(ν)) = λ0 (rd(ν)) < min{λ0 (u) | u ∈ V (ν)}, and max{λ0 (u) | u ∈ V (ν)} < λ0 (`u(ν)) = λ0 (ru(ν)). To compute the numbering λ0 , we consider the tree T of C, where the leaves u1 , . . . , un are arranged from left to right in the order of the c-st numbering λ. We see that, for two consecutive leaves ui and ui+1 , the number δi of new dummy vertices w that satisfy λ0 (ui ) < λ0 (w) < λ0 (ui+1 ) is 2α − 1, where α is the number of internal nodes in the path of T between ui and ui+1 . Thus all δi can be obtained by traversing such paths in O(n) time. Based on this, we can easily extend the c-st numbering λ to a c-st numbering λ0 of F in O(n) time. G( ν)
G( ν) lu (ν)
ru (ν)
lu (ν)
ru (ν)
ld (ν)
rd (ν)
ld (ν)
rd (ν)
Figure 7: Forming a rectangle for a cluster.
3.1.6
Find a constrained visibility drawing
Using the dummy vertices `d(ν), `u(ν), rd(ν) and ru(ν) as corners of rectangles, we can easily deduce the following result.
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
16
Theorem 3 Let C = (G, T ) be an n vertex clustered graph with a c-planar embedding. There is a linear time algorithm which constructs a visibility representation of G such that each cluster ν of C can be represented by a rectangle. Proof: We obtain a visibility representation Γ of F with the vertices and edges of each cluster ν drawn within a rectangle formed by Γ(`d(ν), `u(ν)), Γ(rd(ν), ru(ν)) and two line segments (Γ(`d(ν)), Γ(rd(ν))) and (Γ(`u(ν)), Γ(ru(ν))), as in Figure 7. Since this algorithm preserves the embedding of the input, it is simple to form the rectangles. Computing the c-st numbering takes linear time, and gives the y coordinate of each vertex of G. The algorithm for finding support triangles, given in subsection 3.1.3, also takes linear time. Extending the graph with dummy vertices and edges and extending the c-st numbering is trivial. Finding a visibility drawing (e.g., using the algorithm of [3]) takes linear time. 2
v
v
Figure 8: Alignment requirement for a vertex v.
Figure 9: Edge alignment rules.
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
3.1.7
17
Edge alignment constraints
Theorem 3 does not use the constraints available in the constrained visibility algorithm. However, looking ahead to the orthogonalization phase, we require that some edges around a vertex are aligned. In the orthogonalization phase, only graphs of maximum degree 4 are considered, and so the edge alignment rules only apply to such graphs. The dummy edges introduced for triangulation are not needed here, and the edge alignment constraints only apply at the original vertices of the graph, and at the vertices `u(v), `d(v), ru(v), and rd(v), of degree 2. The purpose of the edge alignment constraints is to avoid unnecessary bends in the orthogonal drawing. For example, suppose that a vertex v has two incoming edges and two outgoing edges; then we require that the right incoming edge is aligned with the left outgoing edge (see Figure 8). The input of the orthogonalization phase is restricted to clustered graphs C = (G, T ) for which the vertices in G have maximum degree 4. Thus Figure 9 illustrates all the cases for our alignment requirements; the edges that are marked by thick lines are required to be aligned. All the above alignment requirements together form a complete specification of the paths that are to be aligned for our visibility representation. Although some of these paths share common vertices, they do not cross with each other. This is because there is at most one path going through each original (nondummy) vertex of G, and at every dummy vertex, the paths originate from distinct edges of G and therefore do not cross. We apply the algorithm Constrained Visibility of [3] to the graph F defined in subsection 3.1.4 with a c-st-numbering and the above requirements for alignment. In the next phase, we perform orthogonalization operations on this visibility representation. 3.1.8
Remarks on the visibility phase
The representation provided by Theorem 3 does not depend on the maximum degree of the graph; it holds for any c-planar clustered graph. Note also that the triangulation is necessary only for the computation of the c-st numbering and the support triangles; the dummy edges inserted to make the triangulation can be omitted after these steps.
3.2
Orthogonalization
For this phase, we assume that the input has maximum degree 4. Note that the process of adding dummy vertices and edges does not increase the maximum degree. To transform the visibility representation to an OGRC drawing, we only need to perform some local operations at each vertex, transforming a horizontal segment to a point. These local operations are illustrated in Figure 10; symmetric cases for (a), (c), (d), (e) and (f) are omitted for brevity. Note that Figure 10
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
18
covers all the cases that can appear, since we have required that certain edges around a vertex are aligned. Further, note that a new row is added at every source or sink of degree 4 (see Figure 10(h) and (i)). The number of rows and columns becomes at most twice in in the resulting OGRC drawing.
3.3
Bend Reduction
In the OGRC drawing obtained from the previous phase, an edge is bent only near its endpoints. Hence every edge can have at most 3 bends except in the following case: the edge is between a source of degree 4 and a sink of degree 4 and it has 2 bends near each endpoint (see Figure 11). We show that this 4 bend case can be eliminated by making some adjustments in the drawing. Note that graph G in a sub-clustered graph C = (G, T ) may have multiple sources or sinks. For a source or sink u of degree 4 in G, either the leftmost edge or the rightmost edge gets 2 bends near it, but not both. We say that the
(c)
(b)
(a)
(d)
(e)
(f)
(g)
(h)
(i)
Figure 10: Orthogonalization rules.
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
19
leftmost or the rightmost edge of source (or sink) u is an extreme edge of u. An edge e = (u, v) is a critical edge if e is an extreme edge of both u and v. Suppose that there is an edge e = (u, v) that has 2 bends near u and another 2 bends near v. Then we fix one end u and rotate the edges around the other end v, letting the edge e bend only once near v (see Figure 12). However, this operation creates a new bend in the other edge e0 = (v, w) of v which may be a critical edge. To avoid this, we construct an auxiliary graph H from G as follows. Let H be the undirected subgraph induced from G by the set of critical edges, where all isolated vertices are deleted and directions of the edges are ignored. Note that the degree of any vertex in H is at most two. This implies that each connected component in H is either a path or cycle. Thus there is an assignment σ of direction of edges such that each vertex has at most one outgoing edge and at most one incoming edge. Let tailσ (e) denote the tail of a critical edge e in terms of such a direction σ. For each critical edge e, we apply the above rotation procedure to tailσ (e) if tailσ (e) has 2 bends near it in the current OGRC drawing. Clearly, after applying the rotation procedure (if necessary) for all tails tailσ (e), there is no critical edge with four bends. It is easy to see that the entire procedure for reducing bends can be performed in O(n) time and the final OGRC drawing has an O(n) number of rows and columns (and hence the height and width are O(n)).
Figure 11: An edge with 4 bends.
v
v e u
e u
Figure 12: Reduce a bend on a critical edge e.
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
3.4
20
The complete algorithm
The algorithm Orthogonal Grid Rectangular Draw is described as follows. Algorithm 1 Orthogonal Grid Rectangular Draw Input: an n vertex connected clustered graph C = (G, T ) of maximum degree at most 4, and a c-planar embedding of C. Output: a c-planar OGRC drawing of C. (1) Construct a visibility representation: (1.1) triangulate G and compute a c-st numbering λ on C; (1.2) obtain graph F by modifying G to include the dummy vertices for the rectangles, and compute a c-st numbering λ0 of the resulting clustered graph C ∗ = (F, T ∗ ); (1.3) apply algorithm Constrained Visibility to F and λ0 . (2) Construct an OGRC drawing for C from the visibility representation produced from the previous step, using local operations in Figure 10; obtain rectangles for clusters from the visibility representation. (3) Eliminate all the 4 bend edges by using a rotation procedure. 2 For an n vertex clustered graph C = (G, T ), we can triangulate G in O(n) time and compute a c-st numbering on C in O(n) time. Since algorithm Constrained Visibility takes linear time [3] in terms of the size of its input, and the graph F has O(n) vertices and edges, step (1) of our algorithm takes O(n) time. Clearly, step (2) takes O(n) time. As noted in Section 3.3, step (3) can be carried out in O(n) time. These make our algorithm take O(n) time. Since graph F has O(n) vertices, edges and bends, the height and width of the output drawing are O(n), as observed in Section 3.3. We summarize the performance of our algorithm in the following theorem. Theorem 4 Let C = (G, T ) be an n vertex connected clustered graph of maximum degree at most 4, with a c-planar embedding. The algorithm Orthogonal Grid Rectangular Draw constructs in O(n) time a c-planar OGRC drawing of C with O(n2 ) area, and with at most 3 bends in each edge.
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
21
A a1
a2
a3
b1
a5
a4
b3
b2
a6
a7
b4 B
Figure 13: The sub-clustered-graph I.
4
A Lower Bound for Bends
In this section, we present a class of c-planar embedded clustered graphs of n vertices, for which every c-planar OGRC drawing requires Ω(n) edges bent more than twice. This shows that our algorithm Orthogonal Grid Rectangular Draw is optimal in the worst case (in terms of the number of bends in each edge). To prove our result, let us first consider a small sub-clustered-graph I (see Figure 13), which serves as the building block of our cluster graph. There are two clusters A and B in the sub-clustered-graph I. Cluster A contains vertices a1 , a2 , . . . , a7 ; cluster B contains vertices b1 , b2 , . . . , b4 . We assume that I has a fixed c-planar embedding; the orderings of the edges around cluster A and cluster B are shown in Figure 14. The drawings that we discuss in the rest of this section are all consistent with this embedding. A
1
2
3
4
5
6
7
8
9
10
B
Figure 14: The embedding for clusters A and B.
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
22
We prove the following lemma. Lemma 2 In every c-planar OGRC drawing of I, there is at least one edge bent more than twice. Proof: In a c-planar OGRC drawing of I, cluster A and B are drawn as disjoint rectangular regions. Without loss of generality, we assume that the rectangle for A is drawn above the rectangle for B, and there is a horizontal line ` separating them. Note that all the edges between A and B have to cross this horizontal line `, and they cross the line ` in the order shown in Figure 14. Consider the edge (a4 , b1 ) and the edge (a4 , b4 ), both incident to a4 . Suppose that the edge (a4 , b1 ) has no bend above the line `; it follows that the other edge (a4 , b4 ) must have more than 2 bends above the line `. On the other hand, if the edge (a4 , b1 ) has one bend above the line `, then the other edge (a4 , b4 ) must have more than one bend above the line `. We deduce that at least one of these two edges has more than one bend above the line `. With out loss of generality, let us assume that the edge (a4 , b4 ) has more than one bend above the line `. Now consider the edge (a4 , b4 ) together with the edge (a7 , b4 ). We can show that at least one of these has a total of more than two bends, as follows. If the edge (a4 , b4 ) has a bend below the line `, then it has more than two bends in total; if the edge (a4 , b4 ) has no bend below the line `, then the other edge (a7 , b4 ) must have more than two bends below the line `. Therefore, we have that there is at least one edge in I that has a total of more than two bends. 2 Now we define a class of clustered graphs Φn (n = 1, 2, . . .) with subclustered-graph I as the building block. Clustered graph Φn consists of a sequence of n copies of the sub-clustered-graph I (see Figure 15). The vertex a7 of a previous copy of I also serves as the vertex a1 of the next copy of I. Clustered graph Φn has two clusters An and Bn . Cluster An contains the vertices in the cluster A of each sub-clustered-graph I; cluster Bn contains the vertices in the cluster B of each sub-clustered-graph I. Clearly, Φn has 10n + 1 vertices. By Lemma 2, we have the following theorem. Theorem 5 In every c-planar OGRC drawing of Φn (n = 1, 2, . . .), there are at least n edges bent more than twice.
5
Remarks
In this paper, we present a linear time algorithm Orthogonal Grid Rectangular Draw that produces c-planar OGRC drawings with O(n2 ) area and with at most 3 bends in each edge. These results are as good as the results for classical planar graphs [11, 24, 45]. Lower bounds for the area of orthogonal drawings of
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
23
An a1
a7
b1
b4 Bn
n copies of
I.
Figure 15: The construction of the clustered graph Φn . classical graphs [48] imply that the area of the drawing produced by our algorithm is asymptotically optimal. Further, we show that the performance of our algorithm is optimal in terms of the number of bends per edge. Nevertheless, some open problems remain: • Although the height and the width of our output drawings are both O(n), our algorithm does not guarantee a good aspect ratio. In practice, our algorithm may produce drawings which clearly prefer one dimension against the other; this is because we use a visibility representation which is biased to one dimension. As an example, note that Figure 1 could not be produced by our algorithm as it is. Recent investigations of “2-dimensional visibility representations” [6, 17] of planar graphs (each vertex is represented by a box and each edge is represented by a horizontal or vertical segment between the sides of the boxes) may prove useful in terms of the aspect ratio of the drawing. • Even and Granot [12] have presented some algorithms for grid layout of block diagrams. Although the drawing requirements there are different from the requirements of drawing clustered graphs, it would be worthwhile to investigate whether we can borrow some of the techniques there and for use in drawing clustered graphs. • In recent years, many results have been achieved for orthogonal drawings of non planar graphs [5, 4, 33, 34]. It seems very profitable to use these results to extend our algorithm to non planar clustered graphs. • This paper deals only with graphs of degree at most four. In practice, algorithms must deal with higher degree vertices. Our methods can be
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
24
Figure 16: Simulation of a degree 10 vertex with a cluster. extended to such graphs by simulating the larger degree vertices with clusters; for example, the cluster in Figure16 simulates a vertex of degree 10. It would be interesting to analyze this simulation. However, it is clear that such a simulation increases the area of the drawing. It would be useful to investigate whether the methods for solving the related problem classical graphs [8, 18] can be extended to clustered graphs. Finally, as a byproduct of our modification from a clustered graph C = (G, T ) to an extended clustered graph C ∗ = (F, T ∗ ) in Section 3.1, we present a new result in planar straight-line drawings of clustered graphs. In a planar straight-line drawing of a clustered graph C = (G, T ), edges are required to be drawn as straight-lines and clusters must be drawn as convex polygons. The question of whether every c-planar clustered graph admits a planar straightline drawing or not has been studied and answered affirmatively [9, 10, 14]. However, it is still open whether or not more regular convex bodies such as circles and rectangles can be used for clusters in a planar straight-line drawing. The results of this paper together with those in [9, 10] imply that a c-planar clustered graph C = (G, T ) admits a planar straight-line drawing with clusters drawn as trapezoids, as follows. We use the extended clustered graph C ∗ = (F, T ∗ ) of C defined in Section 3.1. Results in [9, 10] imply that for a given c-planar clustered graph C = (G, T ) and its c-st numbering λ, there is a planar straight-line drawing of C with the following properties: (i) the y-coordinate of each vertex u is its c-st number λ(u), and (ii) the convex polygon for a cluster ν is the convex hull of points in V (ν). The drawing can be obtained in O(n + D) time, where D denotes the total size of convex polygons for clusters.
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
25
By applying this result to the clustered graph C ∗ extended from C and a c-st numbering λ0 on C ∗ , we can obtain a planar straight-line drawing of C ∗ in which the convex polygon for each cluster ν is a trapezoid formed by its dummy vertices `d(ν), `u(ν), rd(ν) and ru(ν) (since λ0 (`d(ν)) = λ0 (`u(ν)) and λ0 (rd(ν)) = λ0 (ru(ν))). This implies the following result. Corollary 1 Let C = (G, T ) be a c-planar clustered graph with n vertices. A planar straight-line drawing of C in which each cluster is drawn as a trapezoid can be constructed in O(n) time.
Acknowledgments The authors wish to thank the referees for several useful suggestions.
References [1] C. Batini, L. Furlani, and E. Nardelli. What is a good diagram? a pragmatic approach. In Proc. 4th Int. Conf. on the Entity Relationship Approach, 1985. [2] G. Di Battista and R. Tamassia. Algorithms for plane representations of acyclic digraphs. Theoretical Computer Science, 61:175–198, 1988. [3] G. Di Battista, R. Tamassia, and I.G. Tollis. Constrained visibility representations of graphs. Information Processing Letters, 41:1–7, 1992. [4] T. Biedl. New lower bounds for orthogonal graph drawings. In Franz J. Brandenburg, editor, GD’95, volume 1027 of Lecture Notes in Computer Science, pages 28–39. Springer-Verlag, 1995. [5] T. Biedl and G. Kant. A better heuristic for orthogonal graph drawings. Comput. Geom. Theory Appl., 9:159–180, 1998. [6] P. Bose, A. Dean, J. Hutchinson., and T. Shermer. On rectangle visibility graphs. In Stephen C. North, editor, GD’96, volume 1190 of Lecture Notes in Computer Science, pages 25–44. Springer-Verlag, 1997. [7] G. Di Battista, P. Eades, R. Tamassia, and I. G. Tollis. Graph Drawing. Prentice Hall, Upper Saddle River, NJ, 1999. [8] Michael Doorley. Automatic Leveling and Layout of Data Flow Diagrams. PhD thesis, Department of Computer Science and Information Sys tems, University of Limerick, Ireland, August 1995.
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
26
[9] P. Eades, Q-W. Feng, and X. Lin. Straight-line drawing algorithms for hierarchical graphs and clustered graphs. Technical Report 96-02, Department of Computer Science, The University of Newcastle, Australia, 1996. [10] P. Eades, Q-W. Feng, X. Lin, and H. Nagamochi. Straight-line drawing algorithms for hierarchical graphs and clustered graphs. Technical Report 98-03, Department of Computer Science, The University of Newcastle, Australia, 1998. [11] S. Even and G. Granot. Rectilinear planar drawings with few bends in each edge. Technical Report 797, Computer Science Department, Technion, Israel Institute of Technology, 1994. [12] S. Even and G. Granot. Grid layout of block diagrams - bounding the number of bends in each connection. In R. Tamassia and I. G. Tollis, editors, GD’94, volume 894 of Lecture Notes in Computer Science, pages 64–75. Springer-Verlag, 1995. [13] S. Even and R. E. Tarjan. Computing an st-numbering. Theoretical Computer Science, 2:339–344, 1976. [14] Q. Feng. Algorithms for Drawing Clustered Graphs. PhD thesis, Department of Computer Science and Software Engineering, University of Newcastle, 1997. [15] Q. Feng, R. Cohen, and P. Eades. How to draw a planar clustered graph. In COCOON’95, volume 959 of Lecture Notes in Computer Science, pages 21–31. Springer-Verlag, 1995. [16] Q. Feng, R. Cohen, and P. Eades. Planarity for clustered graphs. In ESA’95, volume 979 of Lecture Notes in Computer Science, pages 213–226. Springer-Verlag, 1995. [17] U. F¨oßmeier, G. Kant, and M. Kaufmann. 2-visibility drawings of planar graphs. In Stephen C. North, editor, GD’96, volume 1190 of Lecture Notes in Computer Science, pages 155–168. Springer-Verlag, 1997. [18] U. F¨oßmeier and M. Kaufmann. Drawing high degree graphs with low bend numbers. In Franz J. Brandenburg, editor, GD’95, volume 1027 of Lecture Notes in Computer Science, pages 254–266. Springer-Verlag, 1995. [19] A. Garg and R. Tamassia. On the computational complexity of upward and rectilinear planarity testing. In R. Tamassia and I. G. Tollis, editors, GD’94, volume 894 of Lecture Notes in Computer Science, pages 286–297. Springer-Verlag, 1995. [20] D. Harel. On visual formalisms. Communications of the ACM, 31(5):514– 530, 1988.
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
27
[21] D. Harel and R. Tarjan. Fast algorithms for finding nearest common ancestors. SIAM J. Computing, 13:338 – 355, 1984. [22] T. Kamada. Visualizing Abstract Objects and Relations. World Scientific Series in Computer Science, 1989. [23] G. Kant. Drawing planar graphs using the lmc-ordering. In Proc. 33th IEEE Symp. on Foundations of Computer Science, pages 101–110, 1992. [24] G. Kant. Drawing planar graphs using the canonical ordering. Algorithmica, 16:4–32, 1996. [25] G. Kar, B.P. Madden, and R.S. Gilbert. Heuristic layout algorithms for network management presentation services. IEEE Network, pages 29–36, November 1988. [26] J. Kawakita. The KJ method – a scientific approach to problem solving. Technical report, Kawakita Research Institute, Tokyo, 1975. [27] M.R. Kramer and J. van Leeuwen. The complexity of wire-routing and finding minimum area layouts for arbitrary VLSI circuits. In F.P. Preparata, editor, Advances in Computing Research, volume 2, pages 129–146. JAI Press, Greenwich, Conn., 1985. [28] W. Lai. Building Interactive Digram Applications. PhD thesis, Department of Computer Science, University of Newcastle, 1993. [29] C. E. Leiserson. Area-efficient graph layouts (for VLSI). In Proceedings of the IEEE Symposium on the Foundations of Computer Science, pages 270 – 281, 1980. [30] K. Misue and K. Sugiyama. An overview of diagram based idea organizer: D-abductor. Technical Report IIAS-RR-93-3E, ISIS, Fujitsu Laboratories, 1993. [31] S. North. Drawing ranked digraphs with recursive clusters. In Proc. ALCOM Workshop on Graph Drawing ’93, September 1993. [32] J. Nummenmaa and J. Tuomi. Constructing layouts for er-diagrams from visibility representations. In Proc. 9th Int. Conf. on Entity-Relationship Approach, pages 303–317, 1990. [33] A. Papakostas and I. G. Tollis. Improved algorithms and bounds for orthogonal drawings. In R. Tamassia and I. G. Tollis, editors, GD’94, volume 894 of Lecture Notes in Computer Science, pages 40–51. Springer-Verlag, 1994.
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
28
[34] A. Papakostas and I. G. Tollis. A pairing technique for area-efficient orthogonal drawings. In Stephen C. North, editor, GD’96, volume 1190 of Lecture Notes in Computer Science, pages 355–370. Springer-Verlag, 1997. [35] D. Reiner, G. Brown, M. Friedell, J. Lehman, R. McKee, P. Rheingans, and A. Rosenthal. A database designer’s workbench. In S. Spaccapietra, editor, Entity-Relationship Approach: Proc. 5th Int. Conf. on Entity-Relationship Approach (Dijon France 1987), pages 347–360, New York, N.Y., 1987. North-Holland. [36] P. Rosenstiehl and R.E. Tarjan. Rectilinear planar layouts and bipolar orientations of planar graphs. Discrete and Computational Geometry, 1(4):343–353, 1986. [37] B. Schieber and U. Vishkin. On finding lowest common ancestors: simplification and parallelization. SIAM J. Computing, 17:1253–1262, 1988. [38] K. Sugiyama and K. Misue. Visualization of structural information: Automatic drawing of compound digraphs. IEEE Transactions on Systems, Man and Cybernetics, 21(4):876–892, 1991. [39] K. Sugiyama and K. Misue. Visualization of structural information: Automatic drawing of compound digraphs. IEEE Transactions on Software Engineering, 21(4):876–892, 1991. [40] R. Tamassia. New layout techniques for entity-relationship diagrams. In Proc. 4th Int. Conf. on Entity-Relationship Approach, pages 304–311, 1985. [41] R. Tamassia. On embedding a graph in the grid with the minimum number of bends. SIAM J. Computing, 16(3):421–444, 1987. [42] R. Tamassia, G. Di Battista, and C. Batini. Automatic graph drawing and readability of diagrams. IEEE Transactions on Systems, Man and Cybernetics, SMC-18(1):61–79, 1988. [43] R. Tamassia and I.G. Tollis. A unified approach to visibility representations of planar graphs. Discrete and Computational Geometry, 1(4):321–341, 1986. [44] R. Tamassia and I.G. Tollis. Efficient embedding of planar graphs in linear time. In Proc. IEEE Int. Symp. on Circuits and Systems, pages 495–498, 1987. [45] R. Tamassia and I.G. Tollis. Planar grid embedding in linear time. IEEE Trans. on Circuits and Systems, CAS-36(9):1230–1234, 1989. [46] R. Tamassia, I.G. Tollis, and J.S. Vitter. Lower bounds for planar orthogonal drawings of graphs. Information Processing Letters, 39:35–40, 1991.
P. Eades et al., Drawing Clustered Graphs, JGAA, 3(4) 3–29 (1999)
29
[47] J.D. Ullman. Computational Aspects of VLSI. Principles of Computer Science. Computer Science Press, Rockville, Md., 1984. [48] L. Valiant. Universality considerations in VLSI circuits. IEEE Transactions on Computers, C-30(2):135–140, 1981. [49] C. Williams, J. Rasure, and C. Hansen. The state of the art of visual languages for visualization. In Visualization 92, pages 202 – 209, 1992. [50] R. Wirfs-Brock, B. Wilkerson, and L. Wiener. Designing Object-Oriented Software. P T R Prentice Hall, Englewood Cliffs, NJ 07632, 1990.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 3, no. 4, pp. 31–62 (1999)
A Linear Algorithm for Bend-Optimal Orthogonal Drawings of Triconnected Cubic Plane Graphs Md. Saidur Rahman, Shin-ichi Nakano and Takao Nishizeki Graduate School of Information Sciences Tohoku University Aoba-yama 05, Sendai 980-8579, Japan http://www.nishizeki.ecei.tohoku.ac.jp/
[email protected],
[email protected],
[email protected] Abstract An orthogonal drawing of a plane graph G is a drawing of G in which each edge is drawn as a sequence of alternate horizontal and vertical line segments. In this paper we give a linear-time algorithm to find an orthogonal drawing of a given 3-connected cubic plane graph with the minimum number of bends. The best previously known algorithm takes time √ O(n7/4 log n) for any plane graph with n vertices.
Communicated by Giuseppe Di Battista and Petra Mutzel. Submitted: March 1998. Revised: November 1998 and March 1999.
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
1
32
Introduction
An orthogonal drawing of a plane graph G is a drawing of G with the given embedding in which each vertex is mapped to a point, each edge is drawn as a sequence of alternate horizontal and vertical line segments, and any two edges do not cross except at their common end. Orthogonal drawings have attracted much attention due to their numerous practical applications in circuit schematics, data flow diagrams, entity relationship diagrams, etc. [1, 5, 9, 10, 11]. In particular, we wish to find an orthogonal drawing with the minimum number of bends. For the plane graph in Fig. 1(a), the orthogonal drawing in Fig. 1(b) has the minimum number of bends, that is, seven bends. For a given planar graph G with n vertices, if one is allowed to choose its planar embedding, then finding an orthogonal drawing of G with the minimum number of bends is NP-complete [3]. However, Tamassia [10] and Garg and Tamassia [4] presented algorithms that compute an orthogonal drawing of a given plane graph G with the minimum number of bends in O(n2 log n) and √ 7/4 log n) time respectively, where a plane graph is a planar graph with a O(n fixed planar embedding. They reduce the minimum-bend orthogonal drawing problem to a minimum cost flow problem. On the other hand, several linear-time algorithms are known for finding orthogonal drawings of plane graphs with a presumably small number of bends although they do not always find orthogonal drawings with the minimum number of bends [1, 5]. In this paper we give a linear-time algorithm to find an orthogonal drawing of a 3-connected cubic plane graph with the minimum number of bends. To the best of our knowledge, our algorithm is the first linear-time algorithm to find an orthogonal drawing with the minimum number of bends for a fairly large class of graphs. An orthogonal drawing in which there is no bend and each face is drawn as a rectangle is called a rectangular drawing. Linear-time algorithms have been known to find a rectangular drawing of a plane graph in which every vertex has degree three except four vertices of degree two on the outer boundary, whenever such a graph has a rectangular drawing [6, 8]. The key idea behind our algorithm is to reduce the orthogonal drawing problem to the rectangular drawing problem. An outline of our algorithm is illustrated in Fig. 1. Given a plane graph as shown in Fig. 1(a), we first put four dummy vertices a, b, c and d of degree two on the outer boundary of G, and let G0 be the resulting graph. Fig. 1(c) illustrates G0 , where the four dummy vertices are drawn by white circles. We then contract each of some cycles C1 , C2 , · · · and their interiors (shaded in Fig. 1(c)) into a single vertex as shown in Fig. 1(d) so that the resulting graph G00 has a rectangular drawing as shown in Fig. 1(e). We also find orthogonal drawings of those cycles C1 , C2 , · · · and their interiors recursively (see Figs. 1(d) and (e)). Patching the obtained drawings, we get an orthogonal drawing of G0 as shown in Fig. 1(f). Replacing the dummy vertices a, b, c and d in the drawing of G0
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
b
a
b
a
33
c
c
d
G d
G
(b)
(a) y1
z1
b
y
1
b x1
a
C1
G
z2
z1
C1
C2
x1
a
c
c
z2
x2 y2
x2
y
2
C2
d
G
d
dummy vertex
contracted vertex
(c)
(d) a
b
y
1
b
a
z1 x1 y
2
y
C1
2
G
z2
z
1
x2
C 2 x2
c d
(e)
1
x1
c
d
y
z2
G (f)
Figure 1: Illustration of our algorithm.
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
34
with bends, we finally obtain an orthogonal drawing of G as shown in Fig. 1(b). The rest of the paper is organized as follows. Section 2 gives some definitions and presents preliminary results. Section 3 presents an algorithm to find an orthogonal drawing in which the number of bends may not be the minimum but does not exceed the minimum number by more than four. Section 4 presents an algorithm to find an orthogonal drawing with the minimum number of bends, modifying the algorithm in Section 3. Section 5 presents bounds on the grid size of our orthogonal drawing on the plane grid. Finally Section 6 concludes the paper. A preliminary version of the paper was presented in [7].
2
Preliminaries
In this section we give some definitions and present preliminary results. Let G be a connected simple graph with n vertices and m edges. We denote the set of vertices of G by V (G), and the set of edges of G by E(G). We also denote by n(G) the number of vertices in G and by m(G) the number of edges in G. Thus n(G) = |V (G)| and m(G) = |E(G)|. The degree of a vertex v is the number of neighbors of v in G. If every vertex of G has degree three, then G is called a cubic graph. The connectivity κ(G) of a graph G is the minimum number of vertices whose removal results in a disconnected graph or a singlevertex graph K1 . We say that G is k-connected if κ(G) ≥ k. A graph is planar if it can be embedded in the plane so that no two edges intersect geometrically except at a vertex to which they are both incident. A plane graph is a planar graph with a fixed embedding. A plane graph divides the plane into connected regions called faces. We regard the contour of a face as a clockwise cycle formed by the edges on the boundary of the face. We denote the contour of the outer face of graph G by Co (G). For a simple cycle C in a plane graph G, we denote by G(C) the plane subgraph of G inside C (including C). We say that cycles C and C 0 in a plane graph G are independent if G(C) and G(C 0 ) have no common vertex. An edge e of G(C) is called an outer edge of G(C) if e is located on C; otherwise, e is called an inner edge of G(C). An edge of G which is incident to exactly one vertex of a simple cycle C and located outside C is called a leg of the cycle C. The vertex of C to which a leg is incident is called a leg-vertex of C. A simple cycle C in G is called a k-legged cycle of G if C has exactly k legs in G. The cycle C indicated by a dotted line in Fig. 2(a) is a 3-legged cycle. In Fig. 2(a) the three legs of C are drawn by thin lines and the three leg-vertices by black big circles. Let C be a 3-legged cycle in a 3-connected cubic plane graph G. Then the three leg-vertices of C are distinct with each other since G is cubic. We denote by CC the set of all 3-legged cycles of G in G(C) including C itself. For the cycle C in Fig. 2(a) CC = {C, C1, C2, · · · , C7 }, where all cycles in CC are drawn by thick lines. For any two 3-legged cycles C 0 and C 00 in CC , we say that C 00
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
35
is a descendant cycle of C 0 and C 0 is an ancestor cycle of C 00 if C 00 is contained in G(C 0 ). We also say that a descendant cycle C 00 of C 0 is a child-cycle of C 0 if C 00 is not a descendant cycle of any other descendant cycle of C 0 . In Fig. 2(a) cycles C1 , C2 , · · · , C7 are the descendant cycles of C, cycles C1 , C2 , · · · , C5 are the child-cycles of C, and cycles C6 and C7 are the child-cycles of C4 . We now have the following lemma. Lemma 1 Let C be a 3-legged cycle in a 3-connected cubic plane graph G. Then the child-cycles of C are independent of each other. Proof: Suppose for a contradiction that a pair of distinct child-cycles C1 and C2 of C are not independent. Then C1 and C2 have a common vertex. However, either cannot be a descendant cycle of the other since both are child-cycles of C. Therefore C2 has a vertex in G(C1 ) and a vertex not in G(C1 ). Thus C2 must pass through two of the three legs of C1 . Let v be the leg-vertex of the other leg of C1 . Similarly, C1 must pass through two of the three legs of C2 . Let w be the leg-vertex of the other leg of C2 . Then removal of v and w disconnects G, contrary to the 3-connectivity of G. 2 Lemma 1 implies that the containment relation among cycles in CC is represented by a tree as illustrated in Fig. 2(b); the tree is called the genealogical tree of C and denoted by TC . We have the following two lemmas.
C
1
C2
C
C4 C5 C7
C6
C1
C2
C3
C4 C6
C3
C5 C7
(b) C
(a) Figure 2: (a) Cycles in CC and (b) genealogical tree TC . Lemma 2 Let C be a 3-legged cycle in a 3-connected cubic plane graph G. Then |CC | ≤ n(G(C))/2.
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
36
Proof: It suffices to show that one can assign two vertices of G(C) to each cycle in CC without duplication; thus each vertex of G(C) is assigned to at most one cycle in CC . We decide the assignment in the top-down order on the tree TC as follows. We first assign any two leg-vertices of C to C. For each child-cycle Ci of C we next assign two of Ci ’s three leg-vertices to Ci . Since the child-cycles of C are independent of each other by Lemma 1, no two child-cycles of C share any vertex. Cycles C and Ci share at most one common leg-vertex; otherwise, Ci would have at least four legs. The common leg-vertex may have been assigned to C. However, since Ci has three distinct leg-vertices, Ci has at least two leg vertices which have not been assigned yet. Thus we can assign these two legvertices to Ci . In a similar fashion, for each child-cycle Cj of a child-cycle of C, we can assign two of Cj ’s leg-vertices to Cj , and so on. Clearly the assignment above can be done without duplication. 2 Lemma 3 Let C be a 3-legged cycle in a 3-connected cubic plane graph G. Then the genealogical tree TC can be found in linear time. Proof: We outline an algorithm to find all 3-legged cycles in CC and construct TC in linear time. We first traverse the contour of each inner face of G(C)
C
1
C2
C9 C8
C4
C5 C7
C6
C3
C Figure 3: Illustration for the proof of Lemma 3. containing an outer edge of G(C) as illustrated in Fig. 3, where the traversed contours of faces are indicated by dotted lines. Clearly each outer edge of G(C) is traversed exactly once, and each inner edge of G(C) is traversed at most twice. The inner edges of G(C) traversed exactly once form cycles, called singly traced
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
37
cycles, the insides of which have not been traversed. In Fig. 3 C4 , C8 and C9 are singly traced cycles, the insides of which are shaded. During this traversal one can easily find all 3-legged cycles in CC that share edges with C; C1 , C2 and C3 drawn in thick lines in Fig. 3 are these cycles. (Note that a 3-legged cycle in CC sharing edges with C has two legs on C and the other leg is either an inner edge which is traversed twice or a leg of C. Using edge-labellings similar to one in [8, pp. 215-216], one can find such a 3-legged cycle.) Any of the remaining 3-legged cycles in CC either is a singly traced cycle or is located inside a singly traced cycle. One can find all 3-legged cycles inside a singly traced cycle by recursively applying the method to the singly traced cycle. In Fig. 3 cycle C4 ∈ CC is a singly traced 3-legged cycle, cycles C6 , C7 ∈ CC are inside C4 , cycle C5 ∈ CC is inside C8 , and there is no 3-legged cycle inside C9 . One can also determine the containment relation of the cycles in CC while finding them. Since the algorithm traverses the contour of each inner face of G(C) exactly once, each edge of G(C) is traversed at most twice. Thus the algorithm takes linear time. 2 An orthogonal drawing of a plane graph G is a drawing of G in which each edge is drawn as a sequence of alternate horizontal and vertical line segments, and any two edges do not cross except at their common end. A bend is defined to be a point where an edge changes its direction in a drawing. We denote by b(G) the minimum number of bends needed for an orthogonal drawing of G. A rectangular drawing of a plane graph G is a drawing of G such that each edge is drawn as a horizontal or vertical line segment, and each face is drawn as a rectangle. Thus a rectangular drawing is an orthogonal drawing in which there is no bend and each face is drawn as a rectangle. The drawing of G00 in Fig. 1(e) is a rectangular drawing. The drawing of G0 in Fig. 1(f) is not a rectangular drawing, but is an orthogonal drawing. The following result on rectangular drawings is known. Lemma 4 Let G be a connected plane graph such that all vertices have degree three except four vertices of degree two on Co (G). Then G has a rectangular drawing if and only if G has none of the following three types of simple cycles [12]: (r1) 1-legged cycles; (r2) 2-legged cycles which contain at most one vertex of degree two; and (r3) 3-legged cycles which contain no vertex of degree two. Furthermore one can check in linear time whether G satisfies the condition above, and if G does then one can find a rectangular drawing of G in linear time [8]. In a rectangular drawing of G, the four vertices of degree two are the four corners of the rectangle corresponding to Co (G). A cycle of type (r1), (r2) or
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
38
vertex of degree two vertex of degree three
C
3
C 5 C7 C1
C2
C4 C6
(a) 1-legged cycle
(b) 2-legged cycles
(c) 3-legged cycles
Figure 4: Bad cycles C1 , C2 , C3 and C5 , and non-bad cycles C4 , C6 and C7 . (r3) is called a bad cycle. Figs. 4(a), (b) and (c) illustrate 1-legged, 2-legged and 3-legged cycles, respectively. Cycles C1 , C2 , C3 and C5 are bad cycles. On the other hand, cycles C4 , C6 and C7 are not bad cycles; C4 is a 2-legged cycle but contains two vertices of degree two, and C6 and C7 are 3-legged cycles but contain one or two vertices of degree two. Linear-time algorithms to find a rectangular drawing of a plane graph satisfying the condition in Lemma 4 have been obtained [6, 8]. Our orthogonal drawing algorithm uses the algorithm in [8], which we call Rectangular-Draw in this paper.
3
Orthogonal Drawing
In this section we give a linear-time algorithm to find an orthogonal drawing of a 3-connected cubic plane graph G with at most b(G) + 4 bends. Thus there are at most four extra bends in a drawing produced by the algorithm. Let G be a 3-connected cubic plane graph. Since G is 3-connected, G has no 1- or 2-legged cycle. Every cycle C of G has at least four convex corners, i.e., polygonal vertices of inner angle 90◦ , in any orthogonal drawing of G. Since G is cubic, such a corner must be a bend if it is not a leg-vertex of C. Thus we have the following facts for any orthogonal drawing of G. Fact 5 At least four bends must appear on Co (G). Fact 6 At least one bend must appear on each 3-legged cycle in G.
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
39
An outline of our algorithm is as follows. Let G0 be a graph obtained from G by adding four dummy vertices a, b, c and d of degree two on Co (G) as follows. If there are four or more edges on Co (G), then add four dummy vertices on any four distinct edges on Co (G), one for each. If there are exactly three edges on Co (G), then add two dummy vertices on any two distinct edges on Co and two dummy vertices on the remaining edge. If the resulting graph G0 has no bad cycle, then by Lemma 4 G0 has a rectangular drawing, in which the four dummy vertices become the corners of the rectangle corresponding to Co (G0 ). From the rectangular drawing of G0 one can immediately obtain an orthogonal drawing of G with exactly four bends by replacing the four dummy vertices with bends at the corners. By Fact 5 the orthogonal drawing of G has the minimum number of bends. Thus we may assume that G0 has a bad cycle. Since G has no 1- or 2-legged cycle, every bad cycle in G0 is a 3-legged cycle containing no dummy vertex of degree two like C5 in Fig. 4(c). A bad cycle C in G0 is defined to be maximal if C is not contained in G0 (C 0 ) for any other bad cycle C 0 in G0 . In Fig. 5(a) C1 , C2 , · · · , C6 are the bad cycles, C1 , C2 , · · · , C4 are the maximal bad cycles in G0 , and C5 and C6 are not maximal bad cycles since they are contained in G0 (C4 ). The 3-legged cycle C7 indicated by a dotted line in Fig. 5(a) is not a bad cycle in G0 since it contains a dummy vertex a. Since G is a 3-connected cubic plane graph, all maximal bad cycles in G0 are independent of each other similarly as in Lemma 1. Let C1 , C2 , · · · , Cl be the maximal bad cycles in G0 . (In Fig. 1(c) l = 2, and in Fig. 5(a) l = 4.) Let G00 be the graph obtained from G0 by contracting G0 (Ci ) into a single vertex vi for each maximal bad cycle Ci , 1 ≤ i ≤ l, as illustrated in Figs. 1(d) and 5(b). Clearly G00 has no bad cycle. We find a rectangular drawing of G00 , and recursively find a “suitable” orthogonal drawing of G0 (Ci ), 1 ≤ i ≤ l, with the minimum number of bends, defined later and called a feasible drawing, and finally patch them to get an orthogonal drawing of G. (See Figs. 1, 5 and 12.) We define the following terms for each 3-legged cycle C in G in a recursive manner based on its genealogical tree TC . Each 3-legged cycle C in G is divided into three paths P1 , P2 and P3 by the three leg-vertices x, y and z of C as illustrated in Fig. 6. These three paths P1 , P2 and P3 are called the contour paths of C. Each contour path of C is classified as either a green path or a red path. In addition, we assign an integer bc(C), called the bend-count of C, to each 3-legged cycle C in G. We will show later that G(C) has an orthogonal drawing with bc(C) bends and has no orthogonal drawing with fewer than bc(C) bends, that is b(G(C)) = bc(C). Furthermore we will show that, for any green path of C, G(C) has an orthogonal drawing with bc(C) bends including a bend on the green path. On the other hand, for any red path of C, G(C) does not have any orthogonal drawing with bc(C) bends including a bend on the red path. We define the bc(C), red paths and green paths in a recursive manner on the genealogical tree TC , as follows. Let C be a 3-legged cycle in G, and let C1 , C2 , · · · , Cl in CC be the child-
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
40
v2 a
C2
a b
C1
b v1
C7 C3 C5
v3
v4
C6
C4
d
d c
dummy vertex
c
(a) G
(b) G
original vertex contracted vertex
Figure 5: G0 and G00 . cycles of C. Assume that we have already defined the classification and the assignment for all child-cycles of C and are going to define them for C. There are three cases. Case 1: C has no child-cycle, that is, l = 0, and hence TC consists of a single vertex (see Fig. 6(a)). In this case, we classify all the three contour paths of C as green paths, and set bc(C) = 1.
(1)
(By Fact 6 we need at least one bend on C. In Fig. 6(a) green paths of C are indicated by dotted lines.) Case 2: None of the child-cycles of C has a green path on C. In this case, we classify all the three contour paths of C as green paths, and set bc(C) = 1 +
l X
bc(Ci ).
(2)
i=1
(In Fig. 6(b) the child-cycles of C are C1 , C2 , · · · , C5 , and all green paths of them, drawn by thick lines, do not lie on C. Since none of C1 , C2 , · · · , Cl and their descendant 3-legged cycles has a green path on C as known later, the orthogonal drawings of G(C1 ), G(C2 ), · · · , G(Cl) with the minimum number of
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
41
y1 P1
y
P1
C5
C1
P1 P2
x z
C4
C3
C2 P3
y
y
z1
P2
x
C4
C3
C2
P2
x
C
z P3
(a) Case 1
C5
C1
x1
z P
3
C
C
(c) Case 3
(b) Case 2 Figure 6: Green paths.
bends have no bend on C and hence we need to introduce a new bend on C in an orthogonal drawing of G(C). In Fig. 6(b) the three green paths of C are indicated by dotted lines.) Case 3: Otherwise (see Fig. 6(c)). In this case at least one of the child-cycles C1 , C2, · · · , Cl , for example C1 , C4 and C5 in Fig. 6(c), has a green path on C. Classify a contour path Pi , 1 ≤ i ≤ 3, of C as a green path if a child-cycle of C has its green path on Pi . Otherwise, classify Pi as a red path. Thus at least one of P1 , P2 and P3 is a green path. We set bc(C) =
l X
bc(Ci ).
(3)
i=1
(In Fig. 6(c) P1 and P2 are green paths but P3 is a red path. For a child-cycle Cj having a green path on C, G(Cj ) has an orthogonal drawing with bc(Cj ) bends including a bend on the green path, and hence we need not to introduce any new bend on C.) We have the following lemmas. Lemma 7 At least one of the three contour paths of every 3-legged cycle in G is a green path under the classification above. Proof: Immediate.
2
Lemma 8 Let C be a 3-legged cycle in G. Then the classification and assignment for all descendant cycles of C can be done in linear time, that is, in time O(n(G(C))), where n(G(C)) is the number of vertices in G(C). Proof: By Lemma 3 TC can be found in linear time. Using TC , the classification and assignment for all descendant cycles of C can be done in linear time. 2
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
42
Lemma 9 Let C be a 3-legged cycle in G, then G(C) has at least bc(C) vertexdisjoint 3-legged cycles of G which do not contain any edge on red paths of C. Proof: We will prove the claim by induction based on TC . We first assume that C has no child-cycle. According to the classification and assignment, all the three contour paths of C are green paths, and bc(C) = 1. Clearly G(C) has a 3-legged cycle C of G which does not contain any edge on red paths of C. Thus the claim holds for C. We next assume that C has at least one child-cycle, and suppose inductively that the claim holds for any descendant 3-legged cycle of C. Let C1 , C2 , · · · , Cl be the child-cycles of C, then the hypothesis implies that, for each Ci , 1 ≤ i ≤ l, G(Ci ) has at least bc(Ci ) vertex-disjoint 3-legged cycles of G which do not contain any edge on red paths of Ci . There are the following two cases to consider. Case 1: None of the child-cycles of C has a green path on C (see Fig. 6(b)). In this case, all the three contour paths of C are green, and bc(C) = 1 + Pl i=1 bc(Ci ) by (2). For each i, 1 ≤ i ≤ l, a child-cycle Ci of C has no green path on C, and hence all Ci ’s contour paths on C are red. By the induction hypothesis G(Ci ) has bc(Ci ) vertex-disjoint 3-legged cycles which do not contain any edge on red paths of Ci . Therefore, these bc(Ci ) cycles do not contain any edge on C. Furthermore by Lemma 1 the child-cycles C1 , C2 , · · · , Cl of C are Pl independent of each other. Therefore G(C) has i=1 bc(Ci ) vertex-disjoint 3legged cycles Pl of G which do not contain any edge on C. Since G is cubic, C and these i=1 bc(Ci ) 3-legged cycles are vertex-disjoint. Trivially C does not contain any edge on red paths of C since Pl all the contour paths of C are green. Thus G(C) has at least bc(C) = 1 + i=1 bc(Ci ) vertex-disjoint 3-legged cycles of G which do not contain any edge on red paths of C. Case 2: At least one of the child-cycles of C has a green path on C (see Fig. 6(c)). Pl In this case, bc(C) = i=1 bc(Ci ) by (3). By the induction hypothesis each cycle Ci , 1 ≤ i ≤ l, has bc(Ci ) vertex-disjoint 3-legged cycles which do not child-cycles contain any edge on red paths of Ci . Furthermore by Lemma 1 the P l Ci , 1 ≤ i ≤ l, are independent of each other. Therefore G(C) has i=1 bc(Ci ) vertex-disjoint 3-legged which do not contain any edge on red paths of any Pcycles l child-cycle Ci . These i=1 bc(Ci ) cycles may contain edges on green paths of Ci , by the classification but any green path of Ci is not contained in a red path of C P l of contour paths. Therefore, G(C) has at least bc(C) = i=1 bc(Ci ) vertexdisjoint 3-legged cycles which do not contain any edge on red paths of C. 2 Lemma 10 Every 3-legged cycle C of G satisfies b(G(C)) ≥ bc(C). Proof: By Fact 6 at least one bend must appear on each of the 3-legged cycles. By Lemma 9 G(C) has at least bc(C) vertex-disjoint 3-legged cycles. Therefore any orthogonal drawing of G(C) has at least bc(C) bends, that is, b(G(C)) ≥ bc(C). 2
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
43
Conversely proving b(G(C)) ≤ bc(C), we have b(G(C)) = bc(C) for any 3legged cycle C in G. Indeed we will prove a stronger claim later in Lemmas 11 and 12 after introducing the following definition. Let x, y and z be the three leg-vertices of C in G. One may assume that x, y and z appear on C in clockwise order. For a green path P with ends x and y on C, an orthogonal drawing of G(C) is defined to be feasible for P if the drawing satisfies the following properties (p1)–(p3): (p1) The drawing of G(C) has exactly bc(C) bends. (p2) At least one bend appears on the green path P . (p3) The drawing of G(C) intersects none of the the following six open halflines. • the vertical open halfline with the upper end at x. • the horizontal open halfline with the right end at x. • the vertical open halfline with the lower end at y. • the horizontal open halfline with the left end at y. • the vertical open halfline with the upper end at z. • the horizontal open halfline with the left end at z. The property (p3) implies that, in the drawing of G(C), any vertex of G(C) except x, y and z is located in none of the following three areas (shaded in Fig. 7): the third quadrant with the origin x, the first quadrant with the origin y, and the fourth quadrant with the origin z. It should be noted that each leg of C must start with a line segment on one of the six open halflines above if an orthogonal drawing of G is extended from an orthogonal drawing of G(C) feasible for P . Fig. 7 illustrates an orthogonal drawing feasible for a green path P . We will often call an orthogonal drawing of G(C) feasible for a green path of C simply a feasible orthogonal drawing of G(C). Lemma 11 For any 3-legged cycle C of G and any green path P of C, G(C) has an orthogonal drawing feasible for P . Proof: We give a recursive algorithm to find an orthogonal drawing of G(C) feasible for P , as follows. There are three cases to consider. Case 1: C has no child-cycle (see Fig. 6(a)). In this case bc(C) = 1 by (1). We insert, as a bend, a dummy vertex t of degree two on an arbitrary edge on the green path P in graph G(C), and let F be the resulting graph. Then every vertex of F has degree three except four vertices of degree two: the three leg-vertices x, y and z, and the dummy vertex t. Since C has no child-cycle, trivially F has no bad cycle. Therefore by Algorithm Rectangular-Draw in [8] one can find a rectangular drawing
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
44
y y
P
z x
z x
bend on P 3-legged cycle C the six halflines in property (p3)
Figure 7: An example of a feasible drawing. of F with four corners on x, y, z and t. The drawing of F immediately yields an orthogonal drawing of G(C) having exactly one bend at t, in which C is a rectangle. Thus the drawing satisfies (p1)–(p3), and hence is feasible for P . Case 2: None of the child-cycles of C has a green path on C (see Fig. 6(b)). Let C1 , C2 , · · · , Cl be the child-cycles of C, where l ≥ 1. First, for each i, 1 ≤ i ≤ l, we choose an arbitrary green path of Ci , and find an orthogonal drawing D(G(Ci )) of G(Ci ) feasible for the green path in a recursive manner. Next, we construct a plane graph F from G(C) by contracting each G(Ci ), 1 ≤ i ≤ l, to a single vertex vi . Fig. 8(a) illustrates F for the graph G(C) in Fig. 6(b) where the green path P is assumed to be P1 . One or more edges on P are contained in none of Ci , 1 ≤ i ≤ l, and hence these edges remain in F . Add a dummy vertex t on any of these edges of P as shown in Fig. 8(b), and let H be the resulting plane graph. All vertices of H have degree three except the four vertices x, y, z and t on Co (H) of degree two, and H has no bad cycle. Therefore, by Rectangular-Draw, we can find a rectangular drawing D(H) of H with four corners on x, y, z and t. D(H) immediately yields an orthogonal drawing of F with exactly one bend at t. Fig. 8(c) illustrates a rectangular drawing of H for C and P = P1 in Fig. 6(b). Finally, as explained below, patching the drawings D(G(C1 )), D(G(C2 )), · · · , D(G(Cl )) into D(H), we can construct an orthogonal drawing of G(C) with P bc(C) = 1 + li=1 bc(Ci ) bends (see Fig. 8). As illustrated in Fig. 9(b), there are twelve distinct embeddings of a contracted vertex vi and the three legs incident
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999) v1
v5
v1 P1
v5
P1
y
45
y
t
v3
v3
v4
v4 x
x
v2
v2
(b) H
(a) F v5
v1
t
z
z
t
y
y
C1
C5
C3
v4
C4
v3 C2 x
x
z
z
v2 (c) D(H)
contracted vertex
(d) D(G(C))
original vertex dummy vertex bend
Figure 8: F , H, D(H) and D(G(C)) for Case 2. to vi , depending on both the directions of the three legs and the chosen green path of Ci , where the ends of the path are denoted by x and y. For each of the twelve cases, we can replace a contracted vertex vi with an orthogonal drawing of G(Ci ) feasible for the green path or a rotated one shown in Fig. 9(c), where the drawing of G(Ci ) is depicted as a rectangle for simplicity. For example, the embedding of the contracted vertex v1 with three legs in Fig. 8(c) is the same as the middle one of the leftmost column in Fig. 9(b) (notice the green path of C1 drawn in a thick line in Fig. 6(b)); and hence v1 in D(H) is replaced by D(G(C1 )), the middle one of the leftmost column in Fig. 9(c). Clearly t is a bend on P , and C is a rectangle in the drawing of G(C). Thus the drawing is feasible for P . We call the replacement above a patching operation.1 Case 3: Otherwise (see Fig. 6(c)). Let C1 , C2, · · · , Cl be the child-cycles of C, where l ≥ 1. In this case, for 1A
replacement operation similar to our patching operation is used in [5].
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
46
y
z x
(a) x
y x
z
z
z
x
x
y
x
z
y
y
z y
y
y
x
x
z
x y
z
z
y z
z
z
x
x
y
y
y
z x
x
(b) x
x
y
y
y
y x
z
z
x
z
z
x z
x z y
z
x
y
y y
z
y x
x
y
z
y z
x
(c)
z
z
y
x x
Figure 9: (a) A 3-legged cycle, (b) twelve embeddings of a vertex vi and three legs incident to vi , and (c) twelve feasible orthogonal drawings of G(Ci ) and rotated ones.
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
47
any green path P on C, at least one of C1 , C2 , · · · , Cl has a green path on P . One may assume without loss of generality that C1 has a green path Q on the green path P of C, that the three leg-vertices x1 , y1 and z1 of C1 appear on C1 clockwise in this order, and that x1 and y1 are the ends of Q as illustrated in Fig. 6(c). We first construct a plane graph F from G(C) by contracting each G(Ci ), 1 ≤ i ≤ l, to a single vertex vi . Fig. 10(a) illustrates F for G(C) in Fig. 6(c). Replace v1 in F with a quadrangle x1 ty1 z1 as shown in Fig. 10(b) where t is a dummy vertex of degree two, and let H be the resulting plane graph. Thus all vertices of H have degree three except four vertices on Co (H) of degree two: the dummy vertex t and the three leg-vertices x, y and z of C. Furthermore H has no bad cycle. Therefore, by Rectangular-Draw, we can find a rectangular drawing D(H) of H with four corners on t, x, y and z, in which the contour x1 ty1 z1 of a face is drawn as a rectangle. Fig. 10(c) illustrates a rectangular drawing of H for G(C) in Fig. 6(c). We next find feasible orthogonal drawings D(G(C1 )), D(G(C2 )), · · ·, D(G(Cl )) in a recursive manner; D(G(C1 )) is feasible for the green path Q, and D(G(Ci )) is feasible for an arbitrary green path of Ci for each i, 2 ≤ i ≤ l. Finally, patching the drawings D(G(C1 )), D(G(C2 )), · · · , D(G(Cl )) into D(H), we can construct an orthogonal drawing D(G(C)) of G(C) feasible for P ; we replace the rectangle x1 ty1 z1 of D(H) by D(G(C1 )), and replace each vertex vi , 2 ≤ i ≤ l, by D(G(Ci )). In this case C is not always a rectangle in D(G(C)). One can observe with the help of Fig. 9 that each of the replacement above can be done without introducing any new bend or edge-crossing and without any conflict of coordinates of vertices as illustrated in Fig. 10. Note that the resulting drawing always expands outwards, satisfying the property (p3). Since we replace the rectangle x1 ty1 z1 in D(H) by D(G(C1 )) and we have already counted the bend corresponding to t for C1 , we need not count it for Pl C. Thus one can observe that the drawing D(G(C)) has exactly bc(C) = i=1 bc(Ci ) bends. Since a bend of D(G(C1 )) appears on Q, the bend appears on the green path P of C in D(G(C)). Hence D(G(C)) is an orthogonal drawing feasible for P. 2 The definition of a feasible orthogonal drawing and Lemmas 10 and 11 immediately imply the following Lemma 12. Lemma 12 For any 3-legged cycle C in G, b(G(C)) = bc(C), and a feasible orthogonal drawing of G(C) has the minimum number b(G(C)) of bends. The algorithm for finding a feasible orthogonal drawing of G(C) described in the proof of Lemma 11 above is hereafter called Feasible-Draw. We have the following lemma on Feasible-Draw. Lemma 13 Algorithm Feasible-Draw finds a feasible orthogonal drawing of G(C) for a 3-legged cycle C in linear time, that is, in time O(n(G(C))).
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
v1 x1
v5
y1
y1
t
z1
v5
x1
y
y
P1
P1
z1 v3
v3
48
v
v
4
4
x
x v2
v2
z
z
(b) H
(a) F t
v5
y1
Q
y
y1
C5
y
C1 z1
x1
z1
x1
C4 v
4
v3
C3
x
x v2
C2 z
z
(c) D(H)
contracted vertex original vertex dummy vertex bend
(d) D(G(C))
Figure 10: F , H, D(H) and D(G(C)) for Case 3. Proof: Denote by TRG (G) the computation time of Rectangular-Draw(G). Since TRG (G) = O(n) [8], there is a constant c such that TRG (G)
≤
c · m(G)
(4)
for any connected plane graph G. By Lemma 3 one can find the genealogical tree TC of C in linear time. By Lemma 8 one can classify the three contour paths as green or red paths for all cycles in CC in linear time. We first consider the time needed for contraction and patching operations. During the traversal of all inner faces of G(C) for constructing TC , we can find the three leg-vertices for each cycle in CC . Given the three leg-vertices of a 3-legged cycle, we can contract the 3-legged cycle to a vertex in constant time. Since |CC | ≤ n(G(C))/2 by Lemma 2, the contraction operations in FeasibleDraw take O(n(G(C))) time in total. Similarly the patching operations in Feasible-Draw take O(n(G(C))) time in total.
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
49
We then consider the time needed for operations other than the contractions and patchings. Denote by T (G(C)) the time needed for Feasible-Draw(G(C)) excluding the time for the contractions and patchings. We claim that T (G(C)) = O(n(G(C))). The number m(G(C)) of edges in a plane graph G(C) satisfies m(G(C)) ≤ 3n(G(C)). Furthermore |CC | ≤ n(G(C))/2 by Lemma 2. Therefore it suffices to prove that T (G(C)) ≤
c · m(G(C)) + 4 · c · |CC |.
(5)
We prove (5) by induction based on TC . First consider the case where C has no child-cycle. Then |CC | = 1. In this case Feasible-Draw adds a dummy vertex on C to obtain a graph F from G(C). Therefore m(F ) = m(G(C)) + 1. Feasible-Draw finds a rectangular drawing of F by Rectangular-Draw. Hence, by (4) we have T (G(C)) = TRG (F ) ≤ c · m(F ). Thus T (G(C)) ≤ c · m(G(C)) + 4 · c · |CC |, as desired. Next consider the case where C has child-cycles C1 , C2 , · · · , Cl where l ≥ 1. Suppose inductively that (5) holds for each Ci , 1 ≤ i ≤ l: T (G(Ci ))
≤
c · m(G(Ci )) + 4 · c · |CCi |.
(6)
Algorithm Feasible-Draw constructs a plane graph F from G(C) by contracting each G(Ci ), 1 ≤ i ≤ l, to a single vertex, and then constructs a graph H from F by either adding a dummy vertex on Co (F ) or replacing exactly one contracted vertex on Co (F ) by a quadrangle as illustrated in Figs. 8 and 10. Therefore one can observe that m(H) +
l X
m(G(Ci )) ≤
m(G(C)) + 4.
(7)
i=1
Algorithm Feasible-Draw recursively finds drawings of G(Ci ), 1 ≤ i ≤ l, and patches them into a rectangular drawing D(H) of H found by RectangularDraw. Therefore we have T (G(C))
= TRG (H) +
l X
T (G(Ci )).
(8)
i=1
By (4) we have TRG (H)
≤
c · m(H).
Using (6), (7), (8) and (9), we have T (G(C)) ≤
c · m(H) +
l X i=1
(c · m(G(Ci )) + 4 · c · |CCi |)
(9)
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
=
c · (m(H) +
l X
m(G(Ci ))) + 4 · c ·
i=1
≤
l X
50
|CCi |
i=1
c · (m(G(C)) + 4) + 4 · c ·
l X
|CCi |.
(10)
i=1 l
Since CC = {C} ∪ ( ∪ CCi ), we have i=1
|CC | =
1+
l X
|CCi |.
(11)
i=1
By using (10) and (11), we have T (G(C)) ≤ c · (m(G(C)) + 4) + 4 · c · (|CC | − 1) = c · m(G(C)) + 4 · c · |CC |. 2 We are now ready to present our algorithm for orthogonal drawings of G, which is shown in Fig. 11.
1
2 3 4 5 6 7 8
Algorithm Orthogonal-Draw(G) begin add four dummy vertices of degree two on Co (G); {if Co (G) has four or more edges, then add four dummy vertices on four distinct edges, otherwise, add two dummy vertices on two distinct edges and two dummy vertices on the remaining edge.} let G0 be the resulting graph; let C1 , C2, · · · , Cl be the maximal bad cycles in G0 ; for each i, 1 ≤ i ≤ l, construct genealogical trees TCi and determine green paths and red paths for every cycle in TCi ; for each i, 1 ≤ i ≤ l, find an orthogonal drawing D(G(Ci )) of G(Ci ) feasible for an arbitrary green path of Ci by Feasible-Draw; let G00 be a plane graph derived from G0 by contracting each G(Ci ), 1 ≤ i ≤ l, to a single vertex vi ; {G00 has no bad cycle.} find a rectangular drawing D(G00 ) of G00 by Rectangular-Draw; patch the drawings D(G(C1 )), D(G(C2 )), · · · , D(G(Cl )) into D(G00 ) to get an orthogonal drawing of G end. Figure 11: Algorithm Orthogonal-Draw.
Fig. 12(a) illustrates a rectangular drawing of G00 in Fig. 5(b). The specified green path of each of the maximal bad cycles C1 , C2 , C3 and C4 of G0 is drawn
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
51
by a thick line in Fig. 5(a). Fig. 12(b) illustrates a final orthogonal drawing of G0 in Fig. 5(a). b v2
a
b
C2
a
v1
C1 v
C3
3
C4 v4 c
d
(a)
d
c
(b)
Figure 12: (a) A rectangular drawing of G00 and (b) an orthogonal drawing of G0 . We now have the following theorem. Theorem 1 Let G be a 3-connected cubic plane graph, let G0 be the graph obtained from G by adding four dummy vertices in Algorithm Orthogonal-Draw, . Then and let C1 , C2 , · · · , Cl be the maximal bad cycles in G0P l Orthogonal-Draw finds an orthogonal drawing of G with exactly 4+ i=1 bc(Ci ) Pl bends in linear time. Furthermore, we have 4 + i=1 bc(Ci ) ≤ 4 + b(G). Proof: (a) Number of bends. There are two cases. Case 1: G0 has no bad cycle. In this case we have a drawing with exactly four bends. By Fact 5 it is a drawing with the minimum number of bends. Case 2: Otherwise. Let C1 , C2 , · · · , Cl be the maximal bad cycles in G0 . For each i, 1 ≤ i ≤ l, an orthogonal drawing D(G(Ci )) feasible for an arbitrary green path of Ci has exactly bc(Ci ) bends. Furthermore the rectangular drawing D(G00 ) has exactly four bends corresponding to the four dummy vertices. Algorithm OrthogonalDrawing patches the drawings D(G(C1 )), D(G(C2 )), · · · , D(G(Cl )) into D(G00 ) to get an orthogonalP drawing of G. Therefore we have an orthogonal drawing of l G with exactly 4 + i=1 bc(Ci ) bends. Since the 3-legged cycles C1 , C2 , · · · , Cl Pl are independent of each other, by Lemma 9 G has at least i=1 bc(Ci ) vertex-
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
52
Pl disjoint 3-legged cycles. Therefore Fact 6 implies that i=1 bc(Ci ) ≤ b(G). Pl Thus 4 + i=1 bc(Ci ) ≤ 4 + b(G). (b) Time complexity. By a method similar to one in the proof of Lemma 3 we can find all maximal bad cycles in G0 in linear time. Orthogonal-Draw calls Rectangular-Draw for G00 and Feasible-Draw for G(Ci ), 1 ≤ i ≤ l. Both Rectangular-Draw and Feasible-Draw run Pl in linear time. Since cycles Ci , 1 ≤ i ≤ l, are independent of each other, i=1 n(G(Ci )) ≤ n. Therefore the total time needed by Feasible-Draw is O(n). Furthermore all contraction operations and all patching operations can be done in time O(n) in total. Therefore Orthogonal-Draw runs in linear time. 2
4
Bend Minimization
Algorithm Orthogonal-Draw in the preceding section finds an orthogonal drawing of a 3-connected cubic plane graph G with at most b(G) + 4 bends. In this section, by modifying Orthogonal-Draw, we obtain a linear-time algorithm Minimum-Bend to find an orthogonal drawing of G with the minimum number b(G) of bends. Our idea behind Minimum-Bend is as follows. If a 3-legged cycle in G has a green path on Co (G), then we can save one of the four bends mentioned in Fact 5, because a bend on the green path can be a bend on Co (G) and a bend on the 3-legged cycle at the same time; hence one of the four bends mentioned in Fact 5 has been accounted for by the bends necessitated by Fact 6. We therefore want to find as many such 3-legged cycles as possible, up to a total number of four. We had better to find a 3-legged cycle which has a green path on Co (G) but none of whose child-cycles has a green path on Co (G), because a bend on such a cycle can play also a role of a bend on its ancestor cycle. We call such a cycle a “corner cycle”, that is, a corner cycle is a 3-legged cycle C in G such that C has a green path on Co (G) but no childcycle of C has a green path on Co (G). (In Fig. 14(a) C10 and C20 drawn in thick lines are corner cycles. On the other hand, the two 3-legged cycles indicated by dotted lines are not corner cycles since C10 is their descendant cycle.) If G has k(≤ 4) independent corner cycles C10 , C20 , · · · , Ck0 , then we can save k bends. By a method similar to one given in the proof of Lemma 3 one can find independent corner cycles of G as many as possible in linear time. We are now ready to give the algorithm Minimum-Bend to find an orthogonal drawing with the minimum number of bends, which is shown in Fig. 13. We have the following lemma. Lemma 14 Let Ci0 be a corner cycle of a 3-connected cubic plane graph G. Then none of the child-cycles of Ci0 has a green path on Ci0 , and all contour paths of Ci0 are green. (See Fig. 15 where Ci0 is indicated by a dotted line.)
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
1 2 3 4
5
6
7 8
9
10
53
Algorithm Minimum-Bend(G) begin find as many independent corner cycles C10 , C20 , · · · , Ck0 of G as possible, up to a total number of four; {k ≤ 4. In Fig. 14(a) k = 2.} 0 let Pi1 , 1 ≤ i ≤ k, be the green path of Ci0 on Co (G); 0 let xi , yi0 and zi0 be the leg-vertices of Ci0 , and let x0i and yi0 be the 0 ; ends of Pi1 replace each subgraph G(Ci0 ), 1 ≤ i ≤ k, in G with a quadrangle x0i t0i yi0 zi0 where t0i is a dummy vertex of degree two, and let G∗ be the resulting graph; {See Figs. 14(a) and (b).} add 4 − k dummy vertices t1 , t2 , · · · , t4−k on edges of Co (G∗ ) so that these vertices are adjacent to none of t01 , t02 , · · · , t0k as in step 1 of Orthogonal-Draw, and let G0 be the resulting graph; {See Fig. 14(c).} let C1 , C2, · · · , Cl be the maximal bad cycles in G0 with respect to the four dummy vertices t01 , t02 · · · , t0k and t1 , t2 · · · , t4−k of degree two; {In Fig. 14(c) l = 2, and the insides of the two maximal bad cycles C1 and C2 are shaded.} let G00 be a plane graph derived from G0 by contracting each G(Ci ), 1 ≤ i ≤ l, to a single vertex vi ; {G00 has no bad cycle. See Fig. 14(d).} find a rectangular drawing D(G00 ) of G00 by Rectangular-Draw; {The drawing of Co (G00 ) in D(G00 ) has exactly four corners t01 , t02 · · · , t0k and t1 , t2 · · · , t4−k , and the quadrangle x0i t0i yi0 zi0 is drawn as a rectangle for each i, 1 ≤ i ≤ k, in D(G00 ). See Fig. 14(e).} 0 find an orthogonal drawing D(G(Ci0 )) of G(Ci0 ) feasible for Pi1 for each i, 1 ≤ i ≤ k, and find an orthogonal drawing D(G(Ci )) of G(Ci ) feasible for an arbitrary green path of Ci for each i, 1 ≤ i ≤ l, by Feasible-Draw; { See Fig. 14(f).} patch the drawings D(G(C10 )), D(G(C20 )), · · · , D(G(Ck0 )) and D(G(C1 )), D(G(C2 )), · · · , D(G(Cl )) into D(G00 ) to get an orthogonal drawing D(G) of G { See Fig. 14(g).} end. Figure 13: Algorithm Minimum-Bend.
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
54
y1 y1
t1
x1
x1
y1
x1
z1 z1
x2 C1
z1
x2
G(C ) 1
x2
t2
C2
z2
y2
y
z2
2
y
z2
2
G(C2 )
dummy vertex
G
(b)
(a) t1 x1
y1
y1
1
x1
z1
z2
y1
t1
z
x1 t1
G*
v1
y1
x2
x2
C1
x1
t1
z2
G(C1 )
t2
t2
C2
z1
z1
z2
y2
z2
y2
v2 x2 y2
x2
y2 t2
t2
G G
(d)
(c) x1
t
G(C ) 2
contracted vertex
t
1
1
x1
t1
x1
y
1
z1 y1
z1 v2
z1 D(G(C1))
v
1
y
2
2
t2
y
D(G )
(e)
z
x1
1
x2 x2
y z2
1
z2
z2
2
1
z2
y
D(G(C1))
y
y 1 y
z1
x1
D(G(C2))
x2
x2 t2
D(G(C2 ))
2
(f)
t2
D(G)
(g)
Figure 14: Illustration for Algorithm Minimum-Bend.
z2 y2
x
2
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
55
0 0 0 , Pi2 and Pi3 be the contour paths of Ci0 . According to the Proof: Let Pi1 0 , is a green path on Co (G), but definition of a corner cycle, one of them, say Pi1 0 none of the child-cycles of Ci has a green path on Co (G). (In Fig. 15 all green 0 is on Co (G), paths of the child-cycles of Ci0 are drawn by thick lines.) Since Pi1 0 0 none of the child-cycles of Ci has a green path on Pi1 . 0 0 or Pi3 . Furthermore none of the child-cycles of Ci0 has a green path on Pi2 0 Otherwise, according to Case 3 of the classification of contour paths, Pi1 would be a red path, a contradiction. Thus none of the child-cycles of Ci0 has a green path on Ci0 . Therefore, according to Case 1 or 2 of the classification of contour paths, all contour paths 0 0 0 , Pi2 and Pi3 of Ci0 are green. 2 Pi1
P i1 Ci xi
yi
Ci j Ci1 Ci3 Ci2
Pi 2
Pi3 zi
G Figure 15: Corner cycle Ci0 , its child-cycles, and their child-cycles. We now have the following theorem. Theorem 2 Algorithm Minimum-Bend produces an orthogonal drawing of a 3-connected cubic plane graph G with the minimum number b(G) of bends in linear time. Furthermore, we have b(G) =
k X i=1
bc(Ci0 ) +
l X i=1
bc(Ci ) + 4 − k,
(12)
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
56
where k, C10 , C20 , · · · , Ck0 and C1 , C2 , · · · , Cl are defined as in algorithm MinimumBend. Proof: (a) Number of bends. We first show that Minimum-Bend(G) produces an orthogonal drawing of Pl Pk G with exactly i=1 bc(Ci0 ) + i=1 bc(Ci ) + 4 − k bends. For each i, 1 ≤ i ≤ k, an orthogonal drawing D(G(Ci0 )) feasible for Pi0 has exactly bc(Ci0 ) bends. Also, for each i, 1 ≤ i ≤ l, an orthogonal drawing D(G(Ci )) feasible for an arbitrary green path of Ci has exactly bc(Ci ) bends. The rectangular drawing D(G00 ) has exactly four dummy vertices t01 , t02 · · · , t0k and t1 , t2 · · · , t4−k of degree two, as illustrated in Fig. 14(e). Algorithm Minimum-Bend patches the drawings D(G(C10 )), D(G(C20 )), · · · , D(G(Ck0 )) and D(G(C1 )), D(G(C2 )), · · · , D(G(Cl )) into D(G00 ) to get an orthogonal drawing of G. The rectangle x0i t0i yi0 zi0 in D(G00 ) is replaced by D(G(Ci0 )) for each i, 1 ≤ i ≤ k as illustrated in Fig. 14(g), and the bend corresponding to t0i in the final drawing has been counted by bc(Ci0 ). Therefore only t1 , t2 , · · · , t4−k among the four dummy vertices in G00 should be counted as bends with Co (G) in the final drawing. Thus the final orthogonal Pl Pk drawing of G has exactly i=1 bc(Ci0 ) + i=1 bc(Ci ) + 4 − k bends. Pl Pk Thus it suffices to show that b(G) ≥ i=1 bc(Ci0 ) + i=1 bc(Ci ) + 4 − k. There are two cases. Case 1: k = 4. Since cycles C10 , C20 , · · · , Ck0 and C1 , C2, · · · , Cl are independent of each other Pl Pk in G, by Lemma 9 G has at least i=1 bc(Ci0 ) + i=1 bc(Ci ) vertex-disjoint 3Pl Pk Pk legged cycles. Thus by Fact 6 b(G) ≥ i=1 bc(Ci0 )+ i=1 bc(Ci ) = i=1 bc(Ci0 )+ Pl i=1 bc(Ci ) + 4 − k. Case 2: k ≤ 3. 0 0 , Ci2 , · · · , Cil0 i be the child-cycles For a corner cycle Ci0 , 1 ≤ i ≤ k, let Ci1 0 0 0 , Pi2 and of Ci in CCi where li ≥ 0. By Lemma 14 all three contour paths Pi1 0 0 0 0 0 Pi3 of Ci are green, and none of Ci1 , Ci2, · · · , Cili has a green path on Ci0 . (In 0 0 , Ci2 , · · · , Cil0 i Fig. 15 Ci0 is indicated by a dotted line, and all green paths of Ci1 are drawn by thick lines.) Therefore, by (1) or (2) we have bc(Ci0 ) = 1 +
li X
0 bc(Cij ).
(13)
j=1 0 0 ), 1 ≤ j ≤ li , has bc(Cij ) vertex-disjoint 3-legged cycles which By Lemma 9 G(Cij 0 . Therefore, if such a cycle contains do not contain any edge on red paths of Cij 0 0 , which is not an edge on Cij , then the edge is necessarily on a green path of Cij 0 0 on Ci . Thus none of these cycles contains any edge on Ci , and hence contains Pli 0 bc(Cij ) = bc(Ci0 ) − 1 any edge on Co (G). Therefore, by (13), G(Ci0 ) has j=1 vertex-disjoint 3-legged cycles which do not contain any edge on Co (G). Since k ≤ 3, none of the maximal bad cycles Ci , 1 ≤ i ≤ l, of G0 has a green path on Co (G); otherwise, such a cycle Ci or its descendant cycle would be a
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
57
corner cycle of G and hence G would have k +1 (≤ 4) independent corner cycles, a contradiction. Therefore only a red path of Ci can be on Co (G). However, by Lemma 9, G(Ci ) has bc(Ci ) vertex-disjoint 3-legged cycles of G which do not contain any edge on red paths of Ci . Hence these bc(Ci ) cycles in G(Ci ) do not contain any edge on Co (G). Pl Pk 0 Thus G has i=1 (bc(Ci ) − 1) + i=1 bc(Ci ) vertex-disjoint 3-legged cycles which do not contain any edge on Co (G) since cycles C10 , C20 , · · · , Ck0 and of each other. Therefore by Fact 6 at least C Pl P1k, C2 , · · · ,0Cl are independent (bc(C ) − 1) + bc(C ) i bends must appear in the proper inside of i i=1 i=1 Co (G). By Fact 5 at least four bends must appear on Co (G). Thus we have Pl Pk Pl Pk b(G) ≥ i=1 (bc(Ci0 )−1)+ i=1 bc(Ci ) +4 = i=1 bc(Ci0 )+ i=1 bc(Ci ) +4 −k. This completes a proof of (12). (b)Time complexity. Similar to (b) in the proof of Theorem 1. 2
5
Grid Drawing
In this section we give our bounds on the grid size for an orthogonal grid drawing corresponding to an orthogonal drawing obtained by the algorithm MinimumBend. An orthogonal drawing is called an orthogonal grid drawing if all vertices and bends are located on integer grid points. Given an orthogonal drawing, one can transform it to an orthogonal grid drawing in linear time [10, 2 (pp. 157– 161)]. Let W be the width of a grid, that is the number of vertical lines in the grid minus one, and let H be the height of a grid. Let n be the number of vertices, and let m be the number of edges in a given graph. It is known that any orthogonal drawing using b bends has a grid drawing on a grid such that W + H ≤ b + 2n − m − 2 [1]. It is also known that any 3-connected cubic plane graph has an orthogonal grid drawing using at most n3 + 3 bends on a grid such that W ≤ n2 and H ≤ n2 [1, 5]. Given a 3-connected cubic plane graph G, one can find in linear time an orthogonal drawing of G with the minimum number b(G) of bends using our algorithm Minimum-Bend, then one can also transform it in linear time to an orthogonal grid drawing with the same number of bends using the algorithm in [10, 2]. The grid size of a produced drawing satisfies W +H ≤ b(G)+2n−m−2 = b(G) + 12 n − 2 [1]. In the rest of this section we will prove that any orthogonal drawing produced by our algorithm Minimum-Bend can be transformed to an orthogonal grid drawing on a grid such that W ≤ n2 and H ≤ n2 . We have the following known result on the grid size of a rectangular grid drawing [8]. Lemma 15 Any rectangular drawing of a plane graph G produced by Algorithm Rectangular-Draw can be transformed to a rectangular grid drawing on a grid
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999) such that W + H ≤
58
n 2.
We now show that the following lemma holds for an orthogonal grid drawing of G(C) for a 3-legged cycle C in G. Lemma 16 Let C be a 3-legged cycle in a 3-connected cubic plane graph G. Then an orthogonal drawing of G(C) produced by Algorithm Feasible-Draw can be transformed to an orthogonal grid drawing on a grid such that W ≤ n(G(C))−1 and H ≤ n(G(C))−1 . 2 2 Proof: We only give a proof for the bound on W since the proof for the bound on H is similar. We prove the bound on W by induction based on TC . First consider the case where C has no child-cycle. In this case FeasibleDraw adds a dummy vertex on C to obtain a graph F from G(C). Therefore n(F ) = n(G(C)) + 1. Feasible-Draw finds a rectangular drawing of F by Rectangular-Draw. By Lemma 15 the rectangular drawing of F can be ) transformed to a rectangular grid drawing on a grid such that W + H ≤ n(F 2 = n(G(C))+1 . The rectangular grid drawing of F immediately gives an orthogonal 2 grid drawing of G(C) on the same grid regarding the dummy vertex as a bend. Therefore the width W and the height H of the grid required for the orthogonal . One can easily observe grid drawing of G(C) satisfies W + H ≤ n(G(C))+1 2 that H ≥ 1 for any orthogonal grid drawing of G(C). Therefore, for a grid required for the orthogonal grid drawing of G(C) corresponding to the orthogonal − 1 = n(G(C))−1 . drawing of G(C) obtained by Feasible-Draw, W ≤ n(G(C))+1 2 2 Next consider the case where C has child-cycles C1 , C2 , · · · , Cl where l ≥ 1. Suppose inductively that the following bound on the width Wi of a grid required for the orthogonal grid drawing of each G(Ci ), 1 ≤ i ≤ l holds: Wi ≤
n(G(Ci )) − 1 . 2
(14)
Algorithm Feasible-Draw constructs a plane graph F from G(C) by contracting each G(Ci ), 1 ≤ i ≤ l, to a single vertex, and then constructs a graph F 0 from F by either adding a dummy vertex on Co (F ) or replacing exactly one contracted vertex on Co (F ) by a quadrangle as illustrated in Figs. 8 and 10 where F 0 = H. Consider the case where F 0 is constructed from F by adding a dummy vertex. In this case n(F 0 ) = n(F ) + 1. Algorithm Feasible-Draw patches orthogonal drawings of G(Ci ), 1 ≤ i ≤ l, into a rectangular drawing D(F 0 ) of F 0 found by Rectangular-Draw. Therefore W ≤ WF 0 +
l X i=1
Wi ,
(15)
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
59
where WF 0 is the width of the grid required for the rectangular grid drawing of n(F 0 ) n(F )+1 , where HF 0 is the height of the F 0 . By Lemma 15 WF 0 + HF 0 ≤ 2 = 2 grid required for the rectangular grid drawing of F 0 . Since F 0 has at least four vertices, HF 0 ≥ 1. Hence WF 0
≤ =
n(F ) + 1 −1 2 n(F ) − 1 . 2
(16)
From (14), (15) and (16) we have W
≤ =
l n(F ) − 1 X n(G(Ci )) − 1 + 2 2 i=1 Pl n(F ) + i=1 (n(G(Ci )) − 1) − 1 . 2
(17)
During the patching operation exactly one contracted vertex is replaced by the orthogonal drawing of each G(Ci ), and hence n(F ) +
l X
(n(G(Ci )) − 1) = n(G(C)).
(18)
i=1
. From (17) and (18) we have W ≤ n(G(C))−1 2 We now consider the case where F 0 is constructed from F by replacing exactly one contracted vertex on Co (F ) by a quadrangle. In this case n(F 0 ) = n(F ) + 3. As in the former case, Algorithm Feasible-Draw patches orthogonal drawings of G(Ci ), 1 ≤ i ≤ l, into a rectangular drawing D(F 0 ) of F 0 found by Rectangular-Draw. During the patching operation one of G(Ci ), 1 ≤ i ≤ l, say G(C1 ), replaces the quadrangle, and each G(Ci ), 2 ≤ i ≤ l replaces exactly one contracted vertex in F 0 . Furthermore, any drawing of a quadrangle on a grid has width at least one. Therefore the following equation holds: W ≤ WF 0 + (W1 − 1) +
l X
Wi ,
(19)
i=2
where WF 0 is the width of the grid required for the rectangular grid drawing of 0 ) = n(F2)+3 , where HF 0 is the height of the F 0 . By Lemma 15 WF 0 + HF 0 ≤ n(F 2 grid required for the rectangular grid drawing of F 0 . Since HF 0 ≥ 1, WF 0 ≤
n(F ) + 1 . 2
(20)
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
60
From (14), (19) and (20) we have, l
W
≤ =
X n(G(Ci )) − 1 n(F ) + 1 n(G(C1 )) − 1 + −1+ 2 2 2 i=2 Pl n(F ) + i=1 (n(G(Ci )) − 1) − 1 . 2
(21)
Clearly n(F ) +
l X
(n(G(Ci )) − 1) = n(G(C)).
(22)
i=1
From (21) and (22) we have W ≤
n(G(C))−1 . 2 ≤ n2 and H
2
≤ n2 for a grid required for an We are now ready to show W orthogonal grid drawing corresponding to an orthogonal drawing of G produced by Minimum-Bend. We here use the same notations used in MinimumBend. By Lemma 15, the rectangular drawing of G00 has a corresponding 00 ) 00 rectangular grid drawing on a grid such that WG00 + HG00 ≤ n(G 2 , where WG and WG00 respectively are the width and the height of the grid. Since G is a 3-connected plane graph, HG00 ≥ 2. Hence n(G00 ) − 2. (23) 2 Algorithm Minimum-Bend patches the orthogonal drawings of G(C10 ), G(C20 ), · · · , G(Ck0 ) and G(C1 ), G(C2), · · · , G(Cl ) into the rectangular drawing of G00 and get an orthogonal drawing of G. During the patching operation, the drawing of each G(Ci0 ), 1 ≤ i ≤ k, replaces the drawing of a quadrangle, and the drawing of each G(Ci ), 1 ≤ i ≤ l, replaces a contracted vertex in G00 . The width of a quadrangle on a grid is at least one. Thus one can observe that the width W of a grid required for an orthogonal grid drawing of G obtained by algorithm Minimum-Bend satisfies the following relation. WG00 ≤
W ≤ WG00 +
k X i=1
(Wi0 − 1) +
l X
Wi ,
(24)
i=1
where Wi0 is the width of the grid required for an orthogonal grid drawing of G(Ci0 ) for 1 ≤ i ≤ k and Wi is the width of the grid required for an orthogonal grid drawing of G(Ci ) for 1 ≤ i ≤ l. Then by Lemma 16, Eqs. (23) and (24) we have W
≤ =
k l X X n(G(Ci0 )) − 1 n(G(Ci )) − 1 n(G00) −2+ − 1) + ( 2 2 2 i=1 i=1 P P k l n(G00) + i=1 (n(G(Ci0 )) − 3) + i=1 (n(G(Ci )) − 1) − 4 . (25) 2
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
61
One can observe that n(G00 ) +
k X
(n(G(Ci0 )) − 3) +
i=1
From (25) and (26) we have W ≤ have the following theorem.
l X
(n(G(Ci )) − 1) − 4 = n.
(26)
i=1 n 2.
Similarly we can prove H ≤
n 2.
Thus we
Theorem 3 Let G be a 3-connected cubic plane graph with n vertices. Any orthogonal drawing of G with the minimum number b(G) of bends produced by Algorithm Minimum-Bend has a corresponding orthogonal grid drawing on a grid with width H and height H such that W + H ≤ b(G) + 12 n − 2, W ≤ n2 and H ≤ n2 .
6
Conclusions
In this paper we have presented a linear-time algorithm to find an orthogonal drawing of a 3-connected cubic plane graph with the minimum number of bends. It is left as future work to find a linear-time algorithm for a larger class of graphs. Acknowledgement: We wish to thank the three anonymous referees for their valuable comments and suggestions for improving the presentation of the paper.
References [1]
T. C. Biedl. Optimal orthogonal drawings of triconnected plane graphs. Proc. of SWAT’96, Lect. Notes in Computer Science, 1097, pp. 333-344, 1996.
[2]
G. Di Battista, P. Eades, R. Tamassia and I. G. Tollis. Graph Drawing: Algorithms for the Visualization of Graphs, Prentice-Hall Inc., Upper Saddle River, New Jersey, 1999.
[3]
A. Garg and R. Tamassia. On the computational complexity of upward and rectilinear planarity testing. Proc. of Graph Drawing’94, Lect. Notes in Computer Science, 894, pp. 286-297, 1995.
[4]
A. Garg and R. Tamassia. A new minimum cost flow algorithm with applications to graph drawing., Proc. of Graph Drawing’96, Lect. Notes in Computer Science, 1190, pp. 201-226, 1997.
[5]
G. Kant. Drawing planar graphs using the canonical ordering., Algorithmica, 16, pp. 4-32, 1996.
M. S. Rahman et al., Orthogonal Drawings, JGAA, 3(4) 31–62 (1999)
62
[6]
G. Kant and X. He. Regular edge labeling of 4-connected plane graphs and its applications in graph drawing problems. Theoretical Computer Science, 172, pp. 175-193, 1997.
[7]
M. S. Rahman, S. Nakano and T. Nishizeki. A linear algorithm for optimal orthogonal drawings of triconnected cubic plane graphs. Proc. of Graph Drawing’97, Lect. Notes in Computer Science, 1353, pp. 99-110, 1998.
[8]
M. S. Rahman, S. Nakano and T. Nishizeki. Rectangular grid drawings of plane graphs. Comp. Geom. Theo. Appl., 10, pp. 203-220, 1998.
[9]
J. Storer. On minimum node-cost planar embeddings. Networks, 14, pp. 181-212, 1984.
[10] R. Tamassia. On embedding a graph in the grid with the minimum number of bends. SIAM J. Comput., 16, pp. 421-444, 1987. [11] R. Tamassia, I. G. Tollis and J. S. Vitter. Lower bounds for planar orthogonal drawings of graphs. Inf. Proc. Letters, 39, pp. 35-40, 1991. [12] C. Thomassen. Plane representations of graphs. (Eds.) J.A. Bondy and U.S.R. Murty, Progress in Graph Theory, Academic Press Canada, Don Mills, Ontario, pp. 43-69, 1984.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 3, no. 4, pp. 63-79 (1999)
Bounds for Orthogonal 3-D Graph Drawing T. Biedl School of Computer Science, McGill University Montreal, PQ H3A2A7, Canada
T. Shermer School of Computing Science, Simon Fraser University Burnaby, BC V5A1A6, Canada
S. Whitesides School of Computer Science, McGill University Montreal, PQ H3A2A7, Canada
S. Wismath Department of Mathematics and Computer Science, University of Lethbridge Lethbridge, AB T1K3M4, Canada Abstract This paper studies 3-D orthogonal grid drawings for graphs of arbitrary degree, in particular Kn , with vertices drawn as boxes. It establishes asymptotic lower bounds for the volume of the bounding box and the number of bends of such drawings and exhibits a construction that achieves these bounds. No edge route in this construction bends more than three times. For drawings constrained to have at most k bends on any edge route, simple constructions are given for k = 1 and k = 2. The unconstrained construction handles the k ≥ 3 cases. Communicated by G. Di Battista and P. Mutzel. Submitted: February 1998. Revised: November 1998.
The authors gratefully thank N.S.E.R.C. for financial assistance. The conference version of this paper appeared in the proceedings of Graph Drawing ’97. These joint results were also presented as part of the Ph.D. thesis of T. Biedl at Rutgers University. This work was done while the fourth author was on sabbatical leave at McGill University.
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999)
1
64
Introduction
This paper offers upper and lower bounds for the volume and the total number of bends in 3-D orthogonal grid drawings for graphs of arbitrary degree. In particular, we study how the volume depends on the maximum number of bends permitted per edge. All of our constructions have a total number of bends that is asymptotically optimal, and one construction also exhibits asymptotically optimal volume. To state the main results clearly, we first give some terminology and the drawing conventions and volume measure used. A grid point is a point in R3 whose coordinates are all integers. A grid box is the set of all points (x, y, z) in R3 satisfying x0 ≤ x ≤ x1 , y0 ≤ y ≤ y1 and z0 ≤ z ≤ z1 for some integers x0 , x1 , y0 , y1 , z0 , z1 . A grid box is said to have dimensions a×b×c whenever x1 = x0 +a−1, y1 = y0 +b−1, and z1 = z0 +c−1. The volume of such a box is defined to be the number of grid points it contains, namely abc. For example, a single grid point is a 1 × 1 × 1 box of volume 1. The volume of a drawing is the volume of its bounding box, which is the smallest volume grid box containing the drawing. Often we refer to the bounding box as an X × Y × Z-grid. Throughout this paper, a 3-D orthogonal grid drawing of a graph G = (V, E) is a drawing that satisfies the following. Distinct vertices of V are represented by disjoint grid boxes. While in general these boxes may be degenerate, i.e., they may have dimension 1 with respect to one or more coordinate directions, such degeneracies can be avoided, as we describe later. An edge e = (v1 , v2 ) of E is drawn as a simple path that follows grid lines, possibly turning (“bending”) at grid points; the endpoints of the path for e are grid points that are extremal points for the boxes representing v1 and v2 . The intermediate points along the path for an edge do not belong to any vertex box, nor do they belong to any other edge path. See Fig. 1. In what follows, graph theoretic terms such as vertex are typically used to refer both to the graph theoretic object and to its representation in a drawing.
Figure 1: Two boxes joined by a 4-bend edge.
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999)
1.1
65
Focus of this paper
The focus of this paper is on establishing upper and lower bounds for the volume and the number of bends of 3-D orthogonal grid drawings. In particular, we give upper bounds on the volume that depend on the allowed maximum number of bends per edge. More useful than upper and lower bounds would be an algorithm that computes for an arbitrary input graph an embedding that minimizes volume or number of bends. However, the problem of bend minimization or volume minimization is apparently computationally intractable. See [8]. We exclusively study embeddings of the complete graph Kn for the following reason. Any simple graph G on n vertices is a subgraph of the complete graph Kn . Thus, a drawing of Kn immediately provides a drawing for G by deleting irrelevant edges. Consequently, upper bounds for Kn yield upper bounds for all other simple graphs on n vertices. Furthermore, no simple graph on n vertices can yield larger lower bounds than Kn . Since our focus is on bounds, our constructions are not designed with the intention of giving attractive looking drawings. In particular, vertex boxes may be degenerate as previously described. Such degeneracies may be easily removed from a drawing by inserting extra axis-aligned planes of grid points. This increases the volume of a drawing by a multiplicative constant and does not affect the order of the upper bound. The boxes produced by our upper bound constructions can be poorly proportioned in two respects. The surface area can be large relative to the degree of the vertex. Also, the vertex boxes can be far from cube-shaped. Algorithms that proportion vertices better have recently been presented in [20], [1].
1.2
Relation to other work
The problem of embedding a graph in a rectangular grid has been addressed in the context of VLSI design (see [16] for an overview). However, the objectives of graph drawing and those of VLSI, while similar, are often prioritized differently. For example, while bend (or “jog”) minimization within layers is an issue in circuit layout design, apparently this cost measure does not have a high priority (see [16, p. 222]). By contrast, in graph drawing, the notion that bend minimization is important for diagram readability has been widely accepted ([21] provides some experimental evidence for this). Another difference between graph drawing and VLSI is that in 3-D VLSI design one of the dimensions is radically different from the other two: connections between layers (“vias”) are undesirable, whereas bends within a layer (“jogs”) are of minor importance. Also, one of the dimensions is usually restricted to a small number of layers. In 3-D graph drawing there are no such differences between directions. With advances in fabrication technology, it has become practical for VLSI design to use more than two or three layers; hence our results may nevertheless be of interest in that field. In the field of graph drawing, for graphs drawn orthogonally in the 2-D grid, early research mainly considered graphs of maximum degree 4 and represented
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999)
66
vertices as single grid points. See for example [23], [2], [19]. More recently, 2-D orthogonal grid drawings of higher degree graphs have been investigated, where vertices have been drawn as rectangular boxes. See for example [12], [18], [3]. At present, there are few results on 3-D orthogonal grid drawings. Rosenberg showed that any graph of maximum degree 6 can be embedded in a 3-D grid of volume O(n3/2 ) and that this is asymptotically optimal [22]. No bounds on the number of bends were given. Recently, Eades, Symvonis and Whitesides gave √ a method for drawing graphs of maximum degree 6 in a grid of side-length 4 n, with vertices represented by single grid points and each edge having at most 7 bends [9]. They also gave a simple method for drawing such graphs in a grid of side-length 3n, creating at most 3 bends on each edge. This volume was subsequently improved to at most 4.66n3 [20] and then to volume at most 2.37n3 [27]. For graphs with maximum degree 5, volume n3 and 2 bends per edge suffice [27]. As for drawings with higher degree, only two papers are known to the authors. Papakostas and Tollis showed how to draw graphs in a 3-D grid of volume O(m3 ) ≤ O(n6 ) [20]. Very recently, Biedl [1] extended the techniques presented here and showed how to draw graphs in a 3-D grid of volume O(n3 ). Neither paper matches our upper bound volume of O(n2.5). However, both papers yield constructions where vertex boxes have a more cube-like appearance. This suggests a trade-off between cube-like appearance of of vertex boxes and volume.
1.3
Results of this paper
Our results concern volume and number of bends for 3-D orthogonal grid drawings. Since we give upper and lower bounds, we first explain what functions are being bounded, and then we state the results. convention: From now on, the terms drawing and 3-D orthogonal grid drawing are used interchangeably. Let vol(n) denote the minimum, taken over all drawings of Kn , of the volumes of the drawings. Here, there are no restrictions on these drawings of Kn , other than that they are understood, by the above convention, to be 3-D orthogonal grid drawings. Similarly, let volk (n) denote the minimum, taken over all drawings of Kn that have k or fewer bends on any edge, of the volumes of the drawings. Let bend(n) denote the minimum, taken over all drawings of Kn , of the total number of bends in the drawings. main results: Our main results are that • • • •
vol(n) ∈ Θ(n2.5 ); vol1 (n) and vol2 (n) ∈ O(n3 ); for k ≥ 3, volk (n) ∈ Θ(n2.5 ); and bend(n) ∈ Θ(n2 ).
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999)
67
Note that for k ≥ 3, the upper and lower bounds on the volume match (within a constant factor) when a maximum of k bends per edge is allowed. The constructions of this paper have reasonably small constant factors for the volume. Only for the k = 1 and k = 2 cases do the bounds on the volume not match; in each of these cases we give an O(n3 ) volume drawing of Kn and leave as an open problem whether this drawing indeed has asymptotically optimum volume.
2 2.1
Lower Bounds A lower bound on the volume
Recall that vol(n) is the minimum possible volume for a drawing of Kn . This definition is valid since, as later sections show, every Kn has a drawing if edges are allowed to bend. The main result of this section is to show that vol(n) is in Ω(n2.5 ). A z-line is a line that is parallel to the z-axis; y-lines and x-lines are defined analogously. A (z = z0 )-plane is a plane that is orthogonal to the z-axis and intersects the z-axis at coordinate z0 ; (x = x0 )-planes and (y = y0 )-planes are defined analogously. Theorem 1 vol(n) ∈ Ω(n2.5 ). In fact, for any 0 < ε < min{( 41 − ε)n5/2 , f(n)} where f(n) ∈ Θ(n3 ).
1 , 4
we have vol(n) ≥
Proof: Consider a drawing of Kn in a grid of dimensions X × Y × Z. Let 0 < ε < 14 be given and choose 0 < δ < 14 so small that 14 (1 − 4δ)5/2 > 14 − ε. We distinguish three cases. Case 1: A line intersects many vertices Assume that there exists a z-line intersecting at least 2δn vertices. Set t = d2δne, and let v1 , . . . , vt be any t of the vertices intersected by the z-line, listed in order of occurrence along the line. Let z0 be a not necessarily integer z-coordinate such that the (z = z0 )-plane intersects none of these t vertices and separates the first b 2t c of them from the remaining d 2t e. See the top left picture in Fig. 2. Since the b 2t c·d 2t e ≥ 14 t2 −1 edges connecting these two groups must cross the (z = z0 )-plane, this plane must contain at least 14 t2 − 1 points having integer xand y-coordinates. Hence XY ≥ 14 t2 − 1. Also, Z ≥ t since the z-line intersects at least t vertices. Thus XY Z ≥ 14 t3 − t ≥ 2δ 3 n3 − 2δn ∈ Θ(n3 ). Case 2: A plane intersects many vertices Assume now that no x-line, y-line or z-line intersects as many as 2δn vertices, but that there exists a (z = z0 )-plane intersecting at least (1 − 2δ)n vertices. A vertex is left of an (x = x0 )-plane if all the points in its grid box have xcoordinates less than x0 . The notion of right of an (x = x0 )-plane is analogous. As an (x = x0 )-plane is swept from smaller to larger values of x0 , the y-line determined by the intersection of this (x = x0 )-plane with the (z = z0 )-plane
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999)
68
sweeps the (z = z0 )-plane. At any time, this y-line intersects fewer than 2δn vertices by assumption. During the sweep by the (x = x0 )-plane, an integer x∗ is encountered where, for the last time, there are fewer than ( 12 −2δ)n vertices left of the (x = x∗ )-plane and intersecting the (z = z0 )-plane. See the top right picture in Fig. 2. Since the y-line determined by the (x = x0 )-plane intersects fewer than 2δn vertices, and the (z = z0 )-plane intersects at least (1 − 2δ)n vertices by assumption, at least (1 − 2δ)n − ( 12 − 2δ)n − 2δn = ( 12 − 2δ)n vertices intersect the (z = z0 )-plane and lie right of the (x = x∗ )-plane. All these vertices also lie to the right of (x = x∗ + 12 )-plane. By definition of x∗ , the number of vertices that intersect the (z = z0 )-plane and that lie left of the (x = x∗+1)-plane is at least ( 12 − 2δ)n. All these vertices also lie to the left of (x = x∗+ 12 )-plane. There are at least ( 12 − 2δ)2 n2 edges between the vertices on the left and the vertices on the right of the (x = x∗+ 12 )-plane, so Y Z ≥ ( 12 − 2δ)2 n2 = 14 (1 − 4δ)2 n2 . Apply exactly the same argument in the y-direction to obtain XZ ≥ 1 2 2 since the (z = z0 )4 (1 − 4δ) n . Finally, note that XY ≥ (1 − 2δ)n ≥ (1 − 4δ)n, √ Y Z · XZ · XY ≥ plane intersects (1 − 2δ)n vertices. Consequently, XY Z = q 1 (1 16
− 4δ)5 n5 = 14 (1 − 4δ)5/2 n5/2 > ( 14 − ε)n5/2 by the choice of δ.
Case 3: No plane intersects many vertices Assume now that no plane intersects as many as (1 − 2δ)n vertices. As an (x = x0 )-plane is swept from smaller to larger values of x0 , by an argument analogous to the one in Case 2 a value x∗ (not necessarily integral) will be encountered for which at least δn vertices lie left of the (x = x∗ )-plane and at least δn vertices lie right of the (x = x∗)-plane. See the bottom picture in Fig. 2. Consequently, the (x = x∗)-plane contains at least δ 2 n2 points with integer yand z-coordinates, and Y Z ≥ δ 2 n2 . Since the same argument holds for the other two directions, XY Z ≥ (δ 2 n2 )3/2 = δ 3 n3 ∈ Θ(n3 ). For all sufficiently large n, the bound given by Case 2 is the smallest of the 2 three; hence vol(n) ∈ Ω(n5/2 ).
2.2
A lower bound on the bends
Recall that bend(n) is the minimum possible number of bends for a drawing of Kn . This definition is valid since, as later sections show, every Kn has a drawing if edges are allowed to bend. The main result of this section is that bend(n) is in Ω(n2 ). To prove this result, we use the fact that there exist graphs that have no 0-bend 3-D orthogonal drawing [11]. We present here a simple proof of this fact. If no bends are permitted in the drawing, then the edges correspond to axisparallel visibility lines between pairs of boxes. Such visibility representations have been studied in 2-D by Wismath [26], [15] and by Tamassia and Tollis [24], and in 3-D with 2-D objects in [4], [10], [11]. A 3-D orthogonal drawing of a graph with no bends splits the edges into three classes, depending on the
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999)
69
Figure 2: Cases 1,2,3 for the lower bound. direction of visibility. Each class of edges forms a graph that has a visibility representation using only one direction of visibility. Our lower bound result depends on the fact that K56 has no such visibility representation, as shown in [10]. Lemma 1 For all sufficiently large n, Kn has no bend-free 3-D orthogonal grid drawing. Proof: The 3-Ramsey number R(r, b, g) is the smallest number such that any
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999)
70
arbitrary coloring of the edges of KR(r,b,g) with colors red, blue and green induces either a red Kr , or a blue Kb , or a green Kg as a subgraph. This number exists and is finite; see for example [13]. Assume Kn , n > R(56, 56, 56), is drawn without a bend. Color an edge red if it is parallel to an x-line, green if it is parallel to a y-line, and blue if it is parallel to a z-line. By the choice of n, we must have a monochromatic K56 , which contradicts the fact that K56 has no visibility representation using only one direction of visibility. Therefore Kn must have a bend in any 3-D orthogonal grid drawing. 2 Fekete and Meijer [11] independently proved this lemma. They were interested in obtaining good bounds for the minimum such n, and therefore gave a longer proof to show that K184 requires a bend in any 3-D orthogonal drawing. One consequence of this lemma is that bend(n) ∈ Ω(n2 ). Theorem 2 bend(n) ∈ Ω(n2 ). Proof: Let c be an integer (e.g., 184) such that any 3-D orthogonal grid drawing of Kc has a bend. For n > c, the graph Kn contains nc copies of a Kc . Each of these copies must have a bend. Any edge of Kn belongs to exactly n−2 c−2 of these copies of Kc . Consequently, the number of edges with a bend must be at least n (c − 2)!(n − c)! n(n − 1) n2 n! c = ≥ 2 n−2 = c!(n − c)! (n − 2)! c(c − 1) c c−2 for n ≥ c.
3
2
Constructions
The lower bound of Section 2.1 provides a volumetric goal for layout strategies for drawings with at most k bends per edge. This section presents a construction that achieves this lower bound with a small constant factor. For the k = 1 case, two strategies are described and then modified to give a drawing for the k = 2 case. A simple construction that realizes the Ω(n2.5 ) lower bound for volume is described in Subsection 3.3. The construction generates at most 3 bends on any edge and hence is valid for each k ≥ 3. Whether the lower bound is attainable when k = 1 or 2 remains an open problem. In each of the constructions, vertices are first placed as points in a 2-D xy-plane. Next, all the edges are routed in the same xy-plane, with overlap and crossings of edges temporarily permitted. Then a number Z of z-planes is introduced, and edges are assigned to these planes so that no edges overlap or cross. The vertices are stretched into segments of z-lines. While the VLSI and MCM literature proposes many layout constructions of similar flavor (see e.g. [14]), our work differs from those results in several aspects. Our constructions provide proof techniques for obtaining upper bounds for Kn ; by contrast, the VLSI literature aims to provide usable layout heuristics and
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999)
71
algorithms for arbitrary input graphs. Another important difference is that the constraint on the maximum number of bends per edge that we study in this paper is apparently not an issue for the VLSI and MCM technologies.
3.1
Drawings of O(n3 ) volume for k = 1
In this section, we describe two strategies to draw Kn with at most k = 1 bend on any edge. For simplicity, we assume in the description of our constructions that n is divisible by 4. When this is not the case, slightly modified constructions yield the same asymptotic bounds. The first layout scheme draws Kn in an n × n × n-grid. The second scheme then makes two drawings of Kn/2 (without recursion) using the first scheme; then it positions these drawings in an n2 × n × n2 -grid and supplies the edges between the two parts. 3.1.1
Drawing Kn in an n × n × n-grid for k = 1
Enumerate the vertices as v1 , . . . , vn . Place vertex vi at (i, i). Route edge e = (vi , vj ), where i < j, with one bend via (i, i), (i, j), (j, j). Note that no vertex or part of an edge is placed at a point (x, y) with y < x. Now partition the edges of Kn into n edge sets Eia , Eib , i = 1, . . . , n2 , defined as Eia = {(vi−l+1 , vi+l )|l = 1, . . . , n2 } and Eib ={(vi−l , vi+l )|l = 1, . . . , n2 − 1} (all additions are modulo n). It is easy to check that these sets indeed partition the edges of Kn , and that neither crossings nor overlaps occur either among edges in Eia or among edges in Eib . Hence only n z-planes are needed. See Fig. 3.
E1a
E2a
E3a
E4a
E1b
E2b
E3b
E4b
Figure 3: The sets E1a , . . . , E4a and E1b , . . . , E4b for K8 . This gives the following lemma. Lemma 2 If n is even, there exists a drawing of Kn in an n × n × n-grid with one bend per edge such that the points {(x, y, z)|y < x} are unused.
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999)
72
Proof: Represent each vertex vj , i ≤ j ≤ n, as a line segment (hence a grid box) with endpoints (j, j, 1) and (j, j, n). Route the edges in Eia , 1 ≤ i ≤ n/2, in the (z = i)-plane as described above. Similarly, route the edges in Eib , 1 ≤ i ≤ n/2, in the (z = n/2 + i)-plane. This gives a crossing-free drawing with the desired properties. 2 Remark: Note that Eia and Eib can be drawn in the same plane by reflecting the edges of Eia with respect to the diagonal line through the vertices. This yields a drawing of Kn in an n × n × n2 -grid. This strategy is closely related to the pagenumber of a graph (see for example [6]), and in fact, may prove a useful idea for drawing sparse graphs. Drawing Kn in an
3.1.2
n 2
× n × n2 -grid for k = 1
Let K 1 and K 2 denote two drawings of Kn/2 with coordinates as described in the proof of the previous lemma. Thus each drawing has an n2 × n2 × n2 bounding box and initially, K 1 and K 2 are superimposed. Rotate K 2 and its bounding box about the y-axis clockwise by 90 degrees (looking towards +∞). Then rotate it about the x-axis by 180 degrees. In this rotated K 2 , vertex vj contains the points {(x, −j, j)|1 ≤ x ≤ n2 }. See Fig. 4. z
B
z
D C
A
y
y
F
F
H
B
E
E (0, 0, 0)
G
A
x
D
H G z
K1
C D
y
y
K2
E F
C z
G H
x
A
x
x
B
Figure 4: Rotate K 2 twice: first by 90 degrees about the y-axis, and then by 180 degrees about the x-axis. Finally, we show the combination of K 1 and the rotated K 2 . The gray area is the area that contains edges of K 2 . Each vertex vi in K 1 sees each vertex vj in the rotated K 2 along the y-line
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999)
73
segment [(i, i, j), (i, −j, j)]. Therefore, these edges can be drawn as straight line segments, thus producing a drawing of Kn . The unused (y = 0)-plane can be deleted to give a drawing with dimensions X = Z = n2 and Y = n. Theorem 3 For a given n, let N ≥ n be the smallest number that is divisible by 4. Kn can be drawn in an N2 × N × N2 -grid with at most one bend per edge and total number of bends at most N 2 /4 − N/2. Proof: Draw KN as described above, ignoring the N − n vertices not belonging to Kn , and their incident edges. The volume bounds follow directly from the construction. There are N 2 /4 edges drawn without a bend, and all other edges 2 have one bend, so the total number of bends is at most N 2 /4 − N/2. Remark: Since N ≤ n + 3, our construction has a volume of 14 n3 + O(n2 ).
3.2
A smaller O(n3 ) volume drawing for k = 2
A similar strategy can be applied when a maximum of k = 2 bends on an edge is allowed. For simplicity, we assume in the description of our constructions that n is divisible by 4. When this is not the case, slightly modified constructions yield the same asymptotic bounds. We draw Kn with at most two bends per edge by first making two copies of a drawing for K n2 (without recursion) and then placing them in a grid of side-length n2 and supplying the edges connecting the two parts. 3.2.1
Drawing in an n ×
n 2
× n-grid
Enumerate the vertices as {v1 , . . . , vn } and place vi at (x, y) = (i, 1) in a 2-D e and route e via xy-plane. To route edge e = (vi , vj ), where i < j, let y = d j−i 2 the points (i, 1), (i, y), (j, y), (j, 1), creating two bends if y > 1 and no bends if y = 1. Define the edge sets Eia and Eib as above. Again there are neither crossings nor overlaps among edges in the same set and so n z-planes suffice. Since the e, the bounding box has dimensions n × n2 × n. largest y-coordinate is d n−1 2
E1a
E2a
E3a
E4a
E1b
E2b
E3b
E4b
Figure 5: The edge sets of K8 drawn with at most two bends per edge.
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999)
74
Lemma 3 If n is even, there exists a drawing of Kn in an n × n2 × n-grid, with a total of n2 − 3n + 2 bends and at most two bends per edge, such that the line segment (grid box) for vertex vi contains the points {(i, 1, z)|1 ≤ z ≤ n}. Proof: Represent each vertex vj , i ≤ j ≤ n, as a line segment (hence a grid box) with endpoints (j, 1, 1) and (j, 1, n). Route the edges in Eia , 1 ≤ i ≤ n/2, in the (z = i)-plane as described above. Similarly, route the edges in Eib , 1 ≤ i ≤ n/2, in the (z = n/2 + i)-plane. This gives a crossing-free drawing with the desired volume bounds. The edges (vi , vi+1 ) for i = 1, . . . , n − 1 are drawn straight; all other edges have two bends, so the total number of bends is 2 2(n(n − 1)/2 − (n − 1)) = n2 − 3n + 2. 3.2.2
Drawing in an
n 2
×
n 2
× n2 -grid
Let K 1 and K 2 denote two drawings of Kn/2 with coordinates as described in the proof of the previous lemma. Thus each drawing has an n2 × n4 × n2 bounding box and initially, K 1 and K 2 are superimposed. Rotate the bounding box of K 2 as described in Section 3.1.2 and Fig. 4. Then vertex vj of the rotated K 2 contains the points {(x, −1, j)|1 ≤ x ≤ n2 }. See Fig. 6. z
K1
y
K2 x
Figure 6: The combination of K 1 , and the rotated K 2 (we moved K 2 farther away for clarity). Each vertex vi in K 1 sees each vertex vj in the rotated K 2 along the y-line segment [(i, 1, j), (i, −1, j)]. Therefore, these edges can be drawn as straight lines, thus producing a drawing of Kn . The unused (y = 0)-plane can be deleted to give a drawing with dimensions X = Y = Z = n2 . Theorem 4 For a given n, let N ≥ n be the smallest number that is divisible by 4. Kn can be drawn in a N2 × N2 × N2 -grid with at most two bends per edge and total number of bends at most N 2 /2 − 3N + 4. Proof: Draw KN as described above, ignoring the N − n vertices not belonging to Kn , and their incident edges. The volume bounds follow directly from the
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999)
75
construction, and the bound on the number of bends follows from Lemma 3, 2 since we have at most 2(( N2 )2 − 3 N2 + 2) bends. Remark: Since N ≤ n + 3, our construction has a volume of 18 n3 + O(n2 ).
3.3
An O(n2.5 ) volume drawing for k = 3
In this section, we draw Kn with at most k = 3 bends on any edge and with volume O(n2.5 ). Case 2 of the lower bound proof suggests what general form such a drawing might take. For simplicity, we assume in the description of our constructions that n = r 2 for some integer r. When this is not the case, slightly modified constructions yield the same asymptotic bounds. Enumerate the vertices as ordered pairs (i, j), where 1 ≤ i ≤ r, 1 ≤ j ≤ r, and place vertex (i, j) at (2i, 2j) in the 2-D xy-plane. Suppose edge e joins vertex (i1 , j1 ) and vertex (i2 , j2 ). After possible renaming, we may assume that i1 ≤ i2 , and that if i1 = i2 , then j1 > j2 . Call e an L-edge if j1 > j2 and a Γ-edge otherwise. Fig. 7 shows some L-edges. Initially route each L-edge via the points (2i1 , 2j1 ), (2i1 +1, 2j1 ), (2i1 +1, 2j2 + 1), (2i2 , 2j2 + 1), (2i2 , 2j2 ), thus with three bends. Route each Γ-edge via points (2i1 , 2j1 ), (2i1 + 1, 2j1 ), (2i1 + 1, 2j2 − 1), (2i2 , 2j2 − 1), (2i2 , 2j2 ). Split the L-edges into r(r − 1) groups Edx ,dy , with 0 ≤ dx ≤ r − 1 and 1 ≤ dy ≤ r − 1. Each group Edx ,dy consists of those edges ((i1 , j1 ), (i2 , j2 )) for which i2 = i1 + dx and j2 = j1 − dy . These groups cover all L-edges since i1 ≤ i2 and j1 > j2 for any L-edge. Now split each group Edx ,dy into at most dx + dy sets of edges as follows. For p = 0, . . . , dx + dy − 1, let Edpx ,dy be the edges in Edx ,dy for which j2 − i1 = p modulo (dx+dy ). In other words, the lower left “corners” of the L-edges in Edpx ,dy lie on diagonals that intersect the y-axis at the value 2p modulo (2dx + 2dy ). See Fig. 7. It is easy to check that no two edges in Edpx ,dy overlap or intersect (except at endpoints), since the corners of the L’s are placed on a sequence of diagonals; these diagonals have a vertical spacing of 2dx + 2dy between adjacent diagonals. Also, note that Edpx ,dy is non-empty only if p ≤ 2r − dx − dy .1 Assign a z-plane to each set Edpx ,dy to obtain a legal drawing of the L-edges. Route the Γ-edges in an analogous fashion. This doubles the √ number of z-planes, yielding a drawing of Kn in a grid with X = Y = 2r = 2 n. The Z dimension is given by r−1 r−1 X X min{dx + dy , 2r − dx − dy }, 2 dx =0 dy =1
which is shown in the following technical lemma to be no greater than 43 r 3 . Lemma 4
Pr−1 Pr−1 dx =0
dy =1
min{dx + dy , 2r − dx − dy } < 23 r 3 .
1 A java applet demonstrating the sets and their routings for K 100 can be found at http://www.cs.uleth.ca/∼wismath/ortho.html. VRML constructions of any graph can be created with the OrthoPak software package available from the above Web site.
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999) y
76
y
2dy
2dx + 2dy
(0,0)
x
2dx
(0,0)
x
0 2 Figure 7: The edge sets E1,2 and E1,2 .
Proof: We write the values of min{dx + dy , 2r − dx − dy } in the specified range as the following r × (r − 1)-rectangle: dy min{dx + dy , 2r − dx − dy } r-1 r-2 4 3 2 1
r-1 r r-1 r-2 r-2 r-1 r r-1 r-2 r-2 r-1 r r-1 r-2 r-1 r r-2 r-1 3 r-2 2 3 1 2 3
3 r-2 r-1 r r-1 r-2
r-2 r-1 r r-1 r-2
2 3
r-2 r-1 r-2 r r-1 r-1 r
0 1 2 r-3 r-2 r-1 dx P 2 k . The sum of the r − 1 upper The sum of the r − 1 lower diagonals is r−1 k=1 Pr−1 diagonals is k=1 k(k + 1). Hence the total sum is r−1 X k=1
k2 +
r−1 X
k(k + 1) =
k=1
2
r−1 X k=1
=
k2 +
r−1 X k=1
k=
(r − 1)r(2r − 1) r(r − 1) + 3 2
4r 3 − 3r 2 − r 2 (r − 1)r(4r − 2 + 3) = < r3 . 6 6 3
2 √ Theorem 5 For a given n, let r = d n e and let√N = r 2 . Then Kn can be N + 6 N bends and at most three drawn in a 2r × 2r × 43 r 3 -grid with 32 N 2 − 15 2 bends per edge. Proof: Draw KN as described above, ignoring the N − n vertices not belonging to Kn , and their incident edges. The volume bounds follow directly from the construction. √ Every edge has three bends, except the 2r(r − 1) = 2N − 2 N edges where dx = 0 and dy = 1, or dx = 1 and dy = 0, which can be drawn without √ a bend. So the√total number of bends is 3(N 2 /2 − N/2) − 3(2N − 2 N ) = 3 2 15 2 2N − 2 N + 6 N.
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999)
77
√ √ √ Remark: Since r = d n e < n+1, we have N ≤ n+2 n, so our construction N 2.5 = 16 n2.5 + O(n2.25 ). has a volume of 16 3 3
4
Conclusions
This paper is one of the first to address volume and bend considerations for 3-D orthogonal grid drawings of graphs. The focus has been on Kn , since it is the most difficult graph on n vertices to draw in small volume or with restrictions on bends. In particular, we have • provided a method for drawing Kn with volume that is provably within a constant factor (same constant for all n) of best possible in the case that at most k bends per edge are allowed, where k ≥ 3; • proved a lower bound of Ω(n2.5 ) and an upper bound of O(n3 ) on the volume of drawings of Kn when k = 1 and k = 2; • proved a lower bound of Ω(n2 ) on the number of bends, which is matched by our constructions. An open problem is to close the gap between the upper and lower bounds in the k = 1 and k = 2 cases, where at most 1 and at most 2 bends on each edge are permitted, respectively. Another interesting problem is to find upper and lower bounds that depend not only on the number of vertices n but also on the number of edges m.
5
Acknowledgments
Thanks to Michael Kaufmann for discussions on orthogonal drawings, and to S´ andor Fekete for pointing out reference [11].
References [1] T. Biedl. Three approaches to 3D-orthogonal box-drawings. In Whitesides [25], pages 30–43. [2] T. Biedl and G. Kant. A better heuristic for orthogonal graph drawings. Computational Geometry: Theory and Applications, 9:159–180, 1998. [3] T. Biedl, B. Madden, and I. Tollis. The three-phase method: A unified approach to orthogonal graph drawing. In Di Battista [7], pages 391–402. [4] P. Bose, H. Everett, S. Fekete, M. Houle, A. Lubiw, H. Meijer, K. Romanik, G. Rote, T. Shermer, S. Whitesides, and C. Zelle. A visibility representation for graphs in three dimensions. J. Graph Algorithms Appl., 2(3):1–16, 1998.
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999)
78
[5] F. Brandenburg, editor. Symposium on Graph Drawing GD’95, volume 1027 of Lecture Notes in Computer Science. Springer-Verlag, 1996. [6] A. Dean and J. Hutchinson. Relations among embedding parameters for graphs. In Graph theory, combinatorics, and applications, Vol. 1, Kalamazoo, MI, 1988, Wiley-Intersci. Publ., pages 287–296. Wiley, New York, 1991. [7] G. Di Battista, editor. Symposium on Graph Drawing GD’97, volume 1353 of Lecture Notes in Computer Science. Springer-Verlag, 1998. [8] P. Eades, C. Stirk, and S. Whitesides. The techniques of Komolgorov and Bardzin for three-dimensional orthogonal graph drawings. Information Processing Letters, 60:97-103, 1996. [9] P. Eades, A. Symvonis, and S. Whitesides. Two algorithms for three dimensional orthogonal graph drawing. In North [17], pages 139–154. [10] S. Fekete, M. Houle, and S. Whitesides. New results on a visibility representation of graphs in 3D. In Brandenburg [5], pages 234–241. [11] S. Fekete and H. Meijer. Rectangle and box visibility graphs in 3D. International Journal for Computational Geometry and Applications, 1998. To appear. [12] U. F¨oßmeier and M. Kaufmann. Drawing high degree graphs with low bend numbers. In Brandenburg [5], pages 254–266. [13] R. Graham, B. Rothschild, and J. Spencer. Ramsey theory. Wiley, New York, 1980. [14] J. M. Ho, M. Sarrafzadeh, G. Vijayan, and C. K. Wong. Layer assignment for multichip modules. IEEE Trans. CAD, 9(12):1272–1277, 1990. [15] D. Kirkpatrick and S. Wismath. Determining bar-representability for ordered weighted graphs. Computation Geometry: Theory and Applications, 6(2):99–122, 1996. [16] T. Lengauer. Combinatorial Algorithms for Integrated Circuit Layout. Teubner/Wiley & Sons, Stuttgart/Chicester, 1990. [17] S. North, editor. Symposium on Graph Drawing GD’96, volume 1190 of Lecture Notes in Computer Science. Springer-Verlag, 1997. [18] A. Papakostas and I. Tollis. High-degree orthogonal drawings with small grid-size and few bends. In 5th Workshop on Algorithms and Data Structures, volume 1272 of Lecture Notes in Computer Science, pages 354–367. Springer-Verlag, 1997. [19] A. Papakostas and I. Tollis. Algorithms for area-efficient orthogonal drawings. Computational Geometry: Theory and Applications, 9:83–110, 1998.
T. Biedl et al., Orthogonal 3-D Graph Drawing, JGAA, 3(4) 63-79 (1999)
79
[20] A. Papakostas and I. Tollis. Incremental orthogonal graph drawing in three dimensions. In Di Battista [7], pages 52–63. [21] H. Purchase. Which aesthetic has the greatest effect on human understanding? In Di Battista [7], pages 248–261. [22] A. Rosenberg. Three-dimensional VLSI: A case study. Journal of the Association of Computing Machinery, 30(3):397–416, 1983. [23] R. Tamassia. On embedding a graph in the grid with the minimum number of bends. SIAM J. Computing, 16(3):421–444, 1987. [24] R. Tamassia and I. Tollis. A unified approach to visibility representations of planar graphs. Discrete and Computational Geometry, 1:321–341, 1986. [25] S. Whitesides, editor. Symposium on Graph Drawing GD’98, volume 1547 of Lecture Notes in Computer Science. Springer-Verlag, 1998. [26] S. Wismath. Characterizing bar line-of-sight graphs. In 1st ACM Symposium on Computational Geometry, pages 147–152, Baltimore, Maryland, USA, 1985. [27] D. Wood. An algorithm for three-dimensional orthogonal graph drawing. In Proceedings of Graph Drawing GD’98, Lecture Notes in Computer Science, 1998. To appear.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 3, no. 4, pp. 81-115 (1999)
Algorithms for Incremental Orthogonal Graph Drawing in Three Dimensions Achilleas Papakostas Network Management Division NEC America 1525 W. Walnut Hill Ln. Irving, TX 75038
[email protected]
Ioannis G. Tollis Dept. of Computer Science The University of Texas at Dallas Richardson, TX 75083-0688
[email protected] Abstract We present two algorithms for orthogonal graph drawing in three dimensional space. For a graph with n vertices of maximum degree six, the 3-D drawing is produced in linear time, has volume at most 4.63n3 and has at most three bends per edge. If the degree of the graph is arbitrary, the vertices are represented by solid 3-D boxes whose surface is proportional to their degree. The produced drawing has two bends per edge. Both algorithms guarantee no crossings and can be used under an interactive setting (i.e., vertices arrive and enter the drawing on-line), as well.
Communicated by G. Di Battista and P. Mutzel. Submitted: March 1998. Revised: November 1998 and April 1999.
Research supported in part by NIST, Advanced Technology Program grant number 70NANB5H1162, and by the Texas Advanced Research Program under Grant No. 009741-040.
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 82
1
Introduction
Graph drawing addresses the problem of automatically generating geometric representations of abstract graphs or networks. For a survey of graph drawing algorithms and other related results see the book by Di Battista, Eades, Tamassia and Tollis [10]. An orthogonal drawing is a drawing in which vertices are represented by points of integer coordinates and edges are represented by polygonal chains consisting of horizontal and vertical line segments. Various algorithms have been introduced to produce orthogonal drawings of planar [2, 15, 20, 34, 36] or general [2, 24, 27, 33] graphs of maximum degree 4, and maximum degree 3 [20, 23, 24]. All these algorithms run in linear time, except for the algorithm in [34]. For drawings of general graphs, the required area can be as little as 0.76n2 [24, 27], the total number of bends is no more than 2n + 2 [2, 24, 27], and at most two bends can be on the same edge [2, 24, 27]. There has been a recent trend in Graph Drawing to visualize graphs in the three dimensional space. Although the number of applications that require such a representation for graphs is still limited [4, 17, 22, 31, 32, 37, 38], there is no doubt that 3-D Graph Drawing will find many applications in the future. A number of software systems that produce straight-line 3-D drawings of graphs have been introduced. In the case of [5], the system is based on the spring-embedder paradigm [19]. Spring-embedders use a physical model based on vertices treated as currents exerting a repulsive force, while edges are modeled as forces attracting the vertices they combine. Simulated Annealing has also been used [8] to produce straight-line 3-D drawings of graphs. The idea here is that there is a predefined cost associated with the current 3-D drawing of the graph, and the system moves to drawings of lower costs (while sometimes accepting higher cost drawings if they look ‘nice’), until no further improvement is possible. Other special purpose systems are described in [11, 32]. Little is known about the theory of 3-D Graph Drawing. The concept of a visibility representation of a graph [35] has been extended to 3-D space, known as 3-D visibility representations of graphs. Research in this area [1, 3, 6, 16, 18] has revealed characterizations of several families of graphs and other theoretical results. In [7] it is shown that an n-vertex graph has a non-orthogonal 3-D drawing in a n × 2n × 2n grid, so that all vertices are located on grid points, and no two edges cross. In the same paper, a technique to convert an√orthogonal √ 2-D drawing of area H ×V to a 3-D straight-line drawing of volume d He×d He×V is also presented. Naturally, orthogonal drawing in three dimensional space has also received attention recently [4, 5, 8, 12, 13, 17, 32]. A 3-D orthogonal drawing typically has the following properties: • Vertices are points with integer coordinates in three dimensional space. • Each edge is a polyline sequence of consecutive straight line segments;
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 83 each one of these line segments is parallel either to the x-axis, y-axis, or z-axis. • The meeting point of two consecutive straight line segments of the same edge is a bend and has integer coordinates. • Line segments coming from routes of two different edges are not allowed to overlap. A very interesting upper bound on the volume for 3-D orthogonal drawings of graphs of maximum degree 6 is √ specifically, the volume √shown in√[13]. More for such drawings is at most O( n) × O( n) × O( n), while each edge has at most seven bends, and no two edges cross. This improves the result in [12], where the volume upper bound was the same but the drawings allowed up to 16 bends per edge. If we require that each edge has at most three bends, then another algorithm is presented in [13] that requires volume exactly 27n3 (the 3 produced drawings have no crossings). Both algorithms run in O(n 2 ) time. Note that Kolmogorov and Bardzin [21] show an existential lower bound of 3 Ω(n 2 ) on the volume occupied by 3-D orthogonal grid drawings of graphs of maximum degree 6. In this paper we present an algorithm for producing 3-D orthogonal drawings of simple graphs of maximum degree 6, and a second algorithm that produces 3D orthogonal drawings of simple graphs of arbitrary degree. Note that there has not been any previous work that dealt with the theory of 3-D orthogonal drawing of graphs of arbitrary degree. Both algorithms are based on the ‘RelativeCoordinates’ paradigm for vertex insertion [25, 26, 28]. As such, both algorithms support interactive environments where vertices arrive and enter the drawing on-line. An important feature of this work is that both algorithms guarantee no edge crossings. Given an n-vertex graph G of maximum degree 6, our first algorithm produces a 3-D orthogonal drawing of G whose volume is at most 4.63n3, in linear time. Moreover, each edge of the drawing has at most three bends. Hence, our algorithm outperforms the algorithm of [13] in terms of both running time and volume of the drawing. Our second algorithm uses solid three dimensional boxes to represent vertices. The surface of each such box is proportional to the degree of the represented vertex. The produced 3-D orthogonal drawings have at most + O(n))3 ), where m is the number of two bends per edge, and volume O(( m 3 edges of the drawing.
2
Preliminaries
Clearly, for each graph of maximum degree 6, there is a 3-D orthogonal drawing according to the definition of the previous section. The system of coordinates typically used in three dimensional space is based on three axes x, y, z so that
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 84
top
each one of them is perpendicular to the other two (see Fig. 1a). Three different planes are formed by the three possible ways we can pair these axes: The xzplane is defined by the x, z-axes, the yz-plane is defined by the y, z-axes, and the xy-plane is defined by the x, y-axes. Each one of these planes is called a base plane; each base plane is perpendicular to the other two.
y
left
v
p
ba ck
z
e’
(a)
bottom
x
fro
nt
right
(b)
v
e (c)
Figure 1: (a) Coordinates system for 3-D drawing, (b) possible directions from where an edge can enter v, (c) v’s left free direction is blocked. Each vertex of a 3-D drawing has six possible directions around it from where incident edges may enter the vertex. The two directions parallel to the z-axis are top (extending towards the positive part of the z-axis) and bottom (extending towards the negative part of the z-axis). Front and back directions are parallel to the y-axis and they extend towards the negative and positive parts of the y-axis, respectively. The remaining two directions are parallel to the x-axis and are called left (extending towards the negative part of the x-axis) and right (extending towards the positive part of the x-axis), see also Fig. 1b. Two directions parallel to the same axis are opposite directions. Two directions parallel to two different axes are orthogonal directions. If there is no edge entering a vertex v from a specific direction of v, this direction is called free direction of v. A free direction of v is blocked by straight line segment e, if we can draw a straight line from v along the free direction that intersects e. Such a situation is depicted in Fig. 1c: v and e are both placed in plane p which is parallel to the xy-plane. v’s left free direction is blocked since line e0 (which is parallel to the x-axis and extends towards the negative part of this axis) crosses line e. A plane free direction is a left, right, front, or back free direction. Consider vertices v1 , v2 , · · · vr , where r ≥ 2, having plane free directions fd1 , fd2 , · · · fdr which extend towards the same direction (e.g., they are all left free directions). The set of the fdi ’s forms a beam. If the fdi ’s are left (resp. right, front, back) free directions, then their beam is a left (resp. right, front, back) beam. Vertices v1 , v2 , · · · vr are the origins of the beam. Two beams are opposite (resp. orthogonal) if the free direction of one beam is opposite (resp. orthogonal) to
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 85 the free direction of the other. The length of a 3-D drawing is the maximum distance between two planes parallel to the yz-plane containing any part of the drawing. The width of a 3-D drawing is the maximum distance between two planes parallel to the xz-plane containing any part of the drawing. The height of a 3-D drawing is the maximum distance between two planes parallel to the xy-plane containing any part of the drawing. If a 3-D drawing has length l, width w and height h, its volume is l × w × h. It is actually the volume of the smallest rectangular parallelepiped that encloses the 3-D drawing. Before we present our two algorithms, we repeat very briefly the following interactive graph drawing terminology: The current drawing is the drawing before the insertion of new vertex v; the number of vertices of the current drawing that are going to be connected with v through new edges, is v’s local degree. We call these vertices adjacent vertices of v. Finally, a plane is to the top of the topmost plane of the current drawing, if it is parallel to the xy-plane and located one unit above the point of the current drawing with the highest z-coordinate. This notion extends similarly to the other directions.
3
Drawing Graphs with Maximum Degree Six
In this section we present our incremental algorithm for producing orthogonal drawings of graphs of maximum degree 6 in the three dimensional space. The incremental nature of our algorithm comes from the fact that a user is allowed to insert vertices (along with edges to existing vertices) into the current drawing in any order. The algorithm supports such vertex insertions at any moment t, as long as each request observes the following rules: • We start the drawing from scratch, that is the very first current drawing is the empty graph. • The degree of any vertex of the current drawing at any time t is at most 6. • The graph represented by the current drawing is always connected. In the following two subsections, we describe how a new vertex is placed in the current drawing and how its (at most six) incident edges are routed. Vertices are represented by points. Our technique follows the Relative-Coordinates scenario. This means that the decision about where a new vertex will be placed and how its incident edges will be routed depends entirely on the free directions around the adjacent vertices. The properties of the Relative-Coordinates scenario [25, 26, 28] are also properties of the 3-D drawings produced by our algorithm and guarantee a ‘smooth’ transition from the current drawing to the next. The notation u → p → p0 means that from vertex u we draw a straight line segment that intersects plane p perpendicularly, and from the intersection
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 86 point we draw another segment to plane p0 that intersects p0 perpendicularly as well. We use the notation pa,v , where a = x, y, or z and v is some vertex, to denote the plane which is perpendicular to the a-axis and contains vertex v. As we will see later, our 3-D orthogonal drawing is built in an upward fashion (i.e., it grows along the positive z-axis). For this reason, we always keep the following basic rule during the interactive drawing process: Basic Rule: No vertex has a bottom free direction in any current drawing. Most of the edges we route in 3-D follow one of five fundamental routes that we now explain. Assume that w and w 0 are two vertices of the current drawing. In the first three fundamental routes, edge (w 0 , w) always enters w 0 from its left free direction.
w
w
w
w’ (b)
(a)
w’
w’ (c)
p
p
z,w
w
w w’
w’ w’
w’
(e)
(d) Figure 2: (a) First, (b) Second, (c) Third Fundamental Routes, (d) Same-Plane, (e) Over-The-Top Routes. • First Fundamental Route: Edge (w0 , w) enters w from its left free direction. We open up a new plane p to the left of the leftmost plane of the current drawing. Edge (w 0 , w) is routed with three bends as follows: w 0 → p → py,w → pz,w → w. This is shown in Fig. 2a. The small empty circles of this figure denote the three bends of the route.
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 87 • Second Fundamental Route: Vertex w has lower x-coordinate than w 0 , and edge (w 0 , w) enters w from its right free direction. We open up a new plane p parallel to the yz-plane and one unit to the right of w. Edge (w 0 , w) is routed with three bends (see Fig. 2b), as follows: w 0 → p → py,w → pz,w → w. • Third Fundamental Route: Vertex w has lower x-coordinate and higher y-coordinate than w 0 , and edge (w 0 , w) enters w from its front free direction. No new plane is opened up and we route edge (w 0 , w) with two bends (see Fig. 2c) as follows: w 0 → px,w → pz,w → w. Although we used specific free directions for both w and w 0 in order to describe the first three fundamental routes, we must stress that these routes generalize to other situations as well. More specifically, if we derive the symmetric of the route shown in Fig. 2a with respect to the xy-plane or yz-plane, we have new legal routes which still fall within the First Fundamental Route category. Also, rotating the configuration of Fig. 2a or a symmetric of it by a multiple of a right angle around the z-axis produces additional legal routes of the First Fundamental Route type. In the same way, we can use symmetry and/or rotation in the way described before to produce additional legal configurations for the Second and Third Fundamental Routes. In the remaining two fundamental routes, edge (w 0 , w) enters w 0 from its top free direction. We also assume that w has higher z-coordinate than w 0 . • Same-Plane Route: Edge (w 0 , w) may enter w from any one of its plane free directions. We draw a straight line segment from w 0 intersecting plane pz,w perpendicularly. The remaining portion of edge (w0 , w) is routed exclusively in pz,w , and may enter w from any one of its plane free directions with at most two bends (if two bends are required, then a new plane parallel either to the xz or yz-plane has to be inserted). This means that the whole route has at most three bends. In Fig. 2d we show three examples of the portions of three routes in plane pz,w . • Over-The-Top Route: Edge (w 0 , w) enters w from its top free direction. A new plane p parallel to the xy-plane is inserted in the drawing, one unit above w. Edge (w 0 , w) is routed with three bends (see Fig. 2e) as follows: w 0 → p → px,w → py,w → w. In other words, we draw a straight line segment intersecting p perpendicularly, route the edge in p bringing it directly on top of w with one bend, and then just draw the line segment from that point to w. Note that if more than one edge is routed to vertex w using the Same-Plane Route, we have to make sure that: (a) There are no crossings between any two portions of these edges lying in plane pz,w , and (b) no portion of such an edge in pz,w blocks any one of w’s remaining (i.e., after all edges are routed) free
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 88 directions. These requirements can always be satisfied as long as: (a) the points in pz,w where the edges intersect pz,w have general position (i.e., no two points are in the same row or column of pz,w ), and (b) there are no portions of non Same-Plane Routes in plane pz,w . In Fig. 2d, we show how three edges starting from generally positioned points are routed to w with at most two bends. Note that w’s left free direction is not blocked as a result of the routing.
3.1
Overview of the Algorithm - Preprocessing
Assume that we start with an empty graph. The following gives an overview of the algorithm for placing the next vertex v in the current drawing. The steps of this algorithm are analyzed in this and the following subsections. Let v1 be the first vertex to be inserted. Vertex v1 has local degree 0. If v2 is the second vertex to be inserted, then v2 has local degree 1 and is connected with v1 . In Fig. 3a, we show the first two vertices inserted in an empty drawing. There are three observations to make about Fig. 3a. First, edge (v1 , v2 ) has three bends. Second, a total of seven new planes are inserted in the empty drawing. Third, neither v1 nor v2 has a bottom free direction. 1. IF v is the first or second vertex to be inserted, THEN place them as discussed above. 2. ELSE (a) Find v’s adjacent vertices u1 , · · · ul in the current drawing. (b) Determine connectors (one for each adjacent vertex) by using the procedure described below. (c) Find which Routing Case v’s insertion falls into. (d) WITHIN a Routing Case: i. IF Routing Case 1, THEN determine anchor vertex ua . ii. IF Routing Case 2 or 3, THEN A. IF degree of v is 6, THEN determine cover vertex uc . B. Determine anchor vertex ua . iii. Place v. iv. Route edge (ua , v). v. Route remaining edges (ui , v) except (uc, v), using the three Fundamental Routes and/or the Same-Plane Route. vi. IF Routing Case 1, THEN determine cover vertex uc. vii. Route edge (uc, v). 3. END.
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 89 Let v be the next vertex to be inserted in the current drawing and l (1 ≤ l ≤ 6) be v’s local degree. We find the l adjacent vertices u1 , u2 , · · · ul of v. According to the Basic Rule, v must not have a bottom free direction after v is placed and all its l incident edges are routed. This means that exactly one of these edges must enter v from the bottom. The vertex which is the other endpoint of this edge is called anchor vertex, and is denoted by ua . If l = 6, then the last one of v’s incident edges to be routed enters v from its top free direction. The other endpoint of this edge is called cover vertex, and is denoted by uc .
v
v2 u2
v v1
u3
ua (a)
u v
u4
u1
ua
c
(d)
(c)
(b) Figure 3: (a) Inserting the first two vertices, (b) a Routing Case 1 example, (c) (ua , v) of Routing Case 1 when ua does not have top connector, (d) (uc , v) of Routing Case 2 when uc does not have top connector. For each adjacent vertex ui , we must pick one of its free directions which will be used for routing edge (ui , v). The free direction picked for each ui is called ui ’s connector. Once a connector for an adjacent vertex ui is determined, it remains the same throughout the whole process of placing v and routing its incident edges. If a connector of some ui is a right (left, front, back, top) free direction, then it is called right (left, front, back, top) connector. Opposite, orthogonal, and plane connectors are defined in the same way as for free directions. Also, a beam of connectors is defined similarly to the beam of free directions. Let ci be ui ’s connector. We run the following procedure to determine the connector of each ui . 1. Choose a free direction fdi for each ui so that: (a) The number of pairs < fdi , fdj > (i 6= j and 1 ≤ i, j ≤ l) where fdi and fdj are opposite, is the smallest possible. (b) fdi is top free direction, only if ui has only this free direction left. 2. IF there are no two opposite beams among the fdi ’s, THEN
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 90 (a) FOR each ui : i. ci := fdi . (b) RETURN. 3. IF there are two opposite beams B1 and B2 , THEN (a) Consider the beam with the smallest cardinality; say B1 . (b) FOR each origin ui of B1 : i. IF ui ’s top free direction is available, THEN ci := top connector. ii. ELSE ci := fdi . (c) FOR each ui that is NOT an origin of B1 : i. ci := fdi . (d) RETURN. 4. END.
3.2
Vertex Placement and Edge Routing
As we will see in this subsection, many of v’s incident edges are routed using the fundamental routes. When this is the case, vertex v corresponds to w, and the adjacent vertex ui which is the other end of the route corresponds to w 0 . Depending on the types of connectors that v’s adjacent vertices have, we distinguish three Routing Cases: Routing Case 1: There is no beam among connectors ci . We distinguish the following subcases for selecting the anchor vertex ua: 1. First Subcase: There is at least one adjacent vertex with top connector. We consider the following cases: • There is exactly one adjacent vertex with plane connector. If this is left (front) or right (back) connector, then anchor ua is the adjacent vertex with top connector whose y(x)-coordinate is the median of the y(x)-coordinates of all adjacent vertices with top connectors. • If there are exactly two adjacent vertices with plane connectors, we have two situations: – One plane connector is left (front) and the other one is right (back). Anchor ua is the vertex with top connector whose y(x)coordinate is the median of the y(x)-coordinates of all adjacent vertices with top connectors. – The two plane connectors are orthogonal. If one of them is a left (right) plane connector, then anchor ua is the vertex with top connector having the lowest (highest) x-coordinate of all adjacent vertices with top connectors.
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 91 • If there are exactly three adjacent vertices with plane connectors, we find the plane connector which is orthogonal to the other two. If this is a left (resp. back, right, front) connector, then anchor ua is the adjacent vertex with top connector having the lowest xcoordinate (resp. highest y-coordinate, highest x-coordinate, lowest y-coordinate) of all adjacent vertices with top connectors. • In any other situation, any adjacent vertex with top connector can be the anchor ua. We insert a new plane p to the top of the topmost plane of the current drawing. Vertex v is placed at the intersection of planes p, px,ua , py,ua , directly above ua . Edge (ua , v) is a simple straight line segment from ua to v (see Fig. 3b). 2. Second Subcase: There is no adjacent vertex having top connector. In this situation, any adjacent vertex can be the anchor vertex ua . Assume that ua has left connector. We insert three new planes p1 , p2 , p3 so that p1 (p2 ) (p3 ) is to the left (back) (top) of the leftmost (backmost) (topmost) plane of the current drawing. Vertex v is inserted at the intersection of planes p1 , p2 , p3 . Edge (ua , v) is routed with two bends (see Fig. 3c) as follows: ua → p1 → p2 → v. This generalizes to cases where ua has a different plane connector, through a rotation. Any edge (ui , v) where ui is not the anchor is routed in one of the following ways: If ui has plane connector, edge (ui , v) is routed with three bends using the First Fundamental Route (see Fig. 3b for a complete example). If ui has top connector, edge (ui , v) is routed with two or three bends using the Same-Plane Route. Finally, note that if l = 6, cover vertex uc has top connector and is routed with three bends using the Over-The-Top Route. Routing Case 2: There is at least one beam among connectors ci and there are no two opposite beams. If there is at least one adjacent vertex with top connector and l = 6, then any such vertex can be the cover uc . If l = 6 and there is no adjacent vertex with top connector, then cover uc is the adjacent vertex with highest z-coordinate which belongs to a beam. Then, we find the beam Bmax having the highest cardinality without counting uc . Assume that Bmax is a left beam (the following discussion generalizes through rotation). Anchor ua is always one of Bmax ’s origins. More specifically, it is the vertex whose y-coordinate is the median of the y-coordinates of all Bmax ’s origins. We insert three new planes p1 , p2 , p3 parallel to the three base planes, so that p1 is to the left of the leftmost plane of the current drawing. If there is at least one adjacent vertex with top connector or if l < 6, then plane p3 is to the top of the topmost plane of the current drawing. Otherwise, (i.e., l = 6 and there is no adjacent vertex with top connector), we insert p3 one unit to the bottom of uc (note that p3 is parallel to the xy-plane). We distinguish the following subcases for plane p2 which is parallel to the xz-plane:
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 92 1. First Subcase: There are no two orthogonal connectors. If Bmax has cardinality 2, then plane p2 is placed one unit to the front of adjacent vertex ui which has top connector, is not the cover (if there is one), and has the highest y-coordinate among all adjacent vertices with top connectors. If Bmax has cardinality higher than 2 or if such a vertex ui does not exist, then plane p2 is placed one unit to the back of ua . Vertex v is placed at the intersection of planes p1 , p2 , p3 . Edge (ua , v) is routed with two bends (see Fig. 3c) as follows: ua → p1 → p2 → v. 2. Second subcase: There is one pair of orthogonal beams, or there is only one beam and it is orthogonal to at least one connector. This means that Bmax is orthogonal either to another beam (which we assume is a back beam) or to some connector ci (which we assume is a back connector). Plane p2 is placed to the back of the backmost plane of the current drawing. Placing v and routing edge (ua , v) is done as in the First Subcase. We use the First, Second, and Third Fundamental Routes to route the remaining edges (ui , v) where ui has a plane connector. These edges eventually attach only to plane free direction of v. Note that the Third Fundamental Route can be used only by vertices which are origins of Bmax . Edges that come from adjacent vertices having top connectors are routed using the Same-Plane Route. If l = 6 and cover uc has top connector, then edge (uc , v) is routed using the Over-The-Top Route. If cover uc does not have top connector, then, by the way it was chosen, it has the following properties: (a) uc has higher z-coordinate than v, and (b) uc has either left (if it is an origin of Bmax ), or back (if it is an origin of the other beam different from Bmax ) connector. If it has left (back) connector, it is routed with two bends as follows: uc → p1 (p2 ) → p2 (p1 ) → v. Figure 3d shows an example of this route when uc has left connector. Routing Case 3: There are two opposite beams among connectors ci ’s. Clearly, in this routing case, we have that l ≥ 4. Bmax is the beam with the highest cardinality. Let us assume that Bmax is a left beam (the discussion generalizes through rotation). Let B be the beam which is opposite to Bmax . We first discuss the situation where (a) l ≤ 5, or (b) l = 6 and there is at least one adjacent vertex with top connector (this vertex is cover uc and edge (uc, v) is routed using the Over-The-Top Route). Anchor ua is the median of the origins of beam Bmax with respect to their y-coordinates. We open up three new planes p1 , p2 , p3 as follows: p1 is to the left of the leftmost plane of the current drawing, and p3 is to the top of the topmost plane of the current drawing. Plane p2 is parallel to the xz-plane and between the two origins of beam B. Vertex v is inserted at the intersection of planes p1 , p2 , p3 . We route edge (ua , v) with two bends (see Fig. 3c) as follows: ua → p1 → p2 → v. If Bmax has two origins, then there can be at most one adjacent vertex u0 with front, back, or top connector (u0 is not the cover vertex). If u0 has front or
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 93
v v uB
uc (a)
(b)
Figure 4: Routing Case 3: (a) routing the edge coming from vertex uB when uB is an origin of the beam opposite to Bmax , (b) edge (uc , v) when uc does not have top connector. back connector, then edge (u0 , v) is routed using the First Fundamental Route. If u0 has top connector, then edge (u0 , v) is routed using the Same-Plane Route. In this case, edge (u0 , v) enters vertex v from its front (back) free direction if the y-coordinate of u0 is lower (higher) than that of v. Consider the case where Bmax has three origins. If the y-coordinate of anchor ua is lower (higher) than that of v, let u0 be the origin of Bmax whose y-coordinate is lower (higher) than that of ua . Edge (u0 , v) is routed using the Third Fundamental Route entering v from its front (back) free direction. The remaining incident edges of v are routed as follows: Let u00 be Bmax ’s origin whose edge has not been routed yet. We route edge (u00 , v) using the First Fundamental Route. As a result of routing v’s incident edges so far, either v’s back or v’s front free direction is available. If v’s back (front) free direction is available, let uB be the origin of B having higher (lower) y-coordinate than that of v. We open up a new plane p0 to the right of the rightmost plane of the current drawing, and route edge (uB , v) with three bends (see Fig. 4a) as follows: uB → p0 → p3 → p1 → v. Note that edge (uB , v) is routed on top of the current drawing, all the way from the rightmost to the leftmost side of the drawing. Although this edge passes directly over uB , this will not create any crossings in the future since uB ’s top free direction is not available. Let u0B be the other origin of B. Edge (u0B , v) is routed using the First Fundamental Route. Let us now consider the situation where l = 6 and there is no adjacent vertex with top connector. If B has cardinality 3, then cover uc is the origin of B which is between the other two origins of B with respect to the y-coordinate. If B has cardinality 2, then cover uc is the origin of B with the lowest (highest) ycoordinate of the two if there is an adjacent vertex with front (back) connector. Anchor ua is the median of the origins of Bmax with respect to the y-coordinate. Planes p1 , p3 are inserted as described in the previous case, and plane p2 is identical to py,uc . Vertex v is placed at the intersection of planes p1 , p2 , p3 , and edge (ua , v) is routed with two bends as described in the previous case.
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 94 If there are adjacent vertices with front or back connectors, the edges that come from them are routed using the First Fundamental Route. Any edge coming from an origin of B (different from uc ) is routed in the way uB was routed (see Fig. 4a), only if the front and/or back free directions of v are available. If neither of these two free directions of v is available, then the edge coming from B’s origin (different from uc) is routed to the right free direction of v using the First Fundamental Route. Edges coming from the origins of Bmax are routed using the First, Second, and Third Fundamental Routes. Two new planes pc and p0c are inserted so that pc is to the right of the rightmost plane of the current drawing and p0c is parallel to p3 and one unit to the top of it. Edge (uc , v) is routed with three bends (see Fig. 4b) as follows: uc → pc → p0c → p1 → v. The top free direction of uc is not available, so there can be no future edge incident to uc crossing edge (uc , v). Finally, note that since placing v and routing edge (ua , v) requires only two new planes (i.e., p1 , p3 ), the total number of new planes that we open up in order to route all six of v’s incident edges is at most eight.
3.3
Routing Properties - Analysis
Placing a new vertex v and routing its incident edges has several cases which were described in detail in the previous subsection. We believe that this description of all the involved cases was necessary especially if this algorithm is to be implemented. We saw that vertex v is usually placed at the intersection point of three planes, at least two of which are new. Placing a vertex v directly to the top of vertex u (when routing edge (u, v)) happens only when u had current degree 5 before this edge insertion. This way, edges that enter u and v from their same plane free direction cannot cross. In any other case that two vertices have the same either x or y-coordinate, the one with the lower z-coordinate does not have an available top free direction (see Routing Case 3). Note that, although it is possible for two vertices to have the same x and/or y-coordinate, there are never two vertices with the same z-coordinate. An important feature of our edge routing technique is that no two edges cross. The route of each edge is naturally decomposed in three different stages. Let us consider an edge e from u to v, where v is the vertex most recently placed in the drawing. The first stage contains the portion of the route that lies entirely in plane pz,u . This portion consists of a straight line segment that goes all the way until it hits a new plane positioned outside the current drawing. This line segment does not cross any other edges in its way, because no available free direction is ever blocked. When it hits the new plane, the line segment of the first stage may bend staying always in plane pz,u . This new segment does not cross any other edge either, since it runs entirely outside the current drawing. In the second stage, we have the portion of the route consisting of a straight line segment running
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 95 vertically from plane pz,u to plane pz,v . This segment always lies entirely outside the current drawing, so it does not cross any other edge. Finally, the third stage consists of the portion of the route that runs entirely in plane pz,v . This portion is typically a straight line segment entering v. If this portion needs to have one or two bends in plane pz,v , then the routing is done without (a) crossing portions of other edges lying in pz,v , and (b) blocking v’s free directions that may be used in the future (see Same-Plane Route and Routing Case 3). If there is a portion of the third stage lying in px,v or py,v , then it does not cross line segments of other edges that are perpendicular to pz,v since neither px,v nor py,v can be used to route edges that are not incident to v. The only exception to this would be the case where there was a vertex w so that v was placed directly to the top of w. But in that case, w would have degree 6 that is no future incoming vertices will be adjacent to it. If there is a portion s of the third stage lying in px,u or py,u , then we distinguish two cases: In the first case, edge e leaves u from its top free direction. The portion of any future edge (u, v0 ) which is perpendicular to pz,v will lie outside the current drawing, so it cannot cross s. In the second case, edge e leaves u from one of its plane free directions (in other words, we have Routing Case 3). In this case, u’s top free direction was used in the past to route some other edge e0 . The whole route of e0 lies entirely below v, so no portion of this route can cross s. Hence we have: Lemma 1 Our routing technique for 3-D orthogonal graph drawing guarantees that each edge has at most three bends and no two edges cross (in a current drawing). In order to measure the volume of the current 3-D drawing at time t, we count the total number of planes that were inserted in the drawing up to time t. Placing v and routing edge (ua , v) requires two or three new planes. Routing any other edge (ui , v) (where ui is not the cover) adds at most one new plane. Routing edge (uc , v) requires one or two new planes. However, whenever two new planes are required to route edge (uc , v), placing v and routing edge (ua , v) requires only two new planes (see Routing Case 3). From this it follows that if v’s local degree is l ≥ 1, then at most l + 2 new planes need to be inserted when v is placed in the current drawing. Vertex v2 (i.e., the second vertex to be inserted in the drawing) is the only exception and requires four new planes, although it has local degree 1 (see Fig. 2a). Let n1 (t), n2 (t), n3 (t), n4 (t), n5 (t), n6 (t) be the total number of vertices with local degree 1, 2, 3, 4, 5, 6, respectively, and n(t) be the total number of vertices of the current drawing at time t. Also recall that v1 (i.e., the first vertex to be inserted) introduces three planes. If P (t) is the total number of planes inserted in the drawing at time t, then we have: P (t) ≤
3 + 3n1 (t) + 1 + 4n2 (t) + 5n3 (t) + 6n4 (t) + 7n5 (t) + 8n6 (t)
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 96 ≤
(n1 (t) + 2n2 (t) + 3n3 (t) + 4n4 (t) + 5n5 (t) + 6n6 (t)) +(2n1 (t) + 2n2 (t) + 2n3 (t) + 2n4 (t) + 2n5 (t) + 2n6 (t)) + 4
≤ ≤
3n(t) + 2(n(t) − 1) + 4 5n(t) + 2.
Let Px (t), Py (t), Pz (t) be the total number of planes perpendicular to the x, y, zaxes, respectively, inserted in the current drawing up to time t, so that Px (t) + Py (t) + Pz (t) = P (t). The volume V (t) of the current drawing at time t is: V (t) = (Px (t) − 1) × (Py (t) − 1) × (Pz (t) − 1), and it is maximized when: . From this it follows that V (t) ≤ Px(t) = Py (t) = Pz (t) = P 3(t) = 5n(t)+2 3 5n(t)+2 5n(t) 3 3 3 − 1) ≤ ( 3 ) ≈ 4.63n (t). ( 3 Clearly, each edge route has a constant number of bends and each vertex insertion requires a constant number of planes to be added to the current drawing. However, in order to guarantee constant time when a plane is inserted at a particular position in the middle of the current drawing, we have to use the data structure by Dietz and Sleator [9]. A vertex insertion can be completed in constant time as long as the system does not have to produce the new drawing. If a drawing is required, then the time is linear per vertex insertion operation. From the above discussion and Lemma 1 we have: Theorem 1 There is a 3-D orthogonal graph drawing algorithm for graphs of maximum degree 6 that allows on-line vertex insertion so that the following hold at any time t: • after each vertex insertion, the coordinates of any vertex or bend of the current drawing shift by a small constant amount of units along the x, y, zaxes, effectively maintaining the general shape of the drawing, • there are at most three bends along any edge, • no two edges cross, • the volume of the drawing is at most 4.63n3(t), where n(t) is the number of vertices in the drawing at time t, and • vertex insertion takes constant time (if the screen needs to be refreshed after each vertex insertion, then it takes linear time). Our incremental algorithm can be used to produce a 3-D orthogonal drawing of a graph by first numbering its vertices and then inserting each vertex one at a time, according to its number. A numbering with the following property will guarantee that each placed vertex has local degree at least 1: If j (j > 1) is the number assigned to vertex vj , then there is at least one edge (vi , vj ) in the graph, where i < j. Consider the directed acyclic graph that results from the given graph when each edge is directed from the lower to the higher
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 97
7 5 6
4
3
2
1
Figure 5: 3-D orthogonal drawing of K7 produced by our algorithm. numbered vertex. What the above condition means is that the resulting directed graph has one source and at least one sink. A simple Depth-First-Search (DFS [14]) or Breadth-First-Search (BFS [14]) can provide such a numbering for any connected graph. Hence we have the following: Theorem 2 Consider an n-vertex connected graph G of maximum degree 6. There is a linear time algorithm that produces a 3-D orthogonal drawing of G, so that each edge has at most three bends, no two edges cross, and the volume of the drawing is at most 4.63n3. In Fig. 5 we show the 3-D orthogonal drawing of K7 produced by our algorithm. The numbers in the vertices denote the order in which the vertices were inserted. The volume of this drawing is 8 × 8 × 8 = 512 ≤ 1.5n3 , where n = 7. Observe that out of K7 ’s 21 edges, there is one edge with no bends, 12 edges require two bends each, and the remaining eight edges are routed with three bends each. The algorithm has been implemented within 3DCube [29] and we present preliminary experimental results in the Conclusions.
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 98
4
A Model for Vertices of High Degree
In this section we describe a model to support high degree interactive three dimensional orthogonal graph drawing based on the Relative-Coordinates scenario. Our model allows vertices to arrive on-line and the degree of the vertices to increase arbitrarily. At any time there is a change in the drawing, our target is to maintain the general shape of the current drawing. Our model and the drawing algorithm which is based on it, apply also to non-interactive settings. In these settings, the whole graph is known in advance and the user provides the order in which the vertices are considered for placement. The first issue that has to be addressed is the way that vertices are represented. In the previous section, it sufficed to map vertices to points in space since the degree of any vertex was at most 6 at any time during the drawing process. Clearly, we now need a different approach to accommodate arbitrary vertex degrees. We choose to represent vertices using 3-D boxes of volume (initially) at least one cubic unit, regardless of the degree of the vertices. When a vertex is inserted into the drawing, it is represented by a cubic box with size depending on the degree of the vertex. Edges that are adjacent to a vertex are attached to the surface of its box. The points on the box surface where edges can be attached are called connectors, and they have integer coordinates. Each box has six sides, and each side is a rectangle parallel to one of the base planes. If d × d0 is the size of one side of a box, then both d and d0 are integers and there are (d + 1)(d0 + 1) connectors on this side. Let us consider a vertex v and the box that represents it. The two sides of the box that are parallel to the xy-plane are called top and bottom sides, with top being the side located at a higher z-coordinate between the two. The two sides parallel to the yz-plane are called left and right sides, with right being the side located at a higher x-coordinate between the two. Similarly, the remaining two sides are the front and back sides, with back being the side located at a higher y-coordinate between the two. The six sides of box v are shown in Fig. 6a, and the connectors of the front side are shown in Fig. 6b, where v is a 4 × 4 × 4 cube. Note that all connectors located along the line where two sides meet are shared by both sides. Also, the single connector located at the point where three sides meet is shared by all three sides. The distance between the left and right sides is called length of the box. Similarly, the distance between the front and back sides is called width, and the distance between the top and bottom sides is called height of the box. In a d1 × d2 × d3 box the length is d1 , the width is d2 and the height is d3 . Edge routing follows the Relative-Coordinates scenario, and tries to keep both volume and number of bends as low as possible. However, as a result of this routing, edges may require to attach to specific sides of incident boxes. If there are no available connectors on that side, we need to grow the box creating new connectors on that side. Our model for representing vertices in 3-D space
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999) 99
(a)
(b)
Figure 6: (a) Every box has six rectangular sides, (b) front side connectors of a box. supports box growing. Let us assume that we have a d1 × d2 × d3 box representing vertex v. There are two ways to grow a box by increasing its length: one way is to increase the length towards the right direction (see Fig. 7a), and the other is to increase the length towards the left direction (see Fig. 7b). In either case, the result is a (d1 + 1) × d2 × d3 box v. Also notice that the resulting box has: • d2 − 1 new connectors on its top side, • d2 − 1 new connectors on its bottom side, • d3 − 1 new connectors on its front side, • d3 − 1 new connectors on its back side, • one new connector shared by the top (bottom) and back (front) sides, • one new connector shared by the top (bottom) and front (back) sides. Similarly, we can grow box v by increasing its width by one unit (towards the front or the back direction), or its height by one unit (towards the top or the bottom direction). Regardless of the way we choose to grow a box, we always insert a new plane in the middle of the current 3-D drawing. This insertion affects the coordinates of some connectors and bends which shift by one unit along the x, y or z-axes. The general shape of the drawing, though, remains the same. Finally, note that although the box of every vertex starts out having a cubic configuration (when it is inserted for the first time), this is not necessarily the case later. This happens because a box may grow its size in several different ways in the course of the drawing process.
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)100
d2
d3 d1 (a)
(b)
Figure 7: (a) Increasing the length of a box towards the (a) right or (b) left direction creates new connectors.
5
Drawing Graphs of High Degree
In this section we present a drawing algorithm based on the Relative-Coordinates scenario for producing orthogonal drawings of graphs in the three dimensional space. Since this algorithm allows vertices to arrive on-line, the order of vertex insertion is decided by the user. In order to simplify our presentation, we assume that the local degree of any vertex that is about to be inserted cannot be greater than 16. We will discuss how to easily generalize our technique at the end of this section. We compute bounds on the volume and the total number of bends that each (current) drawing requires at time t, when we start the drawing from scratch. A typical user request consists of the name of the vertex to be inserted, say v, and a list of its adjacent vertices in the current drawing. Our algorithm produces a 3-D drawing considering and placing one vertex at a time. The placement of vertex v follows the Relative-Coordinates paradigm. In other words, it tries to maintain the general shape of the current drawing after v is inserted. For this reason, the selection of the position where v will be placed depends on the following factors: • Vertex v’s local degree. • The connector availability situation on the sides of the boxes of v’s adjacent vertices. • The relative position of v’s adjacent vertices in the current drawing.
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)101
5.1
Placing a New Vertex
Again, assume that v is the next vertex to be inserted in the current 3-D drawing. Let k (k ≤ 16) be v’s local degree, and let u1 , u2 , · · · uk be v’s adjacent vertices. For each vertex ui we find the sides of box ui that have available connectors. Recall that some connectors are shared by two or even three sides. Then we find the side of the adjacent boxes on which most of these boxes have at least one available connector. This is the side where the edges connecting v with each ui will be attached. For example, assume that k = 10, there are three adjacent boxes that have available connectors on their back side, and for any other side (i.e., top, bottom, right, left, front) there are no more than two adjacent boxes having available connectors on that side. Then, for each one of the ten adjacent boxes, the edge that connects this box with v will attach to a back side connector of that box. If there is any adjacent box which does not have available connectors on its back side, then we grow the box. This can be done by increasing either the length or the height of the box by one unit, as described in the previous section. Such an increase will create more than one connectors which lie not only on the back side but on other sides as well. These connectors may be used at a later stage. The next step is to create the box representing v and place it in the current 3-D drawing. Box v is a 1 × 1 × 1 cube. Each newly inserted box is placed in such a way so that none of its connectors have the same x, y or z-coordinate as any other connector of any box of the current drawing. This means that our 3-D drawing has the property that there are no two connectors of two different boxes lying on a plane parallel to a base plane. We call this the no-commonplane property of the 3-D drawing. Next we show how v’s exact position in the drawing is calculated so that this property is maintained. For the sake of description, let us consider the case where all k edges connecting v with its adjacent vertices attach to the back sides of these vertices. Also, let c1 , c2 , · · · ck be the connectors of the adjacent boxes where these edges will be attached. We insert a new plane p0 to the back of the backmost plane of the current drawing (clearly, p0 is parallel to the xz-plane). We compute the projections of connectors c1 , c2 , · · · ck on the xz-plane. Because of the no-common-plane property, there are no two projection points sharing the same row or column in the xz-plane. We find the projection point c0i whose x-coordinate is the median of the x-coordinates of all projection points; if there are two medians, we take the one with the higher x-coordinate. Also, we find the projection point c0j whose z-coordinate is the median of the zcoordinates of all projection points; in case there are two medians, we take the one with the higher z-coordinate. Note that it is possible for c0i and c0j to be the same point. In Fig. 8a we show points c0i and c0j chosen from a set of 11 points placed in the xz-plane. If c0i is the projection of connector ci located on the back side of box ui , we insert a new plane pi in the 3-D drawing parallel to the left side of ui at a
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)102
c ’i
c ’i c’ j
c ’j
v
xz-plane xz-plane (a)
(b)
Figure 8: (a) Choosing the median points along x and z-axes, (b) projection of v’s position and connectors on xz-plane. distance of one unit from that. If c0j is the projection of connector cj located on the back side of box uj , we insert a new plane pj in the 3-D drawing parallel to the bottom side of uj at a distance of one unit from that. The three planes p0 , pi and pj intersect at a single point. This is the point where the connector shared by the top, right and front sides of box v is going to be placed. Notice that the exact coordinates of a specific connector of box v determine the location of v. We open up new planes (if required) in the middle of the drawing to accommodate the size of v. Figure 8b shows the relative position of v and the 11 projection points of the example of Fig. 8a. Note that Fig. 8b is the projection of that portion of the 3-D drawing on the xz-plane. Notice that there are no two points (with at most one of them belonging to box v) sharing the same row or column in the xz-plane (i.e., no-common-plane property). Similarly, we compute the coordinates of a newly inserted box v in the cases where all connectors c1 , c2 , · · · ck lie on the top, bottom, front, right or left sides of v’s adjacent vertices. From the above discussion regarding the position where a new vertex is inserted, we have the following three propositions: Proposition 5.1 At any time t, the 3-D drawing has the no-common-plane property, that is there is no plane parallel to one of the three base planes containing two connectors of two different boxes. Proposition 5.2 If c1 , c2 , · · · ck are the connectors of the adjacent boxes of a newly inserted vertex v where v’s incident edges will be attached, then all these
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)103 connectors lie on the ‘same’ side of their boxes (i.e., they are all either on the top, bottom, right, left, front, or back sides of their boxes). Proposition 5.3 Consider the case of placing a new vertex v with local degree k, so that the edges connecting v with its adjacent vertices attach to the back sides of the boxes of the adjacent vertices. Compute the projections of v and the connectors of the adjacent boxes where the edges attach, on the xz-plane. The following hold: • there are d k2 e (b k2 c) projection points lying strictly above (below) v’s top (bottom) side, • there are d k2 e (b k2 c) projection points lying strictly to the right (left) of v’s right (left) side. This generalizes accordingly depending on the way the new vertex v is placed in the 3-D drawing.
5.2
Routing Edges with Two Bends
The step that concludes the insertion of v is routing the edges that connect v with its adjacent vertices. For each edge ei we have that one endpoint of the edge is connector ci of adjacent box ui , and the other endpoint is a connector of some side of v. The portion of edge ei between its two endpoints is routed in an orthogonal fashion in three dimensional space. In the description that follows, we assume that v has been placed as described above, and we continue with the routing of v’s incident edges. Let us first route the edges that come from connectors having z-coordinate greater than the z-coordinate of any point on v’s top side. Because of the no-common-plane property, some of these connectors have x-coordinate smaller than the x-coordinate of any point on v’s left side, and the remaining connectors have x-coordinate greater than the x-coordinate of any point on v’s right side. We call the connectors of the first group outleft, and the connectors of the second group outright. Assume that the outleft connectors are fewer than the outright ones; this dke means that the number of the outleft connectors is less than d 22 e. Since k can be at most 16, we have that the outleft connectors are at most four, which is the maximum number of connectors lying on a single side of box v. The edges that start from outleft connectors are routed to connectors lying on the top side of box v. More specifically, let us route edge ei from outleft connector ci to connector cv of v (see Fig. 9a). From connector ci , we draw a straight line parallel to the y-axis that intersects plane py,cv at point bi forming a right angle. Then we draw another straight line from bi along plane py,cv and parallel to the x-axis, that intersects plane px,cv at point b0i forming a right angle. Then, we simply
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)104
bi
b’i
cv
v ei c
cv
v
ei c
i
(a)
bi b’i
i
(b)
Figure 9: Routing edges to the top side of box v when ci is to the (a) left and (b) right of v. draw a straight line between b0i and connector cv . The full route is depicted in Fig. 9a. Observe that it follows the orthogonal paradigm. Also, edge ei has exactly two bends, one at point bi and one at point b0i . Connector cv of v is picked so that line segment bi b0i does not block the top free direction of any other connector of v (see Fig. 9a). Also, if it turns out that there is a connector c0i of box ui whose back free direction is blocked by line segment bi b0i , then we use c0i as the other endpoint of edge ei instead of ci . The edges that start from the remaining outleft connectors are routed in a similar fashion, that is with exactly two bends per route. The edges that start from the outright connectors are routed to connectors of the top side of box v that are still available, and the routing is done in the way described above. If there are still outright connectors whose edges have not been routed, then these edges are routed to connectors of the right side of v. In Fig. 9b we show an example of the routing of such an edge. Notice that the routing can still be done with two bends, and the line between the two bends is parallel to the z-axis. If there are fewer outright than outleft connectors, then we first route the edges of the outright connectors to the top side of v, and then the edges of the outleft connectors to the top and (if necessary) left side of v. In either case, from Proposition 5.3 and the fact that v’s local degree is at most 16, it follows that routing the edges of all the outleft and outright connectors requires at most two sides of v. So far in this subsection we have discussed how to route edges that come from outleft and outright connectors with z-coordinates greater than the z-coordinate of any point on v’s top side. We follow a similar procedure to route the edges coming from connectors whose z-coordinates are lower than the z-coordinate of any point on v’s bottom side. This means that we first split these connectors into outleft and outright ones, find which one of the two sets has the smallest
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)105 cardinality, and then route the individual edges using the connectors lying on the other two sides of v. After the end of the routing of all incident edges of v, the insertion operation of v is complete. We used a specific situation for the position of v in order to describe our edge routing technique. It is easy to generalize this technique to any other case of box positioning in the 3-D drawing, as long as the principles and properties described in the following routing lemma are maintained: Lemma 2 Let v be the next vertex to be inserted in a 3-D drawing. Let e be the edge connecting v with its already placed adjacent vertex u. Let connector cu of u be one endpoint, and connector cv of v be the other endpoint of edge e. Also, let fdcu and fdcv be cu ’s and cv ’s free directions, respectively, used by e. The following hold: 1. If connector cu belongs to side su which is perpendicular to fdcu and connector cv belongs to side sv which is perpendicular to fdcv , then the planes containing sides su and sv are perpendicular to each other. 2. Edge e connecting cu and cv is routed orthogonally with exactly two bends. 3. If b1 is the bend adjacent to connector cu and b2 is the bend adjacent to connector cv then: • if is the straight line perpendicular to side su at point cu and p is the plane parallel to side su containing cv , then bend b1 lies at the intersection of line and plane p, • if 0 is the straight line of plane p parallel to side sv containing bend b1 and 00 is the straight line of plane p perpendicular to side sv containing point cv , then bend b2 lies at the intersection of lines 0 and 00 , • line segment b1 b2 does not block the free direction of any other connector of u and v. 4. The connectors of v used for routing all v’s incident edges lie on at most four sides of v.
5.3
No-Crossing Routing
Our routing scheme guarantees that each edge of every newly inserted vertex v can be routed so that there are no edge crossings in the resulting 3-D drawing. In order to show this, we first give some definitions. Each edge consists of three straight line segments since it has two bends (see above lemma). We call these line segments legs. More specifically, a leg with a connector as one of its two endpoints is called an end leg, and a leg whose both endpoints are bend-points is called a middle leg. Let v be the next vertex to
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)106 be inserted and e be the edge between v and an adjacent vertex u (u is already placed). We insert v and route e, according to the algorithm. We show that no leg of edge e crosses a leg of any edge of the current drawing. Recall that if two line segments cross each other, then the four endpoints of the two segments lie in the same plane. Because of the no-common-plane property (see Proposition 5.1), it is never the case that an end leg of e crosses an end leg of any other edge of the current drawing. Otherwise we would have two connectors of two different boxes lying in a plane which is parallel to one of the base planes.
cr e
cr
e’
e’ e
u
v
p (a)
(b)
Figure 10: Crossings occurring when e blocks the free direction of other connectors. The middle leg of edge e lies completely outside the current drawing. Because of this, it does not cross a leg of any other edge of the current drawing. Also, since the middle leg of edge e does not block the free direction of any connector of boxes u and v, crossing situations similar to the ones shown in Fig. 10 cannot happen. Figure 10a shows a situation where e blocks the back free direction of some connector of u, and Fig. 10b shows a situation where e blocks the top free direction of some connector of v. If a future edge e0 uses these connectors, then e and e0 will cross at point cr . Therefore we have: Lemma 3 There are no edge crossings in any 3-D orthogonal drawing produced using the techniques for vertex placement and edge routing described in the previous sections.
5.4
Volume and Bend Analysis
From the discussion in previous subsections we have that if m(t) is the total number of edges in the drawing at time t, then the drawing has 2m(t) bends. In what follows we express both the bends and the volume of the drawing in terms of the number of vertices n(t) and the average vertex degree da (t) at time t.
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)107 We have assumed that every time a new vertex is inserted, its local degree is at most 16. Since this is the case, every vertex is represented by a 1 × 1 × 1 box the moment it is placed in the drawing. Clearly, when a new box is placed, we open up two new planes parallel to each one of the three base planes. In other words, each of the length, width, and height of the drawing increases by two units. When a new box is placed, we may have to grow the boxes of some adjacent vertices. We insert a new plane in the drawing when we grow a box. In the worst case, we have to grow the boxes of all adjacent vertices of each vertex inserted in the drawing up to time t. Assume that dloc is the local degree of some newly inserted vertex, so that dloc ≤ 16. Let l, w and h be the numbers of new planes we open up as a result of vertex growth, parallel to the yz-plane, xz-plane, and xy-plane, respectively. In the worst case we have that: l + w + h = dloc . Lemma 4 Let r be a positive number; let d be a positive constant so that integer variables x, y and z satisfy: x + y + z = d, where x, y, z ≥ 0. Then it holds that: (r + x)(r + y)(r + z) ≤ (r + d3 )3 . Proof. It is well known that if we have three positive numbers a, b, c and a positive constant s, then it always holds that: abc ≤ ( s3 )3 as long as a+b+c = s. If we set: a = r + x, b = r + y, c = r + z and s = 3r + d, we have the above lemma. 2 The first vertex inserted to an empty drawing is a 1×1×1 cube, so the volume of the drawing after this insertion is 13 = 1. Let the volume of the current drawing right before the insertion of new vertex v be at most r 3 . Then the 3 volume of the resulting drawing after the insertion of v is at most (r + dloc 3 + 2) (see Lemma 4). The number 2 in the expression giving the volume comes from the size of the box of inserted vertex v. Routing v’s incident edges does not affect the volume since all these edges are routed along existing planes. Also note that the above expression for the volume holds even if inserted vertex v has local degree 0. Theorem 3 There is an algorithm to produce 3-D orthogonal drawings of graphs (not necessarily connected) which allows vertices to arrive on-line. Each inserted vertex is adjacent to at most 16 other vertices at the time of insertion. The drawings have the following properties at any time t: • vertices are represented by boxes and the surface of each box is at most six times the current degree of the vertex, • each edge has two bends, • no two edges cross, +2n(t))3 , where m(t) and n(t) are the number of edges • the volume is ( m(t) 3 and vertices in the drawing at time t, respectively, and
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)108 • vertex insertion takes constant time. Proof. From the description of edge routing in Section 5.2 and Lemma 2 we have that every edge in the drawing has two bends. From Lemma 3 it follows that no two edges cross at any time t during the drawing process. For every box v in the drawing, v’s incident edges attach to connectors located on the sides of the box. Box v grows only when there are no available connectors on the side of v where one of v’s incident edges needs to attach. The worst case happens when v’s incident edges always attach to the same side of v; let sv be this side. Also, let t be the current time and degt (v) be the current degree of v. The surface of side sv is at most degt (v), and the total surface of all sides of v is at most 6 × degt (v). We saw above that the volume of the 3-D orthogonal drawing after the insertion of a vertex v is at most (r + dloc3(v) + 2)3 , where r 3 is the volume before the insertion and dloc (v) is v’s local degree. Let m(t) be the number of edges in the drawing at time t and G(t) be the underlying graph. It holds P dloc (v) = m(t) . Hence, we obtain the upper bound shown in the that: v∈G(t) 3 3 theorem for the volume of the drawing. Let v be the next vertex to be inserted into the current drawing. Creating a box for v and placing v takes constant time. At most dloc (v) other boxes of the current drawing need to grow and exactly dloc (v) edges are routed as a result of v’s insertion. Growing a box and routing an edge takes constant time, therefore v’s insertion takes O(dloc (v)) time. Since dloc (v) ≤ 16, this time is constant. 2 In practice, we expect the volume to be smaller than the upper bound given in the above theorem. This is because our analysis assumed that for each vertex insertion the boxes of all the adjacent vertices had to grow. We expect a box to grow very infrequently, since each box has several connectors on its sides. by the drawing If da (t) is the average vertex degree of the graph represented P degt (v)
v = 2m(t) at time t, we have that da(t) is given by: da (t) = n(t) n(t) , where degt (v) is the degree of vertex v at time t. Another expression for the volume of the drawing is given by the following corollary:
Corollary 5.1 If the average vertex degree at time t is da (t), then a 3-D orthogn(t))3 , in addition onal drawing produced by our algorithm has volume ( da (t)+12 6 to the properties discussed in Theorem 3. It is worth noting that, in terms of volume, the performance of this algorithm for graphs of average degree 6, is the same or better than the one of the algorithm in [13]. For example, if the average vertex degree is 6, the volume of the drawing is at most (3n)3 , which is the same as the exact volume required by the algorithm in [13] for 3-D orthogonal graph drawing. However, the drawing approach of [13] represents vertices with points, handles only vertices of degree at most 6, allows three bends per edge, and requires that the whole graph be known in advance.
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)109 The algorithm for 3-D orthogonal graph drawing and the analysis we presented in this section apply to the case of a non-interactive setting as well. In this case, the whole graph is known ahead of time. Our algorithm produces a 3-D orthogonal drawing of the graph in O(m) time (m is the number of edges in the graph), as long as it is supplied with any vertex numbering. This numbering determines the order of vertex placement. Figure 11 shows the 3-D orthogonal drawing of K5 as produced by our algorithm. The box numbers denote the vertex insertion order.
4
2
5 3
1
Figure 11: 3-D orthogonal drawing of K5 representing vertices with boxes. If we allow the insertion of a vertex v having local degree higher than 16, then the only thing that changes in the above algorithm is the size of the box representing v. Recall that a new box placed in the current drawing is always of cubic configuration. In addition to that, its incident edges attach to at most four of its six sides. A 2 × 2 × 2 cube has nine connectors on each side and can represent a vertex with local degree at most 36. Similarly, a 3 × 3 × 3 cube has 16 connectors on each side and can represent a vertex with local degree at most 64. In this way, we can accommodate the insertion of a vertex of any local degree. The insertion of a 2×2 ×2 box requires opening up three new planes parallel to each one of the base planes (nine new planes total). Similarly, the insertion of an r × r × r box requires opening up r + 1 new planes parallel to each one
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)110 of the base planes (3(r + 1) new planes total). From the volume analysis we presented in this subsection, we have that the general formula for the volume 3 2 2 is: V ≤ ( m 3 + 2n1..16 + 3n17..36 + · · · + rn4(r−1) +1..4r + · · ·) , where ni..j is the number of vertices in the current drawing at time t with local degrees in the range from i to j.
6
Conclusions and Open Problems
We presented two incremental algorithms for producing orthogonal graph drawings in three dimensional space with no edge crossings. The first algorithm deals with simple graphs of maximum degree 6. For any n-vertex graph, the produced drawing has volume at most 4.63n3. No edge has more than three bends. This improves the best known [13] volume requirement of exactly 27n3 significantly, while maintaining the same upper bound for the number of bends per edge. It is also important to underline that our algorithm requires linear time to produce a 3-D orthogonal drawing of an n-vertex graph, 3 whereas the algorithm in [13] runs in O(n 2 ) time. The algorithm has been implemented within 3DCube [29] along with the algorithms of [12, 13, 21] and a new algorithm introduced in [29]. The discussion here is based on the preliminary experimental results of the implementation of our algorithm sent to us by Maurizio Patrignani [30]. He applied our algorithm on 1920 random, simple, connected graphs of maximum degree 6, such that the number of edges is always twice the number of nodes. More extensive results on several 3D orthogonal algorithms will be presented in a forthcoming paper [30]. The graphs of the experimental results are presented in Figs. 12 and 13. These preliminary results indicate that: • the volume is on the average 1.5n3 + O(n2 ), • for medium and large size graphs the average number of bends per edge is about 2.25, and • as expected, the average edge length grows linearly with respect to the number of nodes. The second algorithm introduces 3-D orthogonal drawing for simple graphs of degree higher than 6. Vertices are represented by solid 3-D boxes whose surface is proportional to the degree of the vertex. The number of bends per edge is only two. Improving our volume upper bounds is a natural open problem. Although there have been better volume upper bounds [13] at the expense of allowing more bends per edge (seven bends per edge are allowed in [13]), cubic upper bounds are the best known so far when we allow at most three bends per edge. It is clear that there is a trade-off between volume and number of bends per edge, or between volume and edge crossings. Determining the trade-offs is a
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)111
1.6e+06 1.4e+06 1.2e+06
Volume
1e+06 800000 600000 400000 200000 0 0
10
20
30
40
50 60 Nodes
70
80
90
100
50 60 Nodes
70
80
90
100
(a) 2.5
Average Bends per Edge
2.45
2.4
2.35
2.3
2.25
2.2 0
10
20
30
40
(b) Figure 12: Graphs of the experimental findings: (a) volume; (b) bends.
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)112
100 90
Average Edge Length
80 70 60 50 40 30 20 10 0 0
10
20
30
40
50 60 Nodes
70
80
90
100
Figure 13: Graphs of the experimental findings: edge length. very interesting problem. Finally, if one restricts his/her attention to drawings of graphs that are known ahead of time, is there a numbering of the vertices that guarantees better performance with respect to volume and/or other aesthetic measures?
Acknowledgements We would like to thank Maurizio “Titto” Patrignani for sharing with us the valuable experimental results of his implementation of our algorithm; also, we would like to thank Janet Six for useful discussions, and the referees for their thorough reading of the paper and their useful comments that improved the presentation of the algorithms.
References [1] H. Alt, M. Godau, S. Whitesides, Universal 3-Dimensional Visibility Representations for Graphs, Comput. Geom. Theory Appl., 9:111-125, 1998.
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)113 [2] T. Biedl and G. Kant, A Better Heuristic for Orthogonal Graph Drawings, Proc. 2nd Ann. European Symposium on Algorithms (ESA ’94), Lecture Notes in Computer Science, vol. 855, pp. 24-35, Springer-Verlag, 1994. [3] P. Bose, H. Everett, S. Fekete, M. Houle, A. Lubiw, H. Meijer, K. Romanik, G. Rote, T. Shermer, S. Whitesides, and C. Zelle. A visibility representation for graphs in three dimensions, J. Graph Algorithms Appl., 2:1-16, 1998. [4] M. Brown and M. Najork, Algorithm animation using 3D interactive graphics, Proc. ACM Symp. on User Interface Software and Technology, 1993, pp. 93-100. [5] I. Bruß and A. Frick, Fast Interactive 3-D Visualization, Proc. of Workshop GD ’95, Lecture Notes in Comp. Sci. 1027, Springer-Verlag, 1995, pp. 99110. [6] M. Chrobak, M. Goodrich, and R. Tamassia, Convex drawings of graphs in two and three dimensions, Proc. 12th Annual ACM Symposium on Computational Geometry, 1996, pp. 319-328. [7] R. Cohen, P. Eades, T. Lin, F. Ruskey, Three Dimensional Graph Drawing, Algorithmica, 17:199-208, 1997. [8] I. Cruz and J. Twarog, 3D Graph Drawing with Simulated Annealing, Proc. of Workshop GD ’95, Lecture Notes in Comp. Sci. 1027, Springer-Verlag, 1995, pp. 162-165. [9] P. F. Dietz and D. D. Sleator, Two algorithms for maintaining order in a list, Proc. 19th Annual ACM Symp. Theory of Computing, 1987, pp. 365-372. [10] G. Di Battista, P. Eades, R. Tamassia and I. G. Tollis, Graph Drawing, Prentice Hall, 1999. [11] D. Dodson, A Tool for Information Visualization using Co-operative 3D Diagram Layout, Proc. of Workshop GD ’95, Lecture Notes in Comp. Sci. 1027, Springer-Verlag, 1995, pp. 190-201. [12] P. Eades, C. Stirk, S. Whitesides, The Techniques of Kolmogorov and Bardzin for Three Dimensional Orthogonal Graph Drawings, Information Processing Letters, 60:97-103, 1996. [13] P. Eades, A. Symvonis, S. Whitesides, Two Algorithms for Three Dimensional Orthogonal Graph Drawing, Proc. of GD ’96, Lecture Notes in Comp. Sci. 1190, Springer-Verlag, 1996, pp. 139-154. [14] S. Even, Graph Algorithms, Computer Science Press, 1979.
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)114 [15] S. Even and G. Granot, Grid Layouts of Block Diagrams — Bounding the Number of Bends in Each Connection Proc. DIMACS Workshop GD ’94, Lecture Notes in Comp. Sci. 894, Springer-Verlag, 1994, pp. 64-75. [16] S. Fekete, M. Houle, S. Whitesides, New Results on a Visibility Representation of Graphs in 3D, Proc. of Workshop GD ’95, Lecture Notes in Comp. Sci. 1027, Springer-Verlag, 1995, pp. 234-241. [17] A. Garg and R. Tamassia, GIOTTO3D: A System for Visualizing Hierarchical Structures in 3D, Proc. of GD ’96, Lecture Notes in Comp. Sci. 1190, Springer-Verlag, 1996, pp. 193-200. [18] A. Garg, R. Tamassia, and P. Vocca, Drawing with colors, Proc. 4th Annual European Symposium on Algorithms (ESA ’96), Lecture Notes Comp. Sci. 1136, Springer-Verlag, 1996, pp. 12-26. [19] T. Kamada and S. Kawai, An algorithm for drawing general undirected graphs, Inf. Proc. Letters 31, (1989), 7-15. [20] G. Kant, Drawing Planar Graphs Using the Canonical Ordering, Algorithmica, vol. 16, no. 1, 1996, pp. 4-32. [21] A. N. Kolmogorov and Y. M. Bardzin, About Realization of Sets in 3dimensional Space, Problems in Cybernetics, 1967, pp. 261-268. [22] J. MacKinley, G. Robertson, S. Card, Cone Trees: Animated 3d visualizations of hierarchical information, In Proc. of SIGCHI Conf. on Human Factors in Computing, pp. 189-194, 1991. [23] A. Papakostas and I. G. Tollis, Improved Algorithms and Bounds for Orthogonal Drawings, Proc. DIMACS Workshop GD ’94, Lecture Notes in Comp. Sci. 894, Springer-Verlag, 1994, pp. 40-51. [24] A. Papakostas and I. G. Tollis, Algorithms for Area-Efficient Orthogonal Drawings, Computational Geometry Theory and Applications, 9 (1998), 83-110. [25] A. Papakostas and I. G. Tollis, Issues in Interactive Orthogonal Graph Drawing, Proc. of Workshop GD ’95, Lecture Notes in Comp. Sci. 1027, Springer-Verlag, 1995, pp. 419-430. [26] A. Papakostas and I. G. Tollis, Interactive Orthogonal Graph Drawing, IEEE Transactions on Computers, vol. 47, no. 11 November 1998, pp. 12971309. [27] A. Papakostas and I. G. Tollis, A Pairing Technique for Area-Efficient Orthogonal Drawings, Proc. of GD ’96, Lecture Notes in Comp. Sci. 1190, Springer-Verlag, 1996, pp. 355-370.
Papakostas and Tollis, Incremental 3-D Drawing, JGAA, 3(4) 81-115 (1999)115 [28] A. Papakostas, J. Six, and I. G. Tollis, Experimental and Theoretical Results in Interactive Graph Drawing, Proc. of GD ’96, Lecture Notes in Comp. Sci. 1190, Springer-Verlag, 1996, pp. 371-386. [29] M. Patrignani and F. Vargiu, 3DCube: A Tool for Three Dimensional Graph Drawing, Proc. of GD ’97, Lecture Notes in Comp. Sci. 1353, Springer-Verlag, 1997, pp. 284-290. [30] M. Patrignani, Personal communication, March 1998. [31] P. Reid, Dynamic interactive display of complex data structures, in Graphic Tools for Software Engineers, Cambridge 1989. [32] S. Reiss, An engine for the 3D visualization of program information, J. Visual Languages and Computing, vol. 6, no. 3, 1995. [33] M. Sch¨ affter, Drawing Graphs on Rectangular Grids, Discr. Appl. Math. 63 (1995) pp. 75-89. [34] J. Storer, On minimal node-cost planar embeddings, Networks 14 (1984), pp. 181-212. [35] R. Tamassia and I. G. Tollis, A unified approach to visibility representations of planar graphs, Discr. and Comp. Geometry 1 (1986), pp. 321-341. [36] R. Tamassia and I. G. Tollis, Planar Grid Embeddings in Linear Time, IEEE Transactions on Circuits and Systems CAS-36 (1989), pp. 1230-1234. [37] O. Tversky, S. Snibbe, R. Zeleznik, Cone Trees in the UGA graphics system: Suggestions of a more robust visualization tool, Technical Report CS-93-07, Brown University. [38] C. Ware, D. Hui, G. Frank, Visualizing object oriented software in 3 dimensions, in Proc. CASCON, 1993.