Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 6, no. 1, pp. 3–5 (2002)
Graph Drawing and Representations Special Issue on Selected Papers from the Seventh International Symposium on Graph Drawing, GD’99 Guest Editors’ Foreword Hubert de Fraysseix CNRS UMR 8557 — E.H.E.S.S. 54 Bd Raspail, 75006 Paris, France http://www.ehess.fr/centres/cams/person/hf
[email protected]
Jan Kratochv´ıl Department of Applied Mathematics and Institute for Theoretical Computer Science Charles University Malostransk´e n´ am. 25, 188 00 Praha 1, Czech Republic http://www.ms.mff.cuni.cz/acad/kam/kratochvil
[email protected]
GD’99 was supported in part by DIMATIA Charles University and Czech Research ˇ 201/99/0242. Editorial work on this volume was partially supported grant GACR by the Institute for Theoretical Copmputer Science of Charles University (project LN00A056 of the Ministry of Education of the Czech Republic).
H. de Fraysseix and J. Kratochv´ıl, Foreword , JGAA, 6(1) 3–5 (2002)
1
4
A few words about the conference
This special issues features contributions based on five of the papers and one of the invited talks presented at GD’99 at Stirin Castle in the vicinity of Prague, Czech Republic. The conference brought together researchers, practitioners, developers and users working on all aspects of graph visualization and representations. The issues considered in graph drawing range from geometry, topology, partially ordered sets and graph theory, through algorithms and complexity theory to practical systems and applications. The interaction between theoretical advances and implemented solutions has always been an important part of the graph drawing field and of the Graph Drawing Symposia. In a recently restored baroque castle 30 km out of Prague, the participants were less distracted by the numerous opportunities of day- and night-life attractions of the fabulous city. The English style gardens of the castle provided opportunities for walks and discussions, the artistic atmosphere of the castle was enhanced by the conference concert given by Jiˇr´ı Stiv´ın, a prominent Czech jazz musician, and by the invited talk “Art of drawing” by Jaroslav Neˇsetˇril, who is also a prominent Prague painter. It is our pleasure to include a paper based on this talk in our volume. In total 38 papers were accepted and presented during the conference. Five of these papers were invited for this special volume. All of them went through further rigorous refereeing process. Also because of this, but from other reasons as well, the papers in this volume differ substantially from their proceedings versions. Most of them are presented in more detail, and therefore became significantly longer. In one case, on the other hand, the new version became considerably shorter than the conference one. This is because a stronger and more general theorem was proven by the author in the meantime. We believe that both publishing new stronger results as well as including more details to other papers’ results and proofs will be welcome and appreciated and justifies the 2 year span between the conference and the appearance of this special volume. We would like to thank the authors for their patience and the referees for their hard work.
2
A few words about the papers
The first and last papers of the volume are devoted to geometrical representations of graphs or partially ordered sets. The question if every planar graph allows a representation as an intersection graph of straight line segments has now become a well known problem in the area, with names as Fellows, Pach, Pollack, Scheinerman and Erd¨ os attached to various partial results and variants of the problem. It is well known that planar bipartite graphs are even contact graphs of segments. The result stating that planar triangle-free graphs are intersection graphs of segments in three directions in the plane proved in Triangle-free planar graphs and segment intersection graphs by de Castro, Cobos, Dana, Marquez and Noy is still today, 2 years after the GD’99 conference,
H. de Fraysseix and J. Kratochv´ıl, Foreword , JGAA, 6(1) 3–5 (2002)
5
the strongest result in the area. The paper Planar Graphs with Topological Constraints by Dornheim considers the question of drawing graphs under certain topological constraints, namely of the form that a vertex is inside or outside a particular cycle in the graph. This novel approach is treated very thoroughly and a number of NP-completeness results and polynomial time algorithms are presented. J¨ unger and Leipert in their paper Level Planar Embedding in Linear Time provide a second step towards automatic drawing of level planar graphs. At GD’98, J¨ unger, Leipert and Mutzel presented a linear time algorithm for recognizing level planar graphs. The step from recognition to actual construction of an embedding, which is definitely not straightforwardly linear time, is presented in this paper. Drawing planar graphs on a prescribed locations of vertices is an important question, both from theoretical and practical points of view. The paper Embedding Vertices at Points: Few Bends suffice for Planar Graphs by Kaufmann and Wiese show (among other results) that every 4-connected planar graph can be embedded on any given point set with at most one bend per edge, while this question is NP-complete for general planar graphs. The invited talk of Jarik Neˇsetˇril about “Art of drawing” was very well accepted by the participants of GD’99. It is true that the speaker talked slightly more about art and drawings than about graphs, but the audience learned a lot from this talk about the meaning and significance of drawings. After the recent development in the area, namely the talk of the author at the symposium Graph Drawing 2001 in Vienna (coauthored by J. Adamec), we have asked Neˇsetˇril to prepare a paper stemming from his earlier presentation which would, however, reflect and comment on the new notion of fractal length or combinatorial entropy of drawings. We appreciate very much that he was willing to prepare this contribution in such a short time, so that it is possible to include it in the present volume. The last paper of the volume, Realization of Posets by Ossona de Mendez is another paper on geometric representations. It presents a very general result on representations of partially ordered sets which, among others, generalizes a famous result of Schnyder about incidence posets of planar graphs.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 6, no. 1, pp. 7–26 (2002)
Triangle-Free Planar Graphs as Segment Intersection Graphs Natalia de Castro
Francisco Javier Cobos Alberto M´ arquez
Juan Carlos Dana
Departamento de Matem´ atica Aplicada I Universidad de Sevilla http://www.ma1.us.es/ {natalia, cobos, dana, almar}@us.es
Marc Noy ∗ Departamento de Matem´ atica Aplicada II Universitat Polit`ecnica de Catalunya http://www.upc.es/
[email protected] Abstract We prove that every triangle-free planar graph is the intersection graph of a set of segments in the plane. Moreover, the segments can be chosen in only three directions (horizontal, vertical and oblique) and in such a way that no two segments cross, i.e., intersect in a common interior point. This particular class of intersection graphs is also known as contact graphs.
Communicated by H. de Fraysseix and and J. Kratochv´ıl: submitted October 1999; revised February 2001 and July 2001.
∗
Partially supported by projects SEUI-PB98-0933 and CUR Gen. 1999SGR00356.
Cat.
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
1
8
Introduction
Given a set S of segments in the plane, its intersection graph has a vertex for every segment and two vertices are adjacent if the corresponding segments intersect. Intersection graphs of segments and other geometrical objects have been widely studied in the past. For instance, if the segments are contained in a straight line then we have the interval graphs [5], a well-known family of perfect graphs. If the segments are chords of a circle then the intersection graph is called a circle graph, see for instance [8, 10]. An interesting result, due to de Fraysseix, Osona de Mendez and Pach [4], and independently to Ben-Arroyo Hartman, Newman and Ziv [2], says that every planar bipartite graph is the contact graph (a particular case of intersection graph, where no two segments cross) of a set of horizontal and vertical segments and, in a different formulation, Tamassia and Tollis proved in [11] almost the same result. On the other hand, it is known that the recognition of such graphs is an NP-complete problem (see [6], [7] and recently [3]). This result provides a partial answer to a question of Scheinerman [9]: Is every planar graph the intersection graph of a set of segments in the plane? The main result in this paper, which is a significant extension of [4], is that every triangle-free planar graph is the intersection graph of a family of segments. Moreover, the segments can be drawn in only three directions and in such a way that they do not cross, i.e. the segments do not have any interior point in common. This particular class of intersection graphs is also known as contact graphs. We call such a representation a segment representation of the graph.
v1
h1
o1
h1 o2
v2 v4
v3
v5
v1
v2
v3
v5
v4
o2
h2
h3
h5 h4
h3
h2
o3
h4
v7
o1
v6 h6
v6
o3 h5 v7
h6
Figure 1: A segment representation of a planar graph.
Our technique is similar in spirit to the one used in [2] for bipartite planar graphs with some transformations. A key point in our proof is Gr¨ otzsch’s Theorem [12], which guarantees that every planar triangle-free graph is 3-colorable.
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
9
The sketch of the proof is as follows. Fixing an embedding of a given triangle-free planar graph G, adding new vertices and (induced) paths between the vertices of the graph we can obtain a new triangle-free graph embedded in the plane which is a subdivision of a 3-connected graph. Starting with a 3-coloring, a segment representation in three directions is obtained for this new graph using several technical lemmas. Finally, removing the dummy vertices and paths, we obtain a segment representation of the graph G. The three directions considered are horizontal, vertical and oblique (parallel to the bisector of the second quadrant of the plane).
2
Pseudo-convex faces with three directions
In this section we present some preliminaries and we indicate the basic techniques that are used. Let G be a planar graph, and consider a fixed embedding of G in the plane. The embedding divides the plane into a number of regions that we call faces of the graph. Let IG be a segment representation of G. We assume throughout the paper that no segment continues beyond its last intersection with a segment in another direction. The segment representation also partitions the plane into regions which we call faces of the representation, whose are simple n-polygons (if n ≥ 4, there is no pair of non-consecutive edges sharing a point). The proof of our main result is based on adapting the concept of “convex polygon” for segments in three directions. A segment path of length n is a sequence of horizontal, vertical and oblique segments P = {s1 , . . . , sn } such that segment si intersects si−1 and si+1 , for 1 < i < n. A segment path P = {s1 , . . . , sn } is said to be monotone with respect to a straight line l if any line orthogonal to l intersects P in exactly one point. We consider monotone paths of the segment representation with respect to the following two lines: the bisector of the second quadrant of the plane (l1 = {x + y = 0}) and the line (l2 = {x − 2y = 0}). Since we can draw a monotone path rightward or leftward, we distinguish four different kinds of monotone paths: • A path P is an increasing monotone path to the right (IMPR) if its horizontal segments are drawn rightward, its vertical segments are drawn upward, and its oblique segments are drawn rightward and downward. • A path P is a decreasing monotone path to the right (DMPR) if its horizontal segments are drawn rightward, its vertical segments are drawn downward, and its oblique segments are drawn rightward and downward. • A path P is a decreasing monotone path to the left (DMPL) if its horizontal segments are drawn leftward, its vertical segments are drawn downward, and its oblique segments are drawn leftward and upward.
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
10
• A path P is an increasing monotone path to the left (IMPL) if its horizontal segments are drawn leftward, its vertical segments are drawn upward, and its oblique segments are drawn leftward and upward.
s1
DMPL sn IMPL
DMPR
sn
IMPR s1
Figure 2: Monotone paths. Let IG be a segment representation of a plane triangle-free graph G. Recall that the face boundaries of the representation correspond to closed walks in G. A face F of a segment representation is pseudo-convex if its boundary can be divided into an IMPR, a DMPR, a DMPL and an IMPL (clockwise). It can be seen that the partition of a pseudo-convex face into monotone paths is not unique, but there are only a few possibilities and this does not modify the proofs of the theorems. From now on, we consider the boundary of a pseudo-convex face clockwise.
IMPR DMPR
F
IMPL
DMPL
Pseudo-convex Face
Non Pseudo-convex Face
Figure 3: The four paths of a pseudo-convex face.
Given a pseudo-convex face, we define the upper subpath as the union of its IMPR and its DMPR and, the lower subpath as the union of its DMPL and IMPL subpath. Analogously, we define the right subpath as the union of the DMPR and DMPL, and the left subpath as the union of the IMPL and IMPR. In this way the boundary of a pseudo-convex face can be considered as the
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
11
union of the upper and lower subpaths, and also as the union of the right and left subpaths. We say that the upper and lower subpaths are opposite subpaths to each other (analogously with the right and the left subpaths).
Left subpath Right subpath
Upper subpath
F Lower subpath
Figure 4: The upper, lower, right and left subpaths of a pseudo-convex face. Note that if F is a pseudo-convex face, and P is a monotone path inside F connecting two segments in its boundary, then P partitions F into two new pseudo-convex faces. Moreover, if two segments on the boundary of F can be extended inside F until they cross, those extended segments also would split F into two new pseudo-convex faces. In order to build a segment representation of a plane graph G, we proceed by representing the boundary of the outerface of G by contact segments, using a pseudo-convex representation. If two vertices of the outerface are joined in G by a path, we represent this path as a monotone segment path inside the representation of the outerface, obtaining two pseudo-convex faces. Recursively we represent monotone paths of G until the representation of the graph is completed. We see then that in order to represent a graph by contact segments it is necessary to join segments by segment paths inside the faces of the representation. We need to extend segments of the boundary of the faces inside them to contact the segments. However it is not always possible to extend segments inside a pseudo-convex face. A segment of a pseudo-convex is extensible along one of its ends if and only if its angle inside the face is concave. Thus, a segment of a pseudo-convex face is extensible by one of its ends, or by both or by none, depending on the adjacent segments (see Figure 5).
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
12
Non-extensible Extensible by one Extensible end by both ends
Figure 5: Extensible segments.
It is obvious that in order to join two segments inside a pseudo-convex face, one of them must be extended, but this is not sufficient in general as we can see in Figure 6: segment r2 can be extended inside F , but we can not join it with r1 because r2 intersects other segments of the face. The segment r3 can be also extended inside the face, but we cannot join r1 with r3 because they never contact.
r1
r2 r3
Figure 6: Extension of segments.
According to the above remark, we have two different problems when we try to join segments inside a pseudo-convex face; when the segments can be extended inside the face, but they find some “obstacle” before the intersection (other segments of the face), and on the other hand when the segments cannot be extended or they never contact. To solve these problems we define two basic operations in the segment representation. The first operation is enlarging a segment of the representation, and the second one is changing the sense of drawing of some segments. Although we are interested in some specific segments, these operations will transform other segments of the representation.
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
13
Enlarging a segment means to increase its length, and obviously we also need to increase the length of other segments of the representation and make a translation of other segments without modifying their length. With this operation we can keep away the obstacles and to overlap parallel segments, if we want to join them by a segment path. The other operation allows us to extend a segment by one of its ends, if it was not possible before. It changes the sense of drawing of its adjacent segment and the other segments of its monotone path, to preserve the pseudo-convexity of the face.
Figure 7: Transforming the segment representation. The following technical lemmas allow us to construct a topological equivalent representation where we modify some segments, allowing to join the segments by a path of any length. Lemma 1 Let IG be a segment representation of a subdivision of a 3-connected plane graph G such that all its faces are pseudo-convex, let k be a positive real number and let s be a segment on the boundary of a face F of IG . Then IG can be transformed into another segment representation IG satisfying: 1. IG is topologically equivalent to IG (that is, the faces of IG and IG have the same facial walks), and the faces of IG are pseudo-convex; 2. it is possible to enlarge s (and at most two segments on the opposite subpath of F ), such that the length of s in IG is k + l.
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
14
Proof: The proof is by induction on the number of faces of the graph G. Firstly, we suppose that F is just the boundary of IG , and let s be the segment of F that we want to enlarge. We can distinguish three cases depending on the direction of s. Case 1 Let s be a horizontal segment. If s is a horizontal segment in the upper subpath of F (analogously if s is in the lower subpath) we look for a horizontal segment s0 in the lower subpath of F . If there exists such segment we enlarge s and s0 by the same amount and we make a translation of all the segments between s and s0 , transforming F into another pseudo-convex face (see Figure 8 (a)). If there does not exist a horizontal segment s0 in the lower subpath of F , there must exist a vertical segment s0 and an oblique segment s00 which are adjacent in the lower subpath of F , because the boundary of F is a closed path. In this case, we increase the length of s, s0 and s00 and we make a translation of the rest of the segments (see Figure 8 (b)).
s
s
(a)
s'
s
s'
s
s' s''
s' (b)
s''
Figure 8: How to enlarge a segment of a pseudo-convex face by any amount, using parallel segments (a), using three segments (b).
Case 2 If s is a vertical segment, the proof is as Case 1, considering the boundary of F as the union of the right and left subpaths. Case 3 If s is an oblique segment, the proof is similar to the other cases, considering the boundary of F as the union of the upper and lower subpaths.
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
15
Suppose that G has two bounded faces and let us denote by u1 , . . . , un the vertices of G which are in both faces. Let {s1 , . . . , sn } be the segments of IG corresponding to u1 , . . . , un , respectively, and let us denote by F1 and F2 the boundary of the bounded faces in IG .
s1 s
F2 s2
F1
s3 s4 s'
Figure 9: The adjacent segments are s1 , . . . , s4 . Let s be the segment of F1 we want to enlarge. By considerations given above, this transformation will enlarge other segments of F1 , but if none of these segments belong to F2 , we can reduce to Case 1 because the transformations does not modify F2 . If we have selected two (or three) segments in F1 to enlarge them, they will modify F2 if and only if F1 and F2 share more than one point of those segments. Thus, we can suppose that F1 ∩ F2 ∩ s1 is not just one point, and neither is F1 ∩ F2 ∩ sn . Otherwise, we do not consider the segments s1 and sn in the subpath {s1 , . . . , sn }. According to that, the path {s1 , . . . , sn } is monotone because the faces of IG are pseudo-convex. Suppose that s is in F1 . As in the case where G had only one bounded face, in the opposite subpath of F1 we look for a parallel segment or two contiguous segments non-parallel to s. If these segments are not in F2 we only modify F1 according to the first case. Let us suppose that s belongs to F1 and we have found a parallel segment s0 in the opposite part of F1 . Since F1 ∩ F2 is a monotone path and the segments are in opposite parts of F1 , just one of them belongs to F2 . Now, the task is to find a parallel segment in the opposite part of F2 , and we are sure that this new segment does not belongs to F1 , so enlarging all selected segments, a new representation IG0 equivalent to IG is obtained. The same proof remains valid if we choose two contiguous segments s0 and 00 s in F1 and they belong also to F2 . Suppose now that IG has n bounded pseudo-convex faces with boundaries F1 , . . . , Fn , and let s be a segment in the boundary of a face F . Since G is a subdivision of a 3-connected graph, there exists a face (for example Fn ) adjacent
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
16
to the unbounded face (i.e., the boundary of the face in G corresponding to Fn has an edge in the unbounded face H of G) and such that s is not in Fn ∩ H. Thus, if we construct the graph G1 as the graph obtained from G by deleting all the edges of the face of G corresponding to Fn which are contained in the outerface, then we can assure that s belongs to G1 .
v1 v2 Fn v
3
v
4
v5 G
G1
s1 s
2
s
3
s s
4
5
IG
IG
1
Figure 10: Induction. Let v1 , . . . , vk be the vertices of G, corresponding to the segments s1 , . . . , sk of Fn , which are also on the outerface, where v2 , . . . , vk−1 are of degree two. By removing the segments of IG corresponding to the vertices v2 , . . . , vk−1 , we obtain a segment representation IG1 of G1 . Since IG1 has n − 1 faces, enlarging in any amount some of the segments, we can transform its segment representation into another one which has the same convex faces. To obtain this new representation, we have to enlarge other segments in IG1 besides s, but we have preserved the structure of the segments in the representation. So, we are able to represent again the segments corresponding to v2 , . . . , vk−1 enlarging the length of one (or two) of them, if it is necessary, to obtain a segment representation of G. 2 We can see, using Lemma 1, that by enlarging some segments, a segment representation with pseudo-convex faces can be transformed into another one preserving the topology of the embedding. But this is not sufficient to join segments inside a face, so we need another kind of transformation.
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
17
Changing the sense of drawing of the segments of a monotone path of a pseudo-convex face F (for instance, the segments which were drawn to the left are drawn to the right) it is possible to draw a new pseudo-convex face F where these segments belong now to another monotone path. The remaining paths of F only change in the length of some of the segments (see Figure 11).
F
F s3
s2
s2 s1
s1
s4
s3
s4
Figure 11: How to restructure a face through a path. In the segment representation, the change of the face F to F produces some changes in the faces adjacent to F along the monotone path, and we obtain another segment representation with pseudo-convex faces as in the proof of Lemma 1 (see Figure 12). When we change the drawing in the manner described above, we say that the face F is restructured through the monotone path. Lemma 2 Let IG be a segment representation of a subdivision of a 3-connected plane graph G such that all its faces are pseudo-convex. Let F be a face of IG . Then, IG can be transformed into another segment representation IG satisfying: 1. IG is topologically equivalent to IG (that is to say, the faces of IG and IG have the same facial walks), and the faces of IG are pseudo-convex; 2. the face F corresponding to F has been restructured through a monotone path. Proof: We first suppose that F is just the boundary of IG . It is easily seen that we can change the drawing of the segments so that they belong to the previous or the following monotone path. Suppose now that IG has n bounded pseudo-convex faces. Let F be the face that we want to restructure through the monotone path s1 , . . . , sn . It is necessary to change the sense of drawing of all the segments of the restructured path, thus the other faces that contain in their boundaries the segments s1 , . . . , sn will be also restructured, but they will preserve their pseudo-convexity. The main idea is that no other face of the representation will be modified, except for the length of some segments, but by Lemma 1 it is possible to increase the length of the segments of the representation preserving the pseudo-convexity.
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
18
In fact, we can consider the faces adjacent to F . The union of these faces determines a region of the plane, R, whose boundary is also a pseudo-convex face. Since restructuring F only modifies the segments in the interior of R but never in its boundary, the faces of the representation that are not adjacent to F will keep their structure. For instance, in Figure 12, we have restructured the face F and this transformation forces restructuring the shaded face. Other faces of the segment representation have been transformed in the length of some segments of their boundaries, but by Lemma 1 they preserve their pseudo-convexity.
F F
Figure 12: How to restructure the faces adjacent to the restructured face F . 2
3
Triangle-free graphs
We need the following result proved by Barnette [1]: Theorem 1 If G is a subdivision of a 3-connected graph, there exists a family Q1 , . . . , Qn−1 of paths in G such that the family of subgraphs defined as G1 = G, G2 = G1 − Q1 , . . . , Gn = Gn−1 − Qn−1 satisfies the properties 1. Each Gk is a subdivision of a 3-connected graph. 2. Gn is a subdivision of K4 . Moreover, if we fix a subgraph of G which is a subdivision of K4 , G can be reduced, by deleting edges and paths, to this subgraph. An easy consequence is that every planar triangle-free graph which is a subdivision of a 3-connected graph can be reduced, by deleting edges and paths with internal vertices of degree two, to a subdivision of a fixed complete subgraph K4 in such a way that in each step we have a subdivision of a 3-connected graph.
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
19
This result will allow us to build a segment representation in three directions of subdivisions of 3-connected graphs as follows. Firstly we build a segment representation of a subdivision of K4 and then insert, in reverse order, the edges and paths that were removed to obtain from G the subdivision of K4 . In order to do this, we need two basic operations: (1) insert a segment path between two segments of the same face and (2) join two segments of the same face. The second operation is, at least, as difficult as the first one, so we will concentrate only in the second operation. As we see in Figure 6, we can find some problems in the segment representation to join two segments inside a face. Most of the cases can be solved by changing the drawing of the segments of the representation with the basic operations “enlarge segments” and “restructure faces”, but there are four rare cases that need an special operation. We need at this point some new definitions. Given a 3-colored plane graph G with colors {h, o, v}, a path P = {u1 , . . . , un } of G is rare if it verifies one of the following conditions: Case 1. u1 is colored as h, u2 as o, and un as v. Case 2. u1 is colored as v, un−1 as h, and un as o. Case 3. u1 is colored as h, u2 as o, un−1 as h, and un as o. Case 4. u1 is colored as o, u2 as v, un−1 as v, and un as h.
sn
v1
s
1
vn-1
s2
vn
rn r2 r1
w2
wn
w1 wn-1
Figure 13: Rare face (four rare paths). A face of a graph is called rare if there exists a monotone path containing a rare subpath (see Figure 13). We say that a rare face is repaired if we subdivide its rare path with a new vertex colored as v between u1 and u2 in the first and the third case, and between un−1 and un in the second case, or a new vertex colored as h between u1 and u2 in the fourth case.
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
20
In the following lemma, when we say that two segments s and t can be joined by a segment path of length k, we mean a path {s, s1 , s2 , . . . , sk , t}. Lemma 3 Let IG be a segment representation of a plane graph G and let s1 and s2 be two distinct non adjacent segments in a pseudo-convex non-rare face F . Then IG can be transformed into another segment representation IG satisfying 1. IG and IG have the same faces and face boundaries as G, and the faces of IG are pseudo-convex; 2. s1 can be joined to s2 by a segment path of length k, for all k > 0, or directly if s1 and s2 have not the same direction inside the pseudo-convex face F , corresponding to F . Proof: The proof falls naturally into two cases: the segments have the same direction, or they do not.
s1
s2
s1
(a)
s2
s1
(b)
(c) s2
s2
s1
s1 s2
Figure 14: Joining segments Case 1: s1 and s2 do not have the same direction. Suppose the segments cannot be joined inside F directly. The lines containing
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
21
s1 and s2 indicate us which end has to be extended for the segments to intersect. Let us mark these ends. 1. At least one of the segments is extensible by the marked end but it intersects other segments of F (Figure 14 (b)). Then we can enlarge some segments of F using Lemma 1 and save the obstacle. 2. No segment is extensible by the marked end (Figure 14 (c)). Then we have to restructure the face through the path containing s1 (or s2 ) to make it extensible. Note that there exists exactly four configurations where the segments are not extensible and restructuring the face does not solve the problem, but these are the rare paths which are excluded.
S1 S2
Non pseudo-convex face
Non pseudo-convex face
Figure 15: Segments s1 and s2 cannot be adjacent. We need that s1 and s2 are non adjacent segments because we cannot join them by a segment path inside F if their angle inside F is concave. Note that in this case F will split into two faces, but one of them will not be pseudo-convex (see Figure 15). Case 2: s1 and s2 have the same direction. In this case, it suffices to join the segments by a segment path of length one, because this path can be substituted by any path of length greater than one. Again there are two subcases: 1. If the segments belong to opposite subpaths (they are drawn in opposite sense). By Lemma 1, we can enlarge s1 and s2 until there exists a perpendicular line that crosses both segments, and a segment path of any length can be drawn inside the face.
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
s
22
s1
1
s2
s2
(a) s1
s1
s2
s
2
(b)
Figure 16: Joining segments.
2. If the segments are drawn in the same sense and they cannot be extended, we have to restructure the face through the path containing s1 (or s2 ) to make it extensible. 2 The interest of these Lemmas is that they allow us to proof the following. Lemma 4 Any triangle-free plane graph which is a subdivision of a 3-connected graph can be represented by segments in three directions. Proof: As G is a triangle-free plane graph, in virtue of Gr¨otzsch’s Theorem [12], G admits a 3-coloring with the colors h, v and o (horizontal, vertical and oblique, respectively). Since G is a subdivision of a 3-connected graph, we can find a vertex, not in the outerface of G, connected by three disjoint paths to three vertices in the outerface. These paths and the outerface determine a graph K, which is a subdivision of K4 . Using Theorem 1 [1] it is possible to build a sequence of graphs G1 , . . . , Gn and a sequence of paths Q1 , . . . , Qn−1 such that G1 = G, Gi is a subdivision of a 3-connected plane graph, Gi is obtained from Gi−1 by deleting the path Qi−1 , and the graph obtained from Gn−1 deleting Qn−1 is K. When the path Qi is deleted, a new face F appears in Gi+1 as the union of two faces in Gi . The boundary of F can be divided into two paths; on the one hand the path beginning in the first vertex of Qi and ending in the last one and, on the other hand, the rest of the boundary. If one of them is rare, we must
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
23
repair F by subdividing an edge with a new vertex (that we label as a repaired vertex), to make the face F non-rare. So, we can construct another sequence G01 , . . . , G0n where G0i is Gi with a new repaired vertex, if necessary.
sn s1
v1 v
s
n-1
2
rn r2 r1
vn
u
u
w2 wn
w1
u u
wn-1 Rare face (four rare paths)
Repaired face
Figure 17: Repairing rare paths. It is easy to give a segment representation of K 0 with all its faces pseudoconvex. It suffices to represent pseudo-convexly the outerface of K 0 and proceed according to the above remark. Using Lemma 3 it is possible to add the path Qi to the segment representation of G0i+1 to obtain a pseudo-convex face representation of G0i . Since every subgraph is a subdivision of a 3-connected graph, the path Qi cannot join adjacent vertices and so we can apply Lemma 3. In order to obtain a segment representation of the graph G, we must remove the repaired vertices. These segments cannot be removed directly, because we must change the drawing of one of the segments adjacent to the repaired vertex, so it is necessary to modify the representation. Since this is the last operation of the representation, and the repaired vertex is not adjacent to any other segment, it is possible to remove it, as illustrated in Figure 18. Notice that we could not remove the repaired vertices if the rare path would have exactly three segments u1 , u2 and u3 , but this case is not possible because joining u1 with u3 it will be form a triangle, and G was a triangle-free graph. 2 We can now formulate our main result as follows. Theorem 2 Every triangle-free planar graph is the contact graph of a set of segments in three directions. Proof: Let G be a triangle-free plane graph. Since G has no triangles, we can obtain a 3-coloring of G using Gr¨otzsch’s Theorem [12]. The colors will be labeled as h, v and o (horizontal, vertical and oblique, respectively). We can build a new triangle-free plane graph G1 , subdivision of a 3-connected graph, which contains G as a subgraph, by adding new vertices and edges joining the
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
F'
F'
F'
F
F
F'
F
F'
F'
u F
F
F
F'
u F
F'
F
F'
u F
u
F'
F
F'
u
F
F'
F'
u
u F
24
F
u F
F'
F'
F'
F
F
Figure 18: How to remove the repaired vertex u in the four cases.
blocks of G. If this is the case, these vertices are labeled as dummy vertices. When an added edge produces a triangle, we subdivide it, and when a new edge joins two vertices with the same color, we subdivide it too. We call these new vertices and edges virtual. All the new vertices (dummy and virtual) can be colored so that the 3-coloring is preserved. By Lemma 4, G1 admits a segment representation. Out of this segment representation we must remove all the vertices and edges added. A virtual edge (or a path built with virtual edges and vertices) in the segment representation of G1 is an adjacency between two segments (or a virtual path joining two segments). It suffices to break this adjacency and to shorten these segments (note that the segments do not cross, they only contact). The dummy vertices are removed as the repaired vertices in Lemma 4 (see Figure 18). 2
4
Concluding remarks
The hypothesis that the graph has no triangles can be relaxed in some cases. No doubt there exist planar graphs with triangles that admit segment rep-
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
25
resentations (see Figure 1). The problem lies in the fact that we have followed a constructive proof to obtain a segment representation using the pseudo-convex faces representation of a subdivision of a 3-connected graph. This construction would not be possible in general if the graph contains triangles, because if we fix the three directions of the segments we can observe that the graph in Figure 19 cannot be represented by non-crossing segments.
v1
o1
v2 h1
v1 o2
h1
o1 o2
h2
h2
v2
Figure 19: Two segments must cross. In this example we see the intersection graph of a family of segments, but this representation by segments of the graph contains regions that do not correspond to faces of the embedding of the graph. So, the topology of the embedding of the plane graph cannot be preserved and inductive arguments are no longer possible. This problem admits a partial solution as follows. A 3-coloring of a plane graph G with colors {h, v, o} is good if all the triangles of G are colored (clockwise), as h − v − o. The proof of Theorem 2 can be adapted yielding the following result: Theorem 3 Let G be a 3-colored plane graph. The coloring is good if and only if there exists a segment representation IG verifying that the faces of G correspond to faces of IG , and the boundaries of the faces are preserved.
N. de Castro et al., Segment Intersection Graphs, JGAA, 6(1) 7–26 (2002)
26
References [1] D.W. Barnette. On Steinitz’s theorem concerning convex 3-polytopes and on some properties of planar graphs In The many facets of graph theory. Lectures Notes in Mathematics Springer, Berlin, 110:27–39, 1969. [2] I. Ben-Arroyo Hartman, I. Newman and R. Ziv. On grid intersection graphs. In Discrete Math., 87:41–52, 1991. [3] P. Hlineny. Contact graphs of line segments are NP-complete. In Discrete Math., 235:95–106, 2001. [4] H. de Fraysseix, P. Osona de Mendez and J. Pach. Representation of planar graphs by segments. In Colloquia Mathematica Societatis J´ anos Bolyai, Intuitive Geometry, Szeged (Hungary), 1991. [5] M.C. Golumbic. Algorithmic Graph Theory and Perfect Graphs. Academic Press, 1980. [6] J. Kratochv´ıl. A special planar satisfiability problem and a consequence of its NP-completeness. In Discrete Applied Math., 52:233–252, 1994. [7] J. Kratochv´ıl and J. Matouˇsek. Intersection graphs of segments. In J. of Comb. Theory, Serie B, 62:289–315, 1994. [8] W. Naji. Reconnaisance des graphes de cordes. In Discrete Math., 54:329– 337, 1985. [9] E.R. Scheinerman. Intersection classes and multiple intersection parameters of graphs. Ph D. thesis,, Princeton University, 1984. [10] J. Spinrad. Recognition of circle graphs. In J. of Algorithms, 16:264–282, 1994. [11] R. Tamassia and I.G. Tollis. A unified approach to visibility representation of planar graphs. In Discrete and Computational Geometry, 1:321–341, 1986. [12] C. Thomassen. Gr¨ otzsch’s 3-colour theorem and its counterparts for the torus and the projective plane. In J. Comb. Theory B, 62:268–279, 1994.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 6, no. 1, pp. 27–66 (2002)
Planar Graphs with Topological Constraints Christoph Dornheim Institut f¨ ur Informatik Albert-Ludwigs-Universit¨ at D-79110 Freiburg, Germany http://www.informatik.uni-freiburg.de/~dornheim
[email protected] Abstract We address in this paper the problem of constructing embeddings of planar graphs satisfying declarative, user-defined topological constraints. The constraints consist each of a cycle of the given graph and a set of its edges to be embedded inside this cycle and a set of its edges to be embedded outside this cycle. Their practical importance in graph visualization applications is due to the capability of supporting the semantics of graphs. Additionally, embedding algorithms for planar graphs with topological constraints can be combined with planar graph drawing algorithms that transform a given embedding into a topology preserving drawing according to particular drawing conventions and aesthetic criteria. We obtain the following main results on the planarity problem with topological constraints. Since it turns out to be NP-complete, we develop a polynomial time algorithm for reducing the problem for arbitrary planar graphs to a planarity problem with constraints for biconnected graphs. This allows focussing on biconnected graphs when searching for heuristics or polynomial time subproblems. We then define a particular subproblem by restricting the maximum number of vertices that any two distinct cycles involved in the constraints can have in common. Whereas the problem remains NP-complete if this number exceeds 1, it can otherwise be solved in polynomial time. The embedding algorithm we develop for this purpose is based on the reduction method.
Communicated by H. de Fraysseix and and J. Kratochv´ıl: submitted May 2000; revised March 2001.
This research was supported by the Deutsche Forschungsgemeinschaft (DFG) as part of the graduate school on Human and Machine Intelligence.
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
1
28
Introduction
Most research in the graph drawing field has focussed so far on developing algorithms that produce drawings of graphs according to particular drawing conventions and aesthetic criteria (see [5], [6], [11] and [23]). Common drawing conventions require, for instance, the vertices to have integer coordinates, the edges to be polylines or straight lines or to be composed of straight line segments parallel to one of the coordinate axes. Aesthetic criteria are in general optimization goals such as minimizing the number of edge crossings, maximizing the minimum distance between vertices or, in case of polyline drawings, minimizing the number of bends. Both drawing conventions and aesthetic criteria are intended to ensure readability of the drawings. They can be seen as geometric constraints implicit to the drawing algorithms. Many applications, however, need a visualization of graphs satisfying userdefined constraints to emphasize certain semantical aspects. Visual languages [27], for instance, may require some subgraphs to be drawn with a predefined shape to support their semantics. And in VLSI design [14] it is often necessary to have a graph layout where certain vertices are arranged in a group or cluster [21]. Although “the study of constraints is a strategic research direction for the graph drawing field” [22], there are only few graph drawing approaches allowing the user to define constraints. A survey of these approaches and those drawing algorithms that can be modified to support some sort of constraints is given in [22]. Again, the resulting constraints are primarily geometric and most of them are covered by the approach of [15] which supports the specification of arithmetic linear equality and inequality constraints on the coordinates of the vertices. These approaches to constrained graph drawing have often the disadvantage of not drawing a planar graph without crossings, i.e. as a planar embedding. For graph planarity without constraints there are many testing and embedding algorithms developed so far: from conceptually simple procedures such as [4] (also briefly described in [1]) to more involved linear time procedures such as the path addition embedding algorithm presented by Mehlhorn and Mutzel [18] based on the planarity testing procedure of Hopcroft and Tarjan [16] or the vertex addition embedding algorithm presented by Chiba et al. [3] based on the planarity testing procedure of Booth and Lueker [2]. However, the problem of constructing a planar embedding according to explicit constraints has obtained only little attention so far, despite its impact to planar graph theory and practice. An interesting approach to constrained graph embedding presented in [19] is the problem of finding a planar embedding such that the user’s preferences for facial cycles are satisfied. The preferences, or constraints, are specified by a cost function on the cycles of the graph. In an embedding that satisfies these constraints the overall costs of its facial cycles are minimized. Another approach is the construction of planar embeddings for clustered graphs [12]. A clustered graph is a graph with a user-defined hierarchical structure over the vertices such that each level decomposes the graph into disjoint clusters. In a planar drawing of a clustered graph a cluster is represented by a simple region
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
29
containing exactly the vertices that belong to this cluster. Additionally, edges are allowed to intersect the boundaries of the regions only once; in particular, edges connecting vertices of the same cluster must be inside the corresponding region. The embedding algorithm developed in [12] requires the vertices of each cluster to induce a connected graph. As shown in [9] and [10], these embeddings can be further transformed into drawings according to specific drawing conventions while preserving their cluster structure. Since many drawing procedures for planar graphs need a particular embedding (more precisely, a combinatorial representation of an embedding) as input and produce drawings of the same topology, the construction of embeddings satisfying given constraints can be used as a preprocessing step for a wide range of planar graph drawing algorithms. This paper is devoted to planar graph embedding with topological constraints; it considerably extends the previous work in [8]. We define a topological constraint for a graph to consist of some of its cycle and a set of its edges to be embedded inside this cycle and a set of its edges to be embedded outside this cycle. These constraints are clearly topological since topological transformations of the plane preserve their validity. Note that we build constraints by sets of edges instead of sets of vertices. If some vertex is to be embedded inside or outside a given cycle, the corresponding topological constraint can be defined by using an edge incident to this vertex (if the vertex is isolated, it must be replaced by some new edge for the time of the embedding process). To see that in some situations vertex sets would be insufficient, think of, e.g., Hamilton cycles: the diagonals of a Hamilton cycle can be embedded inside or outside, but there is no vertex left to constitute a topological constraint. The topological constraints are useful in graph embedding whenever the inner and outer regions of cycles have an intrinsic or user-defined semantics. Graphs whose vertices and edges represent spatial entities such as road maps or subway maps often induce some natural meaning to the faces and regions of their embeddings as well. In this case, topological constraints can be defined to ensure that the embedded graph preserves some important topological relationships. Generally, these constraints can be used to impose some structure on the embedding to be constructed. Consider in Fig. 1 the transition diagram of a finite automaton accepting the language (a(cde)∗ bz + f(hij)∗ gz)∗ . The main components of this expression are a(cde)∗ bz and f(hij)∗ gz, each representing a cyclic walk starting and ending in q0 . Moreover, each component contains a subcomponent (cde)∗ and (hij)∗ representing cyclic walks starting and ending in q1 and q6 , respectively. To reflect this structure in the diagram, it makes sense to draw the cycles q0 , q1 , q7 and q0 , q6 , q7 representing the main components into disjoint regions, but to draw the cycles q1 , q3 , q2 and q6 , q5 , q4 representing the corresponding subcomponents inside q0 , q1 , q7 and q0 , q6 , q7 , respectively. These requirements can be expressed exactly by topological constraints. Last but not least, a topological constraint allows one to specify a cycle to be an inner or outer facial cycle just by postulating the former or latter set, respectively, to consist of all edges not belonging to that cycle. The outline of the paper is as follows. Recalling in Sect. 2 the required defi-
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
30
q1 a
b
q4
c d q 3 z i q5
j
h
g
e
q2
q0 f
q7
q6 Figure 1: A transition diagram of a finite automaton with the language (a(cde)∗ bz + f(hij)∗ gz)∗ . The structure of this expression is reflected in the drawing by the topological relationships of the cycles. nitions and results of planar graph theory, we show in Sect. 3 NP-completeness of the problem of deciding whether a graph has an embedding satisfying a given set of topological constraints. In contrast, we present a linear time embedding algorithm for triconnected graphs. Section 4 is concerned with developing a polynomial time procedure for reducing the embedding problem with topological constraints to biconnected graphs. This can be particularly useful in searching for tractable subproblems. We introduce in Sect. 5 a particular subproblem defined by the maximum number of vertices two distinct cycles involved in the constraints have in common. Whereas this problem remains NP-complete if this number exceeds 1, we develop a polynomial time algorithm for generating a required embedding if this number is 0 or 1. Finally, we conclude with Sect. 6.
2
Preliminaries
Assuming familiarity with basic graph terminology (see [1] and [7]), we recall in this section the required fundamentals on planar graphs. For a thorough presentation of planar graph theory we refer the reader to [24], [7] and [20]. Unless otherwise stated, all graphs are finite, simple and undirected. The set of vertices and edges of a graph G are denoted V (G) and E(G), respectively. Paths and cycles in a graph are always simple, i.e. their inner vertices are pairwise distinct. A cycle C in G is induced if any edge of G joining two vertices of C is already an edge in C. Moreover, C is non-separating if the number of components of G does not increase when deleting C from G. A block means a maximal connected subgraph without a cutvertex, i.e. a maximal 2-connected subgraph or a bridge or an isolated vertex. If A denotes the set of cutvertices of G and B denotes the set of its blocks, then the block graph of G is defined on A ∪ B by the edges aB with a ∈ B for a ∈ A and B ∈ B. Note that the block graph of a connected graph is always a tree. A plane graph (V, E) consists of a finite set V ⊆ R2 and a finite set E of Jordan curves connecting two points of V such that any two points are connected
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
31
by at most one curve and the interior of a curve contains no point of V and no point of any other curve. These points and curves are again called vertices and edges, respectively, since all graph notions can also be applied to plane graphs. e we If there is an isomorphism between an abstract graph G and a plane graph G, e an embedding of G in the plane. A graph is planar if it has an embedding call G e always denotes an embedding of the graph G and in the plane. In the sequel, G e to H simply by H. e for subgraphs H ⊂ G we often denote the restriction of G Every plane graph G divides R2 \ G into disjoint open arcwise connected regions called faces of G; the unbounded one is the outer face and the bounded ones are the inner faces. If a cycle C of G is the boundary of some face, we call C a facial cycle; depending on whether C is the boundary of an inner or outer face, we call C an inner or outer facial cycle, respectively. Any cycle C divides R2 \ C into two open arcwise connected regions; the bounded one is the interior of C, denoted by int C, and the unbounded one is the exterior of C, denoted by ext C. The closure of int C and ext C is denoted by Int C and Ext C, respectively. Given a graph G = (V, E) the edge space E(G) of G is the vector space over the 2-element field F2 = {0, 1} formed by the set of all subsets of E and the sum A ⊕ B = (A \ B) ∪ (B \ A) for A, B ⊆ E. The cycle space C(G) is the subspace of E(G) generated by the cycles of G – more precisely, by their edge sets. The elements of C(G) are unions of edge-disjoint cycles of G. Suppose e is an embedding of a 2-connected planar graph G and F 0 is the set of all G e Then, as follows from MacLane’s planarity criterion [17], facial cycles of G. F = F 0 \ {F } forms a basis of C(G) for any F ∈ F 0 and F is the sum of all cycles in F . There is always an embedding of G where F is the set of inner facial cycles and F the outer facial cycle. We often make use of the fact that the edges e contained in Int C e for some cycle C ⊂ G are exactly the edges of those of G e whose sum is C. Moreover, any two embeddings of G are inner facial cycles of G topologically equivalent if they coincide in their outer facial cycle and their set of inner facial cycles (see [7]). We can thus represent a particular 2-connected embedding up to topological equivalence just by its outer facial cycle and the set of its inner facial cycles. If in addition G is 3-connected, the facial cycles of e can be identified combinatorially as the induced non-separating cycles in G, G as proved by Tutte [26]. This allows representing any embedding of G just by its outer facial cycle because all these embeddings have the same facial cycles. Finally, we introduce a notion that plays a fundamental role in graph embedding algorithms following the principle of path addition. Suppose H is a subgraph of G. Then an H-component of G is either an edge (together with its ends) in E(G) \ E(H) joining two vertices of H or it is a connected component of G− H together with all edges (and their ends) of G joining this component to H.1 The vertices of an H-component in H are its vertices of attachment. Suppose C is a cycle in G. Vertices of attachment of a C-component, provided that there are at least two, divide C into edge-disjoint paths, called segments. We say 1 This definition follows [24]. One can find elsewhere in the literature various notions for H-components, e.g. bridges in [1].
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
32
that two C-components avoid each other if either one of them has fewer than two vertices of attachment or all vertices of attachment of one C-component lie in a single segment of the other C-component; otherwise they overlap. The overlap graph GC of C in G is defined as the graph whose vertices are the C-components of G such that two vertices are adjacent iff the corresponding Ccomponents overlap. Overlap graphs can be used even for characterizing planar graphs: by Tutte’s theorem [25] a graph is planar iff the overlap graph of each of its cycle is bipartite.
3
Topological Constraints
In this section we introduce topological constraints and present a criterion for graphs having an embedding that satisfies such constraints. We also show some basic properties of the computational problem of finding these embeddings: whereas this problem is in general NP-complete, it can be solved in linear time for 3-connected graphs. Definition 1 Let G be a graph and T be a set of triples Ti = hCi , Ini , Outi i such that Ci is a cycle in G, Ini , Outi ⊂ E(G) \ E(Ci ), Ini ∪ Outi 6= ∅ and Ini ∩ Outi = ∅. These triples are called topological constraints for G. e of G satisfies T if for each constraint Ti ∈ T all edges of An embedding G fi and all edges of Outi are contained in ext C fi ; such Ini are contained in int C an embedding is called a T -embedding. Moreover, G is T -planar if G has a T -embedding. Obviously, T -planar graphs are necessarily planar; thus we only consider planar graphs. Given a planar graph G and a set T of topological constraints for G, n always denotes the number of vertices of G, m denotes the number of edges where m ≤ 3n−6 and t denotes the number of constraints in T . Note that t can be exponential in n. The relevant parameters of the problem of finding a T -embedding of G are therefore n and t. Since each constraint Ti consists of at most m edges, the input length of any instance can be assumed to be O(nt). For convenience, if C is a cycle Ci occurring in some constraint, we often write InC and OutC instead of Ini and Outi , respectively. Due to the additional requirements on embeddings, one cannot hope for a simple Kuratowski-like criterion for T -planarity. In contrast to classical planarity, T -planarity of a graph cannot be simply reduced to its components or blocks either; even the required topological relationships between its components can get complex as we will see in the next section. To characterize T -planarity in Theorem 1, we make use of some properties of 3-connected planar graphs given in Sect. 2. This theorem is illustrated in Fig. 2. Theorem 1 Let G be a graph and T be a set of topological constraints. Then, G is T -planar iff there is a 3-connected planar graph G0 with G ⊆ G0 and V (G) = V (G0 ) and a basis F of C(G0 ) consisting of induced non-separating cycles of G0 such that for any hC, InC , OutC i ∈ T and FC ⊆ F defined by
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
33
S S L C = F ∈FC F it holds that x ∈ F ∈FC F for any x ∈ InC and y 6∈ F ∈FC F for any y ∈ OutC . e is a T -embedding of G. Triangulating G e in the plane Proof: (⇒) Suppose G 0 f leads to an embedding G of a maximal planar and thus 3-connected graph G0 . f0 are induced non-separating cycles and form a basis The inner facial cycles of G 0 F of C(G ). Let be hC, InC , OutC i ∈ T and FC be the set of cycles in F whose e of G, e and thus of G f0 , it sum is C. Since any edge of InC is contained in Int C belongs to some cycle in FC . Analogously, any edge of OutC is contained in e of G f0 and therefore does not belong to some cycle of FC . Ext C (⇐) Let G0 be the supergraph of G satisfying the required properties. Then f0 of G0 with L there is an embedding G F ∈F F as the outer facial cycle and all F ∈ F as inner facial cycles. For any hC, InC , OutC i ∈ T we have that all edges e in G f0 and all edges of OutC are contained in Ext C e of InC are contained in Int C 0 0 e f f 2 in G . Thus, we get a T -embedding G by restricting G to G. G
G0
C x1
F3
y x2
F2
F1 F4
F6
F5
F7
F8 T = hC, {x1 , x2 }, {y}i
(a)
F = {F1 , . . . , F8 } FC = {F1 , F2 , F4 , F5 , F6 , F8 } (b)
Figure 2: Illustration of Theorem 1: (a) Graph G with constraint T . (b) Supergraph G0 of G with basis F of C(G) and set FC of those cycles in F whose sum is C. In case of 3-connected graphs, this criterion leads directly to an algorithm for finding a T -embedding. To ensure linear time complexity, we use dual graphs to represent the relationships between facial cycles (see [7]). Suppose G is a 3connected planar graph and F the unique set of facial cycles of some embedding of G. Any two facial cycles have at most one edge in common and each edge belongs to exactly two facial cycles. We define the dual graph G∗ on F such that two facial cycles are adjacent iff they share an edge. Since edges of G are in a one-to-one correspondence to edges of G∗ , let C ∗ denote the set of edges in G∗ that correspond to the edges of C ⊆ E(G). G∗ has the interesting property that C ⊆ E(G) is a cycle in G iff C ∗ is a minimal cut in G∗ , i.e. removing C ∗ from G∗ separates G∗ intoLtwo components U ∗ , W ∗ ⊂ G∗ . These components L satisfy C = F ∈U ∗ F = F ∈W ∗ F . Thus, in any embedding of G U ∗ is the
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
34
set of facial cycles inside C and W ∗ is the set of facial cycles outside C, or vice versa. Figure 3 illustrates the relationship between G and G∗ . G∗
G F1
F2
F3
F4
C
F5
F1 F2 F3 F4
F6 F5
F6 (a)
(b)
Figure 3: (a) A 3-connected planar graph G with a cycle C and unique (b) The dual Graph G∗ of G with minimal cut faces F1 , . . . , F6 . ∗ C = {F1 F6 , F2 F5 , F4 F5 , F3 F6 } corresponding to C and the sets U ∗ = {F1 , F2 , F3 , F4 }, W ∗ = {F5 , F6 }. To find a T -embedding, we only have to decide for each C whether U ∗ or W ∗ is the set of facial cycles outside C and to search for a facial cycle F0 belonging to each of these sets. Then F0 can be chosen as the outer facial cycle. We describe the algorithm in Fig. 4 and prove its correctness in Theorem 2. Algorithm embed triconnected graph Input : G, T Output : outer facial cycle F0 of some T -embedding 1. 2. 3.
4.
Find the set F of facial cycles of some embedding of G. Construct the dual graph G∗ . ∗ ∗ ∗ ∗ For each hC, In SC , OutC i ∈ T find the S components UC , WC of G − C . Let be UC = F ∈U ∗ F and WC = F ∈W ∗ F . C C ∗ = WC∗ ; If InC ⊂ UC and OutC ⊂ WC , define ZC ∗ = UC∗ ; else stop. else if InC ⊂ WC and OutC ⊂ UC , define ZC ∗ , return F0 . If there is some cycle F0 ∈ F belonging to each ZC Figure 4: Embedding algorithm for 3-connected graphs
Theorem 2 Given a 3-connected graph G and a set T of topological constraints for G, algorithm embed triconnected graph generates a T -embedding represented by its outer facial cycle iff G is T -planar. Moreover, it has time complexity O(nt). Proof: (⇒) Suppose the algorithm returns some F0 . There is some embedding e of G with inner facial cycles F 0 = F \ {F0 } and outer facial cycle F0 . By G ∗ ∗ , we have for any hC, InC , OutC i ∈ T and FC := F \ZC ⊆ F0 definition of the ZC
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
35
S that F ∈FC F contains all edges of InC but no edge of OutC . Thus, by Theorem e is a T -embedding. 1, G e with the set F 0 of inner (⇐) Conversely, assume G to have a T -embedding G 0 facial cycles and outer facial cycle F0 . We have to show that the algorithm always generates a cycle F0 as required. Let for any hC, InC , OutC i ∈ T FC denote the sum of those cycles in F 0 that sum up to C. FC and (F 0 ∪SF00 ) \ FC are exactly the components UC∗ , WC∗ of G∗ − C ∗ and, by Theorem 1, F ∈FC F ∗ contains all edges of InC but no edge of OutC . Thus, the algorithm defines ZC 0 0 0 ∗ to be (F ∪ F0 ) \ FC . At least T F0∗ belongs to each ZC such that the algorithm . can return some cycle F0 ∈ C ZC Finally, this algorithm can be implemented as an O(nt) procedure: generating the facial cycles of G by embedding G takes O(n) time as well as the construction of the dual graph G∗ . Since finding the components UC∗ and WC∗ of G∗ − C ∗ and testing the required conditions can both be done in O(n) time, step 3 takes all in all O(nt) time. The last step also needs only O(nt) time. 2 Basically, this polynomial time T -planarity algorithm depends on the simple topological properties of 3-connected planar graphs. The next theorem shows that in the general case we cannot hope for such a polynomial time solution. This also holds for some natural restrictions of the problem. Theorem 3 The problem of T -planarity is NP-complete. Proof: Membership in NP follows immediately from Theorem 2: we only have to guess a 3-connected planar supergraph G0 of G and verify in polynomial time G0 to be T -planar. Next we show the problem to be NP-hard by transformation from the NPcomplete problem BETWEENNESS (see [13]) defined as: given a finite set A and a set S of ordered triples of distinct elements from A, is there a oneto-one function f : A −→ {1, . . . , |A|} such that for each (a, b, c) ∈ S either f (a) < f (b) < f (c) or f (c) < f (b) < f (a) holds? Let A = {a1 , . . . , an } and S be an arbitrary instance of BETWEENNESS. We associate with A the graph GA defined by V (GA ) = {x, y, a1 , . . . , an } and E(GA ) = {xai , ai y | i ∈ {1, . . . , n}}. For any i, j with 1 ≤ i < j ≤ n let Ci,j denote the cycle (x, ai , y, aj , x) illustrated in Fig. 5. Then, S is encoded by a set TS of topological constraints for GA : let InCi,j be the set {xak | (ai , ak , aj ) ∈ S or (aj , ak , ai ) ∈ S} and TS be the set of triples hCi,j , InCi,j , ∅i with nonempty InCi,j . We show that GA is TS -planar iff there is some function f satisfying the fA is a TS -embedding of GA where a0 requirements given above. Suppose G fA . and a00 are the two vertices of GA belonging to the outer facial cycle of G We define a linear order f on A by f (a0 ) = 1, f (a00 ) = n and inductively fA where the f (a) = i if a 6= a00 and a belongs to the outer facial cycle of G −1 −1 vertices f (1), . . . , f (i − 1) are removed. It follows immediately that for each (a, b, c) ∈ S f (b) is between f (a) and f (c). Conversely, suppose f has the required property. Then GA can be embedded while preserving the order of f , i.e. f −1 (i) and f −1 (i + 1) belong to the same
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
36
x
a1
ai
Ci,j
aj
an
y Figure 5: Graph GA defined in the proof of Theorem 3 inner facial cycle and f −1 (1) and f −1 (n) belong to the outer facial cycle. Thus, 2 all edges of InCi,j are inside Ci,j . According to the special properties of GA and TS defined in the proof, we can draw some further conclusions. Since GA is 2-connected and has treewidth 2, T -planarity remains NP-complete for the class of graphs having these properties. Thus, unlike many other graph problems, a bounded treewidth does not result in a polynomial time solution in case of T -planarity. With respect to the connectivity number κ of graphs, we get the exact boundary between P and NP: the problem is NP-complete for κ ≤ 2 while allowing a polynomial time solution for κ ≥ 3. T -planarity remains also NP-complete for Eulerian graphs since GA is Eulerian (if |A| is odd, we have to add the edge xy to E(GA )). Interestingly, NP-completeness holds for topological constraints of the form hC, InC , ∅i. Since in the proof any xak ∈ InCi,j can be expressed equivalently by xai ∈ OutCk,j and xaj ∈ OutCi,k , this is also valid for constraints of the form hC, ∅, OutC i.
4
Reduction to Biconnected Graphs
As far as classical planarity is concerned, the planarity problem of a graph can be simply reduced to its blocks. Correspondingly, many graph embedding algorithms, e.g. [3] and [18], require the input graph to be 2-connected. The embedded blocks can be easily merged to an embedding of the whole graph. A corresponding reduction for T -planarity, however, must involve all the topological constraints between the components and blocks. In this section we develop a polynomial time algorithm providing such a reduction in two steps: first, T planarity for a graph is reduced to its components and second, connected graphs with constraints are reduced to their blocks. Thus, it is sufficient to focus on 2connected graphs when searching for polynomial time subproblems or heuristics to cope with the general NP-complete problem.
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
4.1
37
Reducing a Graph to Its Components
Topological constraints for an arbitrary planar graph can considerably differ from those for a 2-connected graph: this is due to the fact that topological constraints between its components or blocks imply yet another sort of constraints not subsumed by Definition 1. Suppose we have two components H and H 0 of a graph G and three constraints meaning that x ∈ E(H 0 ) must be embedded inside cycles C1 and C2 , but outside cycle C3 of H. To find an embedding of e of H with an G satisfying these constraints, we have to find an embedding H f f f inner face inside C1 and C2 , but outside C3 in which we can embed H 0 . Thus, we get a new constraint between cycles of the same component that cannot be equivalently expressed by topological constraints. Although again topological by nature, we call constraints of this sort overlap constraints. More formally: Definition 2 Let G be a graph and L be a set of pairs Li = hC-Ini , C-Outi i such that C-Ini and C-Outi are sets of cycles of G. These pairs are called overlap constraints for G. e of G satisfies L if for each constraint Li ∈ L there is a face An embedding G e in the interior of all cycles of C-Ini and in the exterior of all cycles of of G C-Outi ; such an embedding is called an L-embedding. Moreover, G is L-planar if G has an L-embedding. We only consider overlap constraints that are induced by topological constraints though they might be of general interest. If a graph has an embedding satisfying both topological constraints T and overlap constraints L, we call it T L-planar and its embedding T L-embedding for short. If H is a subgraph of G, we denote with T |H the set of topological constraints which T induces on H, i.e. hCi , Ini ∩ E(H), Outi ∩ E(H)i if Ci is a cycle in H and hCi , Ini , Outi i ∈ T . Suppose G is a planar graph, T is a set of topological constraints for G and H is the set of components of G to which we want to reduce T -planarity. To represent the induced constraints between distinct components H, H 0 ∈ H, we define the following sets: C-InH,H 0 C-OutH,H 0
= {C ⊂ H | hC, InC , OutC i ∈ T with InC ∩ E(H 0 ) 6= ∅}, = {C ⊂ H | hC, InC , OutC i ∈ T with OutC ∩ E(H 0 ) 6= ∅}.
The sets C-InH,H 0 define moreover a relation ≺ on H by H 0 ≺ H iff C-InH,H 0 6= ∅. This relation means that we have to find an embedding of H that has a face inside all cycles of C-InH,H 0 and outside all cycles of C-OutH,H 0 , thus satisfying the overlap constraint hC-InH,H 0 , C-OutH,H 0 i. However, there are much more overlap constraints for H. Consider the set H0 of all successors of H, i.e. {H 0 | H 0 ≺ H}, and let K be a component of (the undirected graph of) ≺ restricted to H0 . of H. The stronger Then all H 0 ∈ K must lie in the same S S face of an embedding overlap constraints for H are thus h H 0 ∈K C-InH,H 0 , H 0 ∈K C-OutH,H 0 i for all such K. e of G and the induced ordering < on H by Now consider an embedding G e H 0 is in some inner face of G| e H . It can be easily seen, that < is H 0 < H iff G|
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
38
a strict partial order with the additional property that H 0 < H and H 0 < H 00 imply either H < H 00 or H = H 00 or H 00 < H due to planarity. In other words, e is a < is the transitive closure of a disjoint union of rooted trees. If moreover G T -embedding, the relation ≺ defined above is a subrelation of <. An example of both relations is given in Fig. 6.2 G
H1 C1
C2
H2 C4
C5
C3
C6
H3
H4
C-InH1 ,H3 C-InH1 ,H4 C-InH2 ,H3 C-InH2 ,H4 C-OutH1 ,H2 C-OutH2 ,H1 (a)
e G H3 H4 C1 C 4 C6 C5
C3
H3 <
C2
≺
H1
= {C1 } = {C2 } = {C4 } = {C5 } = {C3 } = {C6 }
H2
H4 H1 H2
H3
H4
(b)
Figure 6: (a) A graph G consisting of components H1 , . . . , H4 and topological constraints between them represented by the sets C-InHi ,Hj and C-OutHi ,Hj ; e satisfying these constraints these sets define the relation ≺. (b) An embedding G e and the relation < induced by G. The method of reducing T -planarity of G to its components consists just in finding such an extention < of ≺ and appropriate embeddings of the components of G. Instead of the strict partial ordering <, it is more convenient to construct its transitive reduction which is a disjoint union of rooted trees. When first considering subsets H0 ⊂ H such that ≺ |H0 is a connected relation, we can easily formulate a recursive procedure order components shown in Fig. 7 for constructing the transitive reduction of < w.r.t. to H0 . It makes use of an algorithm A for generating an embedding of a connected graph satisfying given topological and overlap constraints; we also assume that the faces corresponding to the overlap constraints are returned. Such an algorithm A is provided by the reduction to blocks developed in the next section. The procedure order components returns e to H f0 is labelled a tree of embedded components in H0 where an edge from H e in which H f0 must be embedded. Figure 8 shows the only two with a face of H possible labelled trees that can result from the graph and constraints given in 2 Note
that we visualize relations like ≺ by drawing an arrow from H to H 0 if H 0 ≺ H.
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
39
e to H f0 by the overlap constraint Fig. 6 (a). Here we have labelled an edge from H e instead of its corresponding face. The first labelled tree corresponds to for H the embedding shown in Fig. 6 (b). Algorithm order components Input : H0 ⊂ H such that ≺ |H0 is connected Output : labelled tree of embedded components of H0 1. 2.
3. 4.
Determine the set M of components maximal in ≺ |H0 . e Use algorithm A to find an H ∈ S M with an embedding S H satisfying TH and set LH of constraints Li = h H 0 ∈Ki C-InH,H 0 , H 0 ∈Ki C-OutH,H 0 i for components Ki of ≺ |H0 \{H} . e corresponding to Li , else stop. If this succeeds, let Fi be the faces of H For all Ki compute order components(Ki ) resulting in labelled trees Ri . e by adding edges from H e to the Merge the Ri to a new tree with root H roots of Ri labelled with Fi . Finally, return this new tree. Figure 7: Algorithm for ordering components f1 H
f2 H h{C1 , C2 }, {C3 }i
f2 H h{C4 }, ∅i f3 H
h{C5 }, ∅i f4 H
h{C4 , C5 }, {C6 }i f1 H h{C1 }, ∅i f3 H
h{C2 }, ∅i f4 H
Figure 8: Two labelled trees that can result from procedure order components for the graph and constraints given in Fig. 6. Instead of faces, the edges are labelled with the corresponding overlap constraints. The complete reduction algorithm reduce to components is given in Fig. 9. To obtain a T -embedding of G, we only have to embed the components of G according to the structure of the generated trees. Finally, we prove correctness and the time complexity for this algorithm in Theorem 4. We therefore assume that an algorithm A is available for embedding a component H with topological constraints TH and overlap constraints LH . Its time complexity is assumed to be O(p(nH , kH , tH , lH )) for some polynomial p with parameters nH = |H|, tH = |TH |, lH = |LH | and the number kH of all cycles occurring in the constraints of TH and LH . Note that each overlap constraint consists then of at most kH cycles. Theorem 4 Let G be a planar graph and T be a set of topological constraints for G. Then, algorithm reduce to components generates a T -embedding of G iff
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
40
Algorithm reduce to components Input : G, T Output : T -embedding of G 1. 2. 3. 4.
Determine the set H of components of G. Determine the sets C-InH,H 0 and C-OutH,H 0 , the induced constraints TH := T |H and the relation ≺. If ≺ is cyclic, stop. For each component Ki of ≺ compute order components(Ki ) resulting in labelled trees Ri . f0 Construct the embedding of G as described by the Ri , i.e. embed H e iff there is an edge from H e to H f0 labelled with F . into face F of H Figure 9: Reduction of T -planarity of a graph to its components
G is T -planar. Moreover, it takes O n4 + n2 t + n · p(n, t, t, n) time provided that the time complexity of A is given by p. e is an embedding of G generated by the algorithm and < Proof: (⇒) Suppose G e is indeed a T -embedding. is the induced relation on H. We have to show that G e be the generated embedding of the component Let be hC, InC , OutC i ∈ T and H H ∈ H with C ⊂ H. First, consider an x ∈ InC belonging to component H 0 ∈ H. If H = H 0 , x is e in H e since H e is a TH -embedding. Otherwise we have H 0 ≺ H. When inside C choosing H for embedding in step 2 of algorithm order components, H 0 belongs to some component Ki of ≺ |H0 \{H} . Thus, the overlap constraint Li ensures e of H. e that all H 0 ∈ Ki are embedded in a face inside C Second, consider an x ∈ OutC belonging to component H 0 ∈ H. Again, if e in H e since H e is a TH -embedding. Otherwise we have H = H 0 , x is outside C 0 e H 0 must be in some component Ki C ∈ C-OutH,H 0 . If H < H holds in G, of ≺ |H0 \{H} determined in step 2 of algorithm order components. Thus, the overlap constraint Li ensures that all H 0 ∈ Ki are embedded in a face outside e H f0 is obviously outside C e of G. e e of H. e If H 0 < H does not hold in G, C (⇐) Conversely, we show that the algorithm indeed finds an embedding of G if G is T -planar. By the first part of the proof, such an embedding always e be a T -embedding of G and < be its induced relation on satisfies T . So let G H. Since < is an extention of ≺, ≺ is in particular acyclic. For a connected e 0 |H0 the restriction of some T -embedding subrelation ≺ |H0 of ≺ we denote with G 0 0 e of G to the components in H . Note that each G e0 |H0 has a unique maximal G component in < |H0 . We must show that for each call of procedure order components the search for an appropriate maximal component H always succeeds. For this purpose e H0 for each call order components(H0 ) we define inductively a T -embedding G eH0 |H0 is a possible choice in step 2. Let such that the maximal component of G 0 e Ki be the components of ≺ and let G be the embedding of G built by placing
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
41
e0 satisfies T again. e Ki into different regions of the plane. Obviously, G all G| e0 . Thus, for each call order components(Ki ) the eKi to be G We define each G e maximal component of GKi |Ki is a possible choice for H in step 2. eH0 be already deConsider now some call order components(H0 ) and let G 0 fined. By assumption, the search in step 2 for an H ∈ H succeeds; however, H e H0 |H0 . Let Ki be is not necessarily identical with the maximal component of G the components of ≺ |H0 \{H} and Fi be the corresponding faces of the generated e in which the components in Ki must be embedded. Transform embedding H e e 0 of G by replacing G e H0 |H with H e and placing each 0 GH into a new embedding G 0 e e e e Ki to be GH0 |Ki into the face Fi of H. Again, G satisfies T . We define each G 0 e . Consequently, for each call order components(Ki ) the maximal component G e Ki |Ki is a possible choice for H in step 2. This completes the proof that of G the algorithm never stops irregularly if G is T -planar. Finally, we derive the time complexity of reduce to components from algorithm A. As can be easily seen, step 1, 2 and 4 of reduce to components takes O(n), O(nt) + O(n2 ) and O(n) time, respectively. To establish the time needed by step 3, we consider the call order components(H0 ) for some H0 ⊂ H. First, the set M of maximal components of ≺ |H0 can be determined in O(n) time. For some Hj ∈ M let be nj = |Hj |, tj = |THj |, lj = |LHj | and kj be the number of cycles occurring in THj and LHj , i.e. the number of cycles in Hj occurring in T . Then, computing the lj components of ≺ |H0 \{Hj } can be done in O(n2 ) time and determining the constraints LHj needs O(nkj ) time. By assumption, testing if Hj is THj LHj -planar can be done in O(p(nj , kj , tj , lj )) time. P In the ∈ M must be checked. It is clear that nj = n, worst case, however, all the H j P P P P tj ≤ t. Additionally, we have lj ≤ 2n since lj is largest if kj = t and ≺ |H0 is a tree and for a tree the sum is twice the number of edges. Thus, step 2 of order components can be done in X O(n2 ) + O(nkj ) + O(p(nj , kj , tj , lj )) X X X X X X nkj + p kj , tj , lj nj , = O n2 + = O n3 + nt + p(n, t, t, n) . is bounded by n, we get the overall Since the number of calls of order components complexity O n4 + n2 t + n · p(n, t, t, n) for algorithm reduce to components. 2
4.2
Reducing a Component to Its Blocks
The second part of reducing T -planarity of a graph G consists of reducing its components H with induced topological constraints TH and overlap constraints LH to its blocks. Again, this reduction step leads to a new sort of constraints between blocks which are similar, but not entirely equivalent with overlap constraints. Consider two blocks B and B 0 of H having a cutvertex v in common and suppose we have constraints in TH meaning that B 0 must be embedded inside cycles C1 and C2 , but outside cycle C3 of B. A corresponding embedding
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
42
e of B must clearly satisfy the overlap constraint h{C1 , C2 }, C3 i. However, due B to the way these blocks are connected to each other, the topological constraints e inside C1 imply additional requirements: first, the boundary of the face in B and C2 , but outside C3 must contain the cutvertex v, and second, v must belong e f0 of B 0 in order to merge B to the boundary of the outer face of the embedding B 0 0 f to an embedding of B ∪ B satisfying the constraints given above. Since and B these constraints are an extention of overlap constraints, we call them extended overlap constraints. Definition 3 Let G be a graph and X be a set of triples Xi = hC-Ini , C-Outi , vi such that C-Ini and C-Outi are sets of cycles of G and v is a vertex of G. These triples are called extended overlap constraints for G. e of G satisfies X if for each constraint Xi ∈ X there is a face of An embedding G e in the interior of all cycles of C-Ini and in the exterior of all cycles of C-Outi G and whose boundary contains v; such an embedding is called an X -embedding. Moreover, G is X -planar if G has an X -embedding. We are again only interested in those extended overlap constraints that are f0 derived in the reduction step. It can easily be seen that the requirement for B to have v at the boundary of the outer face can be expressed by the extended overlap constraint h∅, C-Out, vi where C-Out denotes the set of all cycles occurring in the constraints for B 0 . This is because taking the face corresponding to this extended overlap constraint as the outer face results in the required embedding where v is on the outer face boundary and all other constraints are preserved. The reduction of TH LH -planarity of H to its blocks works much like the first reduction step of G to its components. This is due to the fact that any embedding of H induces again an ordering < on the set B of blocks of H with the same properties as defined in the previous section. Thus we can adopt the key idea of constructing an appropriate ordering of the blocks. However, some minor modifications are necessary to cope with both the overlap constraints LH and the extended overlap constraints derived during the reduction process. We use the block graph Hb of H, as defined in Sect. 1, to represent the complete decomposition of H into its blocks and cutvertices. Note that Hb is a tree because H is connected. Analogously to the previous section, we represent the constraints between distinct blocks B, B 0 ∈ B by the sets C-InB,B 0 and C-OutB,B 0 . By defining them in terms of C-components, many constraints between B and further blocks are inferred. For the sake of a uniform representation, we transform the overlap constraints Li ∈ LH into the sets C-InB,Li and C-OutB,Li . C-InB,B 0 = {C ⊂ B | hC, InC , OutC i ∈ TH with InC ∩ E(Z) 6= ∅ for some C-component Z containing B 0 }, C-OutB,B 0 = {C ⊂ B | hC, InC , OutC i ∈ TH with OutC ∩ E(Z) 6= ∅ for some C-component Z containing B 0 }, C-InB,Li = {C ⊂ B | Li = hC-Ini , C-Outi i ∈ LH with C ∈ C-Ini }, C-OutB,Li = {C ⊂ B | Li = hC-Ini , C-Outi i ∈ LH with C ∈ C-Outi }.
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
43
The sets C-InB,B 0 and C-InB,Li define again a relation ≺ on B ∪ LH by B 0 ≺ B iff C-InB,B 0 6= ∅ and Li ≺ B iff C-InB,Li 6= ∅. The reason for including the constraints of LH is that this ensures all blocks B with Li ≺ B to be embedded in a linear order of < as must be the case in any embedding of H satisfying LH (see for example Fig. 12). The algorithm reduce to blocks providing the second reduction step is presented in Fig. 10. Again, the resulting embedding of H is obtained from a labelled tree that is generated by the procedure order blocks given in Fig. 11. This procedure assumes that some block B0 is selected from those blocks that are maximal in ≺ to serve as a maximal block in the relation < induced by the TH LH -embedding of H to be generated. Thus, contrary to the reduction algorithm in the previous section, finding a TH LH -embedding of H possibly requires several complete reduction processes if necessary until a proper B0 leads to the required embedding. This is due to the fact that the generated extended overlap constraints for the blocks are partially depending on the choice of B0 ; for instance, all other blocks B with cutvertex q in the path B0 , . . . , q, B of Hb are to be embedded with q at the outer face boundary. Instead of relation ≺, procedure order blocks uses for technical reasons an extention ≺0 of ≺ by adding B 0 ≺0 B iff B0 , . . . , B, q, B 0 is a path in Hb . This enforces the search of which block to consider next in step 2 of order blocks to take those blocks that are nearest to B0 in the tree Hb . Note that in general, however, ≺0 is no longer a subrelation of < induced by some TH LH -embedding of H. Algorithm order blocks works similarly to its corresponding procedure order components except for those parts where the block graph must be taken into account. Algorithm reduce to blocks Input : component H with constraints TH and LH Output : TH LH -embedding of H 1. 2. 3.
4.
Determine the set B of blocks of H and the blockgraph Hb of H. Determine the sets C-InB,B 0 , C-OutB,B 0 , C-InB,Li and C-OutB,Li , the constraints TB := TH |B and the relation ≺. If ≺ is cyclic, stop. Find a block B0 maximal in ≺ such that order blocks(B ∪ LH ) results in a labelled tree R using the extention ≺0 of ≺ by B 0 ≺0 B iff B0 , . . . , B, q, B 0 is a path in Hb . If this fails, stop. Construct the embedding of H as described by R, i.e. for any edge e to B f0 labelled with F and for the cutvertex p with path from B 0 f0 into face F at p of B. e Additionally, return B, p, B in Hb embed B the faces corresponding to the overlap constraints Li ∈ LH , i.e. the labels of the edges to Li in R.
Figure 10: Reduction of TH LH -planarity of a connected graph to its blocks Figure 12 illustrates this reduction step with a simple connected graph H whose blocks B1 , . . . , B4 are cycles C1 , . . . , C4 , respectively, and B5 is a bridge.
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
44
Algorithm order blocks Input : B 0 ⊂ B ∪ LH such that ≺0 |B0 is connected Output : labelled tree of embedded components of B 0 1. 2.
3. 4.
Determine the set M of components maximal in ≺0 |B0 . Use algorithm A0 to find some B ∈ M such that: (i) for any component Ki of ≺0 |B0 \{B} there is at most one cutvertex pi ∈ B in Hb separating B from Ki , e where (ii) B has a TB LB XB -embedding B LB is the set of overlap constraints L0i = hC-InB,Ki , C-OutB,Ki i for all Ki ∈ LH , XB is the S set of extendedSoverlap constraints Xi = h B 0 ∈Ki C-InB,B 0 , B 0 ∈Ki C-OutB,B 0 , pi i for all Ki 6∈ LH . If B 6= B0 , XB contains the additional constraint that q satisfying the path B0 , . . . , q, B in Hb must be at the outer face boundary. e corresponding to L0 and Xi , If this succeeds, let Fi be the faces of B i respectively, else stop. For all Ki 6∈ LH compute order blocks(Ki ) resulting in labelled trees Ri . For any Ki ∈ LH define Ri to be Ki . e by adding edges from B e Merge the Ri to a new tree with root B to the roots of Ri labelled with Fi . Finally, return this new tree. Figure 11: Algorithm for ordering blocks
The topological constraints and the overlap constraint L for H are directly encoded in the relation ≺. As can easily be seen, the only correct choice for B0 among the candidates B1 and B3 is B0 = B1 . This is because B0 = B3 is separated in Hb by two cutvertices from B2 = C2 and B4 = C4 which inhibits embedding one of these cycles into the other and thus contradicts the overlap constraint L. To establish in Theorem 5 correctness and time complexity of algorithm reduce to blocks, we assume an algorithm A0 to be available for embedding a block B with topological constraints TB , overlap constraints LB and extended overlap constraints XB . The time complexity of A0 is assumed to be O(p0 (nB , kB , tB , lB , xB )) for some polynomial p0 with parameters nB = |B|, tB = |TB |, lB = |LB |, xB = |XB | and the number kB of all cycles occurring in the constraints of TB , LB and XB . Consequently, each overlap constraint and each extended overlap constraint consists of at most kB cycles. Theorem 5 Let H be a connected planar graph and TH be a set of topological constraints and LH be a set of overlap constraints for H. Then, algorithm reduce to blocks generates a TH LH -embedding of H iff H is TH LH -planar. Moreover, it takes O n5 + n4 l + n3 k + n2 kl + nt + n2 · p0 (n, k, t, l, n + l) time provided that the time complexity of A0 is given by p0 and n = |H|, t = |TH |,
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002) B1
C1 p1
p1
C2
p2
C4
f1 B B3
B4 L
≺0
B4
≺
h{C1 }, ∅, p1 i
f2 B B5
h∅, {C2 }, p1 i h{C2 }, ∅, p1 i h∅, {C3 }, p1 i
f3 B
B5
L
Hb (a)
B1 B2
B2 B4
B5 H
B3
B2
B3
p2
C3
B1
45
h{C3 }, ∅, p2 i h∅, {C3 }, p2 i f B4 h{C4 }, ∅i L
h∅, ∅, p2 i h∅, ∅, p2 i f5 B R
C1 C2 C3 C4
e H
(b) Figure 12: (a) A connected graph H with its block graph Hb and the relation ≺ determined by C-InB1 ,B2 = {C1 }, C-InB3 ,B4 = {C3 }, C-InB2 ,L = {C2 } and C-InB4 ,L = {C4 }. (b) The relation ≺0 , the labelled tree R and its corresponding e when B1 is chosen as B0 . embedding H
l = |LH | and k is the number of all cycles occurring in the constraints of TH and LH . e is an embedding of H generated by the algorithm and Proof: (⇒) Suppose H e is indeed a TH LH < is the induced relation on B. We have to show that H embedding. Analogously to the proof of Theorem 4, it can easily be seen that the induced topological constraints TB and the extended overlap constraints Xi e satisfies TH . produced in step 2 of algorithm order blocks guarantee that H e To show that H also satisfies LH , we consider an overlap constraint L = e corresponding to L and BF is hC-In, C-Outi ∈ LH . Suppose F is the face in H the block with an edge to L labelled with F in the tree R resulting from step 3 of reduce to blocks. That is, BF appears as the minimal block in < containing cycles from C-In. When choosing BF for embedding in step 2 of order blocks, the generated overlap constraint L0i = hC-InBF ,Ki , C-OutBF ,Ki i for Ki = L clearly ensures that F is a face inside all cycles of C-In in BF and outside all cycles of C-Out in BF . Let C ∈ C-In belong to some block B 6= BF . Since L and
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
46
BF belong to the same component Ki determined in step 2 of order blocks, the e corresponding to the extended overlap constraint Xi is guaranteed to face of B be inside C. Thus, BF is embedded inside C. Next, consider some C ∈ C-Out e BF must be in a belonging to a block B 6= BF . If BF < B holds in H, component Ki . Then, the constraint Xi ensures again its corresponding face in e to be outside C. Otherwise, BF is obviously outside C in H. e B (⇐) Conversely, we show that the algorithm never stops irregularly if H is e is an embedding of H satisfying the constraints TH TH LH -planar. Suppose H and LH and < is the induced relation on B. Clearly, the restriction of ≺ to B is a subrelation of <; thus ≺ must be acyclic. Since in step 3 of reduce to blocks possibly all maximal blocks in ≺ are considered, it is sufficient to show that the choice of a block B0 which is maximal in < succeeds. So let ≺0 be the extention of ≺ defined in step 3 which is also acyclic. In analogy to the proof of Theorem e B0 for each call order blocks(B 0 ) such that the 4 we define a TH LH -embedding H e B0 |B0 is a possible choice in step 2. maximal component of H e such that for the call order blocks(B ∪ LH ) B0 e First we define HB∪LH := H is an appropriate choice in step 2; moreover, B0 is the only candidate because it is the unique maximal block in ≺0 . Consider now some call order blocks(B 0 ) e B0 be already defined. By assumption, the search in step 2 for some and let H B ∈ B 0 succeeds; however, B is not necessarily identical with the maximal block e B0 |B0 . Let Ki be the components of ≺0 |B0 \{B} and Fi be the corresponding of H e in which the blocks in Ki must be embedded. faces of the generated embedding B Moreover, let pi ∈ B be the cutvertex in Hb separating B from Ki . Then e 0 of H by replacing H e B0 |B with B e and e B0 into a new embedding H transform H 0 e e e placing each HB0 |Ki into face Fi of B at cutvertex pi . Again, H satisfies TH e Ki is defined to be H e 0 , we assure that for each call and LH . When each H e Ki |Ki is a possible choice in step 2. order blocks(Ki ) the maximal block of H This completes the proof that this algorithm never stops irregularly if H is TH LH -planar. Finally, we derive the time complexity of reduce to blocks from algorithm A0 . As can be easily seen, step 1 and 4 of reduce to blocks takes O(n) and O(n + l) time, respectively. The construction of the sets C-InB,B 0 and C-OutB,B 0 in step 2 depends on the C-components which can be determined in O(nt) time. Then the four sets can be determined in O(nt) + O(kl) time. Moreover, defining the sets TB can be done in O(nt) time and the relation ≺ can be computed and checked in O(n2 + nl) time. We consider next the call order blocks(B 0 ) for some B 0 ⊂ B ∪ LH . The set M of maximal components in ≺0 |B0 can be determined in O(n) time. For some Bj ∈ M let be nj = |Bj |, tj = |TBj |, lj = |LBj |, xj = |XBj | and kj be the number of all cycles occurring in TBj , LBj and XBj , i.e. the number of all cycles in Bj occurring in TH and LH . Then, determining the lj + xj components Ki of ≺0 |B0 \{Bj } needs O(n2 + nl) time and determining the cutvertices pi needs O(n) time. Moreover, the constraints XBj can be found in O((n + l)kj ) time whereas the constraints LBj consists of sets already generated. By assumption, a TBj LBj XBj -embedding, if any, can be found in O(p0 (nj , kj , tj , lj , xj )) time.
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
47
In the worst P case, however, P all the Bj ∈PM must be checked. It is clear that P kj = k, tj ≤ t and lj P = l. By the argument given in nj ≤ 2n, the proof of Theorem 4, we additionally get xj ≤ 2(n + l). Thus step 2 of order blocks can be done in X (O(n2 + nl) + O((n + l)kj ) + O(p0 (nj , kj , tj , lj , xj ))) X X X X X X X (n + l)kj + p0 kj , tj , lj , xj nj , = O (n2 + nl) + = O n3 + n2 l + nk + kl + p0 (n, k, t, l, n + l) . Since for a fixed B0 the number of calls is bounded by n, the time needed can by the call order blocks(B ∪ LH ) in step 3 of algorithm reduce to blocks be estimated by n O(n) + O n3 + n2 l + nk +kl + p0 (n, k, t, l, n + l) , that is O n4 + n3 l + n2 k + nkl + n · p0 (n, k, t, l, n + l) . In the worst case, however, all maximal blocks B0 in ≺ must be checked. Thus we finally obtain the overall complexity O nt + kl + n2 + nl + n O n4 + n3 l + n2 k + nkl + n · p0 (n, k, t, l, n + l) = O n5 + n4 l + n3 k + n2 kl + nt + n2 · p0 (n, k, t, l, n + l) . 2 As an immediate consequence, we get the complexity of this algorithm when only topological constraints TH are given. In this case we have l = 0 and k = t = |TH |. Moreover, the reduction to blocks leads only to extended overlap constraints, but not to overlap constraints. Corollary 1 For a connected planar graph H with n = |H| and a set TH of topological constraints for H with t = |TH |, the algorithm reduce to blocks takes O n5 + n3 t + n2 · p0 (n, t, t, 0, n) time. The combination of the algorithms developed in this and the previous section leads to the complete reduction method of T -planarity of a graph G to its blocks. When replacing algorithm A with algorithm reduce to blocks in Theorem 4 (and matching the corresponding parameters), the following time complexity of the complete reduction can easily be verified. Corollary 2 Suppose G is a planar graph with n = |G| and T is a set of topological constraints for G with t = |T |. Then, algorithm reduce to components com- bined with algorithm reduce to blocks takes O n6 + n4 t + n3 · p0 (n, t, t, n, 2n) time provided that the time complexity of A0 is given by p0 . We finally note that extended overlap constraints can often be simplified in the following way. Consider some constraint Xi = hC-Ini , C-Outi , vi and a cycle C ∈ C-Ini . In case of v 6∈ C we can remove C from C-Ini and create the topological constraint meaning that v is to be embedded inside C instead. If this constraint is satisfied, any face with v at its boundary is certainly in the interior of C. The cycles of C-Outi containing v can be treated analogously. Thus, this simplification results in extended overlap constraints whose vertex is contained in all cycles involved.
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
5
48
Restricted Topological Constraints
The NP-completeness result of planarity with topological constraints opens the search for interesting tractable subproblems. Such subproblems can be defined in terms of various restrictions on graphs or constraints. For instance, one can study the effect of restricting the degree of graphs to the time complexity of T -planarity. Instead of graph parameters, we are concerned in this section with a particular parameter inherent to topological constraints which we call cycle intersection order. Definition 4 Given a graph G and a set C of cycles in G, the maximum number of vertices two distinct cycles of C have in common is called the cycle intersection order of C. For a set T of topological constraints for G we denote the set of cycles occurring in T by CT . The cycle intersection order of T is the cycle intersection order of CT . If d is the cycle intersection order of T , we also write Td for T . In other words, the cycle intersection order of T is the maximum order of all graphs Ci ∩ Cj for distinct Ci , Cj ∈ CT . We consider it a natural parameter of topological constraints since it captures an important aspect of the relationships between cycles of CT which is worth studying. In particular, we are interested in finding the exact boundary between P and NP w.r.t. this parameter. Recalling the proof of Theorem 3, we can immediately conclude that Td planarity remains NP-hard for all d ≥ 3. This is because any two distinct cycles involved in the defined constraints share either 2 or 3 vertices. By a minor modification of encoding a BETWEENNESS instance, we obtain NP-hardness even for d ≥ 2. Theorem 6 The problem of Td -planarity is NP-complete for all d ≥ 2. Proof: It is sufficient to show NP-hardness of Td -planarity for d = 2. Consider an instance of BETWEENNESS, i.e. a set A = {a1 , . . . , an } and a set S = {s1 , . . . , sr } of ordered triples sj = (aj1 , aj2 , aj3 ) of distinct elements of A. We transform the graph GA defined in the proof of Theorem 3 into a graph G0A by replacing each vertex ai by the path ai,1 , . . . , ai,r (with an edge from each of these vertices to x and y) and adding some cycle C which meets all these vertices involved exactly in x and y. This construction is illustrated in Fig. 13. For any sj = (aj1 , aj2 , aj3 ) let Cjj1 ,j3 denote the cycle (x, aj1 ,j , y, aj3 ,j , x). We define TS0 to contain the constraints hCjj1 ,j3 , {xaj2 ,j }, ∅i for all triples sj and, additionally, the constraint hC, {xai,j | 1 ≤ i ≤ n, 1 ≤ j ≤ r}, ∅i. This last constraint ensures any embedding of G0A to induce some linear order of the paths ai,1 , . . . , ai,r . Obviously, all these cycles have exactly x and y in common such that the cycle intersection order of TS0 is 2. Then it can be proved analogously to Theorem 3 that G0A is TS0 -planar iff hA, Si is a positive instance; however, we omit the details. 2
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
49
x C
a1,1
a1,r
an,1
an,r
1 C1,n
y Figure 13: Graph G0A defined in the proof of Theorem 6 Interestingly, the remaining problem of T1 -planarity turns out to have a positive solution. The next sections are devoted to the development of a polynomial time algorithm for generating a T1 -embedding. Thus, the boundary of Td -planarity between P and NP will be proved to be d = 1. Due to the polynomial time reduction method presented in the previous section, it is sufficient to find a polynomial time embedding algorithm for 2-connected graphs and constraints that are derived from topological constraints with cycle intersection order 1. Expectedly, such an algorithm depends primarily on certain structural properties of sets of cycles in a 2-connected graph with cycle intersection order 1. The next section explores these properties as far as required for developing the T1 -embedding algorithm.
5.1
Decomposition of Biconnected Graphs by Cycles of Intersection Order 1
Suppose we are given a nonempty set C of cycles in a planar 2-connected graph G such that C has cycle intersection order 1. Moreover, let n denote |G| and k denote |C|. Since any edge of G belongs to at most one cycle of C and each cycle = n − 2. consists of at least three edges, we immediately get that |C| ≤ 3n−6 3 This also holds obviously for planar graphs with a smaller connectivity number than 2. Nevertheless, we continue to use parameter k when analyzing time complexity. The main purpose of this section is to present a method of decomposing G into subgraphs with respect to C having certain desirable properties which support the construction of an embedding of G satisfying given constraints. This decomposition is described in terms of C-components of G for cycles C ∈ C. The fact that G admits such a decomposition is mainly due to the cycle intersection order 1 of C; in particular, nonplanar graphs admit the same decomposition. We denote the set of C-components in G for all C ∈ C with HC and often write HC for C-components H of G. As a simple consequence of cycle
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
50
intersection order 1 of C, we have that C 0 must be entirely contained in some C-component of G for any distinct C, C 0 ∈ C; this C-component is denoted by HC,C 0 . The following lemma describes a frequently used relationship between C-components for different cycles of C. Lemma 1 Let G be a 2-connected graph, C be a set of cycles in G with cycle intersection order 1 and C1 , C2 , C3 ∈ C. Then, if C2 and C3 belong to different C1 -components, C1 and C3 belong to the same C2 -component. Proof: We show that there is a path p in G from some vertex a ∈ V (C1 )\V (C2 ) to some vertex b ∈ V (C3 ) \ V (C2 ) such that p does not meet C2 . Then, since p is entirely contained in some C2 -component, both C1 and C3 necessarily belong to that C2 -component, too. The C1 -component H of G containing C3 has at least 2 vertices of attachment, but by assumption |C1 ∩ C2 | ≤ 1, at most one of them belongs to C2 . So let a ∈ V (C1 )\V (C2 ) be the other attachment vertex. Since C2 is not contained in H, C2 can only meet H at its attachment points. Then let H 0 ⊂ H be the component of G − C1 which contains vertices of C3 and let b be such a vertex. Thus we have H 0 ∩ C2 = ∅ and b ∈ V (C3 ) \ V (C2 ). Finally, if a already belongs to C3 , we define p to be the trivial path a. Otherwise, if e is an edge joining a to some z ∈ H 0 and p0 is a path in H 0 from z to b, then p = e ∪ p0 is the required 2 path from a to b without meeting C2 . Any cycle C ∈ C with more than one C-component divides G into just these C-components. It is more appropriate for our purpose, however, to take the union of these C-components with C as the subgraphs into which C divides G. Having in mind the way how cutvertices divide a connected graph into blocks, one can ask whether there is a similar decomposition of G into maximal subgraphs that cannot be further divided by cycles of C. This motivates the following definition of parts. Definition 5 A subset C 0 of C with |C 0 | ≥ 2 is called separable if there is some C ∈ C with at least two C-components in G each of which containing cycles from C 0 . Otherwise, C 0 is called inseparable. T An inseparable C 0 defines the subgraph PC 0 = C∈C 0 C ∪ HC of G where HC is the C-component containing all cycles from C 0 \ {C}. We call the subgraphs PC 0 defined by some maximal inseparable C 0 and the subgraphs C ∪ HC for a C-component HC not containing cycles from C parts of G w.r.t. C. The set of all parts is denoted by P. The decomposition graph D is defined on C ∪ P by the edges CP iff C ⊂ P for C ∈ C and P ∈ P. To illustrate these definitions, consider the graph G and its decomposition graph D shown in Fig. 14. For instance, {C5 , C8 } is separable since C5 and C8 belong to different C1 -components. {C1 , C8 } is inseparable, but not maximal inseparable since {C1 , C8 , C7 } is also inseparable. This set, however, is maximal inseparable, thus defining a part. As we will see, the decomposition graph is always a tree.
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002) G
D
C6
C6 C5
C5
C7
C7 C1 C3 C4
51
C2
C1
C8
C8 C3
C2
C4
Figure 14: A 2-connected graph G (drawn nonplanar) and its decomposition graph. The cycles of C with intersection order 1 are drawn as circles and the parts are marked by dashed outlines and square nodes, respectively. The definition of maximal inseparable subsets and parts, however, is nonconstructive. Thus we develop next an effective method for finding all maximal inseparable subsets of C which then can be transformed into a procedure for computing the parts of G. For this purpose we define in Proposition 1 the relation on C depending on some fixed root cycle Cr . It is called weakly linear if C C 0 and C C 00 imply C 0 C 00 or C 0 = C 00 or C 00 C 0 . Proposition 1 Let be Cr ∈ C and the relation be defined on C by C Cr and C 0 C iff C 0 6⊂ HC,Cr for all distinct C, C 0 ∈ C \ {Cr }. Then, is a weakly linear, strict partial order. Proof: It is sufficient to consider only cycles distinct from Cr . Obviously, is asymmetric since C 0 C implies by Lemma 1 that Cr and C are in the same C 0 -component, i.e. C 6 C 0 . To show transitivity, assume that C 00 C 0 and C 0 C holds and suppose that C 00 6 C. Since C 00 and Cr are in the same C-component, but not C 0 and Cr , we conclude that C and C 00 are in the same C 0 -component. In connection with C 00 C 0 we then get C C 0 in contradiction to asymmetry. Thus C 00 C must hold. To prove that is weakly linear, assume that C C 0 and C C 00 and further suppose that C 0 6= C 00 and C 0 6 C 00 . The latter means that C 0 and Cr are in the same C 00 -component, thus from C C 00 follows that C and C 0 are in different C 00 -components. Then, by Lemma 1, C 00 and C are in the same C 0 -component. In connection with C C 0 this means that C 00 and Cr are in 2 different C 0 -components, thus C 00 C 0 . In other words, the transitive reduction of is a rooted tree with root Cr . For the example graph of Fig. 14 with C1 chosen for Cr , is shown in Fig. 15.
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
52
C1 C2 C5 C6 C7 C8 C3 C4 Figure 15: Relation for the graph given in Fig. 14 and root cycle Cr = C1 . Using the relation , we are able to determine the maximal inseparable subsets C 0 of C, no matter which cycle is the root cycle. We show in Theorem 7 that we get all maximal inseparable sets C 0 by choosing some cycle C and all direct successors C 0 of C in belonging to the same C-component of G. The cycle C 0 is a successor of C if C 0 C holds, and a direct successor if there is no C 00 with C 0 C 00 C. The proof of this theorem makes use of the following lemma on maximal inseparable sets. Lemma 2 Let C 0 ⊂ C be maximal inseparable and B ∈ C be a cycle not belonging to C 0 . Then, there is some C 0 ∈ C 0 dividing B from C 0 \ {C 0 }. Proof: Since C 0 ∪ {B} is separable, there is a B1 ∈ C, B1 6= B, dividing B from all cycles of C 0 \ {B1 }. If B1 ∈ C 0 , we are finished. Otherwise, since C 0 ∪ {B1 } is also separable, there is some B2 ∈ C, B2 6= B1 , dividing B1 from C 0 \ {B2 }. We show that B2 also divides B from C 0 \{B2 }. By Lemma 1, B2 and all cycles of C 0 are in the same B1 -component, thus B and B2 are in different B1 -components. Again by Lemma 1, B and B1 are in the same B2 -component. Then we get that B2 also divides B from C 0 \ {B2 }. If B2 ∈ C 0 , we are finished. Otherwise, one can find again a B3 ∈ C dividing B2 , and thus B, from C 0 \ {B3 }, and so forth. This process results in some Bi belonging to C 0 that divides B from C 0 \ {Bi }. 2 Theorem 7 Let C 0 be a subset of C with |C 0 | ≥ 2. Then, C 0 is maximal inseparable iff there is a C ∈ C 0 such that C 0 \ {C} is a set of all direct successors C 0 C belonging to the same C-component in G. Proof: (⇒) Suppose C 0 is maximal inseparable. By Proposition 1, there is a cycle C ∈ C 0 that is maximal in |C 0 . Let H be the C-component containing all the other cycles of C 0 . We first prove that all C 0 ∈ C 0 \ {C} are successors of C. If Cr ∈ C 0 , we have C = Cr and, by definition, C 0 C for all C 0 ∈ C 0 \ {C}. Otherwise we have Cr 6∈ C 0 . We show that Cr is not contained in H; then all C 0 ∈ C 0 \ {C} are in a different C-component than Cr , thus it follows that C 0 C. So suppose that Cr ⊂ H. Since C 0 is maximal inseparable, from Lemma 2 follows that there is some C ∗ ∈ C 0 , C ∗ 6= Cr , dividing Cr from C 0 \ {C ∗ }. C ∗ must be identical with C: otherwise the maximality of C implies C 6 C ∗ , i.e. C ∗ does not divide Cr from C 0 \ {C ∗ }. However, C = C ∗ means
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
53
that Cr is in a different C-component than all C 0 ∈ C 0 \ {C}, contrary to the assumption that Cr ⊂ H. Next we show that all C 0 ∈ C 0 \{C} are direct successors of C in . Suppose that there is some C ∗ with C 0 C ∗ C. From C ∗ C follows by Lemma 1 that C and Cr are in the same C ∗ -component. In connection with C 0 C ∗ we get that C 0 and C are in different C ∗ -components. Then, however, C 0 would not be inseparable. Finally, we have to show that any direct successor C 0 of C belonging to H is already contained in C 0 . Suppose that C 0 6∈ C 0 . By Lemma 2, there is some C ∗ ∈ C 0 , C ∗ 6= C 0 , dividing C 0 from C 0 \ {C ∗ }. From C ∗ C follows that Cr and C are in the same C ∗ -component, and C 0 6 C ∗ means that Cr and C 0 are in the same C ∗ -component. Then, C ∗ does not divide C 0 from C and, thus, from C 0 \ {C ∗ }. This shows that C 0 must belong to C 0 . (⇐) Suppose C 0 satisfies the requirements where C is the maximal cycle. Let H be the C-component containing all other cycles of C 0 . We first show that C 0 is inseparable. So let C ∗ be some cycle of C. If C ∗ 6⊂ H, C ∗ is in a different C-component than all C 0 ∈ C 0 \ {C}. By Lemma 1, all C 0 ∈ C 0 are in the same C ∗ -component. Suppose C ∗ ⊂ H, thus in particular C ∗ 6= C and C ∗ 6= Cr . If C ∗ ∈ C 0 , we have C ∗ C, i.e. Cr and C are in the same C ∗ -component. Since for all C 0 ∈ C 0 \ {C} we have C 0 C, and in particular C 0 6 C ∗ , Cr and C 0 are in the same C ∗ -component. Thus, all C 0 ∈ C 0 belong to the same C ∗ component. Otherwise, if C ∗ 6∈ C 0 , C ∗ must be a successor of some C 0 ∈ C 0 \{C} according to the assumption. From C ∗ C 0 C follows that Cr , C 0 and C are in the same C ∗ -component. Since for all other C 00 ∈ C 0 \ {C, C 0 } we have C 00 6 C ∗ , it follows that Cr and C 00 are in the same C ∗ -component. Thus, all C 0 ∈ C 0 again belong to the same C ∗ -component. Next we prove that C 0 is maximal inseparable. Suppose that for some C ∗ 6∈ C 0 0 C ∪ {C ∗ } is also inseparable. Then C ∗ must be contained in H. By assumption, C ∗ must be a successor of some C 0 ∈ C 0 \ {C}, i.e. C ∗ and Cr are in different C 0 -components. From C 0 C follows that C and Cr are in the same C 0 component. Thus, C ∗ and C are in different C 0 -components such that C 0 ∪ {C ∗ } is separable. 2 From the results shown above we get some immediate consequences characterizing parts and decomposition graphs in more detail. We summarize them in Corollary 3 and 4. Corollary 3 Let P be the set of parts of G w.r.t. C. Then the following propositions hold: (i) Any part PC 0 ∈ P contains exactly the cycles C 0 from C. (ii) Any cycle C ∈ C in some part P ∈ P has exactly one C-component in P . (iii) For any part P ∈ P and cycle C ∈ C we have P ⊂ C ∪ HC for some C-component HC of G. (iv) Two distinct parts P, P 0 ∈ P have at most one cycle of C in common.
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
54
(v) Any part P ∈ P is 2-connected. S (vi) P ∈P P = G. Corollary 4 Let P be the set of parts and D be the decomposition graph of G w.r.t. C. Then the following propositions hold: (i) D is a tree with |D| < n. (ii) If HC is a C-component of G for C ∈ C and P is the part of G with C ⊂ P ⊂ C ∪ HC , then C ∪ HC is the union of all parts belonging to the component of D − C which contains P . (iii) G has less than n C-components, i.e. |HC | < n. The usefulness of decomposing G into its parts for the embedding algorithm to be developed comes in particular from proposition (ii) of Corollary 3: it guarantees that any cycle of C in some part P is a facial cycle of any embedding of P . As we will see in Sect. 5.2, this allows controlling the satisfaction of constraints during the embedding process. By proposition (ii) of Corollary 4, we have a one-to-one correspondence ε between C-components of G and edges of D: each edge CP ∈ E(D) represents the C-component HC with C ⊂ P ⊂ C ∪ HC , thus we define ε(HC ) = CP . This correspondence ensures the decomposition graph D to be a complete representation of the structure of G w.r.t. C. The method for finding the maximal inseparable subsets of C provided by Theorem 7 leads directly to an efficient procedure for computing the parts of G. The order in which the cycles are processed plays a crucial role in this procedure. Suppose is defined by some fixed cycle Cr and the cycles of C are in the reverse order C1 , . . . , Ck of some topological sorting, i.e. Cj Ci implies j < i. Thus, we always have Ck = Cr . Define G0 = G and Pi , Gi and Ei for 1 ≤ i ≤ k as follows: = {Ci ∪ H | H is a Ci -component of Gi−1 with Cr 6⊂ H}, = Ci ∪ Hr , for the Ci -component Hr of Gi−1 with Cr ⊂ Hr , = {C 0 P | C 0 ∈ C and C 0 ⊂ P ∈ Pi }. S S Defining PCr = Pi and the graph DCr on C ∪ PCr by the edge set Ei , it can easily be seen in Proposition 2 that PCr is in fact the set of all parts of G and DCr is its decomposition graph. Pi Gi Ei
Proposition 2 For any Cr ∈ C PCr is the set P of parts and DCr is the decomposition graph D of G w.r.t. C. Moreover, P and D can be computed by an O(nk) procedure. Proof: By the definition of the Ei , DCr = D follows from PCr = P. Due to the particular order of the cycles Ci , the successors Cj of Ci contained in Gi−1 are exactly the direct successors of Ci . Moreover, each Cj has only one Cj component in Gi−1 , namely that one which contains Ci and Cr . By Theorem 7, Pi contains exactly the parts built by Ci and its direct successors Cj belonging
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
55
to the same Ci -component and also the parts built by Ci and a Ci -component not containing any other cycle of C. Finally, it can easily be seen that a procedure can be implemented for generating P and D which takes O(nk) time. The relation can be determined for some fixed Cr by computing all C-components in HC which needs O(nk) time. The topological sorting can be done in O(k 2 ) = O(nk) time. And in each step i the determination of all Ci -components of Gi−1 takes O(n) time. Thus the overall complexity is O(nk). 2 Figure 16 illustrates the stepwise construction of the parts of graph G given in Fig. 14. The sequence of cycles is C3 , C4 , C2 , C5 , C6 , C7 , C8 , C1 which is the reverse order of some topological sorting of the relation shown in Fig. 15. i=1
i=2
i=3
i=4 C5
C3
C2
C4 i=5
i=6
i=7
i=8
C6 C7 C8
C1
Figure 16: Construction of parts of the graph given in Fig. 14 using the ordering C3 , C4 , C2 , C5 , C6 , C7 , C8 , C1 . For each step i Gi is colored black and the parts in Pi are the grey-colored subgraphs in connection with the cycle of step i. 5.1.1
Representing Embeddings by Labelled Decomposition Graphs
Decomposition graphs are particularly interesting for the planarity problem with topological constraints. We show in this section that labelled decomposition graphs can represent, in a sense, embeddings of 2-connected planar graphs up to topological constraints, i.e. all embeddings corresponding to the same labelled decomposition graph satisfy the same topological constraints involving cycles from C. e of G. Due to the correspondence between edges Consider an embedding G of D and C-components of G, we can label each edge CP with the binary information on which side of C the C-component HC corresponding to CP is
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
56
e If Pe ⊂ Int C e holds in G, e we label CP with 1 and otherwise, embedded in G. e we label CP with 0. Obviously, edges representing overlapping if Pe ⊂ Ext C, e defines a weakly linear, C-components have complementary labels. Since G f0 ⊂ Int C, e there is at least one strict partial order < on C by C 0 < C iff C maximal Cr ∈ C w.r.t. < contained in the exterior of any other cycle of C. As a consequence, for any path Cr , . . . , P, C in D the edge P C is labelled with 0. e induces a labelling of D according to the following definition. Thus G Definition 6 Let D be the decomposition graph of G w.r.t. C. A labelling λ of D is a function λ : E(D) −→ {0, 1} satisfying the following conditions: (1) λ(ε(HC )) + λ(ε(HC0 )) = 1 for overlapping C-components HC and HC0 . (2) There is a Cr ∈ C such that for all paths Cr , . . . P, C in D: λ(P C) = 0. A labelling of D together with D is called a labelled decomposition graph. e and G e 0 are embeddings of G inducing the same labelling of D. Suppose G e iff it is inside C in G e0 , i.e. G e and Then any C-component HC is inside C in G 0 e e G satisfy the same topological constraints involving cycles from C. However, G 0 e and G need not necessarily be topologically equivalent, they can differ in the particular embeddings of the C-components. Conversely, if two embeddings of G induce different labellings of D, they must be distinguished by at least one topological constraint. For this reason labelled decomposition graphs represent embeddings up to topological constraints. For the example graph G of Fig. 14 an embedding of G together with its labelled decomposition graph is shown in Fig. 17. C1 1
C5
P1 C7
C6
C8 C1
C4 C3
P2
1 P3
P4
0
0
C2
C5
C6
C7
1
1
1 C2
0
0
P5 0 C3
(a)
0
P6
0
0 C8
P7
0 C4 (b)
Figure 17: (a) An embedding of the graph G given in Fig. 14. (b) The decomposition graph D of G with a labelling induced by this embedding. Given a labelling λ of D, one can easily construct an embedding of G which induces exactly λ: one has only to embed Cr and then attach in a depth-first
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
57
manner all parts P to the already embedded cycle C for edges CP ∈ E(D) according to the label of CP . Algorithm embedding shown in Fig. 18 describes this embedding procedure more precisely. Depending on the labelling λ, it generates a set F of pairs hF, SF i where F is a cycle in G and SF ⊆ C; the cycles F are called cycles of F and SF are called their labels. If we choose some hF0 , ∅i from F , which is guaranteed to exist, F0 is the outer facial cycle and the cycles of F are the facial cycles of some embedding of G that induces λ. In this case the inner facial cycles of any C ∈ C are exactly those cycles F of F with C ∈ SF . The procedure must be called with C = Cr and F = {hCr , ∅i, hCr , {Cr }i}; the cycles of F represent the two facial cycles of the embedded Cr . Algorithm embedding Input : labelling λ, C ∈ C, F ⊂ C(G) × 2C Output : F For each edge CP ∈ E(D) do: 1. Let H be the (unique) C-component in P . Find some pair hF, SF i ∈ F such that F contains all vertices of attachment of H and C ∈ SF iff λ(CP ) = 1. 2. Determine the set F 0 of facial cycles of some embedding of H ∪ F . 3. Remove hF, SF i from F and add hF 0 , SF i to F for all F 0 ∈ F 0 \ {F }. 4. For any edge P C 0 ∈ E(D) set SC 0 := SC 0 ∪ {C 0 } for cycle C 0 of F and compute embedding(λ, C 0 , F ). Return F . Figure 18: Algorithm for generating an embedding corresponding to a labelled decomposition graph To illustrate the construction of an embedding, Fig. 19 shows the sequence of partial embeddings of the example graph according to the labelling given in Fig. 17 (b). This sequence corresponds to the sequence of the sets F of facial cycles generated by some depth-first search of D. For each visited edge CP H is the grey-colored subgraph and F is the face cycle it is attached to. The correctness of this algorithm is proved in Proposition 3. Proposition 3 Let λ be a labelling of the decomposition graph of G w.r.t. C. Then algorithm embedding generates a set F of pairs hF, SF i with cycle F ⊆ G and SF ⊆ C. F satisfies the following conditions (where F (C) denotes {F | hF, SF i ∈ F with C ∈ SF }): (i) {F | hF, SF i ∈ F} is the set of facial cycles of some embedding of G. (ii) There is some hF0 , ∅i ∈ F. L (iii) C = F ∈F (C) F for all C ∈ C. S (iv) P ⊂ F ∈F (C) F iff λ(CP ) = 1 for CP ∈ E(D).
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002) C1
C1 P1
C2 P5
C1 P2
C1 P3
C6 P6
C1 P4
C7 P7
58
Figure 19: Illustration of algorithm embedding for the labelled decomposition graph D of Fig. 17 (b). For each edge CP H is the grey-colored subgraph and F the face cycle it is attached to. Moreover, the algorithm takes O(n2 ) time. Proof: Define F0 = {hCr , ∅i, hCr , {Cr }i} and for i = 1, . . . , |P| Fi to be the sets F generated by the depth-first search of the algorithm. Note that the number of visited edges CP ∈ E(D) is identical with the number of parts of G. Let Fi (C) denote {F | hF, SF i ∈ Fi with C ∈ SF }. We show by induction that the following propositions hold for all i ≥ 0; then, since G is the union of all of its parts, F|P| satisfies the claim. (i) S {F | hF, SF i ∈ Fi } is the set of facial cycles of some embedding of 0 F 0 ∈Fi F . (ii) There is some hF0 , ∅i ∈ Fi . L (iii) C = F 0 ∈Fi (C) F 0 if Fi (C) 6= ∅. S S (iv) If for CP ∈ E(D) P ⊂ F 0 ∈Fi F 0 , then P ⊂ F 0 ∈Fi (C) F 0 iff λ(CP ) = 1. Clearly, F0 satisfies all these conditions. We assume them to hold for all j ≤ i for some i. Let CP be the currently visited edge of D and H be the Ccomponent of P . Due to condition (1) of Definition 6 and (i), there is some pair hF, SF i ∈ Fi such that F contains the vertices of attachment of H and C ∈ SF iff λ(CP ) = 1. Let F 0 be the generated set of facial cycles of some embedding of H ∪ F . By Corollary 3 (ii), F and all C 0 ∈ C with P C 0 ∈ E(D) are facial cyclesLof this embedding and, thus, are contained in F 0 . Moreover, we have F = F 0 ∈F 0 \{F } F 0 .
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
59
By the definition of Fi+1 := Fi \ {hF, SF i} ∪ {hF 0 , SF i | F 0 ∈ F 0 , F 0 6= F } and SC 0 := SC 0 ∪ {C 0 }, the conditions (i)–(iv) can be easily verified. Condition (i) holds since F 0 \ {F } is a refinement of F and (ii) holds because of cycle intersection order 1 of C. Condition (iii) is shown for C 0 with P C 0 6∈ E(D) by M M M M F0 = F0 ⊕ F0 = F 0 = C0 F 0 ∈Fi+1 (C 0 )
F 0 ∈Fi (C 0 )\{F }
F 0 ∈F 0 \{F }
F 0 ∈Fi (C 0 )
and for C 0 with P C 0 ∈ E(D) by Fi+1 (C 0 ) = {C 0 }. The last condition (iv) follows immediately from the choice of F depending on λ(CP ) and condition (2) of Definition 6. Finally, we note that this algorithm can be implemented as an O(n2 ) procedure since G has less than n parts and steps 1 to 4 can be done in O(n) time. 2
5.2
A Polynomial Time T1 -Embedding Algorithm
Provided with the analysis of the previous sections, we are now able to present a polynomial time algorithm for generating T1 -embeddings of planar graphs. This algorithm is a combination of the reduction algorithms given in Sect. 4 and the procedure for generating T LX -embeddings of 2-connected graphs which we develop next. So let G denote a 2-connected planar graph and T , L and X denote a set of topological constraints, overlap constraints and extended overlap constraints for G, respectively, such that the set C of all cycles involved in these constraints is of cycle intersection order 1. Moreover, we denote n = |G|, t = |T |, l = |L|, x = |X | and k = |C|. The main idea for generating a T LX -embedding of G is finding an appropriate labelling of the decomposition graph D of G w.r.t. C depending on T , L and X that can be transformed by algorithm embedding into a T LX -embedding. For this purpose, we determine edges of D whose labels can be deduced from the constraints and, thus, necessarily belong to this labelling. To find labels according to condition (1) of Definition 6, we make use of overlap graphs GC of cycles C ∈ C. Consider a component Z of GC with at least two C-components. ˙ 2 such that both Z1 Since GC is bipartite, Z has a unique partition Z = Z1 ∪Z and Z2 contain no overlapping C-components. Then, a label for CP ∈ E(D) with CP = ε(HC ) for some C-component HC ∈ Z clearly determines the labels of edges representing all the other C-components in Z. We denote with [CP ] the set of edges representing all the C-components belonging to the same part of the partition as CP and denote with [CP ]− the set of edges representing all the C-components belonging to the other part. Thus, two edges of [CP ] and [CP ]− , respectively, must have complementary labels. We call [CP ] the equivalence class of CP and [CP ]− its complement. With the following definitions we determine equivalence classes of edges of D whose labels can be easily deduced from the constraints. E1 (T ) and E0 (T ) are the sets of equivalence classes whose edges must have label 1 and 0, respectively, due to the topological constraints in T . The sets E1 (L), E0 (L) and
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
60
E1 (X ), E0 (X ) are to be interpreted analogously. Note, however, that these sets are not meant to cover all labels that can be deduced. E10 (T ) E00 (T ) E1 (T ) E0 (T )
= = = =
E0 (L) E1 (L)
= {[ε(HC,C 0 )] | C ∈ C-Outi , C 0 ∈ C-Ini for hC-Ini , C-Outi i ∈ L} = {[CP ]− | [CP ] ∈ E0 (L)}
E00 (X ) E000 (X ) E10 (X ) E1 (X ) E0 (X )
= = = = =
{[ε(HC )] | HC ∩ InC 6= ∅ for HC ∈ HC , hC, InC , OutC i ∈ T } {[ε(HC )] | HC ∩ OutC 6= ∅ for HC ∈ HC , hC, InC , OutC i ∈ T } E10 (T ) ∪ {[CP ]− | [CP ] ∈ E00 (T )} E00 (T ) ∪ {[CP ]− | [CP ] ∈ E10 (T )}
{[ε(HC,C 0 )] | C ∈ C-Outi , C 0 ∈ C-Ini , hC-Ini , C-Outi , vi ∈ X } {[ε(HC )] | v 6∈ C ∈ C-Outi , v ∈ HC ∈ HC , hC-Ini , C-Outi , vi ∈ X } {[ε(HC )] | v 6∈ C ∈ C-Ini , v ∈ HC ∈ HC , hC-Ini , C-Outi , vi ∈ X } E10 (X ) ∪ {[CP ]− | [CP ] ∈ E00 (X ) ∪ E000 (X )} E00 (X ) ∪ E000 (X ) ∪ {[CP ]− | [CP ] ∈ E10 (X )}
As a result, we define E1 = E1 (T ) ∪ E1 (L) ∪ E1 (X ) and E0 = E0 (T ) ∪ E0 (L) ∪ E0 (X ). Next we consider overlap constraints and extended overlap constraints in more detail. By their semantics and cycle intersection order 1 of C, the cycles of C-Ini belonging to some Li ∈ L or Xi ∈ X are embedded in any T LX -embedding of G in a linear order w.r.t. the induced relation < on C. Thus, they must necessarily belong to a path of D if G is T LX -planar. If this holds for Li = hC-Ini , C-Outi i, we denote w(Li ) the smallest path containing all cycles of C-Ini and say that Li induces w(Li ); the constraints of X are treated analogously. Suppose such a path is of the form C1 , P1 , . . . Pj , Cj , Pj0 , . . . , Ps , Cs with C1 , Cj and Cs belonging to a set C-Ini . Then in a T LX -embedding either C1 < . . . < Cj < . . . < Cs or Cs < . . . < Cj < . . . < C1 holds. We define the set E∗ of equivalence classes whose edges potentially get label 1, due to these two cases, during the search for an appropriate labelling: E∗
=
{[CP ] | CP ∈ E(w(Li )), C ∈ C-Ini if Li ∈ L induces w(Li )} ∪ {[CP ] | CP ∈ E(w(Xi )), C ∈ C-Ini if Xi ∈ X induces w(Xi )}.
To construct an appropriate labelling, we have to find in particular a Cr ∈ C satisfying condition (2) of Definition 6. For each edge CP ∈ E(D) let RCP be the set {C 0 ∈ C | C 0 6⊂ ε−1 (CP )}, i.e. the set of cycles not contained in the C-component represented by CP . We can restrict the set of candidates for Cr with the help of RCP : suppose CP has label 1, then no cycle in C \ RCP can satisfy condition (2). Moreover, consider a path w(Li ) whose first and last edges are CP and C 0 P 0 , respectively. Then we can restrict the set of candidates to RLi := RCP ∪ RC 0 P 0 ; RXi is defined analogously. From what is considered so far, we have the following set of candidates: \ \ \ RCP ∩ RLi ∩ RXi . R= [CP ]∈E1
Li ∈L
Xi ∈L
In Definition 7 we establish the criterion of being an appropriate labelling that respects the constraints T , L and X , thus we call it T LX -labelling.
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
61
Definition 7 A T LX -labelling λ of D is a labelling satisfying the following additional conditions: (1) λ(CP ) = 1 if [CP ] ∈ E1 . (2) λ(CP ) = 0 if [CP ] ∈ E0 . (3) Cr ∈ R; each Li ∈ L and Xi ∈ X induces in particular a path in D. (4) For all paths Cr , . . . , C, P with [CP ] ∈ E∗ : λ(CP ) = 1. Clearly, any T LX -embedding of G induces a T LX -labelling on D. It can also easily be verified by Proposition 3 that the converse holds as well: given a T LX -labelling of D, algorithm embedding generates some hF, SF i such that each F0 with hF0 , ∅i is the outer facial cycle and the cycles of F are the facial cycles of some T LX -embedding of G. The algorithm find labelling in Fig. 20 generates a T LX -labelling of D iff G is T LX -planar. Its main part is a depth-first search of D beginning at a candidate Cr ∈ R that labels the visited edges. We consider D a directed tree with root Cr such that each edge is uniquely denoted by CP or P C depending on whether Cr , . . . , C, P or Cr , . . . , P, C is a path in D. When attaching labels to edges, labelling an edge with 0 or 1 fails if this edge already has the complementary label 1 or 0, respectively. Proposition 4 establishes the correctness of the algorithm. Algorithm find labelling Input : decomposition graph D of G, constraints T , L, X Output : T LX -labelling λ with the particular Cr ∈ C 1.
2. 3. 3.1 3.2 3.3 4.
Determine E1 and E0 . If E1 ∩ E0 6= ∅, stop. Check if each Li ∈ L and Xi ∈ X induces a path in D; if not so, stop. Determine E∗ and R. If R = ∅, stop. Label any edge CP of D with 1 if [CP ] ∈ E1 , and with 0 if [CP ] ∈ E0 . Then label any edge CP not labelled so far with ∗ if [CP ] ∈ E∗ . Find a Cr ∈ R such that the following operations executed during a depth-first search of D beginning at Cr are successful: If edge P C is visited, label all edges in [P C] with 0 and all edges in [P C]− with 1. If edge CP with label ∗ is visited, label all edges in [CP ] with 1 and all edges in [CP ]− with 0. If edge CP without any label is visited, label all edges in [CP ] with 0 and all edges in [CP ]− with 1, or vice versa. If this succeeds, return Cr and labelling λ defined by the labels of D.
Figure 20: Algorithm for generating a T LX -labelling of the decomposition graph
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
62
Proposition 4 Given constraints T , L and X for G, algorithm find labelling generates a T LX-labelling iff G is T LX -planar. Moreover, the algorithm takes O n2 k + kl + kx time. Proof: (⇒) It can easily be seen that the set of labels generated by the algorithm defines in fact a T LX -labelling λ of D. Since for any edge CP ∈ E(D) the edges in [CP ] and in [CP ]− have complementary labels and, moreover, each edge has a unique label 0 or 1, condition (1) of Definition 6 is satisfied. Condition (2) is guaranteed by step 3.1, thus λ is a labelling. Conditions (1) and (2) of Definition 7 are ensured by step 2 and (3) is checked in step 1 and 3. The last condition (4) holds because of step 3.2. Thus λ is a T LX -labelling and G is T LX -planar. (⇐) Suppose G has a T LX -embedding. Then there is a T LX -labelling λ0 induced by this embedding. In particular, we have that E1 ∩ E0 = ∅, each Li ∈ L and Xi ∈ X induces a path in D and R 6= ∅. Since for any edge CP of D labelled in step 2 with 0 or 1 it necessarily holds that λ0 (CP ) = 0 or λ0 (CP ) = 1, respectively, and the cycle Cr is searched exhaustively in R, it is guaranteed that the algorithm finds a complete set of labels for D which defines a T LX -labelling as shown above. Finally, we estimate the time complexity of this algorithm. To determine the sets in step 1, it is necessary to find the overlap graphs of cycles of C which can be done in O(kn2 ) time. Then, determining the sets E1 (T ), E0 (T ) and E1 (L), E0 (L) and E1 (X ), E0 (X ) needs O(nt), O(kl) and O(kx) time, respectively. Finding the paths induced by the constraints in L and X and determining E∗ can be done in O(nl + nx) time. Moreover, the set R can be computed in O(nk + lk + xk) time. Next, labelling edges in step 2 and during the depth-first search of D needs O(n) time, thus step 3 takes O(kn) time. The resulting time 2 complexity is therefore O(n2 k + kl + kx). Consider again the example graph of Fig. 14 and suppose we have a topological constraint meaning that cycle C6 should be embedded inside cycle C1 and an overlap constraint meaning that C1 and C3 should include a common face. The first constraint determines the set E1 (T ) = {[C1 P3 ]} and, thus, E0 (T ) = {[C1 P2 ] = [C1 P4 ]}. The other sets for L and X are empty. Because of the second constraint we get E∗ = {[C1 P1 ], [C2 P1 ], [C2 P5 ], [C3 P5 ]} indicating that C1 , C2 and C3 are to be embedded in some linear inclusion order. The set of candidates is R = {C1 , C3 , C5 , C7 , C8 }. Algorithm find labelling encodes these sets by the partial labelling shown in Fig. 21 (a). In figure (b) we see some complete labelling that can result from this partial labelling when C1 is chosen for Cr ; it corresponds to the embedding shown in Fig. 17. The complete T LX -embedding algorithm is shown in Fig. 22. Its correctness and complexity can be easily obtained from what is developed so far.
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
63
C1 C6
P2
P3 0 C1 P1
C4
1 P1
C5
C3
P6
∗ C2 ∗ P5
C7 1 ∗ ∗
P7
0 P4
1
0
P2
P3
0
0
C2
C5
C6
C7
1
1
P5 0 C3
(a)
P4
0
1
C8
0
P6
0
0 C8
P7
0 C4 (b)
Figure 21: Illustration of algorithm find labelling: (a) A partial labelling encoding a topological constraint and an overlap constraint. (b) A complete labelling produced by the algorithm. Algorithm embedding with constraints Input : G, constraints T , L, X Output : T LX -embedding of G 1. 2. 3. 4.
Determine the decomposition graph D of G. Compute find labelling(D, T , L, X ) resulting in a labelling λ and cycle Cr if G is T LX -planar; otherwise stop. Compute embedding(λ, Cr {hCr , ∅i, hCr , {Cr }i}) resulting in hF, SF i. Embed G such that the cycles of F are the facial cycles and F0 is the outer facial cycle for some hF0 , ∅i ∈ F. Figure 22: Algorithm for generating a T LX -embedding
Proposition 5 Given T , L, X for G, algorithm embedding with constraints generates a T LX -embedding iff G is T LX -planar. Moreover, it takes O(n2 k + kl + kx) time. The combination of algorithm embedding with constraints with algorithm reduce to blocks and algorithm reduce to components leads to the complete T1 embedding procedure for planar graphs. Using Corollary 1 and 2 of Theorem 5, we get the complexity of this procedure depending on whether G is disconnected, connected or 2-connected. Theorem 8 Suppose G is a planar graph with n = |G| and T is a set of topological constraints for G of cycle intersection order 1 with t = |T |. Then the following propositions hold:
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
64
(i) If G is disconnected, a T -embedding can be found in O(n6 ) time. (ii) If G is connected, a T -embedding can be found in O(n5 ) time. (iii) If G is 2-connected, a T -embedding can be found in O(n2 t) time.
6
Conclusions
This paper contributes to the relatively new research direction on planar graph embedding with user-defined constraints. We introduced a special sort of constraints, called topological constraints, and studied the problem of finding an embedding satisfying a given set of topological constraints. As this problem turned out to be NP-complete, we developed a polynomial time procedure for reducing the problem for arbitrary planar graphs to a problem for biconnected graphs which allows to focus on biconnected graphs when searching for heuristics or tractable subproblems. This reduction, however, results in another two types of constraints one has to cope with in developing embedding algorithms. We then used this reduction for studying a particular subproblem defined by a parameter called cycle intersection order. With respect to this parameter, we proved the exact boundary between P and NP by showing that this subproblem remains NP-complete if the cycle intersection order exceeds 1 and by presenting a polynomial time embedding algorithm for cycle intersection order 0 or 1.
Acknowledgments The author wish to thank the referees for several useful suggestions.
References [1] J.A. Bondy, U.S.R. Murty. Graph Theory with Applications, MacMillan, 1976 [2] K. Booth, G. Lueker. Testing for the consecutive ones property, interval graphs, and graph planarity using PQ-tree algorithms. J. Comput. Syst. Sci., 13: 335–379, 1976 [3] N. Chiba, T. Nishizeki, S. Abe, T. Ozawa. A linear algorithm for embedding planar graphs using PQ-trees. J. Comput. Syst. Sci., 30: 54–76, 1985 [4] G. Demoucron, Y. Malgrange, R. Pertuiset. Graphes planaires: reconnaissance et construction de repr´esentations planaires topologiques. Revue Fran¸caise de Recherche Op´erationelle, 8: 33–47, 1964 [5] G. Di Battista, P. Eades, R. Tamassia, I.G. Tollis. Algorithms for drawing graphs: An annotated bibliography. Comp. Geom., 4(5): 235–282, 1994
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
65
[6] G. Di Battista, P. Eades, R. Tamassia, I.G. Tollis. Graph Drawing: Algorithms for the Visualization of Graphs, Prentice Hall, 1999 [7] R. Diestel. Graph Theory, Springer, 1997 [8] C. Dornheim. Graph embedding with topological cycle-constraints. In J. Kratochvil (ed.), Graph Drawing, Proc. 7th Int. Symp. GD’99, LNCS 1731, 155–164, 1999 [9] P. Eades, Q.W. Feng. Multilevel visualization of clustered graphs. In S. North (ed.), Graph Drawing, Proc. 4th Int. Symp. GD’96, LNCS 1190, 101–112, 1997 [10] P. Eades, Q.W. Feng, H. Nagamochi. Drawing clustered graphs on an orthogonal grid. J. Graph Algorithms Appl., 3(4): 3–29, 1999 [11] P. Eades, P. Mutzel. Graph drawing algorithms. In M.J. Atallah (ed.), Algorithms and Theory of Computation Handbook, CRC Press, 1999 [12] Q.W. Feng, R.F. Cohen, P. Eades. Planarity for clustered graphs. In P.G. Spirakis (ed.), Algorithms – ESA’95, Proc. 3rd European Symp., LNCS 979, 213–226, 1995 [13] M.R. Garey, D.S. Johnson. Computers and Intractability – A Guide to the Theory of NP-Completeness, Freeman, 1979 [14] D. Harel. On visual formalisms. Communications of the ACM, 31(5): 514– 530, 1988 [15] W. He, K. Marriott. Constrained graph layout. In S. North (ed.), Graph Drawing, Proc. 4th Int. Symp. GD’96, LNCS 1190, 217–232, 1997 [16] J. Hopcroft, R.E. Tarjan. Efficient planarity testing. J. Assoc. Comput. Mach., 21:549–568, 1974 [17] S. MacLane. A combinatorial condition for planar graphs. Fundam. Math., 28: 22–32, 1937 [18] K. Mehlhorn, P. Mutzel. On the embedding phase of the Hopcroft and Tarjan planarity testing algorithm. Algorithmica, 16: 233–242, 1996 [19] P. Mutzel, R. Weiskircher. Optimizing over all combinatorial embeddings of a planar graph. In G. Cornuejols, R.E. Burkard, G.J. Woeginger (eds.), Integer Programming and Combinatorial Optimization, Proc. 7th Int. IPCO Conf., LNCS 1610, 361–376, 1999 [20] T. Nishizeki, N. Chiba. Planar Graphs: Theory and Algorithms. Annals of Discrete Mathematics (32), North-Holland Mathematics Studies, 1988 [21] K. Sugiyama, K. Misue. Visualization of structured information: Automatic drawing of compound digraphs. IEEE Trans. Syst., Man and Cybernetics, 21(4): 876–892, 1991
C. Dornheim, Planar Graphs with Constraints, JGAA, 6(1) 27–66 (2002)
66
[22] R. Tamassia. Constraints in graph drawing algorithms. Constraints, 3(1): 87–120, 1998 [23] R. Tamassia. Advances in the theory and practice of graph drawing. Theor. Comp. Sci., 217(2): 235–254, 1999 [24] C. Thomassen. Planarity and duality of finite and infinite graphs. J. Comb. Theory, Ser. B, 29: 244–271, 1980 [25] W.T. Tutte. Matroids and graphs. Trans. Am. Math. Soc., 90: 527–552, 1959 [26] W.T. Tutte. How to draw a graph. Proc. Lond. Math. Soc., III. Ser. 13: 743–768, 1963 [27] C. Williams, J. Rasure, C. Hansen. The state of the art of visual languages for visualization. Visualization ’92, Proc., IEEE Computer Society Press, 202–209, 1992
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 6, no. 1, pp. 67–113 (2002)
Level Planar Embedding in Linear Time Michael J¨ unger Institut f¨ ur Informatik Universit¨at zu K¨ oln, Germany http://www.informatik.uni-koeln.de/
[email protected]
Sebastian Leipert Stiftung caesar Bonn, Germany http://www.caesar.de/
[email protected] Abstract A level graph G = (V, E, φ) is a directed acyclic graph with a mapping φ : V → {1, 2, . . . , k}, k ≥ 1, that partitions the vertex set V as V = V 1 ∪ V 2 ∪ · · · ∪ V k , V j = φ−1 (j), V i ∩ V j = ∅ for i 6= j, such that φ(v) ≥ φ(u) + 1 for each edge (u, v) ∈ E. The level planarity testing problem is to decide if G can be drawn in the plane such that for each level V i , all v ∈ V i are drawn on the line li = {(x, k − i) | x ∈ R}, the edges are drawn monotonically with respect to the vertical direction, and no edges intersect except at their end vertices. In order to draw a level planar graph without edge crossings, a level planar embedding of the level graph has to be computed. Level planar embeddings are characterized by linear orderings of the vertices in each V i (1 ≤ i ≤ k). We present an O(|V |) time algorithm for embedding level planar graphs. This approach is based on a level planarity test by J¨ unger, Leipert, and Mutzel (1998).
Communicated by H. de Fraysseix and and J. Kratochv´ıl: submitted November 1999; revised March 2001.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
1
68
Introduction
A fundamental issue in Automatic Graph Drawing is to display hierarchical network structures as they appear in software engineering, project management and database design. The network is transformed into a directed acyclic graph that has to be drawn with edges that are strictly monotone with respect to the vertical direction. Many applications imply a partition of the vertices into levels that have to be visualized by placing the vertices belonging to the same level on a horizontal line. The corresponding graphs are called level graphs. Using the P Q-tree data structure, J¨ unger, Leipert, and Mutzel (1998) have given an algorithm that tests in linear time whether such a graph is level planar, i.e. can be drawn without edge crossings. In order to draw a level planar graph without edge crossings, a level planar embedding of the level graph has to be computed. Level planar embeddings are characterized by linear orderings of the vertices in each level. We present a linear time algorithm for embedding level planar graphs. Our approach is based on the level planarity test and it augments a level planar graph G to an st-graph Gst , a graph with a single sink and a single source, without destroying the level planarity. Once the st-graph has been constructed, we compute a planar embedding of the st-graph. This is done by applying the embedding algorithm of Chiba et al. (1985) for general graphs, obeying the topological ordering of the vertices in the st-graph. Exploiting the planar embedding of the st-graph Gst , we are able to determine a level planar embedding of G. This paper is organized as follows. After summarizing the necessary preliminaries in the next section, including the P Q-tree data structure we give a short introduction to the level planarity test presented by J¨ unger et al. (1998) in the third section. In the fourth section, we present the concept of the linear time level planar embedding algorithm. Sections 5 to 8 contain the details of the embedding algorithm. We close the paper with some remarks on how to produce a level planar drawing using the result of our algorithm. A short glossary of terms is given as an appendix.
2
Preliminaries
A level graph G = (V, E, φ) is a directed acyclic graph with a mapping φ : V → {1, 2, . . . , k}, k ≥ 1, that partitions the vertex set V as V = V 1 ∪ V 2 ∪ · · · ∪ V k , V j = φ−1 (j), V i ∩ V j = ∅ for i 6= j, such that φ(v) ≥ φ(u) + 1 for each edge (u, v) ∈ E. A vertex v ∈ V j is called a level-j vertex and V j is called the j-th level of G. For a level graph G = (V, E, φ), we sometimes write G = (V 1 , V 2 , . . . , V k ; E). A drawing of a level graph G in the plane is a level drawing if the vertices of every V j , 1 ≤ j ≤ k, are placed on a horizontal line lj = {(x, k − j) | x ∈ R}, and every edge (u, v) ∈ E, u ∈ V i , v ∈ V j , 1 ≤ i < j ≤ k, is drawn as a monotonically decreasing curve between the lines li and lj . A level drawing of G is called level planar if no two edges cross except at common endpoints. A level graph is level planar if it has a level planar drawing. A level graph G is obviously level planar if and only if all its components are level planar. We therefore may assume in the following without loss of generality that G is connected. A level drawing of G determines for every V j , 1 ≤ j ≤ k, a total order ≤j of the vertices of V j , given by the left to right order of the vertices on lj . A level embedding consists of a permutation of the vertices of V j for every j ∈ {1, 2, . . . , k} with respect to a level drawing. A level embedding with respect to a level planar drawing is called level planar. A level graph G = (V, E) is said to be proper, if every edge e ∈ E connects only vertices
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
69
belonging to consecutive levels. Usually, a level graph G has sinks and sources placed on various levels of the graph. Figure 1 shows a proper level graph. 1 2 3 4 5 Figure 1: An example of a level graph. Sources are drawn black. A P Q-tree is a data structure that represents the permutations of a finite set U in which the members of specified subsets occur consecutively. This data structure has been introduced by Booth and Lueker (1976) to solve the problem of testing for the consecutive ones property (see, e.g., Fulkerson and Gross (1965)). A P Q-tree is a rooted and ordered tree that contains three types of nodes: leaves, P -nodes, and Q-nodes. The leaves are in one to one correspondence with the elements of U . The P - and Q-nodes are internal nodes. In subsequent figures, P -nodes are drawn as circles while Q-nodes are drawn as rectangles. The frontier of a P Q-tree T , denoted by frontier (T ), is the sequence of all leaves of T read from left to right, and the frontier of a node X, denoted by frontier (X), is the sequence of its descendant leaves read from left to right. The frontier of a P Q-tree is a permutation of the set U . We use the notion frontier (T ) and frontier (X) also to denote the set of elements in frontier (T ) and frontier (X), respectively, its meaning being evident by context. An equivalence transformation specifies a legal reordering of the nodes within a P Q-tree. The only legal equivalence transformations are (i) any permutation of the children of a P -node, and (ii) the reverse permutation of the children of a Q-node. Two P Q-trees T and T 0 are equivalent if and only if their underlying trees are equal and T can be transformed into T 0 by a sequence of equivalence transformations. The equivalence of two P Q-trees is denoted T ≡ T 0 . The set of consistent permutations of a P Q-tree is the set of all frontiers that can be obtained by a sequence of equivalence transformations and is denoted by PERM(T ) = {frontier (T 0 ) | T 0 ≡ T } . If two nodes X and Y of a P Q-tree have the same parent, they are siblings. The nodes are called adjacent or direct if they are siblings and appear consecutively in the order of children of their parent. Let Π := {π | π is a permutation of U } and for any subset S ⊆ U let ΠS := {π ∈ Π | all elements of S are consecutive within π}. Given any P Q-tree T over U , the function
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
70
REDUCE(T, S) computes a P Q-tree T 0 such that PERM(T 0 ) = PERM(T ) ∩ ΠS . The function REDUCE applies a sequence of templates to the nodes of a P Q-tree starting at the leaves, and proceeding upwards until the root of the pertinent subtree is reached. Each template has a pattern and a replacement. If a node matches the pattern of a template, the pattern is replaced within the tree by the replacement of the template. The return value of REDUCE is a new P Q-tree. It is the null tree, a tree with no nodes at all, if the original tree could not be reduced for the specified set S. If a null tree is returned, the set of permissible permutations on the set U is empty and the null tree represents an empty set of permutations. Therefore it is convenient to denote the null tree by ∅. A node X in T is said to be full if frontier (X) ⊆ S. A node X is said to be empty if frontier (X) ∩ S = ∅. A node X is partial if it is neither empty nor full. Nodes are said to be pertinent if they are either full or partial. Each template specifies a local change within the tree. Only the node X that has to be matched and its children are altered. The patterns to which nodes are matched depend upon the set S and the frontier of the subtree rooted at the particular node X. The matched pattern is selected by examining the node X and its children after the children themselves have been matched. Depending on the situation in the frontier of X the node is labeled indicating whether X is empty, full, or partial. This bottom-up strategy ensures that all information on the situation in the frontier of the children of X is available when processing X. In Figure 2 and Figure 3 we illustrate two of the template matchings, the templates Q2 and Q3 (see Booth and Lueker (1976) for the templates P1 – P6 and Q1). The pattern at the left hand side is to be transformed into a pattern at the right hand side. A full node or a full subtree is hatched, and a partial Q-node that roots a pertinent subtree is hatched partially. We use a triangle for symbolizing a subtree. A subtree is either full or empty, so its precise form has no effect on the templates.
...
...
... ...
...
...
...
...
Figure 2: Template Q2.
...
... ...
...
... ...
...
...
...
...
...
...
...
...
Figure 3: Template Q3.
Theorem 2.1 (Booth and Lueker (1976)). The data structure P Q-tree and the template matchings can be implemented such that the class of permutations in which the elements of each set Si of a family S = {S P1n, S2 , . . . , Sn } of subsets of U occur as a consecutive sequence can be computed in O(|U | + n + i=1 |Si |) time.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
71
One result that is achieved in the proof of Theorem 2.1 is the following corollary that is needed later when proving the correctness of a level planar embedding algorithm. Corollary 2.2 (Booth and Lueker (1976)). Let X be a child of a Q-node Y . Throughout the template matching algorithm X remains a child of a Q-node.
3
A Linear-Time Level Planarity Test
In this section we give a short introduction to a level planarity test as it has been presented in J¨ unger et al. (1998, 1999). Let Gj denote the subgraph of G induced by V 1 ∪ V 2 ∪ · · · ∪ V j . The basic idea is to perform a top-down sweep, processing the levels in the order V 1 , V 2 , . . . , V k . The graph Gj , 1 ≤ j < k, is not necessarily connected, and a separate P Q-tree is introduced for every component F of Gj to represent the set of permutations of the vertices of F in V j that appear in some level planar embedding of Gj . The P -nodes of such a P Q-tree correspond to cut vertices in F , the Q-nodes to connected components with a fixed embedding that can only be reversed. The leaves correspond either to level-j vertices or to incoming edges of level-l vertices, with l > j. Performing the top-down sweep, standard P Q-tree techniques are applied, as long as different components of Gj are not adjacent to a common vertex on level j. If two components are adjacent to a common vertex v on level j, they have to be merged and a new P Q-tree has to be constructed from the two corresponding P Q-trees. The new P Q-tree then represents all level planar embeddings of the merged component. Applying a combination of reduce operations and merge operations for combining P Q-trees, we maintain for every level V j and for every component F of Gj the set of permutations of the vertices of F in V j that appear in some level planar embedding of Gj . If the set of permutations for Gk is not empty, the graph G = Gk is obviously level planar. Before we describe our algorithm, called LEVEL-PLANARITY-TEST, let us introduce some new terminology. Let X be a Q-node in T corresponding to a subgraph B of Gj , 1 ≤ j ≤ k. The children of X each correspond to a cut vertex on the border of the outer face of B (see also Booth and Lueker (1976); Leipert (1998)). If X is not the root, then there exists an extra cut vertex on the border of the outer face of B that separates the subgraph G0 induced by the subtree rooted at X from Gj − G0 . This cut vertex is called the connective cut vertex of B. Since Gj is not necessarily connected, let mj denote the number of components of Gj and let j Fi , i = 1, 2, . . . , mj , denote the components of Gj . Figure 4 shows a G4 with m4 = 2 components F14 and F24 . The set of vertices in Fij is denoted by V (Fij ). Define LL(Fij ), the low indexed level, to be the smallest d such that Fij contains a vertex in V d and maintain this integer at the root of the corresponding P Q-tree. The height of a component Fij in the subgraph Gj is j − LL(Fij ). The LL-value merely describes the size of the component. The LL-values of the two components shown in Figure 4 are LL(F14 ) = 1 and LL(F24 ) = 2. Let Hij be the graph arising from Fij as follows: For each edge e = (u, v), where u is a vertex in Fij and v ∈ V l , l ≥ j + 1, we introduce a virtual vertex with label v and a virtual edge that connects u and this virtual vertex. Thus there may be several virtual vertices with the same label, adjacent to different components of Gj and each with exactly one entering edge. The form Hij is called the extended form of Fij and the set of virtual vertices of Hij is denoted by frontier (Hij ). Figure 5 shows possible extended forms H14 and H24 of the example in Figure 4. The virtual vertices on level 5 are denoted by their labels. The frontier of H14 consists of one virtual vertex labeled u,
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
72
two vertices labeled v, and two vertices labeled w. The set of virtual vertices of Hij that are labeled v ∈ V j+1 is denoted by Siv . 1 2 3 4 F14
F24
Figure 4: A G4 with m2 = 2 components F14 and F24 .
1 2 3 4 5 w
w
v H14
v
u
x
v
x
H24
Figure 5: Two extended forms H14 and H24 of Figure 4. The graph that is created from an extended form Hij by identifying all virtual vertices with the same label to a single vertex is called a reduced extended form and denoted by Rij . To construct R14 from the example component H14 , the vertices labeled w have to be identified and the vertices labeled v have to be identified. In order to identify the two vertices labeled x in H24 for the construction of R24 , it is necessary to permute the left most vertex labeled x and the vertex labeled v. Both forms R14 and R24 then have exactly one vertex labeled v. The set of virtual vertices of Rij is denoted by frontier (Rij ). If Siv of Hij is not empty, we denote the vertex with label v of Rij (i.e., the vertex that arose from identifying all virtual vertices of Siv )
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
73
by vi and update Siv = {vi }. The graph arising from the identification of two virtual vertices vi and vl (labeled v) of two reduced extended forms Rij and Rlj is denoted Rij ∪v Rlj . We call Rij ∪v Rlj a merged reduced form. The vertex arising from the identification of vi and vl is denoted by v{i,l} (and labeled by v of course). If LL(Rij ) ≤ LL(Rlj ) we say Rlj is v-merged into Rij . The form that is created by v-merging Rlj into Rij and identifying all virtual vertices with the same label w 6= v is again a reduced extended form and denoted by Rij (thus renaming Rij ∪v Rlj with the name of the “higher” form). Figure 6 shows the resulting merged reduced extended form R14 ∪v R24 after R24 (the smaller form) has been v-merged into R14 (the higher form). Since R14 is the higher form, R14 ∪v R24 is renamed into R14 . 1 2 3 4 5 w
v
x
u
Figure 6: A merged reduced extended form R14 ∪v R24 after R24 has been v-merged into R14 . The former vertices of R24 are drawn shaded. We omit scanning for leaves with the same label after we have v-merged several reduced extended forms. This is done in order to achieve linear running time. However, this strategy results in improper reduced extended forms, possibly having several virtual vertices with the same label. These forms are called partially reduced extended forms. If any reduced extended form has been v-merged into Rij , the form Rij is called v-connected , otherwise Rij is called v-unconnected. The form R14 shown in Figure 6 is v-connected. A reduced extended form Rij that is v-unconnected for all v ∈ V j+1 is called primary. A reduced extended form Rij that is v-connected for at least one v ∈ V j+1 is called secondary. Again, R14 shown in Figure 6 is secondary. Let Rij be a reduced extended form such that Siv 6= ∅ for some v ∈ V j+1 and Siw = ∅ for all w ∈ V l − {v}, j + 1 ≤ l ≤ k, then Rij is called v-singular. Let T (Gj ) be the set of level planar embeddings of all components of Gj . In case that Gj is level planar, the set of permutations of level-j vertices in level planar embeddings of each component Fij of Gj as well as its extended form Hij can be described by a P Q-tree T (Fij ) or T (Hij ), respectively (J¨ unger et al. (1998, 1999)). The leaves of T (Hij ) correspond to the virtual vertices of Hij and we
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
74
label the leaves of T (Hij ) as their counterparts in Hij . By construction, T (Gj ) is a set of P Q-trees. Considering a function CHECK-LEVEL that computes for every level j, j = 2, 3, . . . , k, the set T (Gj ) of level planar embeddings of the components Gj , the algorithm LEVEL-PLANARITYTEST can be formulated as follows. Bool LEVEL-PLANARITY-TEST(G = (V 1 , V 2 , . . . , V k ; E)) begin Initialize T (G1 ); for j := 1 to k − 1 do T (Gj+1 ) = CHECK-LEVEL(T (Gj ), V j+1 ); if T (Gj+1 ) = ∅ then return “false”; return “true”; end. The procedure CHECK-LEVEL is divided into two phases. The First Reduction Phase constructs the P Q-trees corresponding to the reduced extended forms of Gj . Every P Q-tree T (Fij ) that represents all level planar embeddings of some component Fij is transformed into a P Q-tree T (Hij ) representing all level planar embeddings of the extended form Hij . We continue to reduce in every P Q-tree T (Hij ) all leaves with the same label, thereby constructing a new P Q-tree, representing all level planar embeddings of Hij , where leaves with the same label occupy consecutive positions. If one of the reductions fails, G cannot be level planar. Leaves with the same label v are replaced by a single representative vi (see also Booth and Lueker (1976)). P Q-trees of different components are merged in the Second Reduction Phase if the components are adjacent to the same vertex v on level j + 1. Given the set of leaves labeled v, we first determine their corresponding P Q-trees. If some leaves labeled v are in the frontier of the same P Q-tree, we reduce them and replace them by a single representative. The P Q-trees are then merged pairwise in the order of their sizes. Using this ordering a P Q-tree T (F ) is constructed that represents all possible level planar embeddings of the merged components. Even though v may not be the only common vertex in the merged components, we do not reduce leaves with label w 6= v in the P Q-tree in order to obtain a linear time algorithm. If one of the reduce or merge operations fails while applied in this phase, the graph G is not level planar. The function REPLACE removes all leaves with a common label v after these leaves have been reduced (and therefore are consecutive in all permissible permutations) and replaces them by a single representative (Booth and Lueker (1976)). Finally we add for every source of V j+1 its corresponding P Q-tree. Thus the set of P Qtrees constructed by the function CHECK-LEVEL represents all level planar embeddings of every unger et al. (1998, 1999)). component of Gj+1 (see J¨ A short description of the pairwise merge operations of Heath and Pemmaraju (1995, 1996) for non singular forms is now given. Singular components are handled by examining certain information on interior faces and regions of the outer face (see J¨ unger et al. (1999)). Let G = (V, E) be a klevel graph and R1j and R2j be two components of Gj , 1 ≤ j < k, both being adjacent to the same vertex v ∈ V j+1 . Let T1 and T2 be the P Q-trees of R1j and R2j , both representing all level planar embeddings of their corresponding forms after the application of the first reduction phase for the level j + 1. Identifying the vertices labeled v of the forms R1j and R2j constructs a new form
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
75
R1j ∪v R2j . For this new component R1j ∪v R2j a new P Q-tree T is needed that represents all level planar embeddings of R1j ∪v R2j . The construction of the P Q-tree T (R1j ∪v R2j ) is is based on the trees T1 and T2 . The merge operation is accomplished using information that is stored at the nodes of the P Qtrees. For any subset S of the set of vertices in V j+1 ∪ V j+2 ∪ · · · ∪ V k that belongs to a form Hij or Rij , define ML(S) to be the greatest d ≤ j such that V d , V d+1 , . . . , V j induces a subgraph in which all nodes of S occur in the same connected component. The level ML(S) is said to be the meet level of S. For a Q-node Y in the corresponding P Q-tree T (Hij ) or T (Rij ) with ordered children Y1 , Y2 , . . . , Yt , integers denoted by ML(Yi , Yi+1 ), 1 ≤ i < t, are maintained satisfying ML(Yi , Yi+1 ) = ML(frontier (Yi ) ∪ frontier (Yi+1 )). For a P -node X a single integer denoted by ML(X) that satisfies ML(X) = ML(frontier (X)) is maintained. Figure 7 shows the P Q-trees corresponding to the forms H1j and H2j of Figure 5 together with the ML-values that are stored at the nodes. The maintenance of the ML-values during the pattern matching algorithm REDUCE is straightforward.
1 u 3 w
3
3
3
4
w
x v
v
x
v
Figure 7: P Q-trees corresponding to H14 and H24 shown in Fig. 5. For describing how to merge T1 and T2 corresponding to R1j and R2j we may assume without loss of generality that LL(T1 ) ≤ LL(T2 ). Thus the form R2j is the smaller form and an embedding of R1j has to be found such that R2j can be nested within the embedding of R1j . This corresponds to adding the root of T2 as a child to a node of the P Q-tree T1 and constructing a new P Q-tree T 0 . In order to find an appropriate location to insert T2 into T1 , we start with the leaf labeled v in T1 and proceed upwards in T1 until a node X 0 and its parent X are encountered satisfying one of the following five conditions. Merge Condition A The node X is a P -node with ML(X) < LL(T2 ). Attach T2 as child of X in T1 . Merge Condition B The node X is a Q-node with ordered children X1 , X2 , . . . , Xt , X 0 = X1 , and ML(X1 , X2 ) < LL(T2 ). Replace X 0 in T1 by a Q-node Y having two children, X 0 and the root of T2 . The case where X 0 = Xt and ML(Xt−1 , Xt ) < LL(T2 ) is symmetric. Merge Condition C The node X is a Q-node with ordered children X1 , X2 , . . . , Xt , X 0 = Xi , 1 < i < t, and ML(Xi−1 , Xi ) < LL(T2 ) and ML(Xi , Xi+1 ) < LL(T2 ). Replace X 0 by a Q-node Y with two children, X 0 and the root of T2 .
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002) Merge Condition D 1 < i < t, and
76
The node X is a Q-node with ordered children X1 , X2 , . . . , Xt , X 0 = Xi , ML(Xi−1 , Xi ) < LL(T2 ) ≤ ML(Xi , Xi+1 ) .
Attach the root of T2 as child of X between Xi−1 and X 0 . In case that ML(Xi , Xi+1 ) < LL(T2 ) ≤ ML(Xi−1 , Xi ) , attach the root of T2 as child of X between X 0 and Xi+1 . Merge Condition E The node X 0 is the root of T1 . Reconstruct T1 by inserting a Q-node Y as new root of T1 with two children X 0 and the root of T2 . Based on the following theorem, we develop a linear time algorithm for embedding a level planar graph. Theorem 3.1 (J¨ unger, Leipert, and Mutzel (1998)). The algorithm LEVEL-PLANARTEST tests any (not necessarily proper) level graph G = (V, E, φ) in O(n) time for level planarity.
4
Concept of the Embedding-Algorithm
One can easily obtain the following naive embedding algorithm for level planar graphs. Choose any total order on V k that is consistent with the set of permutations of V k that appear in level planar embeddings of Gk = G. Choose then any total order on V k−1 that is consistent with the set of permutations of V k−1 that appear in level planar embeddings of Gk−1 and that, together with the chosen order of V k implies a level planar embedding on the subgraph of G induced by V k−1 ∪ V k . Extend this construction one level at a time until a level planar embedding of G results. However, to perform this algorithm, it is necessary to keep track of the set of P Q-trees of every level l, 1 ≤ l ≤ k. Besides, an appropriate total order of the vertices of V j , 1 ≤ j < k, can only be detected by reducing subsets of the leaves of Gj , where the subsets are induced by the adjacency lists of the vertices of V j+1 . More precisely, for every pair of consecutive edges e1 = (v1 , w), e2 = (v2 , w), v1 , v2 ∈ V j , in the adjacency list of a vertex w ∈ V j+1 , we have to reduce the set of leaves corresponding to the vertices v1 , v2 in T (Gj ). This immediately yields an Ω(n2 ) algorithm for non-proper level graphs, with Ω(n2 ) dummy vertices for long edges traversing one or more levels, since we are forced to consider for every long edge its exact position on the level that is traversed by the long edge. Instead, we proceed as follows: Let G = (V, E, φ) be a level planar graph with leveling φG : V → {1, 2, . . . , k}. We augment G to a planar directed acyclic st-graph Gst = (Vst , Est , φGst ) where Vst = V ] {s, t} and E ⊂ Est such that every source in G has exactly one incoming edge in Est \ E, every sink in G has exactly one outgoing edge in Est \ E, φGst (s) = 0, φGst (t) = k + 1, (s, t) ∈ Est , and for all v ∈ V we have φGst (v) = φG (v). This process, in which two vertices and O(n) edges are added to G, is the nontrivial part of the algorithm that will be explained in Sections 6 - 8.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
77
We compute a topological sorting, i.e., an onto function f : Vst → {1, 2 . . . , n + 2}. The function f is comparable with φGst in the sense that for every v, w ∈ Vst we have f (v) ≤ f (w) if and only if φGst (v) ≤ φGst (w). Obviously f is an st-numbering of Gst (see, e.g., Even and Tarjan (1976)). Using this st-numbering, we can obtain a planar embedding Est of Gst with the edge (s, t) on the boundary of the outer face by applying the algorithm of Chiba et al. (1985). From the planar embedding we obtain a level planar embedding of Gst by applying a function “CONSTRUCT-LEVEL-EMBED” that uses a depth first search procedure starting at vertex t and proceeding from every visited vertex w to the unvisited neighbor that appears first in the clockwise ordering of the adjacency list of w in Est . Initially, all levels are empty. When a vertex w is visited, it is appended to the right of the vertices assigned to level φGst (w). The restriction of the resulting level orderings to the levels 1 to k yields a level planar embedding of G. It is clear that the described algorithm runs in O(n) time if the nontrivial part, namely the construction of Gst can be achieved in O(n) time. After adding the vertices s and t we augment G to a hierarchy by adding an outgoing edge to every sink of G without destroying level planarity using a function AUGMENT, processing the graph top to bottom. Using the same function AUGMENT again, we process the graph bottom to top and augment Gst to an st-graph by adding the edge (s, t) and an incoming edge to every source of G without destroying the level planarity. Thus our level planar embedding algorithm can be sketched as follows. El LEVEL-PLANAR-EMBED(G = (V 1 , V 2 , . . . , V k ; E)) begin ignore all isolated vertices; expand G to Gst by adding V 0 = {s} and V k+1 = {t}; if LEVEL-PLANARITY-TEST(Gst ) then AUGMENT(Gst ); else return El = ∅; //Gst is now a hierarchy; orient the graph Gst from the bottom to the top; AUGMENT(Gst ); orient the graph Gst from the top to the bottom; add edge (s, t); //Gst is now an st-graph; compute a topological sorting of Vst ; compute a planar embedding Est according to Chiba et al. (1985) using the topological sorting as an st-numbering; El = CONSTRUCT-LEVEL-EMBED(Est, Gst ); return El ; end. Augmenting a level graph G to an st-graph Gst is divided into two phases. In the first phase an outgoing edge is added to every sink of G. Using the same algorithmic concept as in the first phase, an incoming edge is added to every source of G in the second phase. In order to add an outgoing edge for every sink of G without destroying level planarity, we need to determine the position of a sink v ∈ V j , j ∈ {1, 2, . . . , k − 1}, in the P Q-trees. This is done by inserting an indicator as a leaf into the P Q-trees. The indicator is ignored throughout the
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
78
application of the level planarity test and will be removed either with the leaves corresponding to the incoming edges of some vertex w ∈ V l , l > j, or it can be found in the final P Q-tree. The idea of the approach can be explained best by an example. Figure 8 shows a small part of a level graph with a sink v ∈ V j and the corresponding part of the P Q-tree. Since v is a sink, the leaf corresponding to v will be removed from the P Q-tree before testing the graph Gj+1 for level planarity. Instead of removing the leaf, the leaf is kept in the tree ignoring its presence from now on in the P Q-tree. Such a leaf for keeping the position of a sink v in a P Q-tree is called a sink indicator and denoted by si (v). v v Figure 8: A sink v in a level graph G and the corresponding P Q-tree. As shown in Fig. 9 the indicator of v may appear within the sequence of leaves corresponding to incoming edges of a vertex w ∈ V l . The indicator of v is interpreted as a leaf corresponding to an edge e = (v, w) and G is augmented by e. Adding the edge e to G does not destroy the level planarity and provides an outgoing edge for the sink v. v w
v
w
e
w Figure 9: Adding an edge e = (v, w) without destroying level planarity. When replacing a leaf corresponding to a sink by a sink indicator, a P - or Q-node X may be constructed in the P Q-tree such that frontier (X) consists only of sink indicators. The presence of such a node is ignored in the P Q-tree as well. A node of a P Q-tree is an ignored node if and only if its frontier contains only sink indicators. By definition, a sink indicator is also an ignored node.
5
Sink Indicators in Template Reductions
In order to achieve linear time for the level planar embedder, we have to avoid searching for sink indicators that can be considered for augmentation. Consequently, only those indicators si (v), v ∈ V , that appear within the pertinent subtree of a P Q-tree with respect to a vertex w ∈ V
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
79
are considered for augmentation. We show that every edge added this way does not destroy level planarity. The first lemma considers sink indicators appearing within the sequence of pertinent leaves. Lemma 5.1. Let si (v) be a sink indicator of a vertex v ∈ V j , 1 < j < k, in a P Q-tree T corresponding to an extended form H. Adding the edge e = (v, w) to G does not destroy level planarity if one of the following two conditions holds. (i) si (v) is a descendant of a full node in the pertinent subtree with respect to a vertex w ∈ V l , j < l ≤ k. (ii) si (v) is a descendant of a partial Q-node in the pertinent subtree with respect to a vertex w ∈ V l , j < l ≤ k, and si (v) appears within the pertinent sequence. Proof: Since si (v) is the child of a full node or appears at least within a pertinent sequence of full nodes, adding the edge e = (v, w) does not destroy level planarity of the reduced extended form R corresponding to H. Thus it remains to show that adding the edge has no effect on merge operations. For every embedding E of R, the edge e is embedded either between two incoming edges of w or next to the consecutive sequence of incoming edges of w. If e is embedded between two incoming edges, the edge e obviously does not affect the level planar embedding of any nonsingular form and u-singular form with u 6= w. If e is embedded next to the consecutive sequence of incoming edges of w, then si (v) must be a descendant of a full node X. If X is a P -node, there exists an embedding of R such that the edge e can be embedded between two incoming edges of w. Thus adding the edge does not affect the level planar embedding of any nonsingular form and any u-singular form, with u 6= w. Consider now a full Q-node X. By construction, si (v) is a descendant leaf at one end of X. The Q-node X corresponds to a subgraph B. The vertex v must be on the boundary of the outer face of the subgraph B and there exists a path P = (v = u1 , u2 , . . . , uµ = w), µ ≥ 2, on the boundary of the outer face of B such that φ(ui ) < l for all i = 1, 2, . . . , µ − 1. Thus none of the nodes ui , i = 1, 2, . . . , µ − 1, is considered for a merge operation. Hence, replacing the path P by an edge (v, w) at the boundary of the outer face does not affect the level planar embedding of any nonsingular form and any u-singular form, with u 6= w. Figure 10 illustrates the insertion of an edge e = (v, w) if si (v) is the endmost child of a Q-node.
si (v)
11 00 00 11
w
111 000 000 111
v
w
w Figure 10: The sink indicator si (v) is an endmost child of a Q-node. The path P is drawn shaded, the edge e = (v, w) is drawn as a dotted line.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
80
Considering w-singular forms, adding the edge e produces one more face but the height of the largest interior face or the largest region of the outer face with w being adjacent to this region remains valid. Thus a w-singular form that has to be embedded within an interior face or within a w-cavity can be embedded level planar after the insertion of e. 2 Lemma 5.1 allows us to consider an edge for insertion if a sink indicator is a descendant of a full node or a descendant of a partial Q-node within the sequence of full children of the Q-node. The lemma does not consider a sink indicator si (v) that appears as a child of a partial Q-node X such that si (v) is a sibling to the pertinent sequence. Although the following lemma shows that edges corresponding to sink indicators that are endmost children at the full end of a partial Q-node can be added without destroying level planarity, the case where sink indicators are between the sequence of full and the sequence of empty children reveals problems. Lemma 5.2. Let si (v) be a sink indicator of a vertex v ∈ V j , 1 < j < k, in a P Q-tree T and let si (v) be a descendant of an ignored node X that is a child of a partial Q-node Y in the pertinent subtree with respect to a vertex w ∈ V l , j < l ≤ k. If X appears at the full end of the partial Q-node, the edge e = (v, w) can be added without destroying level planarity. Proof: Analogous to the proof of Lemma 5.1 for the case in which si(v) is a descendant of a full Q-node. 2 Consider now the situation of an extended reduced form R as shown in Figure 11. The sink indicator si (v) is a child of a partial Q-node in the pertinent subtree of some vertex w ∈ V l , j < l ≤ k, and si (v) is adjacent to a full and an empty node. Adding the edge e does not a priori destroy level planarity in R, but it creates a new interior face, such that the large space between w and the rightmost vertex of the subgraph corresponding to the subtree rooted at X is destroyed. Now assume that a nonsingular form R0 has to be w-merged into R, applying merge operation D. Although the ML-value between the leaf w and the node X allows us to add the form R0 between w and X, there is, due to the insertion of e, not enough space between w and X. Hence a crossing is created and a non-level planar graph is constructed as is shown in Figure 12. Consequently, a sink indicator that is found to be a sibling of a pertinent sequence and an empty sequence is never considered for edge augmentation. By applying the results of Lemmas 5.1 and 5.2 during the template matching algorithm, not all sink indicators are considered for edge insertion. Some of the indicators remain in the final P Q-tree that represents all possible permutations of vertices of V k in the level planar embeddings of G. The following lemma allows us not only to insert edges (w, t) for every w ∈ V k but also to insert an edge (v, t) for every remaining sink indicator si (v). Lemma 5.3. Let si(v) be a sink indicator of a vertex v ∈ V j , 1 < j < k. If si (v) is in the final P Q-tree T , the edge e = (v, t) can be added without destroying level planarity. Proof: Adding to every vertex w ∈ V k an edge (w, t) does not affect the level planarity of the graph. Thus consider testing the level V k+1 for level planarity. The pertinent subtree of T is equal to T and thus Lemma 5.1 applies. 2
6
Sink Indicators in Merge Operations
While the treatment of sink indicators during the application of the template matching algorithm is rather easy in principle, this does not hold for merge operations. We consider all merge operations
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
X
X
si (v)
11 00 00 11
81
11 00 00 11
w
w
v w
Figure 11: A doubly partial Q-node and its corresponding part of the form R. The new inserted edge e = (v, w) is drawn as a dotted line.
X
11111 00000 00000 11111 R0 00000 11111 v 11111 00000 00000 11111 11 00 ww
Figure 12: Merging R0 into R with the new edge e = (v, w) is not level planar.
and discuss necessary adaptions in order to treat the sink indicators correctly. If sink indicators and ignored nodes have to be manipulated correctly during the merge process, ML-values as they have been introduced for non-ignored nodes have to be introduced for ignored nodes as well. Consider a node X that becomes ignored. We make the following conventions. (i) If X is a child of a P -node Y , the corresponding ML-value for X is ML(Y ). (ii) If X is a child of a Q-node, we distinguish two cases: (a) X does not have an adjacent ignored sibling. Since X has non-ignored siblings on either side, let Z and Y be its direct non-ignored siblings. Then we leave the values ML(Z, X) and ML(X, Y ) at X, and replace according to the level planarity test the values ML(Z, X) and ML(X, Y ) by a new value ML(Z, Y ) = min{ML(Z, X), ML(X, Y )} at Z and Y . The case where X has just one non-ignored sibling is solved analogously. (b) X has adjacent ignored direct siblings. Since X has ignored siblings on either side, let ZI and YI be the direct ignored siblings and let Z and Y be its direct non-ignored siblings with Z at the side where ZI is, and Y at the side where YI is. Let ML(Z, X) and ML(X, Y ) be the ML-values between Z and X, and X and Y , respectively. Let ML(ZI , X) be the ML-value stored at ZI , and let ML(X, YI ) be the ML-value stored at YI . Then we replace at X the values ML(Z, X) by ML(ZI , X) and ML(X, Y ) by ML(X, YI ), and replace according to the level planarity test the values ML(Z, X) and
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
82
ML(X, Y ) by a new value ML(Z, Y ) = min{ML(Z, X), ML(X, Y )} at Z and Y . The cases with only one non-ignored or one ignored direct sibling are a handled analogously. This strategy ensures that non-ignored siblings Z and Y “know” the maximal height of the space between them, while the knowledge about the height of the space between the sinks and their corresponding indicators is left at the ignored nodes only. Lemma 6.1. Let X be an ignored node that is a child of a Q-node and let MLl and MLr be the ML-values that have been assigned to X by one of the rules (ii)(a) or (ii)(b) described above. Then the values MLl and MLr are valid for X. Proof: The sink indicators in frontier (X) can be interpreted as leaves corresponding to long edges. Thus the ML-values remain valid. 2 Lemma 6.2. Let X be an ignored node that is a child of a P -node Y . Then the value ML(Y ) is valid for X. Proof: Analogous to the proof of Lemma 6.1.
2
Suppose now that two reduced forms R1 and R2 and their corresponding trees T1 and T2 with LL(T1 ) ≤ LL(T2 ) have to be w-merged. As described in 3, we start with the leaf labeled w in T1 and proceed upwards in T1 until a node X 0 and its parent X are encountered such that one of the five merge conditions as described in Section 3 applies. The merge operations are discussed in an order according to the difficulties that are encountered when handling involved sink indicators. Before starting with the less problematic ones, one more convention is made. If X is a node in a P Q-tree, RX denotes the subgraph corresponding to the subtree rooted at the node X. Merge Operation E The tree T1 is reconstructed by inserting a Q-node X as new root of T1 with two children X 0 and the root of T2 . The following observation is trivial. Observation 6.3. There is no need to adapt the merge operation E in order to handle sink indicators correctly. Merge Operation A The root of T2 is attached as a child to a P -node X of T1 thus we have that ML(X) < LL(T2 ). Obviously, all ignored nodes that are children of X are allowed to be permuted in the pertinent subtree. Thus the sink indicators in their frontier are allowed to be considered for edge augmentation. However, the ignored children can only be considered if all children of X are traversed in order to find the ignored children. This implies that all empty children of X have to be traversed as well, yielding a quadratic time algorithm. Thus ignored children of X are not considered for augmentation and we can make following observation. Observation 6.4. There is no need to adapt the merge operation A in order to handle sink indicators correctly.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
83
Merge Operation D Let X be a Q-node of T1 with ordered children X1 , X2 , . . . , Xη , η > 1. Let X 0 = Xλ , 1 < λ < η, and ML(Xλ−1 , Xλ ) < LL(T2 ) ≤ ML(Xλ , Xλ+1 ). Thus R2 has to be nested between the subgraphs RXλ−1 and RXλ and the root of T2 is attached as a child to the Q-node X between Xλ−1 and Xλ . Let I1 , I2 , . . . , Iµ , µ ≥ 0, be the sequence of ignored nodes between Xλ−1 and Xλ with Xλ−1 and I1 being direct siblings, and Xλ and Iµ being direct siblings. As illustrated in Figure 13 there may exist a ν ∈ {1, 2, . . . , µ} such that for every sink indicator si (v) ∈
µ [
φ(w)−1
frontier (Ii ) ,
v∈
i=ν
[
Vi ,
i=1
the graph has to be augmented by an edge e = (v, w). Adding these edges Sµ does not destroy level planarity. Furthermore, augmenting the graph G for every si (v) ∈ i=ν frontier (Ii ), with Sk φ(v) ≥ LL(T2 ), by an edge e0 = (v, u), u ∈ i=φ(w) V i , u 6= w destroys level planarity, since such an edge must cross either a path in R2 connecting w with a vertex v’ of R2 , φ(v 0 ) = LL(T2 ), or a path in R1 connecting w with a vertex v 00 in R1 , φ(v 00 ) = LL(T2 ).
Xλ−1 I1
Xλ−1
Iν−1 Iν
Iµ
Xλ
1111111111111 0000000000000 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 R2 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111
w
w
Figure 13: Merging the form R2 into R1 using the merge operation D forces us to augment G by the edges drawn as dotted lines. Using the following lemma we are able to find all the sink indicators that have to be considered for edge insertion when applying the merge operation D. Lemma 6.5. Let X be a child of a Q-node and let Y be a direct non-ignored sibling of X. Let I1 , I2 , . . . , Iµ , µ ≥ 0, be the sequence of ignored nodes between X and Y with X and I1 being direct siblings, and Y and Iµ being direct siblings. There exists a ν ∈ {1, 2, . . . , µ + 1} such that ML(X, Y ) = ML(Iν−1 , Iν ), with I0 = X and Iµ+1 = Y .
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
84
Proof: The lemma follows immediately from Lemma 6.1.
2
Remark 6.6. We store at every pair of direct non-ignored siblings X and Y pointers to the two ignored siblings Iν−1 and Iν with ML(Iν−1 , Iν ) = ML(X, Y ). The maintenance during the application of the template reduction algorithm and the merge operations is straightforward. We will see later how we benefit from this in the merge operations B and C. Placing the root of T2 between Iν−1 and Iν constructs a P Q-tree such that the ignored nodes This permits to augment the graph G by an Iν , Iν+1 , . . . , Iµ appear within the pertinent subtree. S edge e = (v, w) for every sink indicator si (v) ∈ µi=ν frontier (Ii ) during the reduction with respect to w. Merge Operation C Let X be a Q-node with ordered children X1 , X2 , . . . , Xη , X 0 = Xλ , 1 < λ < η, and ML(Xλ−1 , Xλ ) < LL(T2 ) and ML(Xλ , Xλ+1 ) < LL(T2 ). The node Xλ is replaced by a Q-node Y with two children, Xλ and the root of T2 . Let I1 , I2 , . . . , Iµ , µ ≥ 0, be the sequence of ignored nodes between Xλ−1 and Xλ with Xλ−1 and I1 being direct siblings, and Xλ and Iµ being direct siblings. Let J1 , J2 , . . . , Jρ , ρ ≥ 0, be the sequence of ignored nodes between Xλ and Xλ+1 with Xλ and J1 being direct siblings, and Xλ+1 and Jρ being direct siblings. As illustrated in Figure 14 there may exist a ν, 1 ≤ ν ≤ µ, such that for every sink indicator si (v) ∈
µ [
φ(w)−1
frontier (Ii ) ,
i=ν
v∈
[
Vi ,
i=1
G has to be augmented by an edge e = (v, w) if R2 is embedded between RXλ−1 and RXλ .
Xλ−1 I1
Xλ−1
Iν−1 Iν
Iµ Xλ J1
1111111111111 0000000000000 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 R2 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111
w
Jσ Jσ+1
Jρ Xλ+1
Xλ+1 w
Figure 14: Merging the form R2 into R1 using the merge operation C and embedding it between RXλ−1 and RXλ forces G to be augmented by the edges drawn as dotted lines.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
85
As is illustrated in Figure 15, R2 can be embedded between RXλ and RXλ+1 , and there may exist a σ, 1 ≤ σ ≤ ρ, such that for every sink indicator si (v) ∈
σ [
φ(w)−1
frontier (Ji ) ,
v∈
i=1
[
Vi ,
i=1
G has to be augmented by an edge e = (v, w).
Xλ−1 I1
Iν−1 Iν
Iµ Xλ J1
Xλ−1 w
Jσ Jσ+1
Jρ Xλ+1
1111111111111 0000000000000 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 R2 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111
Xλ+1
w
Figure 15: Merging the form R2 into R1 using the merge operation C and embedding it between RXλ and RXλ+1 forces G to be augmented by the edges drawn as dotted lines. It is not possible to consider both sets of ignored nodes for edge augmentation. Consider Sµ frontier (Ii ) and for instance the example shown in Figure 16, where edges for both sets i=ν Sσ frontier (J ) have been added, yielding immediately a non-level planar graph. i i=1 However, deciding which set of sink indicators has to be considered for edge augmentation is not possible unless Xλ is a full node (see Leipert (1998)). Extending the level planarity test down the levels V φ(w)+1 to V k may embed the component R2 on either of the two sides of RXλ . Since the side is unknown during the merge operation, we have to keep the affected sink indicators in mind. Furthermore, we must devise a method that permits recognizing the correct embedding during subsequent reductions. The sequences Iν , Iν+1 , . . . , Iµ and J1 , J2 , . . . , Jσ are called the reference sequence of R2 and denoted by rseq(R2 ). We refer to Iν , Iν+1 , . . . , Iµ as the left reference sequence of R2 denoted left , J2 , . . . , Jσ as the right reference sequence denoted by rseq(R2 )right . The by rseq(R Sµ 2 ) , and to J1S σ union i=ν frontier (Ii )∪ i=1 frontier (Ji ) is called the reference set of R2 and denoted by ref (R2 ). The left and right reference set ref (R2 )left and ref (R2 )right , respectively, are defined analogously to the left and right reference sequence. In Section 7 a method using a special ignored indicator is developed for deciding which subset of ref (R2 ) has to be considered for edge augmentation. Before continuing with the algorithmic
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
Xλ−1 I1
Iν−1 Iν
Iµ
Xλ
u ˜ Xλ−1 u
w
J1
Jσ Jσ+1
1111111111111 0000000000000 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 R2 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111
86
Jρ Xλ+1
Xλ+1
w
Figure 16: Merging the form R2 into R1 using the merge operation C does not allow to consider sinks on both sides of RXλ for edge augmentation. Independently on the ˜ and chosen embedding of R2 there are always crossings between a path connecting u u and the new edges.
solution, we finish by considering the merge operation B where exactly the same problem occurs as has been encountered for the merge operation C. Merge Operation B Let X be a Q-node with ordered children X1 , X2 , . . . , Xη , and let X 0 = X1 , and ML(X1 , X2 ) < LL(T2 ). The node X1 is replaced by a Q-node Y having two children, X1 and the root of T2 . Let I1 , I2 , . . . , Iµ , µ ≥ 0, be the sequence of ignored nodes at one end of X with X1 and Iµ being direct siblings and I1 being an endmost child of X. Let J1 , J2 , . . . , Jρ , ρ ≥ 0, be the sequence of ignored nodes between X1 and X2 with X1 and J1 being direct siblings, and X2 and Jρ being direct siblings. Analogous to the merge operation C, there may exist sink indicators affected by merging R2 into R1 in both sets I1 , I2 , . . . , Iµ , µ ≥ 0, and J1 , J2 , . . . , Jρ , ρ ≥ 0. Again it is not possible to decide if the left reference set ref (R2 )left or the right reference set ref (R2 )right has to be considered for edge augmentation.
7
Contacts
In order to solve the decision problem of the merge operations B and C, we examine how R2 is fixed to either side of the vertex w ∈ V in a level planar embedding of G. For the rest of this section we consider two P Q-trees T1 and T2 , such that T2 has been w-merged into T1 using a merge operation B or C. Let X be the Q-node with children X1 , X2 , . . . , Xη , η ≥ 2, and let Xλ , λ ∈ {1, 2, . . . , η}, be its child that is replaced by a new Q-node having two children Xλ and the root of T2 . Let RXλ be the subgraph of R1 corresponding to the subtree rooted at Xλ before merging R1 and R2 . Let
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
87
RX be the subgraph corresponding to the subtree rooted at X before merging R1 and R2 . ~ X to be the set of all vertices u ∈ V such that there exists a vertex Definition 7.1. Define R v ∈ RX and a (not necessarily directed) path P connecting u and v not using the connective cut Sk Sk vertex of X. Define further D(RXλ ∪ R2 ) ⊂ i=φ(w) V i to be the set of vertices u ∈ i=φ(w) V i such that the following two conditions hold. 1. There exists a directed path P = (u1 , u2 , . . . , uξ = u), ξ > 1, with u1 ∈ RXλ ∪ R2 . Sk u1 , u ˜2 , . . . , u˜ι = u˜), ι > 1, 2. There exists a vertex u ˜ ∈ i=φ(w) V i and a directed path P˜ = (˜ u) ≥ φ(u) and the paths P and P˜ are vertex disjoint except with u ˜1 ∈ RXλ ∪ R2 , such that φ(˜ for possibly u and u ˜. The vertex set D(RXλ ∪ R2 ) is called the dependent set of RXλ ∪ R2 . Figure 17 illustrates different kinds of dependent sets D(RXλ ∪R2 ). The dependent set D(RXλ ∪ R2 ) is drawn shaded in all four cases. The vertex v in all four subfigures denotes the connective cut vertex of Xλ in Gφ(w) that permits reversing the subgraph RXλ ∪ R2 with respect to RX . For simplicity, we make the overall assumption for the rest of this section that no vertex u ∈ D(RXλ ∪ R2 ) is involved in a merge operation. This matter is discussed in the next section, handling concatenations of merge operations. However, subsequent merge operations to any other vertex not contained in D(RXλ ∪ R2 ) are allowed after w-merging R2 into R1 . Figure 17(a) illustrates the case, where v is not only a cut vertex in Gφ(w) but also a cut vertex in the graph G. Consequently, RXλ ∪ R2 ∪ D(RXλ ∪ R2 ) will be embedded within an interior face or the outer face with the option to chose its embedding unaffected from the embedding of the rest of the graph. Hence R2 may be embedded on an arbitrary side of RXλ with respect to RX . Figure 17(b) illustrates the case, where v is not a cut vertex in the graph G but there exists a vertex u ∈ D(RXλ ∪ R2 ) such that u and v form a split pair and φ(˜ u) < φ(u) if u ˜ ∈ D(RXλ ∪ R2 ) − {u} . Thus RXλ ∪ R2 ∪ D(RXλ ∪ R2 ) forms a split component and its embedding may be chosen freely. Hence R2 may be embedded on an arbitrary side of RXλ with respect to RX . Figure 17(c) illustrates a more delicate situation involving a split pair v and u1 . According to the definition of the dependent set, the vertex u2 is contained in D(RXλ ∪ R2 ) since there exists a vertex u4 with φ(u2 ) = φ(u4 ) and two directed paths P and P˜ , with (i) P connecting a vertex of RXλ ∪ R2 and u2 , (ii) P˜ connecting a vertex of RXλ ∪ R2 and u4 , and (ii) P and P˜ being disjoint. Although u2 ∈ D(RXλ ∪ R2 ), the vertex u2 is not contained in the split component of v and u1 . The vertex u3 , however, does not belong to the dependent set D(RXλ ∪ R2 ) since any directed S path connecting a vertex of RXλ ∪ R2 and a vertex in ki=φ(u3 ) V i must contain the vertex u1 . Hence, the paths are not disjoint and u3 ∈ / D(RXλ ∪ R2 ). Figure 17(c) shows a (not necessarily ˆ directed) path P connecting v and u3 via v˜, such that Pˆ and RXλ ∪ R2 ∪ D(RXλ ∪ R2 ) are disjoint. This leads to the interesting situation that u3 and therefore u2 are fixed in their embedding to the
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
88
side where v˜ is, while we are still able to flip the split component of u1 and v around, choosing an arbitrary side where to embed R2 next to RXλ with respect to RX . However, the existence of a split component does not guarantee a free choice of the embedding. In case that a (not necessarily directed) path P˜ exists, connecting the vertices v and u2 via v˜ such that the path P˜ and RXλ ∪ R2 ∪ D(RXλ ∪ R2 ) are disjoint, and the path P˜ uses only vertices in Sφ(u2 ) i i=1 V , we cannot flip the split component of v and u1 anymore. While Figure 17(a),(b),(c) describe examples of dependent sets such that an embedding of R2 can be chosen freely, Figure 17(d) gives an example of a dependent set that has to be embedded such that R2 is forced to be embedded on exactly one side of RXλ with respect to RX . Consider a vertex u1 ∈ V − (RXλ ∪ R2 ∪ D(RXλ ∪ R2 )) and a vertex u2 ∈ D(RXλ ∪ R2 ) such that there exists path Pˆ disjoint to RXλ ∪ R2 ∪ D(RXλ ∪ R2 ), connecting v and u2 via u1 , and the path Pˆ uses only Sφ(u ) vertices in i=12 V i . If there exists a vertex u3 ∈ D(RXλ ∪ R2 ), u3 6= u2 , with φ(u3 ) ≥ φ(u2 ), the path Pˆ forces R2 to be embedded on one side of RXλ with respect to RX . Figure 17 implicitly assumes that the Q-node X remains a node with at least two non-ignored children, one being the Q-node Y (the node that has been introduced when merging T (R1 ) and T (R2 )). The example of Figure 18 shows a subgraph corresponding to the subtree rooted at X, where X has become a Q-node with only one non-ignored child that is the node Y . Thus, there exists a split pair v and v˜ in G with v˜ being the connective cut vertex of RX that allows reversing the ~ X −(RX ∪R2 ∪D(RX ∪R2 )). This implies that R2 may be embedded split component containing R λ λ on either side of RXλ with respect to RX . We note that a path P = (v = u1 , u2 , . . . , uµ = u), µ ≥ 2, may exist, connecting v and a vertex u ∈ D(RXλ ∪ R2 ) such that P is disjoint to D(RXλ ∪ R2 ), Sφ(u) and the path P uses only vertices in i=1 V i . Such a path has no effect on the embedding of R2 next to RXλ with respect to RX since P must traverse the connective cut vertex v˜ of RX . Figure 18 shows the path P as a dotted line. ~ X − (RX ∪ R2 ∪ D(RX ∪ R2 )) such that for every vertex However, if there exists a vertex u ˜∈R λ λ u) holds, the embedding of R2 is fixed next to RXλ with respect ui ∈ P the inequality φ(ui ) ≤ φ(˜ to RX . Our discussion leads to the following observations. Observation 7.2. Let v be the connective cut vertex of RXλ and let v˜ be the connective cut vertex of RX if X has a parent. The subgraph R2 is not fixed to any side of RXλ with respect to RX if and only if for every vertex u in the dependent set D(RXλ ∪ R2 ) and every undirected path Sφ(u) P = (v = u1 , u2 , . . . , uµ = u), µ ≥ 2, with ui ∈ i=1 V i for all i = 1, 2, . . . , µ, one of the following conditions holds. (i) uµ−1 ∈ RXλ ∪ R2 ∪ D(RXλ ∪ R2 ). ~ X − (RX ∪ R2 ∪ D(RX ∪ R2 )) the inequality φ(v 0 ) < φ(u) holds. (ii) v˜ ∈ P and for all v 0 ∈ R λ λ (iii) v and u form a split pair in G and for all v 0 ∈ D(RXλ ∪ R2 ) − {u} the inequality φ(v 0 ) < φ(u) holds. Observation 7.3. Let v be the connective cut vertex of RXλ and let v˜ be the connective cut vertex of RX if X has a parent. The subgraph R2 is fixed to a side of RXλ with respect to RX if and only if there exists a vertex u in the dependent set D(RXλ ∪ R2 ) and an undirected path Sφ(u) P = (v = u1 , u2 , . . . , uµ = u), µ ≥ 2, with ui ∈ i=1 V i for all i = 1, 2, . . . , µ, and all of the following three conditions hold.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
89
/ RXλ ∪ R2 ∪ D(RXλ ∪ R2 ). (i) uµ−1 ∈ (ii) (a) v˜ ∈ / P , or ~ X − (RX ∪ R2 ∪ D(RX ∪ R2 )) such that φ(v 0 ) ≥ φ(u). (b) v˜ ∈ P and there exists a v 0 ∈ R λ λ (iii) There exists a vertex v 0 ∈ D(RXλ ∪ R2 ) − {u} such that the inequality φ(v 0 ) ≥ φ(u) holds. The path P connecting the vertex v and a vertex u ∈ D(RXλ ∪ R2 ) uses only level-i vertices with i ≤ φ(u). This implies that the last edge (uµ−1 , u) on the path P must be an incoming edge of u. We use this fact to determine to which side of RXλ the form R2 is fixed with respect to RX . During the reduction of the leaves corresponding to the vertex u we analyze the incoming edges of u, determining for each edge if it is the last edge of a path that is treated in one of the Observations 7.2 and 7.3. The following two lemmas help us to perform the case distinction in a very efficient way. We note that the parent of Y (Y is the Q-node that has been inserted by the merge operation) does not need to be the node X throughout the algorithm, e.g., it may have been removed from the P Q-tree when applying a reduction using one of the templates Q2 and Q3. Lemma 7.4. The subgraph R2 has to be fixed in its embedding at one side of RXλ with respect to RX if and only if the Q-node Y is removed from the tree T during the application of the template matching algorithm using template Q2 or template Q3, and the parent of Y did not become a node with Y as the only non-ignored child. Proof: Let R2 be fixed to a side of RXλ with respect to RX . According to Observation 7.3, there exists a vertex u in the dependent set D(RXλ ∪ R2 ) and an undirected path P = (v = Sφ(u) u1 , u2 , . . . , uµ = u), µ ≥ 2, with ui ∈ i=1 V i for all i = 1, 2, . . . , µ. The last edge e = (uµ−1 , u) / RXλ ∪ R2 ∪ D(RXλ ∪ R2 ). Since u is in on P is therefore an incoming edge of u, and uµ−1 ∈ ˜ ∈ D(RXλ ∪ R2 ), it must have a second incoming edge e˜, with e˜ being incident to a vertex u Sφ(u)−1 i ˜l in T corresponding to e˜ it follows that V ∩ (R ∪ R ∪ D(R ∪ R )). Thus for the leaf X 2 X 2 λ λ i=1 ˜l ∈ frontier (Y ). Furthermore, the condition 7.3(i) guarantees that for the leaf l in T corresponding to e we have l ∈ / frontier (Y ). Let Z be the smallest common ancestor of l and ˜l in the P Q-tree. Obviously, the Q-node Y is a descendant of Z and we have Y 6= Z. ˜ be the parent of Y . If condition 7.3(ii)(a) holds, then l ∈ frontier (X), ˜ and v˜ (the Let X connective cut vertex of RX ) and v (the connective cut vertex of RXλ ) do not form a split pair in G. Thus the parent of Y did not become a node with Y as its only non-ignored child. ˜ but there exists at least If on the other hand condition 7.3(ii)(b) holds, then l ∈ / frontier (X), ~ X − (RX ∪ ˜ one empty child of X containing a leaf in its frontier corresponding to a vertex v 0 ∈ R λ R2 ∪ D(RXλ ∪ R2 )). Thus again, the parent of Y did not become a node with Y as the only non-ignored child. The node Y was a child of the Q-node X when it was introduced into the P Q-tree. Since the parent of Y did not become a node with Y as the only non-ignored child, according to Lemma 2.2 Y remains a child of a Q-node throughout the applications of the template matching algorithm. Due to the overall assumption that no vertex in D(RXλ ∪ R2 ) is involved in another merge operation, Y remains a child of a Q-node throughout every merge operation. Due to condition 7.3(iii) there exists an empty leaf in the frontier of the node Y . Thus Y is a ˜ are traversed during the reduction with respect to the vertex partial node, and Y and its parent X
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
90
˜ is a Q-node that is contained in the pertinent subtree with respect to u, either template u. Since X ˜ removing Y from the P Q-tree. Q2 or template Q3 is applied to Y and X, Now let Y be removed from the tree during the reduction with respect to some vertex u by applying template Q2 or Q3 and and let the parent of Y never become a node with Y being its only non-ignored child. Since the parent of Y always has at least two children, condition 7.3(ii)(a) or (ii)(b) must hold. Furthermore, the application of template Q2 or Q3 implies that the template matching algorithm has traversed Y and its parent, which is a Q-node as well. Hence the root of the pertinent subtree must be a proper ancestor of Y . Thus there exists a pertinent leaf l not in the subtree of Y , and Sφ(u) a path P = (v = u1 , u2 , . . . , uµ = u), µ ≥ 2, with ui ∈ i=1 V i for all i = 1, 2, . . . , µ, such that / RXλ ∪ R2 ∪ D(RXλ ∪ R2 ). Since one of the templates Q2 and Q3 has been applied in order uµ−1 ∈ to remove Y from the tree, Y itself must have been partial, and therefore must have had at least one empty leaf in its frontier. Thus condition 7.3(iii) holds. It follows that R2 is fixed on one side 2 of RXλ with respect to RX . Lemma 7.5. The subgraph R2 is not fixed to any side of RXλ with respect to RX if and only if one of the following cases occurs during the application of the template matching algorithm. (i) The Q-node Y gets ignored. (ii) The Q-node Y is a non-ignored node of the final P Q-tree. (iii) The Q-node Y has only one non-ignored child. (iv) The parent of Y has only Y as a non-ignored child. Proof: Let R2 be a subgraph not fixed to any side of RXλ . According to Observation 7.2 the cases 7.2(i), 7.2(ii), or 7.2(iii) apply. If there exists a path P and a vertex u ∈ D(RXλ ∪ R2 ) in G that satisfy condition 7.2(ii), it follows that the Q-node X was transformed into a node with only one non-ignored child and possibly some ignored children. Then the case (iv) follows immediately. If there exists a vertex u ∈ D(RXλ ∪R2 ) that satisfies 7.2(iii) then there exists a level l, φ(w) < l ≤ k, Tk (w being the vertex involved in merging RXλ and R2 ) such that D(RXλ ∪ R2 ) ∩ i=l V i = ∅ and |D(RXλ ∪ R2 ) ∩ V l−1 | = 1. Thus after completing the level planarity test for Gl−1 the node Y is a Q-node with just one non-ignored child. Now assume that 7.2(i) holds for all paths in G connecting v and a vertex u ∈ D(RXλ ∪ R2 ) and no path matches condition 7.2(ii) and 7.2(iii). It follows from 7.2(i) that 7.3(i) does not hold for any vertex u ∈ D(RXλ ∪ R2 ). According to Lemma 7.4, the Q-node Y is not removed from the tree using one of the templates Q2 and Q3, and one of the following two cases must hold. Tk 1. There exists a level l, φ(w) < l ≤ k, such that D(RXλ ∪ R2 ) ∩ i=l V i = ∅ and |D(RXλ ∪ R2 ) ∩ V l−1 | ≥ 1. Thus after completing the level planarity test for Gl−1 the node Y is a Q-node with non-ignored children. Two subcases occur (a) Every leaf in the frontier of the non-ignored children of Y is replaced by a sink indicator before testing Gl for level planarity. It follows that case (i) applies. (b) All leaves in the frontier of Y except for the leaves in the frontier of one child of Y become ignored. Thus case (iii) applies 2. The node Y is found in the final P Q-tree.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
91
Conversely, if one of the four cases applies to the Q-node Y , by Observation 7.2 any embedding may be chosen. 2 Lemmas 7.4 and 7.5 reveal a solution for solving the problem of deciding whether R2 is fixed to one side of RXλ with respect to RX . A strategy is developed for detecting on which side of RXλ the subgraph R2 has to be embedded. One endmost child of Y clearly can be identified with the side where the root of T2 has been placed, while the other endmost child of Y can be identified with the side were Xλ is. Every reversal of the Q-node Y corresponds to changing the side were R2 has to be embedded and all we need to do is to detect the side of Y that belongs to R2 , when finally removing Y from the tree applying one of the templates Q2 or Q3. The strategy is to mark the end of Y belonging to R2 with a special ignored node. Such a special ignored node is called a contact of R2 and denoted by c(R2 ). It is placed as the endmost child of Y during the merge operation B or C next to the root of T2 . Thus the Q-node Y has now three children instead of two. See Figure 19 for an illustration. Since the contact c(R2 ) is related to a w-merge operation, the vertex w is called related vertex of c(R2 ) and denoted by ω(c(R2 )). The corresponding w-merge operation is said to be associated with c(R2 ). Before gathering some observations about contacts, it is necessary to show that the involved ignored nodes remain in the relative position of Y within the Q-node, and are therefore not moved or removed. Lemma 7.6. The ignored nodes of rseq(R2 )left and rseq(R2 )right stay siblings of Y until one of the templates Q2 or Q3 is applied to Y and its parent. Proof: The ignored nodes of rseq(R2 )left and rseq(R2 )right are children of a Q-node, and therefore remain children of a Q-node keeping their order throughout the application of the template matching algorithm, unless either rseq(R2 )left or rseq(R2 )right are found to be within a pertinent sequence. However, this can only happen if the node Y becomes pertinent, provided that the node Y does not become ignored itself. 2 A contact has some special attributes that are immediately clear and very useful for our approach. In the following observations we again assume that Y and its parent have not been an object of another merge operation B or C. Concatenation of contacts is discussed in the next section. Observation 7.7. Since the contact is an endmost child of a Q-node Y , it will remain an endmost child of the same Q-node Y , unless the node Y is eliminated applying one of the templates Q2 or Q3. Observation 7.8. If the node Y is eliminated applying the templates Q2 or Q3, the contact c(R2 ) determines the side were R2 has to be embedded next to RXλ with respect to RX . The contact is then a direct sibling to rseq(R2 )i , for some i ∈ {left , right } and ref (R2 )i has to be considered for edge augmentation. Besides placing c(R2 ) as endmost child next to the root of T2 , c(R2 ) is equipped with a set of four pointers, denoting the beginning and the end of both the left and the right reference sequence of R2 . This is necessary, since direct non-ignored siblings of Y may become ignored throughout the application of the algorithm. Let rseq(R2 )left = {Iν , Iν+1 , . . . , Iµ } be the left reference sequence and let rseq(R2 )right = {J1 , J2 , . . . , Jσ } be the right reference sequence. After performing a reduction
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
92
applying template Q2 or Q3 to the node Y , the contact is either a direct sibling of Iµ or a direct sibling of J1 . In the first case, we scan the sequence of ignored siblings starting at Iµ until the ignored node Iν is detected. In the latter case, the sequence of ignored siblings is scanned by starting at J1 until the node Jσ is detected. Figure 20 illustrates this strategy for the latter case. Storing pointers of the ignored nodes Iν , Iµ , J1 , Jσ at c(R2 ), we are able to identify the reference set ref (R2 ). The nodes Iν , Iµ , J1 , Jσ are called the reference points of the contact c(R2 ). Analogously to the definition of a reference set of R2 , ref (R2 ) is said to be the reference set of c(R2 ) and denoted by ref (c(R2 )). The section closes with a summary of the results. Lemma 7.9. Let c(R2 ) be a contact related to a vertex w and let ref (R2 )left be the left reference set of c(R2 ) with reference points Iν , Iµ and let ref (R2 )right be the right reference set of c(R2 ) with reference points J1 , Jσ . Then the following statements are true. (i) If c(R2 ) is adjacent to Iµ , then augmenting Gst by an edge (u, w) for every si (u) ∈ ref (R2 )left does not destroy level planarity. (ii) If c(R2 ) is adjacent to J1 , then augmenting Gst by an edge (u, w) for every si (u) ∈ ref (R2 )right does not destroy level planarity. Proof: The lemma immediately follows from Lemmas 7.4 and 7.6.
8
2
Concatenation of Contacts
For clarity, the previous section omitted the concatenation of merge operations applied to the vertices of the dependent set corresponding to a merge operation B or C. This section deals with the subject of concatenating merge operations. Let R1 be a reduced extended form that has been w1 -merged into a reduced extended form R by applying a merge operation B or C. Let T and T1 be the P Q-trees corresponding to R and R1 . Let X be the Q-node with children X1 , X2 , . . . , Xη , η ≥ 2, and let Xλ , λ ∈ {1, 2, . . . , η}, be the child that is replaced by a new Q-node having two children Xλ and the root of T1 . Let Ri , i = 2, 3, . . . , µ, be reduced extended forms where every Ri has to be wi -merged into R, and Ri is wi -merged into R before Ri+1 is wi+1 -merged into R, for all i = 2, 3, . . . , µ − 1. S Definition 8.1. Let D(RXλ ∪R1 ) ⊂ kν=φ(w1 ) V ν be the dependent set of RXλ ∪R1 . The dependent set of RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Ri , i ∈ {2, 3, . . . , µ}, is denoted by D(RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Ri ) ⊂ Sk Sk ν ν such that the ν=φ(w1 ) V , and is recursively defined to be the set of all vertices u ∈ ν=φ(w1 ) V following conditions hold. 1. wi ∈ D(RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Ri−1 ). 2. There exists a directed path P = (u1 , u2 , . . . , uξ = u), ξ > 1, with u1 ∈ RXλ ∪R1 ∪R2 ∪· · ·∪Ri . S u1 , u ˜2 , . . . , u ˜ι = u˜), ι > 1, 3. There exists a vertex u ˜ ∈ kν=φ(w1 ) V ν and a directed path P˜ = (˜ u) ≥ φ(u) and the paths P and P˜ are vertex with u ˜1 ∈ RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Ri , such that φ(˜ disjoint except possibly for u and u˜.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
93
Definition 8.2. A sequence of wi -merge operations, i = 1, 2, . . . µ, of reduced extended forms Ri into a reduced extended form R is said to be a concatenation of merge operations if the following three conditions hold. (i) R1 is w1 -merged using a merge operation B or C. (ii) For all wi -merge operations we have wi ∈ D(RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Ri−1 ). (iii) R1 has not been fixed to one side of RXλ with respect to RX and it is unknown if its embedding can be chosen freely. Interestingly, a concatenation of merge operations does not really affect the results of Observations 7.2 and 7.3 and the Lemmas 7.4 and 7.5. This is immediately clear for the observations that we now give for the concatenated case. Observation 8.3. Let v be the connective cut vertex of RXλ and let v˜ be the connective cut vertex of RX if X has a parent. Let Ri , i = 1, 2, . . . , µ, be a sequence of partially reduced extended forms that are wi -merged into R and where their merge operations are concatenations. The subgraph R1 is not fixed to any side of RXλ with respect to RX if and only if for every vertex u in the dependent set D(RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Rµ ) and every undirected path P = (v = u1 , u2 , . . . , uξ = u), ξ ≥ 2, Sφ(u) with ui ∈ ν=1 V ν for all i = 1, 2, . . . , ξ, one of the following conditions holds. (i) uξ−1 ∈ RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Rµ ∪ D(RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Rµ ). ~ X − (RX ∪ R1 ∪ R2 ∪ · · · ∪ Rµ ∪ D(RX ∪ R1 ∪ R2 ∪ · · · ∪ Rµ )) the (ii) v˜ ∈ P and for all v 0 ∈ R λ λ 0 inequality φ(v ) < φ(u) holds. (iii) v and u form a split pair in G and for all v 0 ∈ D(RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Rµ ) − {u} the inequality φ(v 0 ) < φ(u) holds. Observation 8.4. Let v be the connective cut vertex of RXλ and let v˜ be the connective cut vertex of RX if X has a parent. Let Ri , i = 1, 2, . . . , µ, be a sequence of partially reduced extended forms that are wi -merged into R and where their merge operations are concatenations. The subgraph R1 is fixed to a side of RXλ with respect to RX if and only if there exists a vertex u in the dependent set D(RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Rµ ) and an undirected path P = (v = u1 , u2 , . . . , uξ = u), ξ ≥ 2, with Sφ(u) ui ∈ ν=1 V ν for all i = 1, 2, . . . , ξ, and all three of the following conditions hold. / RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Rµ ∪ D(RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Rµ ). (i) uξ−1 ∈ (ii) (a) v˜ ∈ / P , or ~ X −(RX ∪R1 ∪R2 ∪· · ·∪Rµ ∪D(RX ∪R1 ∪R2 ∪· · ·∪Rµ )) (b) v˜ ∈ P and there exists a v 0 ∈ R λ λ 0 such that φ(v ) ≥ φ(u). (iii) There exists a vertex v 0 ∈ D(RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Rµ ) − {u} such that the inequality φ(v 0 ) ≥ φ(u) holds. In order to see that the results of Lemmas 7.4 and 7.5 (up to minor differences) still hold, we show that the “local structure” of the P Q-tree at the Q-node Y and its parent X either does not change or, if it changes, the embedding of R1 is fixed on one side of RXλ with respect to RX . With an “unchanged local structure” we express (informally) that throughout concatenated merge
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
94
operations the node Y (or any node that replaces Y ), and X (or any node that replaces X) stay Q-nodes with Y (or its replacing node) remaining unchanged in the position of its siblings. The following lemma formally describes how the Q-node Y is changed during subsequent concatenated merge operations. The results of the lemma then immediately lead to results similar to the ones in Lemmas 7.4 and 7.5. Lemma 8.5. Let Y be a Q-node that has been introduced by w1 -merging the P Q-tree T1 into T using a merge operation B or C, replacing a child Xλ of a Q-node X. Let Ti , i = 2, 3, . . . , µ, µ ≥ 2, be a sequence of P Q-trees that are wi -merged into T such that the wi -merge operations are concatenations. Let Y 0 be the node that occupies the position of Y in the P Q-tree after the wµ -merge operation is complete. Then Y 0 and its parent are Q-nodes. Proof: Let Ri , i = 1, 2, . . . , µ, be the forms corresponding to the P Q-trees Ti . We prove the lemma by induction. According to the definition of a concatenation, R1 has not been embedded at one side of RXλ with respect to RX and it is unknown if its embedding can be chosen freely. Lemma 7.5 therefore implies that the parent of Y did not become a node with Y as the only non-ignored child, and according to Corollary 2.2 the parent of Y must be a Q-node. Furthermore, Lemma 7.5 implies that Y must have at least two leaves in its frontier both corresponding to different vertices in G. When applying a w2 -merge operation to a vertex w2 ∈ D(RXλ ∪ R1 ) three cases are possible. (i) Only descendants of Y are affected by the merge operation. (ii) The node Y and its parent are affected by the merge operation. (iii) Proper ancestors of Y are affected by the merge operation. Consider the first case. If only proper descendants of Y are involved, neither Y nor its parent are affected. If Y and a child of Y are affected, the merge operations B, C or D are applied to the child of Y . Thus Y remains a Q-node with unchanged position in the P Q-tree. Consider the second case. Since the parent of Y is a Q-node, the only allowed merge operations are B, C, and D. The operations B and C insert a new Q-node Y 0 at the position of Y . Reducing the leaves labeled w2 after the merge operation does only affect the children of Y 0 , since Y 0 is the root of the pertinent subtree. Therefore, the Q-node Y 0 remains unchanged in its position. However, if the merge operation D is applied, the template matching algorithm performed directly after the merge operation removes Y from the tree by applying one of the templates Q2 or Q3. Hence, according to Lemma 7.4, R1 is embedded at one side of RXλ with respect to RX . Therefore, the w1 -merge operation of T1 and the w2 -merge operation of T2 are not a concatenation. If proper ancestors of Y are involved, the reduction of the P Q-tree with respect to w2 removes Y from the P Q-tree by applying one of the templates Q2 or Q3. Again, the w1 -merge operation of T1 and the w2 -merge operation of T2 are not concatenated. The lemma then follows by a simple inductive argument. 2 The following lemmas are almost identical to the Lemmas 7.4 and 7.5, taking into account that the subgraph induced by the subtree rooted at Y (or any Q-node that replaces Y due to a merge operation) may have grown by concatenated merge operations. Lemma 8.6. Let Y be the Q-node that was introduced by a w1 -merge operation B or C of a P Qtree T1 into a tree T , replacing a node Xλ that was a child of a Q-node X in T . Let Y 0 be a Q-node
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
95
occupying the position of Y , and Y 0 has been introduced during a merge operation concatenating the w1 -merge operation. The subgraph R1 corresponding to T1 has to be embedded at exactly one side of RXλ with respect to RX if and only if the Q-node Y 0 is removed from the tree T during the application of the template matching algorithm using template Q2 or template Q3, and the parent of Y did not become a node with Y as the only non-ignored child. Proof: The lemma follows from Lemma 7.4 and Lemma 8.5.
2
Lemma 8.7. Let Y be the Q-node that was introduced by a w1 -merge operation B or C of a P Qtree T1 into a tree T , replacing a node Xλ that was a child of a Q-node X in T . Let Y 0 be a Q-node occupying the position of Y , and Y 0 has been introduced during a merge operation concatenating the w1 -merge operation. The subgraph R1 corresponding to T1 is not fixed to any side of RXλ if and only if one of the following cases occurs during the application of the template matching algorithm. (i) The Q-node Y 0 gets ignored. (ii) The Q-node Y 0 is a non-ignored node of the final P Q-tree. (iii) The Q-node Y 0 has only one non-ignored child. (iv) The parent of Y 0 has only Y 0 as a non-ignored child. Proof: The lemma follows from Lemma 7.5 and Lemma 8.5.
2
Let c be a contact that is a child of the Q-node Y . As long as concatenated merge operations only affect descendants of the Q-node Y , they have no effect on c and its reference sequence. However, if Y and its parent are subject to a merge operation B or C, there exists a coherence between the existing contact c and the new contact that is introduced by the merge operation. Obviously, the merge operations A, D, and E can be performed one after another without worrying about the correct treatment of involved sink indicators. However, the merge operations B and C may “affect” each other. Consider for instance the example shown in Figure 21, presenting three forms R1 , R2 , and R3 that have been successively merged into a form R at the vertices w1 , w2 , w3 . For every form Ri , the example also gives the set of edges that have to be added as incoming edges to wi , i ∈ {1, 2, 3}, in the given embedding. On the other hand, Figure 22 gives the same example only with a different embedding showing different sets of edges that have to be added as incoming edges to wi . In the rest of this section we discuss how to handle sequences of the merge operations B and C that affect each other. We say that two contacts c1 and c2 mutually influence each other if ref (c1 ) ∩ ref (c2 ) 6= ∅. Two merge operations B or C mutually influence each other if their corresponding contacts mutually influence each other. Consider a Q-node Y that has been introduced as a child of a Q-node X applying one of the operations B or C. In case of a w-merge operation B or C, we only need to check if the node Y that has to be replaced by a new Q-node does have a contact as an endmost child. However, the contact is then separated from its reference sequence since Y is not a child of the Q-node X anymore. This seems to destroy the strategy of handling the contact and its reference sequence correctly. However, the new Q-node is obviously the root of the pertinent subtree with respect to w. Since the two merge operations are concatenated, Lemma 7.5 does not apply to Y1 . (Otherwise, simply remove the contact and either the left or right reference set.) It follows that the node Y1 must be a partial Q-node. Therefore, template Q2 or Q3 is applied to Y1 and its parent Y2 , and Y1 is removed
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
96
from the tree, and the children of Y1 become children of Y2 . This ensures that after the reduction with respect to w, c1 is again a child of a Q-node Y2 , where Y2 is a child of X occupying the former position of Y1 . We consider the position of c1 within the sequence of children of Y2 . Let c2 be the contact associated with the merge operation that introduced Y2 . Two cases may occur during the reduction with respect to w. 1. The contact c1 was at the empty end of Y1 and since Y1 was an endmost child of Y2 , c1 is now an endmost child of Y2 . 2. The contact c1 was at the full end of Y1 , and appears within the sequence of full children of Y2 . After having finished the reduction with respect to w one of the following two rules is applied to the contact c1 . Rule I If c1 is an endmost child of Y2 , c1 remains in its position as an endmost child of Y2 . Rule II If c1 is found within the sequence of pertinent nodes, c1 is placed as a new endmost child of Y2 next to c2 . The rules are easily expanded to two or more contacts. Let Yi be the i-th Q-node introduced by the i-th concatenating merge operation. Rule I’ If a sequence of contacts c1 , c2 , . . . , cξ , ξ ≤ i − 1, is endmost at Yi after the reduction is complete, the contacts c1 , c2 , . . . , cξ remain in their positions. Rule II’ If a sequence of contacts c1 , c2 , . . . , cξ , ξ ≤ i−1, is found within the sequence of pertinent nodes and c1 was the former endmost child of Yi−1 , the sequence c1 , c2 , . . . , cξ is placed next to ci that cξ and ci are directly siblings and c1 is a new endmost child of Yi . Lemma 8.8. Let Ri , i = 1, 2, . . . , µ, be a sequence of partially reduced extended forms that are wi -merged into a partially reduced extended form R of a level planar graph G such that their merge operations are concatenations. Let T , T1 , T2 , . . . , Tµ be the P Q-trees corresponding to R, R1 , R2 , . . . , Rµ . Let X, Y1 , Y2 , . . . , Yµ be Q-nodes and Xλ be a node such that (a) Xλ was a child of X in a P Q-tree T before w1 -merging T1 into T . (b) Xλ was replaced by Y1 when w1 -merging T1 into T using the merge operation B or C. (c) Yi was replaced by Yi+1 when wi+1 -merging Ti+1 into T using the merge operation B or C for all i = 1, 2, . . . , µ − 1. Let c(Ri ) be the contact that is associated with the introduction of Yi , i = 1, 2, . . . , µ. Let RXλ be the subgraph corresponding to Xλ , and assume that c(R1 ), c(R2 ), . . . , c(Ri−1 ) have been replaced by applying one of the Rules I’ or II’ when merging R1 , R2 , . . . , Ri into R, i ≥ 2. Then exactly one of the following statements holds. (i) The contacts c(R1 ) and c(Ri ) are both children at the same end of the Q-node Yi if and only if their corresponding forms have to be embedded on the same side of RXλ with respect to RX in every level planar embedding.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
97
(ii) The contacts c(R1 ) and c(Ri ) are both children on opposite sides of the Q-node Yi if and only if their corresponding forms have to be embedded on opposite sides of RXλ with respect to RX in every level planar embedding. Proof: Since the merge operations are concatenated, Lemma 7.5 does not apply to Yi , i = 1, 2, . . . , µ − 1. It follows that Yi is a partial Q-node for every i = 1, 2, . . . , µ − 1. Thus there exist at least two leaves, one corresponding to an incoming edge of wi+1 and one corresponding to an incoming edge of a vertex u ∈ V l , u 6= w2 , φ(wi+1 ) ≤ l ≤ k. Let Yi , i ∈ {2, 3, . . . , µ − 1}, be the partial Q-node that has to be replaced by a Q-node Yi+1 in a wi+1 merge operation. Then the set {R1 , R2 , . . . , Ri } partitions into two subsets: • {R11 , R21 , . . . , Rν1 }, 1 ≤ ν ≤ i, the set of forms that are embedded on the same side as R1 and 2 , R22 , . . . , Ri2 }, the set of forms that are embedded on the opposite side of R1 . • {Rν+1
Since Yi is a partial Q-node, there exists a level planar embedding of RYi and two paths P = (u1 , u2 , . . . , uσ ) u1 ∈ R11 ∪ R21 ∪ · · · ∪ Rν1 2 uj ∈ / RXλ ∪ Rν+1 ∪ R22 ∪ · · · ∪ Ri2 − {wi } φ(uj ) < φ(wi+1 ) φ(uσ ) ≥ φ(wi+1 )
σ≥2 j = 1, 2, . . . , σ j = 1, 2, . . . , σ − 1
and P 0 = (u01 , u02 , . . . , u0ξ ) 2 ∪ R22 ∪ · · · ∪ Ri2 u01 ∈ RXλ ∪ Rν+1 1 1 uj ∈ / R1 ∪ R2 ∪ · · · ∪ Rν1 φ(u0j ) < φ(wi+1 ) φ(u0ξ ) ≥ φ(wi+1 )
ξ≥2 j = 1, 2, . . . , ξ j = 1, 2, . . . , ξ − 1
such that (a) P and P 0 are disjoint, (b) both P and P 0 are on the boundary of the outer face of the embedding of RYi , and (c) either uσ = wi+1 or u0ξ = wi+1 , but not both. See Figure 23 where we have illustrated the case i = 1. First, case (i) is proven. Let Ri+1 and R1 be embedded on the same side of RXλ . It follows that wi+1 ∈ P , otherwise Ri+1 and P would cross each other. Let Z be the child of Yi that is an ancestor of the leaf labeled wi+1 . Since the path P is on the outer face of RYi on the side where R1 is embedded, Z must be an endmost non-ignored child of Yi on the side where c(R1 ) is an endmost child. Since Yi is partial, c(R1 ) will appear within the pertinent sequence of leaves labeled wi+1 after the reduction with respect to wi+1 is complete. Therefore Rule II’ is applied and c(R1 ) and c(Ri+1 ) are both children at the same end of Yi+1 . Now let c(R1 ) and c(Ri+1 ) be children on the same side, and assume that R1 and Ri+1 have to be embedded on opposite sides of RXλ with respect to RX . It follows that wi+1 ∈ P 0 , otherwise Ri+1 and P 0 would cross each other. By construction, c(R1 ) was found within the pertinent sequence
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
98
with respect to the vertex wi+1 after Ri+1 was wi+1 -merged into R. So there exists a path P 00 on the boundary of RYi , and P 00 connects a vertex u ∈ R11 ∪ R21 ∪ · · · ∪ Rν1 and wi+1 , not using any Sk vertices u0 ∈ l=φ(wi+1 ) V l . However, P 00 must cross P , a contradiction. The case (ii) is proven analogously to case (i). 2 If two contacts c1 and c2 influence each other, and therefore ref (c1 ) ∩ ref (c2 ) 6= ∅ holds, we need to redefine their reference sets such that no conflicts appear when sink indicators for edge augmentation are considered. A situation, where we can chose for a sink indicator to which reference set it belongs has to be avoided. Again let R, R1 , R2 , X, Xλ , Y1 , Y2 , c(R1 ), and c(R2 ) be defined as in Lemma 8.8. The idea is to leave the reference set of c(R1 ) (the contact associated to the “first” merge operation) unchanged, and adapt the reference set of c(R2 ) (the contact associated to the “second” merge operation). Let I1 , I2 , . . . , Iµ , µ ≥ 0, be the sequence of ignored nodes on the left side of Xλ with Xλ and Iµ being direct siblings, and let J1 , J2 , . . . , Jρ , ρ ≥ 0, be the sequence of ignored nodes on the right side of Xλ with Xλ and J1 , being direct siblings. Let ! ! µ σ1 [ [ frontier (Ii ) ∪ frontier (Ji ) ref (c(R1 )) = i=ν1
i=1
for 1 ≤ ν1 ≤ µ + 1, 0 ≤ σ1 ≤ ρ be the reference set of c(R1 ), where we assume without loss of generality that none of the two subsets is empty. The reference points of c(R1 ) are Iν1 , Iµ , J1 , Jσ1 . Assume further that ! ! µ σ2 [ [ frontier (Ii ) ∪ frontier (Ji ) ref (c(R2 )) = i=ν2
i=1
for 1 ≤ ν2 ≤ µ + 1, 0 ≤ σ2 ≤ ρ . After performing the second merge operation including the reduction of the leaves labeled w2 , the contacts c(R1 ) and c(R2 ) occupy two relative positions at their parent Y2 . (i) c(R1 ) and c(R2 ) are endmost children on different ends of Y2 . Due to Lemma 8.8, R1 and R2 are embedded on opposite sides of RXλ with respect to RX . Thus c(R1 ) and c(R2 ) do not interfere when finally determining the sets of sink indicators that are considered for edge augmentation. We determine the reference points Iν2 , Iµ , J1 , Jσ2 and store them at c(R2 ). (ii) c(R1 ) and c(R2 ) are at the same end of Y2 with c(R1 ) being (by construction) an endmost child. Due to Lemma 8.8, R1 and R2 are embedded at the same side of RXλ . Thus c(R1 ) and c(R2 ) interfere when we finally determine the sets of sink indicators that are considered for edge augmentation. The new reference set of c(R2 ) is determined as follows. Sν1 −1 left i=ν2 frontier (Ii ) = ref (c(R2 )) ∅ right
ref (c(R2 ))
Sσ2 =
∅
i=σ1 +1
frontier (Ji )
if ν2 < ν1 otherwise if σ2 > σ1 otherwise
(1)
(2)
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
99
Then the reference set of c(R2 ) is ref (c(R2 ))
= ref (c(R2 ))right ∪ ref (c(R2 ))left .
Hence, the ignored nodes Iν2 , Iν1 −1 , Jσ1 +1 , Jσ2 are stored as reference points at c(R2 ). The application to the more general case of three or more contacts is straightforward. Remark 8.9. In order to achieve linear running time, the reference sequence of a newly introduced contact c(Ri ) and its associated form Ri is never determined by scanning the sequence of ignored siblings. Instead we proceed as follows. At every consecutive sequence of contacts, we keep a pointer at the endmost contact cα towards the innermost contact cω . The contact cω is obviously the contact that has been introduced last in this sequence of contacts. When introducing a new contact, we only need to consider the contacts on the same side as the new contact. We check the reference sequence of the innermost contact cω and determine the ML-values ML(Iνω−1 , Iνω ) and ML(Jσω , Jσω+1 ) between the reference sequence and their direct siblings. If ML(Iνω−1 , Iνω ) < LL(Ri ) or ML(Jσω , Jσω+1 ) < LL(Ri ), the left or right reference set of c(Ri ), respectively, is empty. If ML(Iνω−1 , Iνω ) ≥ LL(Ri ) or ML(Jσω , Jσω+1 ) ≥ LL(Ri ), the left or right reference sequence of c(Ri ), respectively, is determined in constant time using the pointers that we have installed as described in Remark 6.6. Consider the case were c(R1 ) and c(R2 ) are at the same end of Y2 . when removing the Q-node Y2 during the application of the template Q2 or Q3. The contact c(R1 ) is an endmost child of Y2 . Thus, after the application of the template Q2 or Q3 the contact c(R1 ) is a direct sibling of either Iµ or J1 . Therefore, the identification of sink indicators that have to be considered for edge augmentation joining the vertex w1 is a straightforward matter. After this identification is finished, the contact c(R1 ) and the set of ignored siblings that were considered for augmentation are removed from the P Q-tree, leaving the contact c(R2 ) as a direct sibling of either Iν1 −1 or Jσ1 +1 . Again, the identification of the sink indicators that have to be considered for edge augmentation joining the vertex w2 is straightforward. Lemma 8.10. Let ci , i = 1, 2, . . . , µ, µ ≥ 1, be contacts that are endmost children of a Qnode Y1 in a P Q-tree T . Let contact ci be related to vertex wi ∈ V , such that φ(wi ) ≤ φ(wi+1 ), i = 1, 2, . . . , µ − 1. In case that φ(wi ) = φ(wi+1 ) holds, let the P Q-tree Ti corresponding to ci be wi -merged into T before the tree Ti+1 corresponding to wi+1 is wi+1 -merged into T . Let ref (ci )left be the left reference set of ci with reference points Iib , Iie and ref (ci )right be the right reference set of ci with reference points Jib , Jie . For every ci , the nodes Iib and Jib denote the first ignored node in the reference sequence rseq (ci )left and rseq(ci )right , respectively, and Iie and Jie denote the last ignored node in the reference sequence rseq(ci )left and rseq(ci )right , respectively. Then the following statements are true. (i) If ci is adjacent to Iib , then augmenting Gst by an edge (u, w) for every si (u) ∈ ref (ci )left does not destroy level planarity. (ii) If ci is adjacent to Jib , then augmenting Gst by an edge (u, w) for every si (u) ∈ ref (ci )right does not destroy level planarity. Proof: By construction, the sequence of children of Y1 is partitioned into the three sets: C1 , N and C2 where
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
100
• C1 = c11 , c21 , . . . , cν1 , 0 ≤ ν ≤ µ, is the sequence of contacts on one end of Y1 with c11 being an endmost child of Y1 . • N is a sequence of ignored and non-ignored nodes. • C2 = c12 , c22 , . . . , cϕ2 , ϕ = µ − ν, is the sequence of contacts on the opposite side of C1 with c12 as an endmost child of Y1 . By construction, for Cξ , ξ = 1, 2, φ(ω(ciξ ))
≤
ξ φ(ω(ci+1 ))
i = 1, 2, . . . , |Cξ | − 1
where ω(ciξ ) denotes the vertex related to ciξ . For any i ∈ {1, 2, . . . , |Cξ | − 1} with φ(ω(ciξ )) = ξ )) the P Q-tree corresponding to ciξ has been ω(ciξ )-merged into T before the tree correφ(ω(ci+1 ξ ξ has been ω(ci+1 )-merged. sponding to ci+1 1 It follows that either c1 = c1 or c12 = c1 and c11 and c12 do no interfere, since their corresponding forms are placed on opposite sides with respect to RXλ and RX . We may assume that c11 = c1 . Due to Observation 7.8, c11 is either adjacent to I1b or to J1b . Assume without loss of generality that c11 is adjacent to I1b . It follows from Lemma 7.9 that considering ref (c1 )left for edge augmentation does not destroy level planarity. Removing c11 and ref (c1 )left from the tree, the correctness of the lemma follows by a simple inductive argument. 2 The function AUGMENT now combines all the described strategies in the level planarity test of J¨ unger et al. (1999). It is almost identical to the function LEVEL-PLANARITY-TEST, except that it does not call the function CHECK-LEVEL but a function EMBED-LEVEL. However, the function EMBED-LEVEL is almost identical to the function CHECK-LEVEL. We only need the following modifications. (i) If v is a sink in V j , 1 < j < k, replace the corresponding leaf by a sink indicator si (v) before processing Gj+1 . If this replacement constructs a node X having only sink indicators in its frontier, mark X as ignored and update the ML-values as described in Section 6. (ii) When reducing a set of leaves with respect to a vertex w in a P Q-tree, ignore all sink indicators and ignored nodes during the application of the template matching algorithm. After the reduction is complete, the pertinent subtree is removed from the tree and replaced by a single representative. During the removal of the pertinent subtree with respect to w, we check for sink indicators in the pertinent subtree. For every si (v) that is found in the pertinent subtree, we add an edge (v, w) to Gst , unless si(v) is affected by the existence of a contact c in the pertinent subtree. If the latter applies, add an edge (v, w0 ), with w0 being the vertex related to c. (iii) When w-merging a P Q-tree T 0 into a P Q-tree T , necessary adjustments as described above have to be applied to the merge operations B or C. If necessary, a contact is introduced as a third child of the new Q-node. Furthermore, if the new contact mutually influences existing ones, Rules I or II (see 8) have to be applied after reducing T with respect to w. (iv) After processing level k, an edge (v, t) is added for every vertex v ∈ V k . Furthermore we scan the final P Q-tree T for remaining sink indicators, and add for every indicator si (v) an edge (v, t) to Gst , unless si (v) is affected by the existence of a contact c in the pertinent subtree. If the latter applies we add an edge (v, w0 ), with w0 being the vertex related to c.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
101
Theorem 8.11. The algorithm LEVEL-PLANAR-EMBED computes a level planar embedding of a level planar graph G = (V, E, φ) in O(n). Proof: From Lemmas 5.1, 5.2, 5.3 and 8.10 it follows that augmenting Gst to a hierarchy using the function AUGMENT does not destroy level planarity. Consequently, the augmentation of Gst to a single source, single sink graph does not destroy level planarity either. The vertices s and t are on the outer face of a level planar embedding of Gst . By the discussion of Section 4 we can compute a topological sorting of Gst that induces an st-numbering and applying the planar embedding algorithm of Chiba et al. (1985) to Gst a level planar embedding of G can be constructed. Since the number of edges added to G to construct Gst is bounded by n, the level planar embedding is computed in O(n) time. It remains to show that augmenting Gst to a hierarchy can be done in O(n) time. The function AUGMENT performs as the function LEVEL-PLANARITY-TEST, with certain modifications. It is sufficient to show that the amount of extra work performed by these modifications consumes O(n) time. Clearly, the maintenance of the ignored nodes during all template reductions, and all merge operations A, D, and E is bounded by the number of ignored nodes in the P Q-trees. The number of ignored nodes is O(n), thus it remains to show that the number of operations needed to perform merge operations B and C is as well bounded by the number of ignored nodes. As described in Remark 8.9 the installation of a contact and the identification of its corresponding reference sequence is bounded by a constant number of operations. Clearly, the number of operations for deinstalling all contacts and their reference sequences is bounded by the number of ignored nodes. Hence, the amount of time needed to handle ignored nodes during the application of the merge operations is in O(n). 2
9
Remarks
Once a level graph has been level planar embedded, we want to visualize it by producing a level planar drawing. This is very simple for proper graphs. Assign the vertices of every level integer x-coordinates according to the permutation that has been computed by CONSTRUCT-LEVELEMBED, and draw the edges as straight line segments. This produces a level planar drawing and after applying some readjustments such a drawing can be aesthetically pleasing. For level graphs that are not necessarily proper, this approach is not applicable. It would be necessary to expand the level graph in the horizontal direction for drawing the edges as straight line segments. If many long edges exist in the graph, the area that is needed will be rather large, and the drawings are not aesthetically pleasing. However, there is a nice and quick solution to this problem that uses some extra information that is computed by our level planar embedding algorithm. Instead of drawing the graph G, we draw the st-graph Gst , and remove afterwards all edges and the vertices s and t that are not contained in G. Drawing st-graphs has been extensively studied recently (see, e.g, Kant (1993), Luccio, Mazzone, and Wong (1987), Rosenstiehl and Tarjan (1986), Tamassia and Tollis (1986), and Tamassia and Tollis (1989)). Suitable approaches for drawing the st-graph Gst have been presented by Di Battista and Tamassia (1988) and Di Battista, Tamassia, and Tollis (1992). These algorithms construct a planar upward polyline drawing of a planar st-graph according to a topological numbering of the vertices. The vertices of the st-graph are assigned to grid coordinates and the edges are
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
102
drawn as polygonal chains. If we assign a topological numbering to the vertices according to their leveling, the algorithm presented by Di Battista and Tamassia (1988) produces in O(n) time a level planar polyline grid drawing of Gst such that the number of edge bends is at most 6n − 12 and every edge has at most two bends. This approach can be improved to produce in O(n) time a level planar polyline grid drawing of Gst such that the drawing of Gst has O(n2 ) area, the number of edge bends is at most (10n − 31)/3, and every edge has at most two bends. Thus once we have augmented G to the st-graph Gst , we can immediately produce a level planar drawing of G in O(n) time.
References Booth, K. and Lueker, G. (1976). Testing for the consecutive ones property, interval graphs, and graph planarity using PQ-tree algorithms. Journal of Computer and System Sciences, 13, 335–379. Chiba, N., Nishizeki, T., Abe, S., and Ozawa, T. (1985). A linear algorithm for embedding planar graphs using PQ-trees. Journal of Computer and System Sciences, 30, 54–76. Di Battista, G. and Tamassia, R. (1988). Algorithms for plane representations of acyclic digraphs. Theoretical Computer Science, 61, 175–198. Di Battista, G., Tamassia, R., and Tollis, I. G. (1992). Constrained visibility representations of graphs. Information Processing Letters, 41, 1–7. Even, S. and Tarjan, R. E. (1976). Computing an st-numbering. Theoretical Computer Science, 2, 339–344. Fulkerson, D. R. and Gross, O. A. (1965). Incidence matrices and interval graphs. Pacific J. Mathematics, 15, 835–855. Heath, L. S. and Pemmaraju, S. V. (1995). Recognizing leveled-planar dags in linear time. In F. J. Brandenburg, editor, Proc. Graph Drawing ’95 , volume 1027 of Lecture Notes in Computer Science, pages 300–311. Springer Verlag. Heath, L. S. and Pemmaraju, S. V. (1996). Stack and queue layouts of directed acyclic graphs: Part II. Technical report, Department of Computer Science, Virginia Polytechnic Institute & State University. J¨ unger, M., Leipert, S., and Mutzel, P. (1998). Level planarity testing in linear time. In S. Whitesides, editor, Graph Drawing ’98 , volume 1547 of Lecture Notes in Computer Science, pages 224–237. Springer Verlag. J¨ unger, M., Leipert, S., and Mutzel, P. (1999). Level planarity testing in linear time (full version). Technical report, Institut f¨ ur Informatik, Universit¨at zu K¨ oln. Kant, G. (1993). A more compact visibillity representation. In J. van Leeuwen, editor, Proc. 19th International Workshop on Graph-Theoretical Concepts in Computer Science , Lecture Notes in Computer Science. Springer Verlag.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
103
Leipert, S. (1998). Level Planarity Testing and Embedding in Linear Time. Ph.D. thesis, Universit¨ at zu K¨ oln. Luccio, F., Mazzone, S., and Wong, C. (1987). A note on visibility graphs. Discrete Mathematics, 64, 209–219. Rosenstiehl, P. and Tarjan, R. E. (1986). Rectilinear planar layouts and bipolar orientations of planar graphs. Discrete and Computational Geometry, 1, 343–353. Tamassia, R. and Tollis, I. G. (1986). A unified approach to visibillity representations of planar graphs. Discrete and Computational Geometry, 1, 321–341. Tamassia, R. and Tollis, I. G. (1989). Tessellation representations of planar graphs. In Proc. 27th Allerton Conf. Communication Control Computing , pages 48–57.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
10
104
Glossary
c(R) is the contact of a form R. The contact is an ignored node that is placed as an endmost child of a Q-nodes Y next to the root of the P Q-tree T (R) where Y was introduced by a merge operation B or C. D(RXλ ∪ R2 ) is the dependent set of RXλ ∪ R2 where RXλ is the subgraph of a form R1 and corresponds to the subtree rooted at Xλ before merging the forms R1 and RS 2 using a merge operation B or C. The dependent set D(RXλ ∪ R2 ) is the set of vertices u ∈ ki=φ(w) V i such that there exists a directed path P = (u1 , u2 , . . . , uξ = u), ξ > 1, with u1 ∈ RXλ ∪ R2 , and Sk u1 , u ˜2 , . . . , u ˜ι = u ˜), ι > 1, there exists a vertex u ˜ ∈ i=φ(w) V i and a directed path P˜ = (˜ ˜ u) ≥ φ(u) and the paths P and P are vertex disjoint except with u ˜1 ∈ RXλ ∪ R2 , such that φ(˜ for possibly u and u ˜. D(RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Ri ) is the dependent set of RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Ri and is recursively Sk defined to be the set of all vertices u ∈ ν=φ(w1 ) V ν such that (i) Ri is wi -merged into R and wi ∈ D(RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Ri−1 ), (ii) there exists a directed path P = (u1 , u2 , . . . , uξ = u), S ξ > 1, with u1 ∈ RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Ri , and (iii) there exists a vertex u˜ ∈ kν=φ(w1 ) V ν and a directed path P˜ = (˜ u1 , u ˜2 , . . . , u ˜ι = u ˜), ι > 1, with u ˜1 ∈ RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Ri , such that φ(˜ u) ≥ φ(u) and the paths P and P˜ are vertex disjoint except possibly for u and u˜. Fij denotes a component of Gj , where i = 1, 2, . . . , mj . G = (V, E, φ) is called a level graph and is a directed acyclic graph with a mapping φ : V → {1, 2, . . . , k}, k ≥ 1, that partitions the vertex set V as V = V 1 ∪ V 2 ∪ · · · ∪ V k , V j = φ−1 (j), V i ∩ V j = ∅ for i 6= j, such that φ(v) ≥ φ(u) + 1 for each edge (u, v) ∈ E. Gj denotes the subgraph of G induced by V 1 ∪ V 2 ∪ · · · ∪ V j . Hij is the graph arising from Fij by introducing for each edge e = (u, v), where u is a vertex in Fij and v ∈ V l , l ≥ j + 1, a virtual vertex with label v and a virtual edge that connects u and this virtual vertex. LL(Fij ) is the low indexed level of Fij , the smallest d such that Fij contains a vertex in V d . ML(S) For any subset S of the set of vertices in V j+1 ∪ V j+2 ∪ · · · ∪ V k that belongs to a form Hij or Rij , ML(S) is the greatest d ≤ j such that V d , V d+1 , . . . , V j induces a subgraph in which all nodes of S occur in the same connected component. The level ML(S) is said to be the meet level of S. mj denotes the number of components of Gj . φ is a mapping φ : V → {1, 2, . . . , k}, k ≥ 1, of a directed acyclic graph G = (V, E) that partitions the vertex set V as V = V 1 ∪ V 2 ∪ · · · ∪ V k , V j = φ−1 (j), V i ∩ V j = ∅ for i 6= j, such that φ(v) ≥ φ(u) + 1 for each edge (u, v) ∈ E. RX is the subgraph corresponding to the subtree rooted at a node X of a P Q-tree.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
105
~ X is the set of all vertices u ∈ V such that there exists a vertex v ∈ RX and a (not necessarily R directed) path P connecting u and v not using the connective cut vertex of X. Rij is the reduced extended form that is created from an extended form Hij by identifying all virtual vertices with the same label to a single vertex. If Rij has been subject to a merge operation, it is a partially reduced extended form. Rij ∪v Rlj is the graph arising from the identification of two virtual vertices vi and vl (labeled v) of two reduced extended forms Rij and Rlj . rseq(R) is the reference sequence of a form R. It is the sequence of ignored nodes Iν , Iν+1 , . . . , Iµ left of a node Xλ and J1 , J2 , . . . , Jσ right of a node Xλ , where Xλ is subject to a merge operation B or C. The reference sequence describes the two sets of sink indicators of which exactly one set has to be considered for edge augmentation in combination with the merge operation and is associated with the ”smaller” form R that has been merged into the larger form. rseq(R)right denotes the right sequence of ignored nodes of rseq(R). rseq(R)left denotes the left sequence of ignored nodes of rseq(R). ref (R) is the reference set of a form R. It is the union of the frontiers of all elements of the reference sequence rseq(R). ref (R)left is the left reference set of a form R. ref (R)right is the right reference set of a form R. ref (c(R2 )) is the reference set of a contact c(R2 ). si (v) is the sink indicator of a sink v. The sink indicator is a leaf for keeping the position of the sink v in a P Q-tree. Siv is the set of virtual vertices of Hij or Rij that are labeled v ∈ V j+1 . vi is the vertex with label v of Rij , i.e., the vertex that arose from identifying all virtual vertices of Siv . ω(c(R)) is the related vertex w of a contact c(R) where the contact c(R) was introduced by a w-merge operation. Concatenation of merge operations is a sequence of wi -merge operations, i = 1, 2, . . . µ, of reduced extended forms Ri into a reduced extended form R such that (i) R1 is w1 -merged using a merge operation B or C, (ii) for all wi -merge operations we have wi ∈ D(RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Ri−1 ), and (iii) R1 has not been fixed to one side of RXλ with respect to RX and it is unknown if its embedding can be chosen freely. Connective cut vertex Let X be a Q-node in T corresponding to a subgraph B of Gj , 1 ≤ j ≤ k. The children of X each correspond to a cut vertex on the border of the outer face of B. If X is not the root, then there exists an extra cut vertex on the border of the outer face of B that separates the subgraph G0 induced by the subtree rooted at X from Gj − G0 . This cut vertex is called the connective cut vertex of B.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
106
Contact of a form R is an ignored node that is placed as the endmost child of a Q-node Y next to the root of the P Q-tree T corresponding to R where Y was introduced by a merge operation B or C. S Dependent set of RXλ ∪ R2 is the set D(RXλ ∪ R2 ) of vertices u ∈ ki=φ(w) V i such that there exists a directed path P = (u1 , u2 , . . . , uξ = u), ξ > 1, with u1 ∈ RXλ ∪ R2 , and there S u1 , u ˜2 , . . . , u ˜ι = u˜), ι > 1, with exists a vertex u ˜ ∈ ki=φ(w) V i and a directed path P˜ = (˜ ˜ u) ≥ φ(u) and the paths P and P are vertex disjoint except for u˜1 ∈ RXλ ∪ R2 , such that φ(˜ possibly u and u ˜. Dependent set of RXλ ∪R1 ∪R2 ∪· · ·∪Ri is denoted by D(RXλ ∪R1 ∪R2 ∪· · ·∪Ri ) and is recursively Sk defined to be the set of all vertices u ∈ ν=φ(w1 ) V ν such that (i)Ri is wi -merged into R and wi ∈ D(RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Ri−1 ), (ii) there exists a directed path P = (u1 , u2 , . . . , uξ = u), Sk ξ > 1, with u1 ∈ RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Ri , and (iii) there exists a vertex u˜ ∈ ν=φ(w1 ) V ν and a directed path P˜ = (˜ u1 , u ˜2 , . . . , u ˜ι = u ˜), ι > 1, with u ˜1 ∈ RXλ ∪ R1 ∪ R2 ∪ · · · ∪ Ri , such that φ(˜ u) ≥ φ(u) and the paths P and P˜ are vertex disjoint except possibly for u and u˜. Extended form Hij of Fij is the graph arising from Fij by introducing for each edge e = (u, v), where u is a vertex in Fij and v ∈ V l , l ≥ j + 1, a virtual vertex with label v and a virtual edge that connects u and this virtual vertex. Ignored node is a node of a P Q-tree such that its frontier contains only sink indicators. Level graph is a directed acyclic graph G = (V, E, φ) with a mapping φ : V → {1, 2, . . . , k}, k ≥ 1, that partitions the vertex set V as V = V 1 ∪ V 2 ∪ · · · ∪ V k , V j = φ−1 (j), V i ∩ V j = ∅ for i 6= j, such that φ(v) ≥ φ(u) + 1 for each edge (u, v) ∈ E. Merged reduced form is the graph arising from the identification of two virtual vertices vi and vl (labeled v) of two reduced extended forms. Mutual influence of two contacts c1 and c2 appears if ref (c1 ) ∩ ref (c2 ) 6= ∅. Mutual influence of two merge operations B or C is at hand if the corresponding contacts mutually influence each other. Partially reduced extended form is an improper merged reduced form possibly having several virtual vertices with the same label. This form is the result of algorithmic design for achieving linear running time. Primary A reduced extended form Rij that is v-unconnected for all v ∈ V j+1 is called primary. Reduced extended form Rij is the graph that is created from an extended form Hij by identifying all virtual vertices with the same label to a single vertex. Reference points of the contact c(R2 ) are the nodes Iν , Iµ , J1 , Jσ of a reference sequence of the associated merge operation.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
107
Reference sequence is the sequence of ignored nodes Iν , Iν+1 , . . . , Iµ left of a node Xλ and J1 , J2 , . . . , Jσ right of a node Xλ , where Xλ is subject to a merge operation B or C. The reference sequence describes the two sets of sink indicators of which exactly one set has to be considered for edge augmentation in combination with the merge operation and is associated with the ”smaller” form that has been merged into the larger form. Reference sequence, left is the sequence of ignored nodes Iν , Iν+1 , . . . , Iµ left of a node Xλ where Xλ is subject to a merge operation B or C. Reference sequence, right is the sequence of ignored nodes J1 , J2 , . . . , Jσ right of a node Xλ , where Xλ is subject to a merge operation B or C. Sσ Sµ Reference set is the union i=ν frontier (Ii ) ∪ i=1 frontier (Ji ) of a reference sequence Iν , Iν+1 , . . . , Iµ and J1 , J2 , . . . , Jσ . Related vertex ω(c(R)) of a contact c(R) is the vertex w related to the w-merge operation that introduced contact c(R). Secondary A reduced extended form Rij that is v-connected for at least one v ∈ V j+1 is called secondary. Sink indicator is a leaf denoted by si (v) for keeping the position of a sink v in a P Q-tree. Virtual edge is an edge of a form Hij connecting a vertex of the component Fij that corresponds to Hij and a vertex on a level l ≥ j + 1. Virtual vertex is a vertex of a form Hij on a level l ≥ j + 1. v-connected A form Rij is called v-connected , if any reduced extended form has been v-merged into Rij , v-merged If Rij and Rlj are merged at a vertex v and LL(Rij ) ≤ LL(Rlj ) we say Rlj is v-merged into Rij . The form that is created by v-merging Rlj into Rij and identifying all virtual vertices with the same label w 6= v is again a reduced extended form and denoted by Rij (thus renaming Rij ∪v Rlj with the name of the “higher” form). v-unconnected A form Rij is called v-unconnected if no reduced extended form has been v-merged into Rij .
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
R1 v R2
R1
RXλ
v
1111111111 0000000000 w 0000000000 1111111111 0000000000 1111111111 0000000000 1111111111 0000000000 1111111111 0000000000 1111111111 0000000000 1111111111 0000000000 1111111111
R2
RXλ
1111111111 0000000000 w 0000000000 1111111111 0000000000 1111111111 0000000000 1111111111 0000000000 1111111111 u
(a) Cut vertex v allows a free embedding of RXλ ∪ R2 ∪ D(RXλ ∪ R2 ).
(b) Split pair u, v allows a free embedding of RXλ ∪ R2 ∪ D(RXλ ∪ R2 ).
R1 v R2
v˜
RXλ
1111111111 0000000000 0000000000 1111111111 w 0000000000 1111111111 0000000000 1111111111 0000000000 1111111111 0000000000 1111111111 0000000000 1111111111 u1 000000000 111111111 0000000000 1111111111 000000000 111111111 0000000000 1111111111 000000000 111111111 0000000000 1111111111 000000000 111111111 0000000000 1111111111 000000000u2 u4 111111111
R1
Pˆ Pˆ
u3 (c) Split pair u, v allows a free embedding of R2 .
v
u1 R2
RXλ
111111111111111111111111111 000000000000000000000000000 w 000000000000000000000000000 111111111111111111111111111 u2 000000000000000000000000000 111111111111111111111111111 000000000000000000000000000 111111111111111111111111111 000000000000000000000000000 111111111111111111111111111 (d) Fixed embedding of RXλ ∪ R2 ∪ D(RXλ ∪ R2 ).
Figure 17: The figure illustrates different dependent sets D(RXλ ∪R2 ). The dependent sets are drawn shaded and path Pˆ is drawn grey.
108
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
v˜
RX
P
v R2
RXλ
111111111111111111111111111 000000000000000000000000000 w 000000000000000000000000000 111111111111111111111111111 000000000000000000000000000 111111111111111111111111111 000000000000000000000000000 111111111111111111111111111 000000000000000000000000000 111111111111111111111111111
u
Figure 18: A graph corresponding to the situation where X became a Q-node with one non-ignored child. The embedding of RXλ ∪ R2 ∪ D(RXλ ∪ R2 ) with respect to RX may be chosen freely.
109
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
110
T1
Xλ Xλ−1 I1
Iν−1 Iν
Iµ
111 000 000 111
J1
Jσ Jσ+1
Jρ Xλ+1
w
T2 1111 0000 0000 1111 0000 1111 0000 1111 0000 1111 01 w
(a) ML(Xλ−1 , Xλ ) < LL(T2 ) and ML(Xλ , Xλ+1 ) < LL(T2 ).
T1
Y
I1
Iν−1 Iν
Iµ
Xλ
111 000 T2 111 000 0000 c(R2 ) 111 000 1111 0000 1111 0000 1111 w 1111 0000 1010
J1
Jσ Jσ+1
w
(b) Contact c(R2 ) is added as a child to Y next to the root of T2 .
Figure 19: Adding a contact during the merge operation C.
Jρ
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
111
T1
Y
I1
Iν−1 Iν
Iµ
J1
Jσ Jσ+1
Jρ
c(R2 )
(a) The node Y with the contact c(R2 ) before the application of a template Q2 or Q3.
T1
I1
Iν−1 Iν
Iµ
c(R2 )
J1
Jσ Jσ+1
Jρ
(b) The contact c(R2 ) is adjacent to the ignored node J1 . We chose ref (R2 )right for augmentation.
Figure 20: The identification of the reference set that has to be chosen for augmentation. The dotted lines denote the pointers of c(R2 ) to its reference points.
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
v 1111111 0000000 0000000 1111111 0000000 1111111 R1 0000000 1111111 0000000 1111111 w1
R3
112
1111111111111 0000000000000 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 R2 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 0000000000000 1111111111111 w2
w3
Edges added to w1 forced by R1 Edges added to w2 forced by R2 Edges added to w3 forced by R3 Figure 21: A concatenation of merge operations. First possible embedding of the forms R1 , R2 , and R3 next to RXλ with respect to RX .
11111111111111111 00000000000000000 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 v 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 R2 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 00000000000000000 11111111111111111 w2
1111111 0000000 0000000 1111111 0000000 1111111 R1 0000000 1111111 0000000 1111111
R3
w1
w3
Edges added to w1 forced by R1 Edges added to w2 forced by R2 Edges added to w3 forced by R3 Figure 22: A concatenation of merge operations. Second possible embedding for the forms R1 , R2 , and R3 next to RXλ with respect to RX .
M. J¨ unger, S. Leipert, Level Planar Embedding, JGAA, 6(1) 67–113 (2002)
u1
v 1111111 0000000 0000000 1111111 0000000 1111111 R1 0000000 1111111 0000000 RX 1111111
λ
u01
w1
P0
P uµ
u0ν
Figure 23: Illustration of the proof of Lemma 8.8.
113
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 6, no. 1, pp. 115–129 (2002)
Embedding Vertices at Points: Few Bends suffice for Planar Graphs Michael Kaufmann
Roland Wiese
Wilhelm-Schickard-Institut f¨ur Informatik Universit¨at T¨ ubingen Sand 13, 72026 T¨ ubingen, Germany
[email protected] [email protected] Abstract The existing literature gives efficient algorithms for mapping trees or less restrictively outerplanar graphs on a given set of points in a plane, so that the edges are drawn planar and as straight lines. We relax the latter requirement and allow very few bends on each edge while considering general plane graphs. Our results show two algorithms for mapping four-connected plane graphs with at most one bend per edge and for mapping general plane graphs with at most two bends per edge. Furthermore we give a point set, where for arbitrary plane graphs it is NP-complete to decide whether there is an mapping such that each edge has at most one bend.
Communicated by H. de Fraysseix and and J. Kratochv´ıl: submitted February 2000; revised May 2001.
M. Kaufmann and R. Wiese, Few Bends, JGAA, 6(1) 115–129 (2002)
1
116
Introduction
The problem of mapping the vertices of a graph to points in the plane has been considered in the past under various objectives depending on the specific applications. This ranges from the band width minimization problem [17, 8] where the points are at unit distance on a line and the objective is to minimize the distance of the points between adjacent vertices to embedding problem of a guest graph onto a host graph [14] under some objectives like dilation, congestion, load, etc. Here we consider a more geometric version of the problem: Originally, the problem was how to map a given tree T of n vertices at a given set of points S in the plane such that the edges can be drawn straightline and without any crossings. Variants of this problem have been explored, either with or without keeping the position of one specific node fixed [16, 12, 2]. Generalizing the graph class, but still using the required straightline planar drawing, Gritzmann et al. [11] gave an elegant divide and conquer scheme to partition the point set and the set of vertices simultaneously. They showed that using this mapping outerplanar graphs can be drawn without any bends. In the consequent papers [3] and [1], efficient implementations have been developed. The latest result in [1] is an O(n · log3 n) time algorithm to find a straightline drawing for such a graph. Astonishingly enough, the case for more general planar graphs has not been considered systematically. It is at exactly this point that we start. Another similar scenario has been recently considered by Pach and Wenger [15]. They assume that the mapping of the vertices to the points is already fixed. The authors prove that O(n) bends per edge are sufficient and that we can not expect to significantly improve the worst case bound for the maximum number of bends per edge. We consider just the first scenario where the mapping of the vertices to the points is not yet fixed. On the other hand, we preserve the given planar embedding of the graph. In the next section, a simple scheme is presented, that provides drawings with at most one bend per edge for a large class of graphs. Next we generalize the technique so that it will work for any planar graph and produces drawings with at most two bends per edge. In section 4, we give a class of graphs and a set of points, where we can prove that there is at least one edge with two bends. Finally, we extend the techniques
M. Kaufmann and R. Wiese, Few Bends, JGAA, 6(1) 115–129 (2002)
117
developed so far to a simple proof to the expected NP-completeness result, namely to decide whether a drawing can be found where each edge has at most one bend. Throughout this paper, we deal with triangulated embedded (plane) graphs, only in the last section do we discuss a more general case. Of course, we always require the drawings to be planar, even if it is not explicitly stated.
2
A basic technique
In this section, we present the basic technique for the mapping and consider the following restriction on the graph. Let G = (V, E) be any plane graph with a hamiltonian cycle C, such that C has at least one edge, say e, on the outer face of G. We call such a property ’external hamiltonicity’ and a corresponding cycle ’external hamiltonian’. We assume the vertices of V to be ordered from v1 to vn as being prescribed by the hamiltonian cycle C. The vertex with the smallest index is chosen such that the edge e is incident to vn and v1 . Let S be any set of points p1 , p2 , ..., pn with pi = (xi , yi ). Assume the plane is rotated in such a way to make the x-coordinates of the points pairwise different. Furthermore assume that the points are ordered with increasing x-coordinates. Now we map the hamiltonian cycle C = (v1 , v2 , . . . , vn , v1 ) to the points p1 , ..., pn , so that the edge e = (vn , v1 ), is assigned in such a way that vn = pn and v1 = p1 . All edges on C with the exception of e can be drawn as a straight line so that they extend monotonically in x-direction. The edge e is drawn from the rightmost point pn to the leftmost point p1 with one bend b located at a place existing very high above all the other points. The idea is to choose the segments of e such that their slopes are the same and they are cone-shaped, c.f. figure 1. The slopes of e is determined by the maximal slope of the straightline edges on the hamiltonian path C − e. This also determines the place where the bend of e is located. More precisely, the slope for a possible straightline segment is computed by σ 0 = maxi |yi+1 − yi |/(xi+1 − xi ). To ensure that the segments of e do not interfere with other segments or points, we have to increase the value σ 0 slightly. In fact, we assign the value σ = 2 · σ 0 as the slope of a line through
M. Kaufmann and R. Wiese, Few Bends, JGAA, 6(1) 115–129 (2002)
118
p1 and −σ should be the slope of another line through pn . The intersection of the two lines gives the position of bend b. The remaining edges are drawn each with exactly one bend such that all the left segments of the edges have the same slope σ and the right segments will have the slope −σ. They will run in parallel. This is more because of aesthetic reasons and to simplify the arguments about avoiding some possible crossings. The edges inside of C are drawn above the polygonal chain C − e, and the edges outside are drawn below. The following case checking proves the planarity of the drawing: Edges inside and outside of C do not cross since they are separated by the polygonal path C − e. We explain the case of two edges e1 and e2 inside of C in more detail. Let e1 = (vi , vl ) and e2 = (vj , vk ). Clearly i ≤ j < k ≤ l holds because of planarity. Now, since the left segments run in parallel and the right segments as well and the four end points occur in that order on the x-monotone polygonal line C − e, there are no crossing segments. The same holds for the edges outside. The slopes for the segments of the edges not in C have been chosen large enough such that edges in C cannot interfere with edges not in C. Note that by this technique, some of the segments adjacent to the same vertex might overlap (cf. the second segments of (p2 , p8 ) and (p3, p8) in Fig. 1). We devise a perturbation scheme that resolves those overlappings: Let be the minimum distance between any two non-overlapping parallel segments, let L be the maximum length of a segment and maxdeg the maximum degree. For each vertex v, we sort the pairwise overlapping adjacent segments according to their length in decreasing order. For each segment s being the i-th overlapping segment adjacent to v, we rotate s by i · L·maxdeg downwards. The new intersection points for the segments give new positions for the bends. This way we ensure that the previously overlapping segments are spread out, and new intersections are avoided since the rotation angles are kept small enough. Theorem 2.1 Let S be an arbitrary set of n points and G be any plane graph with an external hamiltonian cycle and n vertices. Then G can be drawn planar with a mapping of the vertices to the points such that each edge has at most one bend.
M. Kaufmann and R. Wiese, Few Bends, JGAA, 6(1) 115–129 (2002)
6
119
7
4
5
8
9
p7 3 1
p4 p2 2
p5
p1
p8
p9
p6 p3
Figure 1: The basic construction Remarks on the area. Note that the area may be much larger than the area R occupied by the point set. More precisely, let us assume that the minimal enclosing rectangle R is a square of width W and δ is the minimal distance in x-direction between any two points. Clearly, the absolute value of the slope σ of the segments of edge (vn , v1 ) is at most 2 · W/δ. Hence the resulting height is at most 2 · W · W/δ while the width remains the same. This means that if we assume integer-coordinates (δ = 1), we achieve an area of O(W 3) for the drawing. Note that if we would allow 2 bends per edge, we could easily draw the edges in an orthogonal way and keep the area proportional to the area of the convex hull of the point set. In this case, the perturbation scheme does not work anymore and we might have to enlarge the size of the vertices and assign offsets to the adjacent segments. The details are left to the reader.
M. Kaufmann and R. Wiese, Few Bends, JGAA, 6(1) 115–129 (2002)
120
δ
Figure 2: Wasting and saving some area by spending another bend per edge.
3
The general case
In order to apply the technique above we need to find an external hamiltonian cycle, namely a hamiltonian cycle including an edge on the outer face. Testing all possible edges e = (v, w) on the outer face, we could request a hamiltonian path, which is a well-known NP-complete problem even on planar triangulated graphs [6]. On the other hand, we know of a linear-time algorithm to find external hamiltonian cycles by Chiba and Nishizeki [5], if the graph is four-connected. Since the graphs we consider are triangulated, the problematic cases appear if there are separating triangles, namely cycles of length 3 which do not circumscribe single faces. Only such graphs may not contain external hamiltonian cycles. First of all, we give a reduction to the four-connected case which will finally lead to drawings with at most two bends per edge. Then, in the following section we present a small plane graph with only 12 vertices without any external hamiltonian cycle and a point set, and we prove that any planar drawing of this graph on this point set must have at least one edge with 2 bends. This indicates that our simple technique is reasonably good and it will not normally be beaten by other algorithms with respect to the maximal number of bends per edge. Assume G is a plane triangulated graph which is not four-connected. Let e = (v, w) be an edge of any particular separating triangle which clearly
M. Kaufmann and R. Wiese, Few Bends, JGAA, 6(1) 115–129 (2002)
121
exists. Edge e lies adjacent to two triangular faces (v, w, s) and (v, w, t). We destroy those triangles by inserting a dummy vertex z on e, deleting e and connecting z by four new edges to the vertices v, w, s and t. Note that by each single operation, the number of separating triangles decreases and no such triangles are created anew. The dummy vertices z do not appear in any separating triangle. We perform this operation until all separating triangles are destroyed. The separating triangles can be efficiently found by the algorithm of Chiba and Nishizeki [4]. Then the new graph G0 is fourconnected and triangulated. We now apply the basic technique described in the previous section to G0 . The only modification is the handling of the dummy vertices z. Figure 3 gives an example. 1
3
4
5
7 2
1
2 3
4
5
6
7 z1
8
9
10 z2 11 12
1
2 3
4
5
6
7 z1
8
9
10 z2 11 12
6
z1
8 9 10
11 z2
12
Figure 3: An example for the construction of graphs without external hamiltonian cycle. Vertices z1 and z2 are dummies. They arise when destroying the separating triangles. The figures to the right indicate the solutions with three and two bends respectively. Let C 0 be the external hamiltonian cycle as found by the algorithm of Chiba and Nishizeki. Clearly, C 0 visits z, and immediately before and afterwards, it visits two vertices a, b ∈ {v, w, s, t}. We place a new dummy point pz exactly between the points assigned to a and b. Then the graph can be drawn as described above. Finally, we remove the edges (s, z) and (t, z) and join the (at most) two segments of (v, z) and
M. Kaufmann and R. Wiese, Few Bends, JGAA, 6(1) 115–129 (2002)
122
(z, w). This immediately gives a drawing with at most 3 bends per edge, since there is at most one dummy vertex on each edge. Lemma 3.1 Given an arbitrary plane graph with n vertices and a set of n points in the plane. In time O(n log n), we can find a mapping of the vertices to the points, so that the edges can be drawn planar and with at most 3 bends each. Markus Eiglsperger suggested a way of saving one bend (out of three) by drawing some of the segments of the edges vertically. In the third part of Figure 3, we indicate the idea. Lemma 3.2 Given a solution with at most three bends for each edge constructed by the algorithms above, we can modify the drawing so that it remains planar and the maximal number of bends is two. The used area might grow exponentially. Proof: Let P be the designated hamiltonian path along the points p1 , . . . pn such that the edges (pi , pi+1 ) are drawn as a straight line. P induces a partition of the drawing plane into an upper and a lower part. Note that for each edge e with two or three bends there is a dummy vertex de placed on an edge (pi , pi+1 ) where the edge e crosses path P . Following the construction above, it is clear that each edge crosses P once at most, hence the two segments of e incident to the dummy vertex de may be able to be drawn vertically. We discuss now the implications of such operations: We consider just the section in the upper part of the drawing, the lower part is handled analogously. Let e be the edge under consideration with segments s1 and s2 where s2 ends at dummy vertex de . Let α1 and α2 be the angles indicating the slopes of the segments as shown in figure 4. Stretching s1 such that α1 remains the same, the angle α2 increases to 90 and the segment s2 becomes vertical. We will call it s02 now. Planarity is eventually violated if there are some segments s with angle β crossing the cone between s2 and s02 . We can correct this easily by rotating the segment s such that β also increases. This process is iterated if necessary. Obviously it ends after at most m steps since we only proceed from left to right and never backtrack. The proper nesting of the edges (halfedges) in the upper o
M. Kaufmann and R. Wiese, Few Bends, JGAA, 6(1) 115–129 (2002)
s
s02
s2
β
123
s1 α1
α2
de
Figure 4: The configuration before and after rotating segment s2 in vertical position. part of the drawing ensures that for each edge only m rotations are necessary, implying a quadratic running time. Combined with a corresponding process for the lower part we end when the segments incident to any dummy vertices are vertical and the corresponding bend is saved. In the second part of the proof we sketch a situation where the area grows exponentially. The next figure shows two nested edges with corresponding dummy vertices on different sides (left and right). We assume that the slopes are at 45o to start with and the points and bends lie on integer coordinates. When we perform the modifications described above, so that the segments incident to the dummy vertices become vertical, the drawing grows by more than a factor of two. Now assume that we have n/2 of such pairs nested, as indicated in the next figure. Consider the i-th pair from the inside. The drawing of Gi−1 includes an axis-parallel rectangle Ri determined by the length of the vertical segments of the edges from the i − 1-th pair. Next, we see that the two edges from pair i have to circle around this rectangle using only two bends and one vertical segment in the middle. It follows quite easily that the lengths of these segments must be quite large compared to the height of the rectangle Ri−1 and that a new rectangle Ri of height at least twice as large as the height of Ri−1 results. Hence, we can conclude that the height of the drawing grows
M. Kaufmann and R. Wiese, Few Bends, JGAA, 6(1) 115–129 (2002)
124
exponentially, at the very least.
el Gi−1 er i-th pair
Figure 5: The recursive definition of the graph with exponential height. We conclude with a note regarding the runtime. Clearly the first part of the construction works in linear time, since we can use the linear time algorithm of Chiba/Nishizeki [4] to determine the separating triangles. Then the saving of the third bends by rotating some of the segments might cause a quadratic number of steps. Theorem 3.3 Any plane graph can be mapped on any given point set in the plane and can be drawn with at most three bends per edge in linear time and with at most two bends per edge in quadratic time.
4
The lower bound
Next, we show that this bound is optimal in the worst case. Consider the following triangulated graph discussed in the example from figure 3. Although there is a hamiltonian path in G, there is no external hamiltonian path. We try to map G on a set of 12 points with the same y-coordinate Y . This point set has the property that each edge with only one bend must lie completely above or completely below the Y -line. Any edge segment that crosses the Y -line must belong to an at-least-two bend edge. Let x1 , . . . , x12 be the x-coordinates of the points in increasing order. Since the outer face of G is a triangle with vertices a, b, c it is clear that in any one bend drawing {x1 , x12 } ⊂ {xa , xb , xc } (With xa , we mean the xcoordinate vertex a is mapped to). We examine the case where x1 = xc , x12 =
M. Kaufmann and R. Wiese, Few Bends, JGAA, 6(1) 115–129 (2002)
125
a
g
e f h d
b
c
Figure 6: The candidate for the lower bound proof.
c
d
b
h
g
f
e
a
Figure 7: Edge (b, f ) needs two bends in this drawing. xa . Both of the other cases are similar or symmetric. Next we want to draw the outer face. For that we map b to xb , (x1 < xb < x12 ) and draw the outer face edges such that (a, c) bends above the Y -line and (a, b), (b, c) bend below. Next we draw the edges of the triangles b, d, a and b, c, d. W.l.o.g., we map vertex d to xd , (xa < xd < xb ) and draw (a, d), (d, c) with a bend above the Y -line. We draw the edge (d, b) with a bend above the Y -line and show that one edge within triangle {b, d, a} cannot be drawn with only one bend (since {b, c, d} and {b, d, a} are symmetric, we could show the same for {b, c, d} if we would draw edge (d, b) with no bend or a bend below the Y -line). Now we want to draw the edges from d to e, f and h. Since we do not
M. Kaufmann and R. Wiese, Few Bends, JGAA, 6(1) 115–129 (2002)
126
want to change the embedding and edge (d, b) bends above the Y -line, these edges must also bend above the Y -line and the x-coordinates of their end points must obey the order xb < xh < xf < xe < xc . Next we draw the edges from a to e, f and g. Since (d, e) bends above the Y -line the edges (a, f ) and (a, g) must bend below the Y -line. The order of the coordinates is nearly fixed by now: xd < xb < xg , xh < xf < xe < xa . Now we are at a point where we cannot draw edge (b, f ) without letting it cross the Y -line, since (d, h) and (a, g) have their bends in opposite directions. See Figure 7. Theorem 4.1 There is a plane triangulated graph with only 12 vertices such that for every placement of the vertices on a straight line at least one edge must bend at least twice in the resulting drawing.
5
The NP-completeness result
In this section we prove Theorem 5.1 Given any plane graph G with n vertices and n points on a line. The mapping problem of the vertices at the points so that the edges are drawn planar and with at most one bend each is NP-complete. Proof: To show that the 1-bend drawability problem is NP-complete, we reduce it to the hamiltonian cycle problem for plane graphs. First, note that the external-hamiltonian-cycle problem for plane graphs is NP-complete since it can be used to solve the hamiltonian-cycle problem for plane graphs by an iteration over all faces of the embedding. We call a plane graph G = (V, E) (external) hamiltonian-extensible if some edges E 0 can be inserted without destroying the previous planar embedding enabling G0 = (V, E ∪ E 0 ) to become (external) hamiltonian. The problem as to whether a given planar graph G can be made (external) hamiltonian by inserting at most k ≥ 0 edges is clearly NP-complete since its variant with k = 0 is equivalent to the (external) hamiltonian-cycle problem for planar graphs. Let G = (V, E) be a given plane graph. The following argument shows that solutions for the problem to make G (external) hamiltonian-extensible
M. Kaufmann and R. Wiese, Few Bends, JGAA, 6(1) 115–129 (2002)
127
can be converted in polynomial time into a 1-bend drawing for G with a set of points on a straight line and vice versa. If G is external-hamiltonian extensible, we take the corresponding external hamiltonian cycle C and apply our basic technique from section 2 to achieve 1-bend drawings. On the other hand, if G has a mapping M : V → P on the points of the horizontal line L such that a 1-bend drawing D(G) exists, there is clearly no edge which crosses line L. Otherwise, it would bend twice. Let w.l.o.g. M be the mapping such that M(vi ) = pi for i = 1, . . . , n. Hence we can easily extend the embedding of G by edges between any vertex vi and vi+1 for i = 1, . . . , i−1 if necessary. such that this extension completes a hamiltonian path. The last (external) edge between vn and v1 completing the hamiltonian cycle can also be inserted if it does not already exist. This proves the NP-hardness of the drawing problem. From the ‘equivalence’ of the problem to make G (external) hamiltonian and the 1-bend drawability problem for G with a set of points on a straight line we derive that the latter problem is in NP since like the hamiltoneancycle problem, the extensibility problem is in NP.
6
Discussion
One might argue that we are cheating regarding the lower bound example since all points with the same y-coordinate contradict the commonly used assumption of a general position of the points. On the other hand, the scenario seems quite realistic. If the objects (vertices) are required to be arranged in linear order horizontally or vertically, we get exactly the given set of points which we have already proved to be hard. Open problems: 1. Improve the area bounds, especially for the general case. 2. Extend the lower bound proof and the NP-completeness result to a set of points in general position. 3. Note that the complexity of the no-bend variant is still open, although NP-completeness is also conjectured [1].
M. Kaufmann and R. Wiese, Few Bends, JGAA, 6(1) 115–129 (2002)
128
References [1] Bose, P., On Embedding an Outer-Planar Graph in a Point Set, in: G. DiBattista (ed.), Proc. 5th Intern. Symposium on Graph Drawing (GD’97), LNCS 1353, Springer 1998, pp. 25-36. [2] Bose, P., M. McAllister, and J. Snoeyink. Optimal algorithms to embed trees in a point set. Journal of Graph Algorithms and Applications 1998. [3] Castaneda, N. and J. Urrutia., Straight line embeddings of planar graphs on point sets. Proc. 8th Canadian conf. on Comp. Geom., pp. 312-318, 1996. [4] Chiba, N., and T. Nishizeki, Arboricity and subgraph listing algorithms, SIAM J. Comput. 14 (1985), pp. 210–223. [5] Chiba, N., and T. Nishizeki, The hamiltonian cycle problem is linear-time solvable for 4-connected planar graphs, J. Algorithms 10 (1989), pp. 189-211. [6] Chvatal, V., The traveling salesman problem, J. Wiley and Sons, 1985, pp. 426. [7] Di Battista, G., Eades, P., Tamassia R. and I.G. Tollis, Algorithms for Automatic Graph Drawing: An Annotated Bibliography, Brown Univ., Tech. Rep., 1993. [8] Feige, U., Approximation the bandwidth via volume respecting embeddings. Proc. 30th Annual ACM Symp. on Theory of Computing, 1998, pp. 90-99. [9] Garey, M.R., D.S. Johnson, The Rectilinear Steiner Tree Problem is NPcomplete, SIAM J. Appl. Math. 32 (1977), pp. 826-834. [10] Garey, M.R., D.S. Johnson and L. Stockmeyer, Some simplified NP-complete graph problems, Theoret. Comp. Science 1 (1976), pp. 237–267. [11] Gritzmann, P., Mohar, B., Pach, J. and Pollack, R. Embedding a planar triangulation with vertices at specified points. in: American Mathematical Monthly 98 (1991), pp. 165-166. (Solution to problem E3341). [12] Ikebe Y., M. Perles, A. Tamura and S. Tokunaga, The rooted tree embedding problem into points in the plane, Discr. and Comp. Geometry 11 (1994), pp. 51–63. [13] Lengauer, Th., Combinatorial Algorithms for Integrated Circuit Layout, Wiley, 1990.
M. Kaufmann and R. Wiese, Few Bends, JGAA, 6(1) 115–129 (2002) [14] Leighton, F.T., Parallel Algorithms and Architectures: Hypercubes, Morgan Kaufmann, 1992.
129
Arrays-Trees-
[15] Pach J. and R. Wenger, Embedding Planar Graphs at Fixed Vertex Locations, in: Sue Whitesides (ed.), Proc. 6th Intern. Symposium on Graph Drawing (GD’98), LNCS 1547, Springer 1999, pp. 263-274. [16] Pach J. and J. T¨ or¨ ocsik, Layout of rooted trees, in: W.T. Trotter (ed.), Planar Graphs, vol. 9 of DIMACS Series, pages 131-137, 1993. [17] Papadimitriou, Ch., The NP-completeness of the bandwidth minimization problem, Computing, 16(3), 1976, pp. 263–270.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 6, no. 2, pp. 131–147 (2002)
Art of Graph Drawing and Art Jaroslav Neˇsetˇril Department of Applied Mathematics and Institute for Theoretical Computer sciences (ITI) Charles University Malostransk´en´ am. 25, 11800 Praha, Czech Republic
[email protected]
Communicated by H. de Fraysseix and and J. Kratochv´ıl: submitted October 2001; revised November 2001.
The Institute for Theoretical Computer sciences (ITI) is supported by Grant LN00A56 from the Czech Ministry of Education.
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
1
132
Introduction
Art and Science .... These seems to be key words of many contemporary writings. And scientists certainly are only happy to stress aesthetic qualities of their activity and artists like to justify their endeavor by science and technology. But these connections are very often superficial and often lead only to impatience how superficially without a deeper understanding and insight these connections are treated [7]. Here we want to illustrate some conceptual, or rather spiritual and methodological similarities of doing mathematics and art. We stress the word ‘doing’. ‘Doing’ in the true sense of informed and complex pursuit of actual questions and problems of contemporary art and science. (By ”Science” we mean here Mathematics in general, but also Computer Science and. of course, Graph Drawing; this is a volume devoted to the Drawing of Graphs.) Although both these areas are manifold and extremely diverse, we believe that they share some common qualities and profound similarities. These similarities are best traced by considering together the development and the methods of modern mathematics and modern art. Rather than considering the final products (works of art or theorems) we wish to stress similarities in the modus operandi of artists and mathematicians. We wish to stress that some of these similarities can be traced to all levels and moments of the production of both art and mathematics. And we are convinced that these similarities stem mainly from the idealistic character of both pursuits. But one has to search deep and one has to try to avoid superficial similarities and differences. We would like to rephrase the words Kandinsky used when comparing art and music [18]: In our opinion the similarities of art and mathematics are evident but they lie very deep. In fact, in the realm of true activity guided by inspiration and inspiring awareness there seem to be common features in most human activities. We put this forward as a creative thesis [29] and we return to this at the end of this article. But this article is for Graph Drawing and also there is more here than meets the eye. The prime problem of Graph Drawing is to visualize properly and as accurately as possible the information which is given to us in a confusing, sometimes pictorial and sometimes mathematical, or “technical”, way. This intended visualization should help us to understand, should attract and should explain. It is interesting to note that on such abstract gnoseological level these are the same aspects and problems which are facing an artist when he/she is trying to convey his/her message. Visualization, representation, the reality and its model are the code words. Clearly this is complemented by further aspects which make the whole picture more complicated and stresses the differences of these areas but still the abstract core is similar if not the same. (At this place it is only proper to stress the following: one has to be careful with analogies and parallels. We try to stress only those points which one can see and prove beyond doubts. Otherwise we can easily slip to the level of an essay and unjustified speculations.) This text is based on the article Art of Drawing [28] which in turn is based on an invited talk delivered by the author at GD’99. That lecture was conceived as
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
133
a multimedia show with slides, transparencies and CD projection (which operated fluently thanks to Hubert de Fraysseix). These three parts of the lecture, projected on three different screens, were called Samples, Stories and Souveniers. Since then some progress has been made and this lecture has been given in another context. Most notably in March 2001 in the Institute for Art History of the Academy of Sciences of the Czech Republic (thanks to an invitation of Mahulena Neˇslehov´ a) and at E.H.E.S.S., Paris, (thanks to an invitation of Pierre Rosenstiehl). Also on the scientific level a progress (a bit surprisingly) has been made. Recently this author devised an invariant, Combinatorial Entropy, which could serve as a measure of an aesthetic quality of a scheme and this, after several discussions with Michel Mend`es France, was thoroughly tested together with Jan Adamec on a large number of examples from both Art and Graph Drawing. A research article appeared in [2] and led to an article (of a more philosophical contents) in [30]. This text then complements both of these texts and it contains some new complementary material. I thank to the editors H. de Fraysseix and J. Kratochv´ıl for suggestion to include this paper in their volume and for several constructive remarks.
2
Three easy problems
We begin our story by recalling a situation which happens often at IQ (or similar) tests: The person being tested is asked to perform a routine task, task which may be a bit time consuming and which basically tests whether he or she understands a certain notion (i.e., understands under certain mental-time stress). Such a question may read: 1. Draw a curve! 2. Divide a square in two rectangles and two squares! 3. Divide a rectangle into two triangles and two pentagons! Of course the authors (of such tests, if they exist at all) are seeking an easy answer. But sometimes in their own naivete they perhaps do not know that a dog is hidden under carpet. The expected answer to Question 1. is of course some ”easy” picture of a curve. And as the authors of these tests believe, the easier answer mirrors a deeper understanding. But the complicated history of curves and their theory tells us something else. It is hard to tell what a curve is. It is hard to postulate it once for all by means of a self-contained definition (not involving pictures and hand waving) which would nevertheless cover all the variety of shapes of all possible curves. As often happens - a thing which is intuitively clear becomes less clear the more we think about it: A curve may have no derivative (e.g. a sharp peak) at any of its points (Bolzano and Weierstrass), a curve may have an infinite length and yet it may enclose a finite area (Koch and others), a curve may fill the whole plane (Peano and others). Even the notion like the length of a curve is a complicated phenomenon and this question was in fact one of the initial questions which
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
134
started the Theory of Fractals [20] and led to the notion of the fractal dimension. If we generalize Euclidean plane and space to n-dimension we always have n an integer (as it depicts the number of coordinates). However measuring curves in a fractal way we arrive at dimensions which are not necessarily integers. So some curves may have, say, dimension 4/3. The concept of fractal dimension goes back to the beginning of this century (Hausdorff and Besicovitch). Much later it recently played key role in theory which became truly part of popular science. With all its beautiful and easily generated pictures (and perhaps, because of this, so often quoted misleadingly in an art-historical context; see e.g. [19]). The fractal theory got mathematics seemingly as close to visual mathematics and even art as possible. As a result of this, the results were popularized, misunderstood and even misused at both ends of the spectrum. On one side these mathematically involved theories with all its interesting visual output are too tempting to the scientific audience and as a result of this they substitute modern art for many. On the other side, the interesting ‘mystical’ vocabulary is too tempting to art historians and critics alike. There is much evidence that this is done freely, too freely, like a new poetic enchanting word machine. (There is a newly emerging new candidate for this: the complexity theory). But the fractal theory is a natural counterpart of our theory and of our definition of Combinatorial Entropy below. Returning to our main theme: so just to define a curve is a highly non-trivial matter and thus an answer to question 1. could be certainly less self-confident. An informed individual would have the right to ask ‘A curve in which sense?’ Admittedly we cannot use this strategy at questions 2. and 3. Here the questions call for a solution (displaying that one knows the meaning of the concepts). And the answer to 3. comes without any effort at the very moment when one gives up (try a flat rectangle and indicate that you give up by crossing it twice!). But both these questions involve the construction of a special pavement or tiling and that is in general both an important and complicated question. A question which can be traced from prehistoric times, through mysticism of the Middle Ages until today. And in its combinatorial refinement this area took several surprising twists. We cannot resist mentioning here the spectacular configuration (non-periodic tiling of the plane using just two building blocks!) due to Penrose which had spectacular influence in as remote areas as algebra, crystallography, molecular chemistry and other areas which had nothing to do with the original intentions. Now, here is one of the pearls of the tiling theory: In 1903 the German mathematician Max Dehn asked a simple, seemingly innocent question: Can one divide a square into a finite number of squares of different sizes? Unlike in the usual picture (a possible answer to the Question 2) where we divide a square into 4 squares all of which are of the same size. Such a partition of the square is called perfect square. Does a perfect square exist? Does a perfect square exist at all? Yes or no? This is one of the beautiful aspects of mathematics, yes or no, there is no other way around. Modern mathematics developed techniques for asking and answering imprecise questions, for relative answers (subject to
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
135
various models), for answering and (lying) with certain probability. Yet the categorical yes/no question is still one of the main (and proud) characteristics of the field. The Dehn’s problem appeared to be not so easily solvable and after few decades it was solved independently by A. Sprague(1940) and a group of Cambridge undergraduates: A. Brooks, C. Smith, A. H. Stone and W. Tutte (1940), all of whom later became well known researchers. The affirmative answer was not obtained by an elaborate (and primitive) search, but by a search involving the rudiment of a theory. A series of ingenious reductions and reformulations (involving areas such as flows and electrical networks) made the initial problem accessible. Without this the problem would be too difficult to handle. It is interesting to note that the smallest perfect square is uniquely determined. It presents a division of a square into 21 different squares. One cannot partition a square in less than 21 different squares and there is only one such partition into 21 squares (up to natural transformation such as rotations and flipping). This unique design was sought for several decades and Duijvestijn solution finally came in 1978 (partly with the help of a computer). The uniqueness of this configuration of 21 squares is quite astonishing! It is the conviction of this author that the concentration of hard work and ideas makes from this square tiling a similarly unique object as the sensitivity, experience and (yes) hard work of Mondrian. So perhaps these special qualities justify its inclusion here. Actually, Charles Payan (Grenoble) produced an artistic object based on the Duijvestijn pattern and his object shares similarities with some of the Mondrian’s painting, see [30].
3
Openings
The formal similarities between art and various aspects of mathematics (mostly geometry) are both classical and contemporary. The mysticism of the golden ratio, of the pentagon, of the regular polyhedra and of pythagorean numbers draws fascination of many and this is applied with a lot of effort to the analysis of anything from the principles of life to pyramids and Gothic cathedrals. And this is of course more true for complicated mathematical questions of perspective and vision in general. Particularly the Renaissance connection is usually quoted as the prime time of relevance of mathematics and art. There can be no doubts that mathematics at that time did some good service to art. (If only to help to upgrade artists from mere craftsmen to free artists in the same category as thinkers.) Maybe at this time of confusion and (what some call) art crisis, art intuitively seeks again a helping hand or solid base or whatever name you want to use for outwardly directed trends in recent art. But this is not so simple and traps are waiting on this road. All this will succeed only in the case when the mutual relationship (of mathematics and art) is freed from arbitrariness, superficial analogies and passing comments. Mathematics was always a source (yes, a generator; mathematics is also a logical machine) of complex (for outsiders, mystical) patterns. This is even more
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
136
true today than ever. With our understanding of randomness, of deterministic chaos and aided by graphical devices attached to computers, this ‘artistic potential’ of mathematics is growing. It is our conviction that this pattern generation displays mostly formal and superficial similarities to art. This is the case with fractals (mentioned above) and computer graphics in general, with patterns in chip design which resemble both minimalistic works and complex patterns of microbiology and underwater life. These tricks found one of their culminating forms in wonderful commercials and video clips. Complexity of these forms surpasses any expectation and the variety and combination of tools (and energy, and money) is simply amazing. Consider an example from another corner: the work of M.C. Escher displays a dizzying technique and explicitly touches and even anticipates some mathematical problems of tilings (tilings with special symmetries; similar to those we described above). But however intriguing all this may be, we feel that this has no bearing on the mainstream of art, better on the main problems and challenges which art and artists have been solving and are facing and solving today. And in a sense all these forms are based on combinatorially refined byproducts of mathematics and computer science as well.
4
Archaeology of Aesthetic
Consider the following two problems: I. When was the last time that you taught somebody (possibly your own child) how nice this world is and what marvels and beauties it contains? II. When was the last time that men and women were solving the problems how to make a painting, a drawing or a photograph which would depict accurately (and/or romantically, and/or critically, and/or harmoniously) the surrounding world? The answers to these questions seem to be very different. An answer to the first is reflecting (everyday) experience of parents and educators and on the abstract (theoretical) level it was treated in numerous books by various theories. These theories seem to be in (general) agreement with the concrete and mainstream educational praxis. The second question seems to be more complex (and it is also a more abstract problem). Somehow it seems (to many) that this is an old fashioned problem which is the subject of early modernism if not renaissance. Yet we believe that with computers this question gains a new momentum. In this paper we address this problem. Despite the implicit word computer in the title in this paper, we do not address the question of visualization, of picture processing of visual information in the sense of Computer Graphics. The information for us is already processed and typically is of a very simple type such as a drawing (however, not necessarily a technical drawing, it may be also a drawing of an artist). What we would like to decide is how to formalize the fact that a picture (drawing) is harmonious. We mean harmonious in the sense of being aesthetically pleasing. We prefer the word harmonious to aesthetical (which is probably more in common usage)
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
137
as an aesthetic feeling is probably highly individual and we cannot have an ambition to define it (or even approach it). The long tradition of art history is convincingly telling us this. We propose an approach which should capture some features of what makes a picture (drawing) harmonious by means of the notion of Combinatorial Entropy. This approach is based on the analysis of curves ([25]) which in turn goes back to Steinhaus and Poincar´e. The hereditary approach which we introduce below may be viewed as an approach dual to Piaget’s analysis of intelligence, see e.g. [33] and compare [30]. Combinatorial Entropy is an invariant with respect to scaling and rotations, and it is a very robust parameter. This is an important feature as a perception of harmony (and of aesthetic pleasure) is a robust feeling. Moreover Combinatorial Entropy can be computed for a large class of drawing and pictures. It is routine to apply it to scanned information and no analytic description is needed. Perhaps this parameter could aid in the hierarchical approach to graph visualization in selecting a particular model which suits the best a given specific context. And as it can be scanned routinely it can be applied to vast data of molecular biology, digital libraries and even museum collections (particularly graphics and drawings) as an easily available descriptor. After these introductory lines let us begin by describing our initial situation in greater detail.
5
On Invariants for Graph Drawing
What makes the following pictures similar and what makes them different? (The substance and the context are important artistic aspects. However we are interested here only in formal similarities of these pictures; one picture is a musical score - a sketch by Jan´ aˇcek [35], the other picture is one of the Moduli - a sketch by Naˇceradsk´ y and the author [31].)
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
138
And, very simply, can we distinguish or order in some systematic way the following three figures (graph drawings using a program due to [9])?
The modern version of these questions is not how to teach a gifted and collaborating child what is nice and beautiful. Instead we need to teach an individual which is not collaborating at all and who takes every our information deadly seriously and exploits it to the last bit - a computer. People usually do not react this way (and if so, then only in comedies like [13] or [14]; the fact that these great novels have a military setting is then not an accident). In order to “teach” a computer (and even without ambition for teaching, just dealing with it) we need a precision. And precision in the other words calls for some concrete measures of our phenomena, in the other words for invariants. The purpose of this note is to suggest such an invariant and to document some experiments which we performed. Consequently, the traditional principal problem of aesthetics (and art history) - to explain and to predict artistic and aesthetically pleasing - took recently an unexpected twist. We do not explain and deal with individual instances, we have to classify a vast amount of data and we have to design procedures with likely harmonious output. This problem in its manifold variety is interesting already when our objects are well defined compositions composed from simple building blocks such as lines, squares, sticks,.... This in fact is a familiar exercise and training ground of schools of design and architecture and (traditional) art academies. This illustrates difficulty and variety of solutions even of simple situations. This should be not surprising if we realize how many simple lines needed, say Rembrandt or Picasso, to produce full images (for example drawings; 50 lines or even less!). For our “simple composition from simple building blocks” we would like to create an invariant which would help us to categorize and order these compositions. It is difficult to say even on this simple level what it is an invariant, but we can certainly state which properties such an invariant should have: i. invariant should be an (easy) computable aspect of the structure; ii. invariant should be consistent (or invariant, meaning it should not change)
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
139
under chosen modification of structure; iii. invariant should be useful in that it can be used to catalogue, to order (which structure is “better”), to classify, to distinguish. We propose here an invariant - called hereditary combinatorial entropy - to measure an aesthetic quality of a visual data (drawing, scheme, painting, note score, molecular data output and others). This invariant is presented in the next section.
6
Hereditary Combinatorial Entropy of a Drawing
Before defining the invariant we want to specify the rules under which the invariant should remain unchanged. Such rules were specified several times and are folklore in the visualization of scientific results. For example the book [5] lists (in section “Aesthetics”) the following 11 graphic properties (called aesthetics) which are commonly adopted: Crossings, Area, Total Edge Length, Maximal Edge Length, Uniform Edge Length, Total Bends, Maximum Bends, Uniform Bends, Angular Resolution, Aspect Ration and Symmetry. The names of these criteria are self-explanatory and together they form a very good paradigm for drawing of graphs. However most of them are specific for drawings of graphs (or similar structures) and they do not apply generally (for example to artistic drawings or sketches). Yet we believe that the aesthetic quality of visual algorithms should be tested on aesthetically charged objects. This is one of the underlying ideas of our approach. There is another drawback of the above paradigm. In all of these criteria (with exception of angular resolution, where we want to maximize, and symmetry which is a structural property) we are aiming for a minimization (for example we want to minimize the total length of our drawing). That of course means that we have to optimize these criteria (as they are sometimes mutually pointed against each other) and we have to add to our paradigm preferences among them. However as optimization problems these criteria are computationally hard (see [5]). Our approach is different and we believe it could add a new aspect to visualization and analysis of visual data. Let us first specify objects which are relevant to our method: A drawing D is a finite set of curves in Euclidean plane. (As our drawings are man made we assume that the set is finite.) A curve is a continuous image of unit interval in plane (we mean a “nice” image; this is not place for technicalities). A painting can be any image, including photographs. It typically consists of differently colored areas. An engraving is a very special kind of object, since it can be included in the previous two classes. However seeing it as a drawing gives a lot more information.
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
140
For an infinite line L and a drawing D denote by i(L, D) the number of intersections of the line L and the drawing D. We define the Combinatorial Entropy Hc (D) of a drawing D as the expected value of i(L, D) where expectation relates to the random selection of line L. Combinatorial Entropy is also called Fractional Length from reasons to be mentioned later, see [1, 2]. By virtue of this definition we note the following: i. The combinatorial entropy Hc (D) is easily evaluated by a random generation of lines; ii. Hc (D) is invariant under transposition and rotation; iii. Hc (D) is invariant under scaling (i.e. “blowing up”). The role of randomness in the art has been discussed e.g. in [25], [26]. These facts make it possible to evaluate (or very accurately to estimate) combinatorial entropy of many drawing schemata, drawings of artists (we systematically tested some of the early works of Picasso [32] and Kandinsky [18] as well some drawings from [31]). We also used the analytical description of tertiary structure of some of the proteins (provided by P. Panˇcoˇska, compare [17]). The software developed in [1] uses standard tools of digital image processing, see [3], [34] and allows to handle a very broad spectrum of examples. Most difficulties are with paintings, because they must be transformed into drawings in order to count number of intersections (several filters are applied on the picture to find its contours, the resulting picture is drawing as we defined it before). Let us state some specific examples: the above Jan´aˇcek score had combinatorial entropy 18.55 which is quite similar to the combinatorial entropy 17.87 of the above drawing of Naˇceradsk´ y and Neˇsetˇril taken from [31]. The three graph drawings depicted above have combinatorial entropy (from left to right) 5.70, 5.37, 6.96.
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
141
The method is flexible enough to handle complex drawings and pictures. For example classical prints from J. Verne novels when considered as a dense network of individual lines (no blurring). For example the following picture (due to Roux) [38] which serves as the front illustration of [22] has combinatorial entropy 136.6. As expected (both by the intuition and a few trials) the n × n grid has approximate combinatorial entropy n. (As lattices are given analytically we can perform this experiment for very large n). Many more examples are contained in [1, 2]. What do these numbers mean? What is a significance of the combinatorial entropy of a drawing? The definition of the combinatorial entropy is motivated
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
142
by the research done by prof. Michel Mendes France in a series of papers devoted to the analysis of curves, [25]. He defines the temperature T (D) of a curve D by the following formula T (D) = (log
E(i(L, D)) −1 ) E(i(L, D)) − 1
where expectation relates to the random selection of the line L. He related this parameter to entropy, dimension and other parameters which he defined in an analogy to fractal theory, statistical physics and geometric probability and integral geometry. These definitions rest on classical theorems due to Steinhaus [37] (which in turn goes to Poincar´e). One can show that the logHc (D) is a good approximation of the entropy of a curve. Thus the name Combinatorial Entropy for our invariant. By viewing a drawing as a set of curves and thinking of Eulerian trail [22](in each component of the drawing) as a new curve of double length (as we traverse every segment of a drawing twice) we can define the the temperature by the same formula for a more general class of pictures (drawings). For large number of intersections (of a drawing D with a line L) the temperature T (D) is approximately equal to the average value of i(D, L) − 1 = Hc (D) − 1 while the entropy H(D) (in the classical sense) is approximated by the logarithm of the combinatorial entropy Hc (D). It follows (and this is Steinhaus’ theorem) that the combinatorial entropy Hc (D) of a drawing D is approximated by the ratio 2`(D)/c(D) where `(D) denotes the total length of the drawing D and c(D) denotes the length of circumference of the (convex closure) of D. (This suggests the alternative name fractional length, see [30] for details.) Based on these interpretations Hc (D) measures the information content and the amount of work which the artist (explicitly) put into his drawing. On the other hand, by comparing various drawings of the same object (or theme) the lower Hc (D) indicates the elegance and simplicity of the output. However as such the combinatorial entropy captures only the global properties of the drawing (expressed by the total length of the drawing and the circumference). Still, via the average number of intersections it captures, implicitly, many properties of the drawing. In [30] we also proposed a technique (based on the algebraic structure cogroup ) to generate harmonious objects. In our setting this can be formulated as follows: Hereditary Combinatorial Entropy Thesis A harmonious (or aesthetically pleasing) drawing or design has combinatorial entropy in each of its (meaningful) parts proportional to the global combinatorial entropy. Here a meaningful part is a part which reflects the properties of D. For the following (author) drawing (of our institute in Prague)
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
143
we found the following distribution of combinatorial entropies (this is based on the regular partition of the square into smaller squares; the combinatorial entropy of the drawing restricted to a particular subsquare is listed in the middle of the subsquare):
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
7
144
Constructible World
The spiritual contents of art is growing. More and more an artistic object is an act, quoting Damisch, a move of the mind. A painter thinks and he/she does so through and in his/her painting, just in the same way as a mathematician thinks and he/she does so through his/her results: definitions, theorems, proofs. We do not have here in mind only conceptual art and the like, we think of art generally. And this is not a revolution. Only the dust of time, misinterpretations of history and the pride of contemporaries covered all the bold moves (how fitting a word in this context) of old masters. Let us summarize: Our intention in this short paper has been to draw some parallels between art and mathematics mainly from the creative point of view. We have tried to stress some similarities. [28, 29, 30] contains some more and perhaps more complete material. The interested reader probably knows many other examples of such similarities from his/her experience. Is the existence of such similarities just a coincidence? We do not know. Let us end this note in a highly speculative way: In mathematics there is a principle called ‘Church thesis’ which in essence claims that every (intuitive) algorithmic procedure takes a particular form, a form expressed by (any) universal computing machine. Maybe something like Church’s thesis holds in general for human activities. Let us try to formulate this thesis as follows:
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
145
Creative Thesis( [29]) All sufficiently deep human activities, all sufficiently deep understandings, have profound similarities. This is exhibited in the way the work (knowledge) is organized, in the way it is revealed and in the way it interacts with other activities. Admittedly this is too vague. But this one has to expect at such a level of generality. Perhaps one should interpret the thesis positively. How often are stressed only the conflicting features of artistic and scientific communities, say, along the lines of feelings and sensibilities as opposed to mind and brain activities. We feel that these views are often superficial and isolationist, and sometimes simply an overreaction. On the other hand there is a numerous supporting evidence and two such examples were considered in [29]: sketches or sketching and minimalistic trends. By the same token it is difficult to find a counterexample to the thesis. Mathematics, in particular, is a rich generator of complex patterns and as such it is often used (above we mentioned some examples). So it will be difficult to break the mathematical trap -everything goes, everything is possible. There is no doubt that the new means of technology and guided by math- and computerdevices will lead to new art form. But it is a conviction of this author that to break the trap of uniformity and unbelievable combinatorial variety of technology will require some profound and probably not yet discovered ideas. And this is probably the realm of scientists and artists, maybe for the first time since the Renaissance. We do not know yet. But we have to try...
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
146
References [1] J. Adamec. Kreslen´ı graf˚ u. Diploma thesis, Charles University, Prague (2001). [2] J. Adamec, and J. Neˇsetˇril. An Aesthetic Invariant for Graph Drawing. In: Proceedings of Graph Drawing 2001, LNCS, Springer Verlag 2001. [3] G. A. Baxes. Digital Image Processing. Principles and Applications, Wiley, 1994. [4] G. D. Birkhoff. Aesthetic Measure. Harvard University Press, Cambridge, Mass. 1933. [5] G. Di Battista, P. Eades, R. Tamassia, and I. G. Tollis. Graph Drawing. Algorithms for the Visualization of Graphs. Prentice Hall 1999. [6] T. J. Clark. Modernism–a farewell to an idea. Yale Univ. Press, 2000. [7] H. Damisch. The Origins of Perspective. MIT Press 1994, original French edition Flamarion 1987. [8] H. Damisch. Le travail de l’art: vers une topologie de la couleur? In: [31]. [9] H. de Fraysseix. Graph Drawing SW (personal communication). [10] T. de Duve. Kant after Duchamp. MIT Press 1998. [11] R. J. Gardner. Geometric Tomography. Notices AMS, 42, 4 (1995), 422– 429. [12] B. Gr¨ unbaum, and I. Steward. Tilings and patterns. W.H. Freeman, 1986. ˇ [13] J. Haˇsek. Osudy dobr´eho voj´ aka Svejka. 1920 (in English: The Good Soldier Schweik ). [14] J. Heller. Catch–22. 1961. [15] D. Hilbert. Grundlagen der Geometrie. Teubner 1934 [16] A. Edelman, and E. Kostlan. How many zeros of a random polynomial are real? Bull. Amer. Math. Soc. 32, 1 (1995), 1–37. [17] V. Janota, J. Neˇsetˇril, and P. Panˇcoˇska. Spectra Graphs and Proteins. Towards Understanding of Protein Folding. In: Contemporary Trends in Discrete Mathematics, AMS, DIMACS Series 49, 1999, pp. 237–255. [18] W. Kandinsky. Point and Line to Plane. Dover Publications 1979. [19] S. Kol´ıbal. Retrospektiva. N´ arodn´ı Galerie, Praha 1997 [20] B. Mandelbrot. Les Objects Fractals Flammarion 1975, 1984, 1989, 1995.
J. Neˇsetˇril, Art of Graph Drawing and Art , JGAA, 6(2) 131–147 (2002)
147
[21] J. Mandelbrojt, and P. Mounoud. On the Relevance of Piaget’s Theory to the Visual Arts. Leonardo 4 (1971), 155–158. [22] J. Matouˇsek, and J. Neˇsetˇril. Invitation to Discrete Mathematics. Oxford Univ. Press 1998. [23] K. Mehlhorn, and S. Naher. LEDA–A platform for combinatorial and geometric computing. Cambridge Univ. Press, 1999. [24] M. Mend`es France, and A. H´enaut. Art, Therefore Entropy. Leonardo, 27, 3 (1994), 219–221. [25] M. Mend`es France. The Planck Constant of a Curve. In: Fractal Geometry and Analysis (J. B´elair, S. Dubuc, eds.) Kluwer Acad. Publ. 1991, pp. 325– 366. [26] M. Mend`es France, and J. Neˇsetˇril. Fragments of a Dialogue. KAM Series 95–303, Charles University Prague (a Czech translation in Atelier 1997). [27] A. I. Miller. Insight of genius. Springer Verlag, 1966. [28] J. Neˇsetˇril. The Art of Drawing. In: Graph Drawing (ed. J. Kratochv´ıl), Springer Verlag,1999 [29] J. Neˇsetˇril. Mathematics and Art. From The Logical Point of View, 2, 2/93 (1994), 50–72. [30] J. Neˇsetˇril. Aesthetic for Computers or How to Measure a Harmony. To appear in Visual Mind (ed. M. Emmer), MIT Press. [31] J. Naˇceradsk´ y, and J. Neˇsetˇril. Antropogeometrie I, II (Czech and English). Rabas Gallery, Rakovn´ık, 1998 (ISBN 80-85868-25-3). [32] P. Picasso. Picasso–Der Zeichner 1893–1929. Diogenes, 1982. [33] J. Piaget. Logique et connaissance scientifique, Gallimard. Paris, 1967. [34] W. K. Pratt. Digital Image Processing. Wiley, 1978. ˇ edroˇ [35] M. Stˇ n. Leoˇs Jan´ aˇcek and Music of 20. Century. Nauma, Brno, 1998 (in Czech). [36] L. A. Santal´ o. Integral geometry and geometric probability. Addison Wesley 1976. [37] H. Steinhaus. Length, shape and area. Colloq. Math. 3 (1954), 1–13. [38] J. Verne. Sans Dessus Dessous. J. Het zel (Paris), 1889. [39] H. Weyl. Invariants. Duke Math. J. 5 (1939).
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 6, no. 1, pp. 149–153 (2002)
Realization of Posets Patrice Ossona de Mendez CNRS UMR 8557 E.H.E.S.S. 54 Bd Raspail, 75006 Paris, France http://www.ehess.fr/centres/cams/person/pom/index.html
[email protected] Abstract. We prove a very general representation theorem for posets and, as a corollary, deduce that any abstract simplicial complex has a geometric realization in the Euclidean space of dimension dim P (∆) − 1, where dim P (∆) is the Dushnik-Miller dimension of the face order of ∆.
Communicated by H. de Fraysseix and and J. Kratochv´ıl: submitted May 2000; revised July 2001.
P. Ossona de Mendez, Realization of Posets, JGAA, 6(1) 149–153 (2002)
1
150
Introduction
Schnyder proved in [3] that a graph is planar if and only if its incidence poset (that is: the poset where x < y iff x is a vertex, y is an edge and y is incident to x) has dimension at most 3. That an incidence poset has dimension at most 3 implies that the corresponding graph is planar has been extended to abstract simplicial complexes in [2]: if the face order of an abstract simplicial complex ∆ is bounded by d + 1, then ∆ has a geometric realization in Rd . We prove here a more general result on poset representation which implies this last result straightforwardly. We shall first recall some basic definitions from poset theory: A partially ordered set (or poset) P is a pair (X, P ) where X is a set and P a reflexive, antisymmetric, and transitive binary relation on X. A poset is P = (X, P ) is finite if its ground set X is finite. We shall write x ≤ y in P or x ≤P y if (x, y) ∈ P . Two elements x, y ∈ X such that x ≤ y in P or y ≤ x in P are said to be comparable;otherwise, they are said to be incomparable. If P and Q are partial orders on the same set X, Q is said to be an extension of P if x ≤ y in P implies x ≤ y in Q, for all x, y ∈ X. If Q is a linear order (that is: a partial order in which every pair of elements are comparable) then it is a linear extension of P . The dimension dim P of P = (X, P ) is the least positive integer t for which there T exists Tt a family R = (<1 , <2 , . . . ,
2
The Poset Representation Theorem
Definition 2.1 Let P = (X, P ) be a finite poset, n an integer and f : X 7→ Rn a mapping from X to the n-dimensional space Rn . Then f is said to have the separation property for P if, for any A, B ⊆ X, there exists a hyperplane of Rn which separates the points of f (Inf(A) \ Inf(B)) and the ones of f (Inf(B) \ Inf(A)), where Inf(Z) = {x ∈ X, ∀z ∈ Z, x ≤P z} for any Z ⊆ X. Theorem 2.1 Let P = (X, P ) be a finite poset and let d = dim P be its dimension. Then, there exists a function f : X 7→ Rd−1 , which satisfies the separation property for P. Proof: Let R = {<1 , . . . ,
P. Ossona de Mendez, Realization of Posets, JGAA, 6(1) 149–153 (2002)
151
functions from X to ]1; +∞[, each Fi being fast increasing with respect to
On one hand, for any z ∈ Inf(B)\Inf(A), there exists a ∈ A and 1 ≤ i0 ≤ d, with z >i0 a. Then, we get Fi0 (z) > d.Fi0 (a). As min(B,
i0 min(A, d. On the other hand, for any z ∈ Inf(A), we have Fi (z) ≤ Fi (a) for every i ∈ [d] and every a ∈ A. Thus, LA,B (F (z)) ≤ d. Altogether, for any A, B ⊆ X such that none is included in the other, the hyperplane HA,B with equation LA,B (π) − LB,A (π) = 0 separates the points from F (Inf(B) \ Inf(A)) (for which LA,B (F (z)) > d ≥ LB,A (F (z))) and those from F (Inf(A)\ Inf(B)) (for which LA,B (F (z)) ≤ d < LB,A (F (z))). Notice that the origin O belongs to all the so-constructed hyperplanes. P Now, consider a hyperplane H0 with equation 1≤i≤d πi = 1, which separates the origin O and the set of the images of X by F . To each element z of X, we associate the point f (z) of H0 which is the intersection of H0 with the line (O, F (z)). Now, for any A, B ⊆ X (such that none is included in the other), as HA,B includes O, the hyperplane HA,B ∩H0 of H0 separates the points from F (Inf(B)\ Inf(A)) and those from F (Inf(A) \ Inf (B). As H0 ' Rd−1 and as the separation property would be obviously true if A ⊆ B or conversely, the theorem follows. 2 The preceding theorem is sharp, as proved here using the standard example Sn of poset of dimension n (introduced in [1]): Theorem 2.2 For any n ≥ 3, there exists no function f : [n] 7→ Rn−2 which satisfies the separation property for the standard example Sn of poset of dimension n, which is the height two poset on {a1 , . . . , an , b1 , . . . , bn }, with minima {a1 , . . . , an }, maxima {b1 , . . . , bn } and such that ∀i, j, (ai < bj ) ⇐⇒ (i 6= j). Proof: Assume there exists a function f : {a1 , . . . , an , b1 , . . . , bn } 7→ Rn−2 having the separation property for Sn . According to Radon’s lemma, for any family of n point in Rn−2 , there exists a bipartition V, W of them, such that the convex hulls of V and W intersects and thus such that V and W cannot be separated by an hyperplane of Rn−2 . Let A = {bi , f (ai ) 6∈ V } and B = {bi , f (ai ) 6∈ W }. Then, V ⊆ f (Inf(A)) and W ⊆ f (Inf(B)). Hence, the separation property fails for A, B. 2
P. Ossona de Mendez, Realization of Posets, JGAA, 6(1) 149–153 (2002)
152
From Theorem 2.1, one derives a sufficient condition for a graph to be planar, which is that its incidence poset shall be of dimension at most 3 and this condition is actually also a necessary condition: Theorem 2.3 (Schnyder [3]) The incidence poset Incid(G) of a graph G has dimension at most 3 if and only if G is planar, that is: if and only if there exists a mapping f from V (G) ∪ E(G) to R2 having the separation property for Incid(G). 2
3
Applications
Corollary 3.1 Let U be a finite set, and F a family of subsets of U such that: ∀x, y ∈ U, ∃X ∈ F,
x ∈ X and y 6∈ X.
(1)
Let d be the Dushnik-Miller dimension of the inclusion order ⊂F on F . Then, there exists a function f : U 7→ Rd−1 such that (denoting f (A) the set {f (z), z ∈ A}, for A ⊆ U ): ∀X ∈ F, ∀X 6= Y ∈ F,
Conv(f (X)) ∩ f (U ) = f (X),
(2)
Conv(f (X \ Y )) ∩ Conv(f (Y \ X)) = ∅.
(3)
Proof: Equation (3) is a direct consequence of Theorem 2.1. For (2), consider successively all the elements z 6∈ X: According to (1), the intersection of all the sets in F including z does not intersect X. Hence, setting A = {X} and B = {Y ∈ F, z ∈ Y }, it follows from Theorem 2.1 that z does not belong to Conv(f (X)). 2 An abstract simplicial complex ∆ is a family of finite sets such that any subset of a set in ∆ belongs to ∆: ∀X ∈ ∆, ∀Y ⊂ X, Y ∈ ∆. The face order of ∆ is the partial ordering of the elements of ∆ by ⊆. S A geometric realization of ∆ is an injective mapping f of the ground set |∆| = X∈∆ X to some Euclidean space Rd , such that, for any two elements (or faces) X, Y of ∆, the convex hulls of the images of X and Y have the convex hull of the image of X ∩ Y as their intersection: Conv(f (X)) ∩ Conv(f (Y )) = Conv(f (X ∩ Y )). It is a folklore lemma that a mapping from |∆| to Rd is a geometric realization of ∆ if and only if disjoints faces of ∆ are mapped to point sets with disjoint convex hulls. It is well known that an abstract simplicial complex has a geometric realization in Rd when d > 2(maxX∈∆ |X|− 1) and that, obviously, it has no geometric realization in Rd if d < maxX∈∆ |X| − 1. Theorem 3.2 (Ossona de Mendez [2]) Let ∆ be an abstract simplicial complex, and let d be the dimension of the face order of ∆. Then, ∆ has a geometric realization in Rd−1 . Proof: Consider the mapping from the ground set |∆| of ∆ to Rd−1 , whose existence is ensured by Corollary 3.1. Then, for any disjoint faces F, F 0 of ∆, we get Conv(f (F ))∩Conv(f (F 0 )) = ∅, that is: f induces a geometric realization 2 of ∆ in Rd−1 .
P. Ossona de Mendez, Realization of Posets, JGAA, 6(1) 149–153 (2002)
153
References [1] B. Dushnik and E.W. Miller, Partially ordered sets, Amer. J. Math. 63 (1941), 600–610. [2] P. Ossona de Mendez, Geometric realization of simplicial complexes, Graph Drawing (J. Kratochvil, ed.), Lecture Notes in Computer Science, vol. 1731, Springer, 1999, pp. 323–332. [3] W. Schnyder, Planar graphs and poset dimension, Order 5 (1989), 323–343. [4] W.T. Trotter, Combinatorics and partially ordered sets: Dimension theory, John Hopkins series in the mathematical sciences, Johns Hopkins University Press, London, 1992.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 6, no. 2, pp. 157–173 (2002)
Traversing Directed Eulerian Mazes S. Bhatt Akamai Technologies 500 Tech Square, Cambridge MA 02139 [email protected]
S. Even Computer Sci. Dept., Technion – Israel Inst. of Tech. Haifa, Israel [email protected]
D. Greenberg Center for Computing Science Bowie, MD [email protected]
R. Tayar Computer Sci. Dept., Technion – Israel Inst. of Tech. Haifa, Israel [email protected] Abstract The paper describes two algorithms for threading unknown, finite directed Eulerian mazes. Each of these algorithms is performed by a traveling robot whose control is a finite-state automaton. It is assumed that each vertex has a circular list of its outgoing edges. The items of this list are called exits. Each of the algorithms puts in one of the exits of each vertex a scan pebble. These pebbles can be used by a simple robot as traffic signals, which allow it to traverse an Eulerian cycle of the maze. For a directed graph (maze) G(V, E), the simple algorithm performs O(|V | · |E|) edge traversals, while the advanced algorithm traverses every edge three times. Let dout (v) be the out-degree of vertex v. The algorithms use, at each vertex v, a local memory of size O(log dout (v)). Communicated by S. Khuller: submitted January 2002; revised June 2002
Work by S. Even supported by the Fund for the Promotion of Research at the Technion.
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002)
1
158
Introduction and Model
The question of how best to traverse an unknown maze, given only local knowledge, has been long studied. [8, 3, 5, 7, 6, 1, 4, 2]. Without the ability to store some knowledge about the maze the searcher can easily become trapped in cycles. In this paper we consider the case of directed Eulerian mazes/graphs, and show that a finite state automaton, with access to some local memory stored in the vertices, can find an Eulerian cycle. During the search for this cycle, each edge is traversed three times. It is assumed that each vertex has a circular list of its outgoing edges. The items of this list are called exits. The challenge is to use only as simple a “robot,” R, as possible. R has a finite automaton control and a few external actions. The external actions affect the external state which consists of the following: • The vertex in which R is at, and more specifically, the exit at which R is at. • For every vertex v, the location of some small constant number of pebbles at exits of v, and the value of a constant number of flags’ bits at v. Let dout (v) be the out-degree of v. The external actions allow R to access O(log dout (v)) bits of information, stored at v. Note that R’s memory may not be sufficient to store all these bits at any one time, since no bound on dout (v) is assumed. The robot R can perform two essential movement actions: • R can traverse an edge from its beginning, which is an exit of the vertex it is at, to its end, to enter another (the same, in case of a self-loop) vertex. • R can move from the exit it is at to the next/previous exit in the cyclic order of the exits of the vertex it is at. Also, R can perform two pebbling actions: • R can observe if a pebble of a specified type is located at the exit R is at. • R can put/remove any pebble at/from the exit it is at. Finally, R can perform two flagging actions: • R can observe whether a certain flag is turned on at the vertex R is at. • R can turn on/off a certain flag at the vertex R is at. For simplicity we will often use compound actions such as traverse the edge with the scan pebble which are straightforward finite automata functions of the basic actions. The problem considered in this paper can now be restated as follows: Design a robot R so that when it is placed at any vertex of any directed Eulerian finite
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002)
159
graph, with any cyclic ordering of the exits of each vertex, R will eventually halt, leaving a scan pebble at one exit of each vertex. These scan pebbles serve as traffic signals for a simple scanning robot. Using these pebbles, and moving them as it goes along, this robot will traverse an Eulerian cycle, will halt, and when it does, the scan pebbles will be exactly where they have been when the simple robot started this traversal.
2
History of Maze Traversal
In 1967, Michael Rabin [8] considered the problem of threading undirected connected graphs by means of a finite automaton which has some fixed number of pebbles it can leave at vertices and which it can move from one vertex to another. Note that by threading we mean visiting every vertex, at least once. He proved that no such automaton can thread all finite undirected graphs. It follows that no finite automaton can thread all finite, connected graphs, unless some unbounded information can be stored in the vertices. In view of this impossibility result, it is no wonder that the classical (19-th century) algorithms for threading undirected mazes, such as that of Tr´emaux’s and Tarry’s (see, for example Even’s book [5], Chapter 3) store data in the vertices. More about threading undirected mazes can be found in the book of Hemmerling [7]. However, these algorithms are not easy to implement on directed graphs due to the fact that backtracking along edges is no longer allowed. Notice that every connected undirected graph can be transformed to a directed Eulerian graph by replacing every edge u—v with two directed edges u −→ v and v −→ u. Thus, the impossibility result for threading undirected graphs implies the impossibility of threading for directed Eulerian graphs. This, in turn, proves the impossibility of finding an Euler cycle in Eulerian directed graphs. Therefore, in order to thread all finite directed Eulerian graphs, it is natural to allow our robot, R, to store and use some information in the vertices. Even, Litman and Winkler [6] presented an algorithm of time complexity O(|V |2 ) to thread directed networks. However, their algorithm assumes a different computational model — each vertex is a finite automaton and the directed edges are communication links. Afek and Gafni [1] present a fairly complicated solution which uses essentially Depth-First Search (like Tr´emaux’s algorithm), and includes a method to effectively backtrack on directed edges. Their method uses O(|V | · |E| + |V |2 · log |V |) edge traversals, and requires that vertices are labeled with distinct names. We shall later say more about the comparison of our results with those of Afek and Gafni. Deng and Papadimitriou [4] also use a more powerful model than we do. Their purpose is to explore the graph; i.e. to discover its structure. They assume that vertices have distinct identities and that the robot is a general purpose computer (Turing equivalent). They describe a recursive algorithm which finds an Eulerian cycle in a directed Eulerian graph. This algorithm traverses each edge twice. They build on this algorithm to attack the problem
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002)
160
of exploring general strongly connected directed graphs. (See, also, Albers and Henzinger [2].)
3
Overview of the Robot Algorithms
Let G(V, E) be a finite Eulerian directed graph. Namely, G’s underlying undirected graph is connected, and for every vertex v ∈ V , din (v) = dout (v), i.e., its indegree is equal to its outdegree. Euler’s Theorem implies that G has a directed cycle in which every edge of G appears exactly once. Since din (v) = dout (v) we shall simply use d(v) to denote dout (v).
3.1
The Simple Algorithm
Without any pebbles the robot, R, might be doomed to pick the same exit every time it visited a vertex. In this algorithm, R uses a scan pebble to “remember” which is the next exit to be taken. At each vertex, R moves to the exit with the pebble, call it Ep , places the pebble at the next exit, returns to Ep , and traverses that edge. As we will show below, the repetition of this simple “move pebble forward before traverse” alone will eventually establishes an Eulerian tour, i.e., after wandering for a while, R will traverse an Eulerian cycle, and repeat it, indefinitely, unless some mechanism causes it to halt. Afek and Gafni [1] used a similar idea in their Traversal-1 algorithm. We use a different halting mechanism (employing a two bits flag at each vertex and using a single bit of internal state of R,) and take advantage of the fact that our graphs are assumed to be Eulerian, while they assumed only strong connectivity. We will show that this Simple algorithm makes O(|V | · |E|) edge traversals before it halts, using our halting rule. Afek and Gafni [1] show that their scanning method is existentially optimal, that is, that there exists a family of (non-Eulerian) directed graphs which require Ω(|V | · |E|) edge traversals. However, as is shown in the Appendix, there are dense (Eulerian) graphs for which any Depth-First Search approach, including that of Afek and Gafni, takes Ω(|V | · |E|) = Ω(|V |3 ) edge traversals, while our variant takes O(|V |2 ).
3.2
The Advanced Algorithm
To prepare for our second robot algorithm we first describe an algorithm which does not meet our traveling robot model. We first prove the validity of this algorithm and later show that we can return to our model and preserve the validity. The algorithm consists of two phases. The first phase, called preparatory, is nondeterministic. It concludes by placing a scan pebble at one exit of each vertex, thus, in fact, having found an Eulerian tour. The second phase, called stroll, can then execute the simple traveling robot algorithm to trace an Eulerian
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002)
161
cycle. When it halts the pebbles are back where the preparatory phase had placed them. Finally, our Advanced Algorithm replaces the nondeterministic preparatory phase with a traveling robot sub-algorithm. The new preparatory phase requires two more pebbles per vertex and two additional 3-value variables in each vertex. Including both its phases, the Advanced Algorithm traverses each edge 3 times.
3.3
The Recursive Algorithm
It is worth noting that the Recursive Algorithm of Deng and Papadimitriou can also be performed by a traveling finite robot. However, the required memory in each vertex v is Θ(d(v) · log d(v)). If the robot is “input aware”, (i.e. when a vertex is entered the output edge is a constant 1-1 function of the input edge,) then the Recursive algorithm need scan every edge only twice. Without input awareness, each edge is scanned exactly 3 times. This was shown by Tayar [9]. Finally, we note that while each of the three algorithms (Simple, Advanced and Recursive) produces an Eulerian cycle, they may produce different cycles (e.g. when applied to the maze shown in Figure 1.)
4
The Simple Algorithm
4.1
The Algorithm
The traversal of the graph is to be performed by a finite-state robot R. The algorithm which governs the behavior of R consists of two mechanisms: The scanning mechanism, which determines the order in which the edges are traversed, and the halting mechanism. 4.1.1
The Scanning Mechanism
In each vertex v there is a scan pebble, initially placed at some arbitrary exit. Each time the robot enters a vertex it finds the scan pebble, moves it forward one position, and exits through the edge where the scan pebble has been. Clearly, the scanning continues indefinitely, unless the halting mechanism stops it. 4.1.2
The Halting Mechanism
For the purpose of deciding when R stops scanning, vertices and exits are marked as follows: • Each vertex has a root flag r. Initially r = 0 at all vertices. The first action by the robot is to mark its initial vertex flag r = 1. Thereafter, no vertex has its r flag changed. • Each vertex also has a status flag, s, which is initially marked NEW. On first visiting a vertex the robot changes s to SEEN. Eventually, the
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002)
162
robot will change each s flag to DONE and thereafter leave it unchanged. Also, on the first visit the robot finds the exit in which the scan pebble is located and puts the start pebble at the same exit. The start pebble is not moved anymore. It helps determine if all exists have been used to leave the vertex. In addition, the robot carries a state bit F . This bit may be U P or DOW N . The initial value of F is DOW N . The meaning of F = U P is that on the present ”phase”, to be defined shortly, all vertices, it has encountered so far, have had all their outgoing edges traversed, at least once. The actions of the robot under the Simple Algorithm are given in Table 1. Lines 3, 5, 7 and 20 perform the scanning mechanism. Lines 1-2, 4, 8-16 and 18-19 perform the halting mechanism. Line 17 defines the end of a phase. The phases are only defined to simplify the proof. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
r←1 s ← SEEN goto exit with scan pebble put start edge pebble at exit move scan pebble to next exit and leave vertex through current exit while TRUE goto exit with scan pebble if s = N EW then do put start edge pebble at exit s ← SEEN if r = 0 then do if s 6= DON E then do F ← DOW N if start edge pebble at next exit then s ← DON E if r = 1 and exit has the start edge pebble then do (end of phase) if F = U P then HALT F ← UP move scan pebble to next exit and leave vertex through current exit
Table 1: The Simple Algorithm
4.2
Validity
The vertex where r = 1 is called the root ρ. Theorem 1 The robot R will halt at the root, ρ, after having traversed all edges of G. This will happen within O(|V | · |E|) edge traversals. In its last |E| edge traversals R makes an Eulerian tour.
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002)
163
Note that upon termination the scan pebbles are not necessarily back in their initial condition. In fact, their position is exactly what has been “learned”. If now the traversal is restarted, with F = U P , R will perform an Eulerian tour and stop, and the scan pebbles will again be in the “learned” position. Proof: Note the definition of a phase, as in Table 1, Line 17. First, let us examine the route of R during the first phase. Clearly, every edge incident with ρ has been traversed exactly once. Furthermore, every edge on the route of the first phase is traversed once only. This is easily proved by induction on the order in which the edges are traversed: When a vertex v 6= r is entered by an edge (traversed for the first time) the number of used incoming edges is one greater than the number of used outgoing edges. Thus, the exit in which the pebble is placed leads to an edge which has not yet been traversed. Note that if during the first phase every incident edge of v 6= ρ has been traversed then v’s s flag is DON E. Other vertices are still flagged N EW or SEEN . However, for every vertex the number of untraversed incoming edges is equal to the number of untraversed outgoing edges. Now consider the second phase. As long as for every vertex v 6= ρ, encountered by R, s = DON E, the route of the second phase is identical to that of the first phase. This follows from the fact that, at the end of the first phase, for ρ and every DON E vertex, the scan pebble is back at the start exit. If not all edges of G have been traversed in the first phase, there must be vertices on the first route for which some of their outgoing edges have not been traversed and such vertices are still flagged SEEN . This follows from the fact that G is strongly connected. If SEEN vertices exist, let v be the first SEEN vertex encountered in the second phase. A new tour starts at v, using only edges untraversed in the first phase, and ending in v. Now v is flagged DON E and its scan pebble is at the start exit. The route of the first phase is resumed. Since every vertex which is still flagged SEEN and which is on the route of the first phase is similarly treated, at the end of the second phase all vertices encountered on the first route are now flagged DON E. Every traversed edge has been traversed exactly once in the second phase, which is the second time for those traversed on the first route. For every phase i > 1, the algorithm maintains the following properties: • While R is traveling through ρ and DON E vertices, it retraces the route of the (i − 1)0 st phase. • If R encounters a SEEN vertex, u, it suspends the retracing of the tour of the (i − 1)0 st phase. A new tour starts at u and ends there. u is now DON E. The tour of the (i − 1)0 st phase is resumed (using the start exit). Thus, every edge it traversed at most once during a phase. • If for every vertex v 6= ρ, which R encounters, v is DON E, then R returns to ρ with F = U P , and halts. During each phase, other than the last and possibly the first, at least one SEEN vertex becomes DON E. Thus, there are at most |V | + 1 phases. Hence, the number of edge traversals is O(|V | · |E|). 2
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002)
5
164
The Generic Algorithm
In order to explain our more efficient algorithm for finding an Eulerian directed cycle in G(V, E), in terms of the number of edge traversals, we describe first a Generic Algorithm. This is a nondeterministic algorithm which deviates from our computational model; i.e. it is not limited to actions performed by a traveling finite automaton. Later on we show how to remove the nondeterminism and run the algorithm by means of a finite automaton which threads the directed graph.
5.1
Definitions
• An edge is new if it has not been traversed yet. It is old otherwise. • A vertex is new if all its outgoing edges are new. It is old otherwise. • An exploration from vertex v is a directed path which starts in v and continues via a new directed edge, as long as there is one. It is assumed that, in each vertex, exits are chosen according to the specified circular order. For convenience, we shall assume that the exits of a vertex v are labeled v.1, v.2, . . . , v.d, where v.1 is the start exit, as we used it in Section 4, d is dout (v) and the exits are numbered according to the specified circular order. Also, we shall use a scan pebble, one per vertex, to be placed at one of the exists.
5.2
The Preparatory Algorithm
Consider Preparatory, as stated in Table 2. choose a vertex ρ run an exploration from ρ while there are old vertices which have new exits do choose such a vertex u run an exploration from u for every vertex v do if only one exploration passed through v then put v’s pebble at the first exit of this exploration else put the pebble at the first exit of the second exploration which passed through v Table 2: Preparatory Note that the first exploration ends at ρ, the vertex at which it started. This observation, like the proof of Euler’s theorem, follows from the fact that
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002)
165
whenever any vertex u, other than ρ, is entered, the number of old incoming edges is greater (by 1) than the number of old outgoing edges, and since din (u) = dout (u), there is at least one new outgoing edge. When the first exploration ends, for every vertex the number of new incoming and outgoing edges is the same, and this invariant holds every time an exploration ends. For every vertex, Preparatory places a pebble at one of its exits. The position of these pebbles is the information learned by running Preparatory.
5.3
The Scan Algorithm
The benefit of the Preparatory Algorithm becomes evident when it is followed by the Scan Algorithm. The Scan Algorithm is similar to the actions taken by R in the last phase of the Simple Algorithm. The pebble is used just as the scan pebble has been used there. However, the locations of the pebbles, when Scan begins, may be different from those of the scan pebbles, when the last phase of Simple starts. Scan halts when exit ρ.1 is about to be used again. The route R takes during Scan is an Eulerian tour. 1 2
c
r 1
3 2 1
1
b
a 2
Figure 1: Example for running Generic The interaction of Preparatory with Scan may seem a bit magical so we demonstrate their action on the example shown in Figure 1. For each vertex, the exits are numbered, and for convenience, all vertices are given names. Assuming ρ = r, the first exploration yields the cycle C1 : r.1, a.1, c.1. Assume the second exploration starts at a; it yields a cycle C2 : a.2, b.1, c.2. Assume the third cycle is C3 : b.2, c.3. Since only one exploration cycle includes r, a pebble is placed on r.1. The other vertices are in more than one exploration so the pebbles are placed at the first edge used by the second exploration, that is, a.2, b.2 and c.2. This completes the operation of Preparatory. Now, during a Scan, the following Eulerian cycle is traversed: r1, a2, b2, c2, a1, c3, b1, c1. Note that the edges of a Preparatory cycle may not be scanned consecutively, and they may even appear in an order different from the order in which they have been traversed in the exploration. Nonetheless, as we show below, Scan will always traverse an Eulerian path.
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002)
166
Lemma 1 In the directed path indicated by Scan, no edge is traversed more than once. Proof: The only exploration which passes through ρ is the first one, and therefore Preparatory places the pebble at exit ρ.1. Scan halts when R is at ρ and the pebble is back at exit ρ.1 when ρ is entered. Thus, every edge out of ρ has been traversed exactly once. e Assume there are edges which R traverses more than once, and let u −→ v be the first such edge on the route of R. By the argument above, u 6= ρ. Since the pebble is moved in a round robin fashion, the number of times R has left u, at the time it traverses e for the second time, is d(u) + 1. R has not started in u and is not at u now. Thus, u must have an incoming edge which R has traversed more than once before traversing e the second time. This contradicts the choice of e. 2 The following simple observation is used in the proofs of the next three lemmas: The exits of every vertex v are used by Preparatory in consecutive order. Exits v.1, v.2, . . . , v.l1 are used in the first exploration which passes through v. Next, v.(l1 + 1), v.(l1 + 2), . . . , v.l2 are used in the second exploration which passes through v, etc. Lemma 2 Let u be a vertex and Ci , i ≥ 1, is the cycle of the first exploration to pass through u. If during Scan, R traverses all edges of Ci which exit from u, then R has traversed all outgoing edges of u. Proof: If all outgoing edges of u belong to one exploration then the claim is trivial. Otherwise, Preparatory places the pebble at the first exit of the second exploration which passes through u. Thus, R has traversed all other outgoing 2 edges of u before it traverses the edges of Ci . Lemma 3 During Scan, R traverses all edges of G. Proof: Consider the cycles traced during Preparatory, and let Ci be the cycle traced in the i-th exploration. Assume there are edges of G which are not traversed by R during Scan, and let Ck be the first cycle to contain such an edge. Let s be the vertex in which the k-th exploration has started (and ended). First, consider the claim that all outgoing edges of s are traversed by R. If k = 1 then the claim follows from the halting condition of Scan. If k > 1 then there are earlier cycles which pass through s, and all outgoing edges of these cycles have been traversed by R. By Lemma 2, all outgoing edges of s have been traversed. This proves the first claim. Now, let us call all edges of Ck , which have been traversed by R, black, and the remaining edges of Ck — red. The edges of other cycles remain colorless. Next, consider the (second) claim that there is a vertex on Ck for which the number of black outgoing edges is greater than the number of black incoming edges. Note that this holds if and only if there is a vertex on Ck for which the number of black outgoing edges is less than the number of black incoming edges.
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002)
167
Clearly, in every vertex the exits to black edges are consecutive, and the red ones succeed the black. Now, let us trace the edges of Ck in the order they have been chosen in Preparatory. According to the first claim, all outgoing edges of s have been traversed by R, and therefore are all black, and thus, the first edge of Ck is e black. Consider the first red edge u −→ v while we trace Ck . Since we have entered u via a black edge, and all our previous entries into u have been via black edges, the number of black incoming edges is an upper bound on the number of times we visited u. All previous exits from u were through black edges, and e is red. Thus, the number of black outgoing edges is less than the number of black incoming edges. This proves the second claim. Assume v is a vertex on Ck which has more black outgoing edges than black incoming edges. If Ck is the first cycle which passes through v then the number of times that R has visited v is equal to the number of black outgoing edges, plus the number of colorless outgoing edges; these belong to later cycles, and they have all been traversed by R. This follows from the fact that the pebble has been put, by Preparatory, at the first such exit, and all these exits have been used, by R, before the exits of Ck , while at least one black edge exists. Note that the number of entries by R, when it leaves through the last black outgoing edge, is equal to the number of departures. Also note that the number of colorless incoming edges is equal to the number of colorless outgoing edges and that no edge is traversed more than once (Lemma 1). It follows that the number of black incoming edges must be greater than or equal to the number of black outgoing edges. A contradiction. If Ck is not the first cycle which passes through v, then the choice of Ck and Lemma 2 imply that all outgoing edges have been traversed by R, and therefore all incoming edges of u have been traversed as well. Therefore the number of black incoming edges is equal to the number of black outgoing outgoing edges. A contradiction. It follows that every edge is traversed by R. 2 Theorem 2 The robot R, moving according to algorithm Scan, traverses an Eulerian cycle. Proof: By Lemma 1 no edge is traversed more than once, and by Lemma 3, every edge is traversed. 2 Note that after Scan halts, the pebbles are back where Preparatory had put them.
6
The Advanced Algorithm
In this section we describe an algorithm in which the operation of Preparatory is performed by a traveling robot R, whose control is a finite automaton. This new algorithm will ensure that a pebble is placed on edges in a manner consistent
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002)
168
with Preparatory. In total four pebbles are used (equivalently, the amount of memory required in each vertex v is 4 log d(v)+O(1)), and each edge is traversed 3 times. Each vertex has four pebbles, named start-edge, explore, retrace and scan. It is assumed that all four pebbles are initially placed at the same exit. The start-edge pebble will never move. Thus, in what follows, only the movements of the other three pebbles will be discussed. In addition to the root flag, which marks the initial vertex ρ (whose placement will not be discussed any further), there are two more flags stored in each vertex v: • The flag visited indicates the number of cycles (explorations) which have passed through v; its value is 0, 1, or 2. Initially visited = 0. If its value is 2 then there are at least two cycles which have passed through v. • The flag seen indicates if v has previously been passed in the current cycle (exploration). Initially, seen = 0, and when R reaches v for the first time during the current exploration, it changes the flag seen to 1. Once all edges of an exploration are found, R retraces the cycle and assigns all seen flags on the cycle to be 0 again. Thus, the seen flag of a vertex v is changed to 1, and back to 0, as many times as there are cycles which pass through it. The main procedure, which governs the actions of R, is create-euleriancycle; see Table 3. It employs two subroutines, explore (Table 4) and retrace (Table 5). Also, we use the macro: • exit(X-pebble): R exits the vertex it is at via the exit in which the X-pebble is located now, but first it moves the X-pebble to the next exit, in a round-robin fashion.
6.1
The Explore Subroutine
Subroutine explore is activated in order to perform an exploration. If seen = 0 then the current vertex is visited during this exploration for the first time. If in addition, visited = 1 then the running exploration is not the first to pass through the current vertex, and the scan-pebble is moved to the exit where the explore-pebble is at; which is the first exit of the second exploration to pass through the vertex. If visited < 2 then it is incremented. Now seen is set to 1. R leaves the current vertex through the exit indicated by the explore-pebble, not before moving it to the next exit, in a round robin fashion. If seen = 1 then inquire whether all outgoing edges of the current vertex have been explored; this is done by checking if the explore-pebble is back where the start-pebble is at. If so, R is back at the vertex where the exploration has started and the subroutine is terminated. Otherwise, there are still unexplored outgoing edges and the exploration continues.
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002)
1 2 3 4 5 6 7 8
call explore call retrace repeat exit(scan-pebble) if explore-pebble not at start-edge then do call explore call retrace until R is at ρ and scan-pebble is at start-edge
Table 3: Procedure create-eulerian-cycle
while TRUE if seen = 0 then do if visited = 1 then put scan-pebble at explore-pebble’s exit if visited < 2 then visited ← visited + 1 seen ← 1 exit(explore-pebble) elsif explore-pebble at start-edge pebble then EXIT explore subroutine else exit(explore-pebble) Table 4: Subroutine explore while seen = 1 or retrace-pebble not at start-edge do seen ← 0 exit(retrace-pebble) Table 5: Subroutine retrace
169
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002)
6.2
170
The Retrace subroutine
Subroutine retrace is activated after an exploration cycle is found. Its purpose is to reset all seen flags of the vertices of the newly found cycle to 0. This is done as follows. If seen = 0 and the retrace-pebble is at the start-edge, then all edges of the new cycle have been retraced and retrace halts. The halting condition can occur only at the vertex where the exploration has started and all exits of that cycle have been retraced. In every encountered vertex seen is set to 0, whatever its value has been.
6.3
The Create-Eulerian-Cycle Procedure
We shall refer to lines 3,4 and 8 of Table 3 as the Scan behavior. Procedure create-eulerian-cycle uses explore and retrace to perform a deterministic version of Preparatory. R starts an exploration from ρ, first performing explore and then retrace. Now it is back at ρ, while all three pebbles are at the start-edge. R behaves now as Scan, advancing the scanpebble only, but this behavior is stopped when R hits a vertex v which has new outgoing edges; this is detected by the fact that the exit where the explorepebble is at is not at the start-edge. When this happens, R suspends the Scan behavior. It performs an exploration from v, again by first running explore and then retrace. While doing that, the scan-pebble of every vertex encountered on this cycle is moved from its start-edge to the first exit of the new exploration if the present exploration is the second to pass through that vertex. When retrace terminates, R resumes the Scan behavior. It is easy to see that create-eulerian-cycle causes R to place the scanpebbles in accord with Preparatory, and when R uses the exits where the scanpebbles are at, it traverses every edge once. When create-eulerian-cycle terminates, the scan-pebbles are back where Preparatory could have placed them. Thus, at that time, one can use Scan behavior to traverse an Eulerian cycle.
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002)
171
References [1] Y. Afek and E. Gafni, Distributed Algorithms for Unidirectional Networks, SIAM J. Comput., Vol. 23, No. 6, 1994, pp. 1152-1178. [2] S. Albers and M.R. Henzinger, Exploring Unknown Environments, SIAM J. Comput., Vol. 29, No. 4, 2000, pp. 1164-1188. [3] M. Blum and W.J. Sakoda, On the Capability of Finite Automata in 2 and 3 Dimensional Space. In Proceeding of the Eighteenth Annual Symposium on Foundations of Computer Science, 1977. pp. 147-161. [4] X. Deng and C.H. Papadimitriou, Exploring an Unknown Graph, J. of Graph Th., Vol. 32, No. 3, 1999, pp. 265-297. [5] S. Even, Graph Algorithms, Computer Science press, 1979. [6] S. Even, A. Litman and P. Winkler, Computing with Snakes in Directed Networks of Automata. J. of Algorithms, Vol. 24, 1997, pp. 158-170. [7] A. Hemmerling, Labyrinth Problems; Labyrinth-Searching Abilities of Automata, Teubner-Texte zur Mathematik, Band 114, 1989. [8] M.O. Rabin, Maze Threading Automata. An unpublished lecture presented at MIT and UC Berkeley, 1967. [9] R. Tayar, Scanning Directed Eulerian Mazes by a Finite-State Robot, Master thesis, Computer Science Department, Technion — Israel Inst. of Tech., Haifa, Israel. Sep. 2000, 31 pages.
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002)
172
Appendix: The Simple Algorithm — Lower bounds and a comparison with depth first techniques Let us show that, in a certain sense, the upper bound on edge traversals, i.e. O(|V | · |E|), is tight for the Simple Algorithm. And yet, there are some cases in which the Simple Algorithm performs significantly better than any depth-first search algorithm. We present two examples of graphs, one sparse and one dense, for which the Simple Algorithm reaches its upper bound for edge traversals. As our sparse example, we consider a simple chain, as shown in Figure 2. The start exit of every vertex is labeled 1. 1
2
1
1
2
2
1
2
3
1
n-1
1
n
Figure 2: A simple chain Let us denote by fs (n) the number of edge traversals until every edge is traversed, when the initial vertex is vertex No. 1. The last edge to be discovered is the edge from vertex n to vertex n − 1. Clearly, fs (2) = 2 and fs (n + 1) = fs (n) + 2n − 1. Thus, fs (n) = n2 − 2n + 2. It follows that in this case, the bound of O(|V | · |E|) is tight. As our dense graph example, consider the following directed graph Gp (V, E), where p is an odd prime. V = {0, 1, . . . , 2p − 1}, The set of directed edges consists of two types: • body 4 For every two vertices, i, j < p, let δ(i, j) = j − i mod(p); i.e. 0 ≤ δ(i, j) < p. If δ(i, j) < p2 then there is an edge i −→ j, and the exit at i is labeled δ(i, j). • tail – There is an edge 0 −→ p labeled
p+1 2 .
– For every p ≤ i < 2p − 1 there is an edge i −→ i + 1, labeled 2. – For every p < i ≤ 2p − 1 there is an edge i −→ i − 1, labeled 1. – There is an edge p −→ 0 labeled 1.
S. Bhatt et al., Traversing Eulerian Mazes, JGAA, 6(2) 157–173 (2002) 2
2
2
173
2
3 5
6 1
1
8 1
9 1
1
0
1
1
2 2
4
7
1 2
2
1
1
2 3
2 1
Figure 3: G5 The case of G5 is shown in Figure 3. Note that according to the Simple Algorithm, starting in vertex 0, R scans edges of the body; i.e. the edges between vertices whose name is less all p(p−1) 2 than p, before it takes the edge to p. In fact, every time R returns to vertex 0, via the edge from p, it repeats the scan of all edges of the body. This will occur p times. Thus the tour, until the last edge (from 2p − 1 to 2p − 2) is discovered, is of length p(p − 1) + p2 − 2p + 2. p· 2 Again, this is of the order |V | · |E|. We now present two examples in which the Simple Algorithm is superior to any DFS algorithm. The first example is a directed cycle, with a self-loop in every vertex, where exit No. 2 leads to its self-loop. R visits all vertices in the first phase and thus, performs an Eulerian tour on the second phase. The edge traversal complexity is O(|V |). However, if we execute any DFS based algorithm on the same graph, R has to make Ω(|V |2 ) edge traversals. The second example is the case of a complete directed graph of n vertices; namely for every two vertices a and b there is an edge a −→ b. In the first phase all vertices are visited, since the root has an edge to every other vertex. Therefore, all edges not traversed in the first phase are traversed in the second, and the third phase is the last phase. Thus, the total number of edge traversals is O(|V |2 ). However, if one applies a DFS based algorithm, it takes Ω(|V |3 ) steps. (The DFS tree is a directed path of length |V | − 1, and each time a backedge is traversed, the tree must be traversed again, at least up to the parent of the start vertex of the back-edge.).
Journal of Graph Algorithms and Applications http://jgaa.info/ vol. 6, no. 3, pp. 177–178 (2002)
Special Issue on Selected Papers from the 8th International Symposium on Graph Drawing, GD’00 Guest Editor’s Foreword Michael Kaufmann Wilhelm-Schickard-Institut f¨ ur Informatik Universit¨at T¨ ubingen 72076 T¨ ubingen, Germany http://www-pr.informatik.uni-tuebingen.de [email protected]
M. Kaufmann, Foreword , JGAA, 6(3) 177–178 (2002)
178
It is becoming a nice tradition and add-on to the Symposium on Graph Drawing to invite a selection of papers to be included in a special issue of Journal of Graph Algorithms and Applications. After a more theory-oriented special issue for GD’99, I decided to emphasize application-oriented papers. A highlight of GD’00 was the simultaneous submission of three independent papers about spring embedder methods for large graphs. Two of them are included here: a detailed report by Harel and Koren, describing the basis of their multiscale method, and an article by Gajer and Kobourov about the system and the experiments that they conduct to show the effectiveness of their algorithm. Two other papers on related topics in this issue are those by Bridgeman and Tamassia and by Purchase, who derive quality measures and the evaluation of quality measures for different types of drawings. This topic is related to information visualization. Further, two papers on drawing algorithms for specific applications are included in this issue. The first paper, by Tollis et al., deals with the drawing of state chart diagrams using floorplanning methods from VLSI, while the second paper, by Carmignani et al., describes HERMES, a tool for the visualization of web structures. Their method is based on extension of bend-minimization algorithms for orthogonal drawings. Finally, Friedrich presents a nice methodology that describes how one can avoid occlusion and more general confusion when morphing structures from one drawing into another (animation). This special issue indicates in a way the diversity of the graph drawing field: the emphasis here lies on practicability and applicability, and less on algorithmics. Only the first two papers contain new algorithms, the other papers contain either extensions of existing methods or no algorithmics at all.
July, 2002
Michael Kaufmann
Journal of Graph Algorithms and Applications http://jgaa.info/ vol. 6, no. 3, pp. 179–202 (2002)
A Fast Multi-Scale Method for Drawing Large Graphs David Harel
Yehuda Koren
Dept. of Computer Science and Applied Mathematics The Weizmann Institute of Science, Rehovot, Israel http://www.wisdom.weizmann.ac.il/ [email protected] [email protected] Abstract We present a multi-scale layout algorithm for the aesthetic drawing of undirected graphs with straight-line edges. The algorithm is extremely fast, and is capable of drawing graphs that are substantially larger than those we have encountered in prior work. For example, the paper contains a drawing of a graph with over 15,000 vertices. Also we achieve “nice” drawings of 1000 vertex graphs in about 1 second. The proposed algorithm embodies a new multi-scale scheme for drawing graphs, which was motivated by the earlier multi-scale algorithm of Hadany and Harel [HH99]. In principle, it could significantly improve the speed of essentially any force-directed method (regardless of that method’s ability of drawing weighted graphs or the continuity of its cost-function).
Communicated by Michael Kaufmann: submitted February 2001; revised December 2001 and June 2002.
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)180
1
Introduction
A graph G(V, E) is an abstract structure that is used to model a relation E over a set V of entities. Graph drawing is a conventional tool for the visualization of relational information, and its usefulness depends on its readability, that is, the capability of conveying the meaning of the diagram quickly and clearly. In recent years, many algorithms for drawing graphs automatically were proposed (the state of the art is surveyed comprehensively in [Di+ 99, KW01]). We concentrate on the problem of drawing an undirected graph with straightline edges. In this case the problem reduces to that of positioning the vertices by determining a mapping L : V −→ R2 . A popular generic approach to this problem is the force-directed technique, which introduces a heuristic cost function (an energy) of the mapping L, which (hopefully) achieves its minimum when the layout is nice. Variants of this approach differ in the definition of the energy, and in the optimization method that finds its minimum. Some known algorithms are those of [Ea84, KK89, DH89, FR91]. Major advantages of forcedirected methods are their relatively simple implementation and their flexibility (heuristic improvements are easily added), but there are some problems with them too. One severe problem is the difficulty of minimizing the energy function when dealing with large graphs. The above methods focus on graphs of up to 100 vertices. For larger graphs the convergence to a minimum, if possible at all, is very slow. We propose a new method for drawing graphs that could in principle improve the speed of every force-directed method. We build our algorithm around the Kamada-Kawai method, and the resulting algorithm, which is extremely fast, is capable of drawing graphs that are substantially larger than those we have encountered in prior work (although subsequent developments are reviewed in Section 6). The algorithm, which was motivated by the earlier multi-scale algorithm of Hadany and Harel [HH99], works by producing a sequence of improved approximations of the final layout. Each approximation allows vertices to deviate from their final place by an extent limited by a decreasing constant r. As a result, the layout can be computed using increasingly coarse representations of the graph, where closely drawn vertices are collapsed into a single vertex. Each layout in the sequence is generated very rapidly, by performing a local beautification on the previously generated layout.
2
Force-Directed Graph Drawing
The force-directed approach is apparently the prevalent attitude for drawing general graphs. Algorithms based on this approach consist of two components. The first is the force (or energy) model that quantifies the quality of a drawing. The second is an optimization algorithm for computing a drawing that is locally optimal with respect to this model. The resulting final layout brings the system to equilibrium, where the total force on each vertex is zero, or equivalently, the potential energy is locally minimal with respect to the vertex positions. Regard-
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)181 ing the drawing standard, force-directed methods draw the edges as straight-line segments, so the whole issue reduces to the problem of positioning the vertices. In this section we outline some notable work on force-directed graph drawing.
2.1
The Spring Embedder Method
The spring embedder method is the earliest viable algorithm for drawing general graphs. It was proposed by Eades [Ea84], and was later refined by Fruchterman and Reingold [FR91]. This method likens a graph to a mechanical collection of electrical charged rings (the vertices) and connecting springs (the edges). Every two vertices reject each other by a repulsive force and adjacent vertices (connected by an edge) are pulled together by an attractive force. The method seeks equilibrium of these conflicting constraints. Spring based methods are very successful with small-sized graphs of up to around 50 vertices. Regarding the optimization algorithm, we describe the method of [FR91]. A predetermined number of sweeps is performed. In each sweep every vertex is moved in the direction of the total force exerted on it. The extent of the movement is determined by a global cooling schedule that restricts the distance a vertex can move as a decreasing function of the sweep number. Frick et al. [Fr+ 94] have suggested several improvements on this scheme, the most notable of which is a local cooling schedule, resulting in a different extent of movement for each vertex according to its temperature. They show graphs of size 256. More recently, Tunkelang [Tu99] suggested several other refinements to the optimization method. One is to approximate the effect of many distant repulsive forces as being exerted by a single vertex using a quad-tree, in the spirit of the Barnes-Hut method [BH86]. Another improvement is the use of the ConjugateGradient method for decreasing the energy. Tunkelang dealt with 1000-vertex graphs, drawn in 5-10 minutes.
2.2
Kamada and Kawai’s Method
Kamada and Kawai [KK89] modelled a graph as a system of springs that act in accordance with Hooke’s Law: Every two vertices are connected by a spring, whose rest length is proportional to the graph-theoretic distance between its two endpoints, and its stiffness is inversely proportional to the square of its rest length. The optimization procedure tries to minimize the total energy of the system, that is: X 1 (l(u, v) − Lduv )2 E= d2uv v,u∈V
where l(u, v) is the length of the spring between u and v, L is the length of a single edge, and duv is the graph-theoretic distance between u and v. Kamada and Kawai’s method treats all the aesthetic criteria that the springembedder method addresses, and produces drawings with a similar quality. An advantage of this method is that it can be applied straightforwardly to drawing edge-weighted graphs, assuming that edge lengths have to reflect their weights.
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)182
2.3
Hadany and Harel’s Multi-Scale Algorithm
The multi-scale approach proposed by Hadany and Harel [HH99] is an improvement of the force-directed technique, which facilitates the drawing of larger graphs. The main idea of this method is to consider a series of abstractions of the graph called coarse graphs, in which the combinatorial structure is significantly simplified, but important topological features are well preserved. The energy minimization is divided between these coarse graphs, in such a way that globally related properties are optimized on coarser graphs, while locally related properties are optimized on finer graphs. As a result, the energy minimization process considers only small neighborhoods at once, yielding a quick running time. The scheme of the algorithm is a recursive repetition of: 1. Perform fine-scale relocations of vertices that yield a locally organized configuration. 2. Perform coarse-scale relocations (through local relocations in the coarse representations) correcting global disorders not found in stage (1). 3. Perform fine-scale relocations that correct local disorders introduced by stage (2). All actual local relocations are carried out in [HH99] by minimizing the energy defined in [KK89] using simple gradient-descent. The coarsening step is done in a pre-processing stage by contracting edges that minimize a convex combination of three objectives (in a greedy fashion): • The cluster number : The number of original vertices forming the new vertex. • The degree number : The degree of the vertices forming the new vertex in the current abstraction of the graph. • The homotopic number : The number of vertices (in the coarse graph) that are adjacent to both the vertices forming the edge. The algorithm produces good results on large graphs containing hundreds of vertices, in a reasonable time. In this paper we continue the multi-scale approach of Hadany and Harel [HH99], and introduce a simpler and much faster algorithm which produces better drawings.
3
Multi-Scale Graph Drawing
The intuition of [HH99] for beauty in graph layout is that the graph should be nice on all scales. In other words the drawing should be nice at both the micro level and the macro level. Relying only on this intuition, we will formalize the notion of scale relevant to the graph drawing problem. The crucial observation
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)183 is that global aesthetics refer to phenomena that are related to large areas of the picture, disregarding its micro structure, which has only a minor impact on the global issue of beauty. On the other hand, local aesthetics refer to phenomena that are limited to small areas of the drawing. Following this line of thinking, we will construct a coarse scale of a drawing by shrinking nodes that are drawn close to each other, into a single node, obtaining a new drawing that eliminates many local details but preserves the global structure of the original drawing. An alternative view of our notion of coarsening is as an approximation of a nice layout. This approximation allows vertices to deviate from their final position by an amount limited to some constant r. As a consequence, we can unify all the vertices whose final location lies within a circle of radius r, and thus obtain the coarse scale representation. Our presentation of the drawing scheme is preceded by some definitions: Definition 3.1 A layout of a graph G(V, E) is a mapping of the vertices to the Euclidean space: LG : V −→ R2 . We often omit the subscript G . For simplicity, we assume that there is a single optimal layout with respect to fixed set of aesthetic criteria accepted in force-directed algorithms. We term this layout nice. The nice layout of G is denoted by L∗G , or simply L∗ . Definition 3.2 L is a locally nice layout of G(V, E) with respect to r, if the intersection of L(V ) with every circle of radius r induces a nice layout of the appropriate subgraph of G. Definition 3.3 L is a globally nice layout of G(V, E) with respect to r if max{|L(v) − L∗ (v)|} < r v∈V
Definition 3.4 A locality preserving k-clustering (a k-lpc for short) of G(V, E) with respect to r is the weighted graph G({V1 , V2 , . . . , Vk }, E 0 , w), where: V = V1 ∪ V2 · · · ∪ Vk ,
∀i 6= j : Vi ∩ Vj = ∅
0
E = { (Vi , Vj ) | ∃(vi , vj ) ∈ E ∧ vi ∈ Vi ∧ vj ∈ Vj } X 1 dvu , ∀(Vi ,Vj )∈E 0 w(Vi , Vj ) = |Vi ||Vj | v∈Vi ,u∈Vj
(dvu is the shortest distance between u and v in G) and for every i: max {|L∗ (v) − L∗ (u)|} < r
v,u∈Vi
i.e., all the vertices in one cluster are drawn relatively close in the nice layout. We sometimes call the vertices of a k-lpc clusters.
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)184 At first glance, this definition seems to be of a little practical value, as it refers to the unknown nice layout L∗ . We will discuss this important point in the next section. Definition 3.5 A multi-scale representation of a graph G(V, E) is a sequence of graphs Gk1 , Gk2 , . . . , Gkl , where k1 < k2 < · · · < kl = |V |, and for all 1 6 i 6 l : Gki is a locality preserving ki -clustering of G(V, E) with respect to ri , where r1 > r2 > · · · > rl = 0. Remark: We naturally assume that in a nice layout of an edge-weighted graph, the lengths of the edges have to reflect their weights. Our method relies on the ease of drawing graphs with a small number of vertices and on the following two assumptions, which formalize what we think to be amenability to multi-scale aesthetics — independence between global and local aesthetics. Assumption 3.1 Let Gr be k-lpc of a graph G with respect to r, and let rˆ > r. L is a globally nice layout of Gr with respect to rˆ if and only if L is a globally nice layout of G with respect to rˆ. (In G, we take L(v) = L(Vi ) for each v ∈ Vi ). Corollary: If L is a nice layout of a k-lpc of a graph G with respect to r then L is a globally nice layout of G with respect to r. The intuition of Assumption 3.1 is that global aesthetics is independent of the micro structure of the graph, so the differences between the layouts of Gr and of G are bounded with r. Assumption 3.2 If L is both a locally and a globally nice layout of a graph G with respect to r, then it is a nice layout of G. Now we present the multi-scale drawing scheme, which draws a graph by producing a sequence of improved approximations of the final layout.
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)185 The Multi-Scale Drawing Scheme 1. Place the vertices of G randomly in the drawing area. 2. Choose an adequate decreasing sequence of radiuses ∞ = r0 > r1 > r2 > · · · > rl = 0. 3. for i=1 to l do 3.1 Choose an appropriate value of ki , and construct Gki , a ki -lpc of G w.r.t. ri . 3.2 Place each vertex of Gki at the (weighted) location of the vertices of G that constitute it. 3.3 Locally beautify local neighborhoods of Gki . 3.4 Place each vertex of G at the location of its cluster (i.e., the vertex in Gki ). 4. end The viability of the scheme stems from the following observations: 1. In the first iteration, after step 3.3, we should have a nice layout of Gk1 . To guarantee this, the value of r1 has to be large enough so that the resulting Gk1 will be small and can be easily drawn nicely. 2. Step 3.3 should yield a locally nice layout of Gki w.r.t. ri−1 . To guarantee this, we have to choose large enough neighborhood. 3. At the beginning of iteration i, we have a globally nice layout of Gki w.r.t. ri−1 . Hence, by Assumption 3.2, after step 3.4 we have a nice layout of Gki . This layout is a globally nice layout of Gki+1 w.r.t. ri , by Assumption 3.1. We remark that the choice of the multi-scale representation can be based upon either the decreasing sequence r1 , . . . , rl = 0 (as described above) or the increasing sequence k1 , . . . , kl = |V | (as we have done in our implementation). In Definition 3.4 we added weights to the edges of the k-lpc in order to retain the size proportions of G, which is necessary for making Assumption 3.1 valid. However, in practice, we conjecture that our scheme works well even without weighting the edges of the k-lpc, when using some variants of the springembedder method (e.g., those of [Ea84] and [FR91]) as the local beatification method. The reason for this is that such methods benefit significantly from the better initialization, which, while not capturing the final size of the graph, often solves many large scale conflicts correctly.
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)186
4
The New Algorithm
In order to implement a multi-scale graph drawing algorithm based on the scheme of Section 3, we have to further elaborate on two points: (1) how to find the multi-scale representation of a graph (line 3.1 of the scheme), and (2) how to devise a locally nice layout (line 3.3 of the scheme).
4.1
Finding a Multi-Scale Representation
In order to construct a multi-scale representation of a graph G based on Definition 3.5, we must find a k-lpc of G, in it vertices that are drawn close in the nice layout should be grouped together. The important question is: How can we know which vertices will be close in the final picture, if we still do not know what the final picture looks like? 1 Luckily we do have a heuristic that can help decide which vertices will be drawn closely. Moreover, this key decision can be made very rapidly, and is a major reason for the fast running time of our algorithm. The heuristic is based on the observation that a nice layout of the graph should convey visually the relational information that the graph represents, so vertices that are closely related in the graph (i.e., the graph theoretic distance is small) should be drawn close together. This heuristic is very conservative, and all the force directed drawing algorithms use it heavily. Employing this heuristic, we can approximate a k-lpc of G by using an algorithm for the well known k-clustering problem. In this problem we wish to partition V into k clusters so that the longest graph-theoretic distance between two vertices in the same cluster is minimized. In reality, we would like to identify every vertex in the cluster with a single vertex that approximates the barycenter of the cluster. Hence we use a solution to the closely related k-center problem, where we want to choose k vertices of V , such that the longest distance from V to these k centers is minimized. These fundamental problems arise in many areas and have been widely investigated in several papers (see e.g., [Go85] and [HS86]). Unfortunately, both problems are NP-hard, and it has been shown in [Go85] and [HS86] that unless P=NP there does not exist a (2−)-approximation algorithm for any fixed > 0.2 Nevertheless, there are various fast and simple 2-approximation algorithms for these problems. We will approximate a k-lpc as the solution to the k-center problem, adopting a 2-approximation method mentioned in [Ho96]: 1 What
is needed is only a sufficient (even if not necessary) condition that vertices are close. δ-approximation algorithm delivers an approximate solution guaranteed to be within a constant factor δ of the optimal solution. 2A
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)187 K-Centers (G(V, E) ,k)
% Goal: Find a set S ⊆ V of size k, such that maxv∈V mins∈S {dsv } is minimized.
S ← {v} for some arbitrary v ∈ V for i = 2 to k do 1. Find the vertex u farthest away from S (i.e., such that mins∈S {dus } > mins∈S {dws }, ∀w ∈ V ) 2. S ← S ∪ {u} return S
Complexity: Line 1 can be carried out in time Θ(|E|) by BFS. In our case, it can be done faster, since, as we shall see, we already have the all-pairs shortest path length (APSP) at our hands (it is needed for the local beautification). Utilizing this fact and memorizing the current distance of every vertex from S, we can implement line 1 in time Θ(|V |), yielding a total time complexity of Θ(k|V |) (without the APSP computation).
4.2
Local Beautification
We have chosen to use a variant of the Kamada and Kawai method [KK89] as our local drawing method. We found it to be very appropriate, because it relates every pair of vertices, so, when constructing a new coarse representation of the graph, we do not have to define which pairs of vertices are connected by an edge. Notice that this property of the Kamada and Kawai method has a price: it forces us to waste Θ(|V |2 ) memory, even when the graph is sparse. Another advantage of the Kamada and Kawai method is that it can deal directly with weighted graphs, which is convenient in our case since the multi-scale representation of a graph contains weighted graphs. The Energy Function: We consider the graph G(V, E), where each vertex v is mapped by the layout L into a point in the plane L(v) with coordinates (xv , yv ). The distance duv is defined as the length of the shortest path in G between u and v. We define the k-neighborhood of v to be: N k (v) = {u ∈ V | 0 6 duv < k}. In order to find a layout with aesthetically pleasing k-neighborhoods, we use an energy function that relates the graph theoretic distance between vertices in the graph to the Euclidean distance between them in the drawing, and is defined as follows: X X kuv (kL(u) − L(v)k − lduv )2 Ek = v∈V u∈N k (v)
where l is the length of a single edge, kL(u)−L(v)k is the Euclidean distance 1 between L(u) and L(v), and kuv is a weighting constant that can be either duv 1 or d2 . uv The energy represents the normalized mean squared error between the Euclidean distance of vertices in the picture and the graph-theoretic distance. Only pairs in the same k-neighborhood are considered.
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)188 Local Minimization of the Energy: Our purpose is to find a layout that brings the energy Ek to a local minimum. The necessary condition of a local minimum is as follows: ∂Ek ∂Ek = = 0, ∂xv ∂yv
∀v ∈ V
To achieve this condition we iteratively choose the vertex that has the largest value of ∆kv , which is defined as: s ∂Ek 2 ∂Ek 2 k ) +( ) ∆v = ( ∂xv ∂yv and move this vertex, v, by the amount of δvk = (δvk (x), δvk (y)). The computation of δvk is carried out by viewing Ek as a function of only L(v) = (xv , yv ), and the use of a two-dimensional Newton-Raphson method. As a result, the unknowns δvk (x) and δvk (y) are found by solving the following pair of linear equations: ∂ 2 Ek k ∂Ek ∂ 2 Ek k δ (x) + δv (y) = − v 2 ∂xv ∂xv ∂yv ∂xv ∂ 2 Ek k ∂Ek ∂ 2 Ek k δ (x) + δ (y) = − ∂yv ∂xv v ∂yv2 v ∂yv The interested reader can find further details in [KK89]. Algorithms for Locally Nice Layout The following algorithm, which is based on [LSD] and as mentioned in [Br+ 95], is a modification of [KK89]. The algorithm computes a nice layout of every k-neighborhood of a graph: LocalLayout(dV ×V , L, k, Iterations) % Goal: Find a locally nice layout L by beautifying k-neighborhoods % dV ×V : all-pairs shortest path length % L: initialized layout % k: radius of neighborhoods
for i = 1 to Iterations · |V | do 1. Choose the vertex v with the maximal ∆kv 2. Compute δvk by solving the above mentioned equations 3. L(v) ← L(v) + (δvk (x), δvk (y)) end A typical value of the parameter Iterations is 4. Complexity: An efficient implementation of line 1 is by storing the first derivatives of Ek in a binary heap, sorted by the values of ∆kv . (After the
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)189 movement of each vertex v, the first derivatives of vertices in N k (v) are updated.) Hence, the computation time of line 1 is Θ(log |V |). The computation time of δvk (line 2) is Θ(|N k (v)|), which is a constant for a bounded degree graph. These computations are carried out Iterations · |V | times, so the overall time complexity for a bounded degree graph is Θ(|V | log |V |). This algorithm differs from the one of Kamada and Kawai [KK89] in its single loop structure, and in the use of a predefined number of iterations, instead of basing termination on the value of ∆kv . This results in much faster termination when dealing with large graphs. We recommend this as an improvement (in a stand-alone sense) of the Kamada and Kawai method. We have tested it and have found it far superior for larger graphs. The recommended value of Iterations when running this algorithm as a stand alone (not as a part of the multi-scale algorithm) is 10, at least. Performance can be improved by executing most of the iterations (the first ones) without choosing the vertex with the largest value of ∆kv , but iterating through all the vertices in some order.
4.3
The Multi-Scale Drawing Algorithm
We now describe the full algorithm: LayoutG(V, E) % Goal: Find L, a nice layout of G % Constants: % Rad[= 7] — determines radius of local neighborhoods % Iterations[= 4] — determines number of iterations in local beautification % Ratio[= 3] — ratio between number of vertices in two consecutive levels % M inSize[= 10] — size of the coarsest graph
Compute the all-pairs shortest path length: dV ×V Set up a random layout L k ← M inSize while k 6 |V | do centers ← K-Centers(G(V, E) ,k) radius = maxv∈centers minu∈centers {dvu } · Rad LocalLayout (dcenters×centers , L(centers),radius,Iterations) for every v ∈ V do L(v) ← L(center(v)) + rand k ← k · Ratio return L Comments: Inside the for-loop, the call center(v) returns the center that is closest to v. We add a small random noise (0, 0) < rand < (1, 1), because our local beautification algorithm performs badly when the vertices are initialized to the same point. One might try to improve the global aesthetics by iteratively repeating the body of the while-loop (for each fixed k) a number of times that | decreases with k (e.g., |V |k| times).
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)190 Complexity: The overall asymptotical complexity is determined by the computation of the all-pairs shortest path length (APSP) (line 1), which we implemented by initiating a BFS from every vertex. It thus takes time Θ(|V ||E|). Experimental running times are given in Table 1. The space complexity is Θ(|V |2 ), since we have to memorize the all-pairs shortest path length matrix.
5
Examples
This section contains examples of the results of our algorithm. The implementation is in C++, and runs on a Pentium III 1GHz PC. Table 1 gives the actual running times of the algorithm on the graphs given here. We should mention that our implementation is far from being efficient, and an optimized version will probably do better. For all the executions, we have used the default parameters: Iterations = 4, Ratio = 3, M inSize = 10. Regarding, Rad, its default value – 7 was sufficient for achieving reasonable results for all the graphs, except the full binary tree. However, we have found for several graphs, that we can get “smoother” results when increasing Rad. Hence, for these graphs we give also results with Rad > 7, as indicated in the table. As can be seen in the table, almost all the running time is dedicated for computing the all-pairs shortest path length (APSP), and for performing local beautification. The layouts shown in Figures 1–3 demonstrate applying our algorithm to regular graphs. We were particularly happy with the graphs in Figures 4 and 5, since the “correct” (grid or torus) appearance is retained despite the partiality of information available to the algorithms. Drawing the full binary trees in Figure 6 was harder. Force-directed methods behave better on bi-connected graphs, since there are forces that work in many ways and directions. They perform quite badly on trees. Our method succeeded in finding a nice layout of the trees only when it considered the entire graph as one in its “local” beautification stages. The problem is that the local beautification scheme is based only on neighborhoods in the graph-theoretic sense, but in deep kinds of trees, leaves should show up close to each other even if they are far apart in the graph-theoretic sense. We mention that even in laying out full binary trees our method has two advantages when compared to Kamada and Kawai’s method [KK89]. First, its running time is still faster; about 5sec for a 1023-vertex tree, compared with 15sec of Kamada-Kawai’s method (implemented efficiently, as discussed in Section 4.2), on account of the relatively few beautification iterations. Second, the resulting picture (Figure 6(a)) is almost planar and has no global distortions, in contrast to Kamada-Kawai’s method, which will be trapped in many local minima, and will always result in many edge crossings (see Figure 6(c)). Figure 7, which is a grid with some of the horizontal edges removed, illustrates a similar problem. In Figure 7(a), we set things up so that the local beautification procedure considered larger than regular neighborhoods, as this is the only way to take into account together the vertices of two consecutive “lines” to make the resulting picture planar. On the other hand, since in Figure
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)191
Graph Name
|V|
|E|
Rad
1(b)
1024 3025 6400 10000 6400
1984 5940 12640 19800 12642
2(a)
1024
2048
2(b)
6400
12800
3
9843
19683
4(b)
6400
5(b)
9480
7 7 7 7 7 20 7 15 7 15 7 15 7
APSP time 0.3 1.45 12.11 38.27 12.11 12.11 0.3 0.3 12.13 12.13 39.36 39.36 12.58
Beautification time 0.7 4.11 15.153 35.11 15.34 34.81 0.81 1.94 15.6 27.06 29.39 38.59 13.75
Overall time 1.08 5.87 29.39 76.22 29.16 49.22 1.16 2.28 29.57 41.27 71.45 80.83 28.11
1600
2133
7
0.42
1.41
2.02
6
1023
1022
7
3025
5156
3elt
8
4720
13722
Crack 4elt
10 9
10240 15606
30380 45878
16 18 7 35 7 20 7 7 20
0.13 0.13 1.41 1.41 6.13 6.13 49.61 129.98 129.98
3.59 4.72 3.85 20.31 10.28 31.75 22.05 143.67 236.33
3.73 4.88 5.56 22.04 17.73 39.71 73.34 285.45 383.06
Grid 32 × 32 Grid 55 × 55 Grid 80 × 80 Grid 100 × 100 Folded Grid 80 × 80 Torus 64 × 16 Torus 160 × 40 Sierpinski depth 8 Random Sparse Grid Random Sparse Torus Full Binary Tree Partial Grid
Figure
1(a)
Table 1: Running time (in seconds; non-optimized) of the various components of the algorithm
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)192
(a)
(b)
Figure 1: (a) 55x55 (3025-vertex) square grid; (b) 80x80 (6400-vertex) square grid with each two opposite corners connected
7(b) the local beautification procedure considered neighborhoods that were too small, we get the overlapping. In Figures 8 and 9 we present “real-life” graphs taken from Francois Pellegrini’s Scotch graph collection, at: http://www.labri.u-bordeaux.fr/Equipe/ PARADIS/Member/pelegrin/graph/. In Figure 10 we present the beautiful Crack graph taken from the collection of Jordi Petit, at: http://www.lsi.upc.es/ ~jpetit/MinLA/Experiments/.
6
Related Work
The multi-scale approach to graph drawing was first proposed in [HH99], as described in Section 2. The major technical improvement of our approach over [HH99] is a more intuitive and easier to implement coarsening step, which is the source of its much better running time. Our method eliminates the entire costly pre-processing step of [HH99] (with the exception of the computation of dV ×V , which is part of the local beautification process). Practically all the coarsening overhead in our algorithm is carried out in a negligible fraction of the overall execution time. Another advantage of our algorithm over that of [HH99] is its simpler schematic structure. Ours starts by beautifying the coarsest-scale representation and proceeds by improving the finer-scale representations until reaching the original graph. The Hadany-Harel method starts with the original graph, continues until it reaches the coarsest level, and then proceeds back to the original graph.
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)193
(a)
(b)
Figure 2: Toruses: (a) 64x16 (1024-vertex) (b) 160x40 (6400-vertex)
Figure 3: A depth 8 Sierpinski (9843 vertices)
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)194
(a)
(b)
Figure 4: (a) 40x40 (1600-vertex) grid with 13 of the edges omitted at random; (b) 80x80 (6400-vertex) grid with 14 of the edges omitted at random
(a) Figure 5: 80x20 (1600-vertex) torus with
(b) 1 5
and
1 3
of the edges omitted at random
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)195
(a)
(b)
(c) Figure 6: Full binary trees: (a,b) 1023-vertices, depth 9; In (a) beautification considered the whole graph at once, while in (b) neighborhoods of radius 16 were considered at once; (c) is the result of the Kamada-Kawai algorithm. Notice that unlike our algorithm, Kamada-Kawai results with bad “global” edge crossings (i.e., near the root).
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)196
(a)
(b)
Figure 7: 55x55 (3025-vertex) partial grid: (a) beautification considered larger than normal neighborhoods, of radius 35 (b) beautification considered usual neighborhoods of radius 7
Figure 8: The graph 3elt from the Scotch collection; |V | = 4720, |E| = 13722
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)197
Figure 9: The graph 4elt from the Scotch collection; |V | = 15606, |E| = 45878
Figure 10: The graph Crack; |V | = 10240, |E| = 30380
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)198 Eliminating this alone results in a 50% improvement in beautification time, by making only half of the local beautification steps. In addition, the beautification process of [HH99] does not directly change the layout, but performs a relative change of the layout, since every vertex is located anew relative to its previous location. This imposes a strong inter-dependency between all the multi-scale representations of the graph. As a result, one has to introduce weights on the edges in order to make it possible to link the layouts of the different scales. In contrast, our scheme makes a direct change to the graph’s layout at each level of the beautification process. As a consequence, the dependencies between the various representations are weaker, and we can use a multi-scale representation with unweighted edges, which while not capturing the final size of the graph often solves many large scale conflicts correctly. As a result of this, we can potentially utilize other force-directed methods as our local beautification procedure, a fact that might possibly yield several additional benefits. Following the appearance of our technical report [HK99], two other multiscale (or “multi-level”) methods were presented at the Graph Drawing 2000 conference together with ours, claiming to have certain advantages over ours. We now describe what seem to be their most important characteristics. The method of Gajer et al. [G+ 00] introduces several changes to our algorithm. The most notable one is that the graph theoretic distances between vertices are not stored in a |V | × |V | table, but are computed dynamically, when needed. This improves the storage requirements of our algorithm, making it suitable for dealing with larger graphs. Other attributes of [G+ 00] are: drawing in higher dimensions and optimizing the energy using gradient-descent, where extent of movement is limited by a local temperature (like [Fr+ 94]). [G+ 00] reports on drawings of 16,000-vertex graphs in around 40 seconds. The method of Walshaw [Wa00] is a multi-level extension of Fruchterman’s and Reingold’s spring embedder algorithm [FR91]. An advantage of working with the forces of [FR91] (compared to the energy of Kamada and Kawai) is that the method of [FR91] does not require the computation (and storage) of the all-pairs shortest path length. As a result, Walshaw [Wa00] can deal with huge graphs of 100,000 vertices in 10–20 minutes, which is very impressive. Another method for drawing large graphs is that of Quigley and Eades [QE00]. Their method is an improvement of the spring embedder algorithm. Unlike the multi-scale approach, they consider the whole graph at once. However, in order to accelerate computation, the nodes are clustered in a quad-tree structure, which reflects actual spatial proximity. The repulsive forces between a vertex and a cluster of distant vertices are approximated as a single force, what significantly lessens the number of forces in the system. There seem to be some connection with the work of Tunkelang [Tu99] mentioned in Section 2 above. We have not conducted tests to compare the running time of the multi-scale approach with that of [QE00]. However, the multi-scale approach optimizes several different energies on several levels, thus apparently capturing the various scales of beauty. Moreover, the multi-scale method may be faster and more robust, since it is not sensitive to the initial placement that is derived
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)199 from coarser scales. Recently, we have developed two new methods [K+ 01, HK02] for drawing huge graphs. They can draw 105 -vertex graphs in few seconds and 106 -vertex graphs in less than a minute, and thus appear to be significantly faster than previously known methods. The method in [K+ 01] draws a graph by quickly calculating eigenvectors of the Laplacian matrix associated with it, using a special algebraic multigrid technique, which is a rather accurate variant of the multi-scale paradigm. The method in [HK02] is somewhat more novel and has two phases: first embed the graph in a very high dimension (say, 50) and then project it onto the 2-D plane using Principal Components Analysis. The high-dimensional embedding is done very rapidly using a simple algorithm that utilizes the freedom given by the many dimensions. This method possesses a useful inherent capability to exhibit the graph in various dimensions, and an effective means for interactive exploration of large graphs.
7
Conclusions and Future Work
We have presented a new multi-scale approach for drawing graphs nicely, and have suggested a useful formulation for the desired properties of the coarse graphs. Our algorithm is able to deal extremely well and extremely fast with certain classes of large graphs. The algorithm was designed for speed and simplicity and does not require explicit representations of coarse graphs. A more powerful and general implementations of the multi-scale drawing scheme would overcome some limitations of our algorithm. We can improve the time and space complexity of our algorithm, by discarding the all-pairs shortest path length computation. This would enable the algorithm to deal with larger graphs. Another improvement lies in the construction of the coarse scale representation, for which we used a simple heuristic. For many graphs this heuristic is fine, but for some graphs it may not be enough. For example consider graphs with a tiny diameter, like the graph of Figure 11, whose diameter is 2. Our heuristic will totally fail on such a graph, since the distances between each pair of vertices are roughly the same, and it is thus unable to differentiate different clusters. Our algorithm uses the heuristic of Kamada and Kawai [KK89], which does not punish edge-crossings explicitly. It may be interesting to see how the explicit consideration of crossings, as is done, e.g., in [DH89], will be reflected in the results of a multi-scale method such as ours. This could be of particular importance in drawing less regular-looking (that is, more random-looking) graphs.
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)200
Result of Fruchterman-Reingold
Result of our method
Figure 11: Bad example: a graph with a degenerate diameter
Acknowledgements We would like to thank the referees for their helpful comments.
References [BH86] J. Barnes and P. Hut, “A hierarchical O(N log N ) Force-Calculation Algorithm”, Nature, 324 (1986), 446–449. [Br+ 95] F.J. Brandenburg, M. Himsolt and C. Rohrer, “An Experimental Comparison of Force-Directed and Randomized Graph Drawing Algorithms”, Proceedings of Graph Drawing ’95, Lecture Notes in Computer Science, Vol. 1027, pp. 76–87, Springer Verlag, 1995. [Di+ 99] G. Di Battista, P. Eades, R. Tamassia and I.G. Tollis, Algorithms for the Visualization of Graphs, Prentice-Hall, 1999. [DH89] R. Davidson and D. Harel, “Drawing Graphs Nicely Using Simulated Annealing”, ACM Trans. on Graphics 15 (1996), 301–331. (Preliminary version: Technical Report, The Weizmann Institute of Science, 1989.) [Ea84] P. Eades, “A Heuristic for Graph Drawing”,Congressus Numerantium 42 (1984), 149–160. [Fr+ 94] A. Frick, A. Ludwig and H. Mehldau, “A Fast Adaptive Layout Algorithm for Undirected Graphs”, Proceedings of Graph Drawing 1994, Lecture Notes in Computer Science, Vol. 894, pp. 389–403, Springer Verlag, 1995.
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)201 [FR91] T.M.G. Fruchterman and E. Reingold, “Graph Drawing by ForceDirected Placement”, Software-Practice and Experience 21 (1991), 1129–1164. [G+ 00] P. Gajer, M. T. Goodrich, and S. G. Kobourov, “A Multi-dimensional Approach to Force-Directed Layouts of Large Graphs”, Proceedings of Graph Drawing 2000, Lecture Notes in Computer Science, Vol. 1984, pp. 211–221, Springer Verlag, 2000. [Go85] T. Gonzalez, “Clustering to Minimize the Maximum Inter-Cluster Distance”, Theoretical Computer Science 38 (1985), 293–306. [HH99] R. Hadany and D. Harel, “A Multi-Scale Method for Drawing Graphs Nicely”, Discrete Applied Mathematics, 113 3-21 (2001). (Also, Proc. 25th Inter. Workshop on Graph-Theoretic Concepts in Computer Science (WG ’99), Lecture Notes in Computer Science, Vol. 1665, pp. 262–277, Springer Verlag, 1999.) [HK99] D. Harel and Y. Koren, “A Fast Multi-Scale Method for Drawing Large Graphs”, Technical Report MCS99-21, Faculty of Mathematics and Computer Science, The Weizmann Institute of Science, 1999. [HK02] D. Harel and Y. Koren, “A Multi-dimensional Approach to ForceDirected Layouts of Large Graphs”, to appear in Proceedings of Graph Drawing 2002, Lecture Notes in Computer Science, Springer Verlag. [Ho96] D. S. Hochbaum (ed.), Approximation Algorithms for NP-Hard Problems, PWS Publishing Company, 1996. [HS86] D. S. Hochbaum and D.B. Shmoys, “A Unified Approach to Approximation Algorithms for Bottleneck Problems”, J. Assoc. Comput. Mach. 33 (1986), 533–550. [KK89] T. Kamada and S. Kawai, “An Algorithm for Drawing General Undirected Graphs”, Information Processing Letters 31 (1989), 7–15. [KW01] M. Kaufmann and D. Wagner (Eds.), Drawing Graphs Methods and Models, Lecture Notes in Computer Science, Vol. 2025, Springer Verlag, 2001. [K+ 01] Y. Koren, L. Carmel and D. Harel “ACE: A Fast Multiscale Eigenvectors Computation for Drawing Huge Graphs”, Technical Report MCS01-17, The Weizmann Institute of Science, 2001. Available at: www.wisdom.weizmann.ac.il/reports.html. To appear in Proceedings of IEEE Symposium on Information Visualization (InfoVis 2002). [LSD]
The LSD library, available from the Graphlet website http://www.fmi.uni-passau.de/Graphlet/download.html
at
Harel and Koren, Fast Drawing of Large Graphs, JGAA, 6(3) 179–202 (2002)202 [QE00] A. Quigley and P. Eades, “FADE: Fraph Drawing, Clustering, and Visual Abstraction”, Proceedings of Graph Drawing 2000, Lecture Notes in Computer Science, Vol. 1984, pp. 183–196, Springer Verlag, 2000. [Tu99] D. Tunkelang, A Numerical Optimization Approach to General Graph Drawing, Ph.D. Thesis, Carnegie Mellon University, 1999. [Wa00] C. Walshaw, “A Multilevel Algorithm for Force-Directed Graph Drawing”, Proceedings of Graph Drawing 2000, Lecture Notes in Computer Science, Vol. 1984, pp. 171–182, Springer Verlag, 2000.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 6, no. 3, pp. 203-224 (2002)
GRIP: Graph Drawing with Intelligent Placement Pawel Gajer Department of Computer Science Johns Hopkins University Baltimore, MD http://www.math.jhu.edu/~pgajer/
Stephen G. Kobourov Department of Computer Science University of Arizona Tucson, AZ http://www.cs.arizona.edu/people/kobourov/ Abstract This paper describes a system for Graph dRawing with Intelligent Placement, GRIP. The system is designed for drawing large graphs and uses a novel multi-dimensional force-directed method together with fast energy function minimization. The algorithm underlying the system employs a simple recursive coarsening scheme. Rather than being placed at random, vertices are placed intelligently, several at a time, at locations close to their final positions. The running time and space complexity of the system are near linear. The implementation is in C using OpenGL for 3D viewing. The GRIP system allows for drawing graphs with tens of thousands of vertices in under one minute on a mid-range PC. To the best of the authors’ knowledge, GRIP surpasses the fastest previous algorithms. However, speed is not achieved at the expense of quality as the resulting drawings are quite aesthetically pleasing.
Communicated by Michael Kaufmann: submitted March 2001; revised February 2002 and June 2002.
This research partially supported by NSF under Grant CCR–9625289. A preliminary version of this paper appeared in the Proceedings of the 8th Symposium on Graph Drawing (GD 2000).
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
1
204
Introduction
Let G be a graph G = (V, E), where V is a set of vertices and E a set of edges, where |V | = n and |E| = m. We would like to display G in two or three dimensions so as to show clearly the underlying relationships. This problem is generally known as the graph drawing problem. In a graph drawing we typically use points to represent the vertices and straight-line segments to represent the edges. The quality of the drawings produced by such algorithms is measured by a set of aesthetic criteria such as: • minimizing the number of edge crossings • displaying graph symmetries • distributing the vertices evenly • uniform edge length. A large class of graph drawing algorithms (including ours) is based on the force-directed placement technique. The spring embedder of Eades [8] is one of the earliest examples and uses a physical model from Newtonian mechanics. In this model vertices are physical objects (steel rings) and edges are springs connecting them. An initial random placement of the vertices is repeatedly refined until a configuration with low energy has been obtained. The functions modeling the forces in these computations are typically simplified in order to speed up the computation. In Eades’ spring embedder, there are two types of forces: attractive and repulsive. Attractive forces exist between vertices connected by edges and are defined by the log of the distance between them, c1 log
distR2 (u, v) , c2
where c1 and c2 are constants and distR2 (u, v) is the distance between vertices u and v in the drawing. Similarly, repulsive forces exist between all pairs of vertices and are defined by the distance between the vertices, c3 , 2 distR2 (u, v) where c3 is a constant. Kamada and Kawai [15, 16] use a similar approach but specify explicitly the function for the total energy of the graph: X cuv (distR2 (u, v) − distG (u, v))2 , 1≤u
where cuv is a constant associated with the spring between vertices u and v, and distG (u, v) is the length of the shortest path between u and v in G. This algorithm also begins with a random placement of all the vertices. The energy
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
205
is minimized by applying a Newton-Raphson method for moving one vertex at a time. Fruchterman and Reingold [10] present a modification of the spring embedder which yields a faster algorithm. In their method the attractive forces are defined by dist2R2 (u, v) , k p where k is the optimum distance between two vertices, defined as k = ( area n ). The repulsive forces are defined as k2 . distR2 (u, v) Davidson and Harel [7] introduce techniques from simulated annealing to the graph drawing process while adding more terms to the energy function to control the distance between vertices and edges. Frick et al. [9] present further improvements. Recently, Bruß and Frick [3] and Cruz and Twarog [6] describe several extensions of the drawing algorithms from 2D to 3D. Most of the above algorithms concentrate on drawing small graphs, typically with 10-50 vertices and produce nice drawing in reasonable time. However, these techniques fail when directly applied to larger graphs. Direct application of these techniques to larger graphs (e.g. graphs with tens of thousands of vertices) fail due to the local nature of the optimization methods used, and the space and time complexity of these techniques. One of the first algorithms to tackle graphs with thousands of vertices is that of Hadany and Harel [12] which uses a multi-scale technique to produce a sequence of approximations to the final layout. The main idea in this approach is to create a hierarchy of graphs, in which each consecutive layer is a coarser version of the previous one. The hierarchy of graphs is created by taking into account the cluster number, the degree number, and the homotopic number. Several new algorithms for drawing large graphs were presented at the 8th Symposium on Graph Drawing. Harel and Koren [13] present a multi-scale scheme that computes a simpler graph hierarchy. Walshaw [20] describes a similar multilevel algorithm. The n-body simulation method of Quigley and Eades [19] uses the Barnes-Hut [1] hierarchical space decomposition method. A method similar to our intelligent placement is described in the context of incremental drawing by Cohen in [4]. In the remainder of this paper we focus on the GRIP system which is based on a multi-dimensional force-directed technique.
2
The GRIP System
The GRIP system is based on the algorithm of Gajer, Goodrich, and Kobourov [11]. GRIP follows a number of force-directed drawing tools [3, 7, 9, 10, 13, 15] but employs several novel ideas first introduced in [11]: intelligent placement of vertices, drawing in higher dimensions, a fast energy minimization function, and a
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
206
G = (V,E)
FILTRATION V 0, V 1 , . . . , V k
i=k
PLACEMENT
REFINEMENT
of V i
of V i i=i-1 i=0 display G
Figure 1: An overview of the algorithm. Given a graph G, the algorithm proceeds in three stages. In the first stage we create a maximal independent set (MIS) filtration. In the second and third stages we use the filtration sets Vk , Vk−1 , . . . , V0 to repeatedly add more vertices and refine the drawing.
simple vertex filtration. Carefully put together, these techniques allow GRIP to draw graphs with tens of thousands of vertices in under one minute. While [11] contains the main methodology this paper focuses on the actual system, implementation, examples and experiments. An overview of the system and its three main stages is given in Fig. 1 and the main algorithm is summarized in Fig. 2. Starting with a graph G = (V, E), we first create a maximal independent set (MIS) or a random filtration V : V = V0 ⊃ V1 ⊃ . . . ⊃ Vk ⊃ ∅ of the set V of vertices of G, so that k = O(log n), and |Vk | = 3. A filtration V of V is called a maximal independent set filtration if V1 is a maximal independent set of G, and each Vi is a maximal subset of Vi−1 so that the graph distance between any pair of its elements is at least 2i−1 + 1. Recall that the graph distance between a pair of vertices is defined as the length of the shortest path between them in the original graph G. Note that the length of a maximal independent set filtration is log δ(G), where δ(G) is the diameter of the graph. Since δ(G) = O(n), the depth of the filtration is also O(log n). Similarly, the expected depth of the random filtration is O(log n). We ensure that the last set has exactly three elements by modifying the last one or two sets in the filtration. Once we have obtained the desired vertex filtration, we proceed to the initial placement and refinement stages. First, we generate an initial embedding of Vk . The vertices of Vk are placed in Rn using their graph distances. More precisely, since |Vk | = 3, we find a triangle with sides equal to the graph distances between the three vertices and place the vertices at the endpoints the triangle. Then, we add the vertices of Vk−1 that are not in Vk , placing them initially at the positions determined by their graph distances to a subset of the elements of Vk . The positions of the vertices in Vk−1 are modified using a force-directed layout method. This process of adding new vertices and refining their positions is repeated for Vk−2 , . . . , V1 , V0 . The refined positions of the elements of V0 constitute the final layout of the vertices of G. Note that we draw only the
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
207
Main Algorithm create a filtration V : V0 ⊃ V1 ⊃ . . . ⊃ Vk ⊃ ∅ for i = k to 0 do for each v ∈ Vi − Vi+1 do find vertex neighborhood Ni (v), Ni−1 (v), . . . , N0 (v) find initial position pos[v] of v repeat rounds times for each v ∈ Vi do compute local temperature heat[v] − → disp[v] ← heat[v] · FNi (v) for each v ∈ Vi do pos[v] ← pos[v] + disp[v] add all edges e ∈ E Figure 2: After creating the vertex filtration and setting up the scheduling function the algorithm processes each filtration set, starting with the smallest one. Here pos[v] is a point in Rn corresponding to vertex v and rounds is a small constant. In the refinement stage heat[v] is scaling factor for the displacement vector disp[v], which in turn is computed over a restriction Ni (v) of the vertices of G.
vertices of G up to this point. Only when all the vertices have been placed and their positions refined do we draw the edges of G as straight line segments connecting their endpoints.
3
Building MIS Filtrations
A straightforward algorithm for finding a maximal independent set filtration of a graph G is to compute the distances between all the pairs of vertices of G and then use this information to produce a maximal independent set filtration. A problem with the all-pairs shortest path algorithm is its running time of is Ω(nm) and storage complexity of Ω(n2 ), e.g., see [5]. When dealing with graphs with tens of thousand of vertices, both the running time and the space complexity of the all-pairs shortest path algorithms pose serious problems. Our solution is based on the observation that to construct a maximal independent set filtration we do not need the distances between all the pairs of vertices. Indeed, we only need the distances between the vertices in the filtration sets. Moreover, the information that has been used to construct Vi is not needed to construct Vi+1 . Therefore, we have adopted the following “create then destroy” strategy for construction of MIS filtrations. Suppose we have already constructed set Vi . The next set in the filtration, Vi+1 is going to contain a proper subset of the vertices in Vi . More precisely, to create Vi+1 , we build for each vertex of Vi a breadth-first search (BFS) tree up to depth 2i , but store in it only elements of Vi . We need to keep track of these vertices as they should
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
208
not be copied to Vi+1 . Note that this is all we need to build Vi+1 . In the process of creating Vi+1 we may need to build many BFS trees, but we destroy them immediately once they have been used, so that by the time we enter the next phase (of building Vi+2 ), all memory has been freed. Note that as i decreases, the number of vertices for which we have to perform a BFS calculation increases, but at the same time the depth to which we have to build these BFS trees decreases as well. The storage required for this strategy is X |bfs2i (v, Vi )|, max i
v∈Vi
where |bfs2i (v, Vi )| is the number of elements of Vi that belong to the BFS tree of v of depth 2i . The time complexity for this strategy in the case of bounded degree graph G is X k X |bfs2i (v)| , Θ i=0 v∈Vi
where |bfs2i (v)| is the number of vertices in the BFS tree of depth 2i for vertex v. Clearly, if we build a complete BFS tree for each vertex of G, then the running time and space complexity of this procedure, even in the bounded degree case, would be O(n2 ). For the above MIS filtration construction procedure however, our tests indicate that the running time is near linear as we only construct partial BFS trees and destroy them right away. In all of our experiments, the time spent creating the MIS filtration was less than 3% of the total running time, see Fig 11 and Fig 12. We store a MIS filtration of a graph of n vertices in an array misFiltration of size n so that the first |Vk | entries in the misFiltration array are the elements of Vk . The first |Vk−1 | entries in the array are the elements of Vk−1 . Similarly, the first |Vi | entries in the array are the elements of Vi . To keep track of where one set ends and another one begins we store the indices indicating the borders of different level sets of the filtration in a separate array misBorder of size log δ(G), see Fig. 3. Thus the space complexity for storing a MIS filtration is n + log δ(G). The same method can be applied to any filtration. In GRIP we have also implemented a random filtration. The random filtration is similar to MIS filtrations and k-centers filtrations of Harel and Koren [13], except that the vertices are filtered out at random. We assign each vertex in Vi a 1/2 probability of propagation to Vi+1 , for i = 0, 1, . . . , k − 1. Random filtrations take O(n) time to create, as opposed to the O(n2 ) time required by MIS and k-centers filtrations. Random filtrations have expected depth O(log n) as opposed to O(log δ(G)) for MIS filtrations. While for most graphs we tested the random filtration produces drawings similar to those created using MIS filtrations, for sparse graphs the performance deteriorates.
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
1
1
209
12
11
1 2
11
3
3 4
10 5
9
5
9
5
9 8
V2
misFiltration
1
5
misBorder
9
3
3
7
6
11
6
7
7
V1
V0
2
4
6
8
10
12
12
G is a cycle on 12 vertices and the filtrations sets are V0 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, V1 = {1, 3, 5, 7, 9, 11}, and V2 = {1, 5, 9}. Note how the filtration is stored in the misFiltration array and how the misBorder array is used to identify the borders of the filtration sets. The first entry, 3, in the misBorder array identifies the first three elements of the misFiltration array as V2 . The second entry, 6, identifies the first 6 elements of the misFiltration array as V1 and the third entry, 12, identifies the first 12 elements of the array as V0 .
Figure 3:
4
Initial Placement and Refinement
The second and third phases of the algorithm are the placement and refinement stages, respectively. In the ith placement stage, the vertices of set Vi are intelligently placed in Rn . In the ith refinement stage, a local force-directed method is used to obtain better positions for the vertices of Vi . After the placement and refinement stages for Vi have been completed, the process is repeated for Vi−1 , Vi−2 , all the way to V1 . Recall that there are exactly three vertices in Vk . We compute their pairwise graph distances and place them at the endpoints of a triangle with sides of lengths equal to these distances. Consider the general placement case. Suppose the refinement and placement stages for Vi have been completed and we want to begin the placement phase for Vi−1 . All the vertices in Vi are also in Vi−1 , since Vi−1 ⊃ Vi as defined by the construction of the filtration. Thus we are only concerned with the placement of the vertices in Vi−1 that are not in Vi . The idea behind the intelligent placement is that every vertex t is placed “close” to its optimal position as determined by the graph distances from t to several already placed vertices. The intuition is that if we can place the vertices close to their optimal positions from the very beginning, then the refinement stages
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
210
Figure 4: Drawing of the vertices in the filtration sets. Here V : V0 ⊃ V1 ⊃ V2 ⊃ V3 ⊃ V4 . The sizes of the sets are 231, 60, 21, 6, 3, respectively. The process begins with a placement for V4 , followed by V3 , etc. Note that edges are drawn only when all the vertices are placed.
need only a few iterations of a local force-directed method to reach a minimal energy state. After experimenting with several initial placement strategies we decided to use two simple strategies in GRIP. The first strategy, “simple barycenter” begins by setting pos[t], the initial position for a new vertex t, to the barycenter (pos[u]+pos[v]+pos[w])/3 of u, v, and w, the three vertices closest to t that are already placed. This is followed by a force-directed modification of the position vector of t with the energy function E calculated only at the three points u, v, w. This makes the procedure very fast, and in our tests it produced good results, see Fig. 4. The second strategy “three closest neighbors” uses the positions of the three closest already placed neighbors to determine the location of new vertex t. We begin by finding t’s three closest neighbors u, v, w ∈ Vi . Since u, v and w have already been placed we can obtain a suitable place for t by solving the following system of equations for u, v, w, and t 2 2 2 (x − xu ) + (y − yu ) = distG (u, t) 2 2 2 (x − xv ) + (y − yv ) = distG (v, t) (x − xw )2 + (y − yw )2 = distG (w, t)2 , where pos[u] = (xu , yu ), pos[v] = (xv , yv ), pos[w] = (xw , yw ), pos[t] = (x, y). Since this system of equations is over-determined and may not have any solutions, we solve the following three pairs of equations instead ( distR2 (u, t) = distG (u, t) distR2 (v, t) = distG (v, t) ( distR2 (v, t) = distG (v, t) distR2 (w, t) = distG (w, t) ( distR2 (u, t) = distG (u, t) distR2 (w, t) = distG (w, t). Solving these three systems of quadratic equations, we obtain up to six different + + solutions. We choose the three closest to each other, call them t+ 1 , t2 , t3 , and + + + place t are their barycenter: pos[t] = (t1 + t2 + t3 )/3.
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
211
Refinement of Vi repeat rounds(i) times for each v ∈ Vi do if i > 0 then − → disp[v] ← F KK (v) else − → disp[v] ← F FR (v) heat [v] ← updateLocalTemp(v) disp[v] disp[v] ← heat[v] · kdisp[v]k for each v ∈ Vi do pos[v] ← pos[v] + disp[v] Figure 5: Pseudocode of the refinement phase of the algorithm. While the refinement is calculated using a force-directed method, it is important to note that the forces are calculated locally, see Fig. 5. For each level of the filtration Vi , we perform rounds(i) updates of the vertex positions, where rounds(i) is a scheduling function which can be specified at the beginning of the execution. Typically, 5 ≤ rounds(i) ≤ 30. At all levels of the filtration except the last one, the displacement vector disp[v] of v is set to a local Kamada-Kawai force vector, X distRn (u, v) − → − 1 (pos[u] − pos[v]). F KK (v) = distG (u, v) · edgeLength2 u∈Ni (v)
In the last level of the filtration, V0 = V all the vertices have been placed. In order to speed up computation, we set the displacement vector for the last level to a local Fruchterman-Reingold force vector, X
− → F FR (v) =
u∈Adj(v)
+
X u∈Ni (v)
s
distRn (u, v)2 (pos[u] − pos[v]) + edgeLength2
edgeLength2 (pos[v] − pos[u]), distRn (u, v)2
Here, distRn (u, v) is the Euclidean distance between pos[u] and pos[v], and distG (u, v) is the graph distance between u and v. In the above equations, edgeLength is the unit edge length, Adj(v) is the set of vertices adjacent to v, and s is a small scaling factor which is set to 0.05 in our program. Note that for a vertex v ∈ G the force calculation is performed over a restriction Ni (v) of the vertices of G. Each vertex neighborhood Ni (v) contains a constant number of vertices closest to v which belong to Vi . Thus only a constant number of vertices which are near vertex v are used to refine v’s position. This is why we call this type of force calculation local.
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
212
updateLocalTemp(v) if kdisp[v]k = 6 0 and koldDisp[v]k = 6 0 then cos[v] =
disp[v] ∗ oldDisp[v] kdisp[v]k ∗ koldDisp[v]k
r = 0.15, s = 3 if oldCos[v] ∗ cos[v] > 0 then heat[v] = heat[v] + (cos[v] ∗ r ∗ s) else heat[v] = heat[v] + (cos[v] ∗ r) oldCos[v] = cos[v] Figure 6: Pseudocode of the local temperature calculation. The local temperature heat[v] of v is a scaling factor of the displacement vector for vertex v, similar to that of Fruchterman and Reingold [10] and Frick et al [9]. The algorithm for determining the local temperature is in Fig. 6. To speed up the calculation, we maintain two auxiliary arrays oldDisp and oldCos, where oldDisp[v] is the previous displacement vector for v, and oldCos[v] is the previous value of the cosine of the angle between oldDisp[v] and disp[v]. When a displacement vector of v is calculated for the first time, heat[v] is set to a default value edgeLength/6. The local temperature helps speed up convergence by distinguishing between oscillating vertices and vertices that continue moving in one directions. There are three cases for determining the local temperature : 1. if either oldDisp[v] or disp[v] is a zero vector, then the value of heat[v] does not change; 2. if v is oscillating around some stationary point we add to it a factor (cos[v]∗ r ∗ s); 3. in all other cases we add a factor of (cos[v] ∗ r).
5
Implementation
The GRIP system was originally written in C++ and then re-done in C with OpenGL, with a Tcl/Tk interface, see Fig. 7. GRIP is available for download at http:\\www.cs.arizona.edu/~kobourov/GRIP. The system can read in files and generates several typical classes of graphs parametrized by their number of vertices, e.g. paths, cycles, square meshes, triangular meshes, and complete graphs. GRIP also contains generators for complete n-ary trees, random graphs with parametrized density, and knotted triangular and rectangular meshes. Different types of tori, as well as cylinders and Moebius bends can be generated with parametrized thickness and length. Finally, Sierpinski graphs in 2 and 3
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
213
Figure 7: The GRIP system: On the top left we have the control window, which lets us chose the type of graph, the graph parameters, dimension of the drawing, parameters of the algorithm, and display settings. Graphs can be read from a file, or one of the several built-in generators can be used. Currently we support generators for trees, paths, cycles, cylinders, tori, degree 4 meshes, degree 6 meshes, and Sierpinski graphs. Parameters of the algorithm include attractive/repulsive force ratio and initial and final number of rounds, among others. The display settings control the interactive display, speed, and color. Within the OpenGL window the graph can be dragged, rotated, and zoomed.
Figure 8: GRIP can read files in the gml format. This allows for displaying properties such as direction of edges, self-loops and colors specified for vertices and edges.
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
214
dimensions (Sierpinski triangles and Sierpinski pyramids, respectively) are also available. In addition to the set of graphs that GRIP can generate, other graphs can be read from a file in gml format [14]. This allows the display of options such as directed edges, different color vertices and edges, self-loops, etc., see Fig. 8. GRIP can draw graphs directly in 2D or 3D or projected down from higher dimensions. Drawings produced in higher dimensions and projected down to 2D or 3D usually produce better results. At this time, the projections are done at random. We are working on incorporating projections based on spectral analysis similar to [2]. Figures 9-10 show how the MIS filtration method compares to the random filtration method. In both the final drawing for each level of the filtration is captured. Note that all but the last drawings show only vertices as the induced graphs are never computed. For a given filtration level Vi , the vertices in Vi \ Vi−1 are shown as bigger dots, while those that came down from the previous level (Vi−1 ) are shown as small dots. While random filtrations take a small fraction of the time required to create MIS filtrations in general they induce more refinement levels. Most drawings produced with random filtrations and MIS filtrations are similar, see Fig. 9. Random filtrations perform worse for sparse graphs as the variation in the distances between vertices in the same level becomes greater, see Fig. 10. Running times for the MIS creation and for the entire drawing process as shown in Fig 11 and Fig. 12. Most of the drawings in the following examples took less than 1 second. The Sierpinski pyramid of order 8 (with 32,770 vertices, 196,608 edges) was the most time consuming: it took 58 seconds on a 500MHz Pentium III machine. The parameters discussed in this paper can be changed via GRIP’s interface, thus allowing for experimentation with different scheduling functions, scaling parameters, filtrations, etc. There are controls for the drawing dimension and the drawing speed. The drawings produced by default are three dimensional, interactive, and use color and shading to aid three dimensional perception. For faster results, the interactive display can be turned off so that only the final drawing is shown. The size and colors of the vertices and edges can also be modified.
6
Examples
In the next few pages we provide several examples of graphs produced by GRIP. None of the drawings have been additionally modified. We focus mostly on larger graphs but also provide several “classical” smaller graphs to illustrate the versatility of the system. Fig. 13 shows drawings of a dodecahedron, C60 (bucky ball), and a 3D cube mesh. Fig. 14 shows 3D drawings of a 4D cube, 5D cube, and 6D cube. Fig. 15 shows binary, 3-ary, and 4-ary trees. Fig. 16 shows several cycles. Fig. 17 shows three “real-world” graphs from the Stanford GraphBase [17]. Fig. 18 shows regular degree 4 meshes of up to 10,000 vertices.
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
215
Figure 9: Mesh on 225 vertices using MIS filtration (1st column) and random filtration (2nd and 3rd columns).
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
216
Figure 10: Cycle on 20 vertices using MIS filtration (1st column) and random filtration (2nd and 3rd columns).
Fig. 19 shows drawings of the same meshes with their endpoints attached (knotted meshes). Fig. 20 shows several cylinders and Fig. 21 shows tori. Fig. 22 shows regular degree 6 meshes and Fig. 23 shows the same meshes with their endpoints attached (knotted meshes). The Sierpinski triangle (pyramid) is a classic fractal [18]. Several 2D, 3D, and 4D drawings are shown on Fig. 24 and Fig. 25. Whereas traditionally the image is defined with fixed vertices and edges, we make ours a fractal graph with no specific embedding. The Sierpinski pyramid graph is created by a recursive procedure, parametrized on the order of the recursion. As in the 2D case, at each iteration, every pyramid is divided into five congruent smaller pyramids with the central pyramid removed. In a Sierpinski pyramid of order k k the number of vertices is |Vk | = 42 + 2 and the number of edges is |E| = 6(|V | − 4) + 12 = 3 × 4k . Fig. 24(c) shows a Sierpinski pyramid of order 7 with 8,194 vertices and 49,152 edges. Fig. 25 shows a Sierpinski pyramid of order 8 with 32,770 vertices and 196,608 edges. Given the parameter k we generate
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
217
6 Cycle Degree 4 Mesh Degree 6 Mesh
Running time in seconds
5
4
3
2
1
0 0
5000
10000
15000
20000 25000 Number of vertices
30000
35000
40000
45000
Figure 11: The chart contains the running times for construction of a MIS filtration for cycles, meshes of degree 4, and meshes of degree 6. As can be expected, the depth of the filtration is the largest for the sparsest graphs, in this case, the cycles.
Cycle Degree 4 Mesh Degree 6 Mesh
60
Running time in seconds
50
40
30
20
10
0 0
2000
4000
6000
8000 10000 Number of vertices
12000
14000
16000
18000
Figure 12: The chart contains the total running time for the three classes of graphs from Fig 11. Note that the construction of the MIS filtration takes less than 3% of the total running time.
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
218
the adjacency matrix of a graph which corresponds to the Sierpinski pyramid of order k. The drawings have been taken directly from the output of GRIP, without any modifications.
7
Conclusion and Future Work
In the process of writing this program several interesting questions arose. Some we answered in this paper, others we address in [11] but quite a few still remain: • How should the type of the graph affect the number of rounds? • What can we do about dense graphs and graphs with small diameter? (The MIS filtration is very shallow for such graphs.) • What filtrations (other than MIS) could produce good results? • Can the MIS filtration be created in provable subquadratic time, in the number of vertices and edges of the graph? (Currently, we have a modified MIS filtration, with similar properties which can be built in linear time. However, we are not aware of a subquadratic algorithm for the creation of a standard MIS filtration, as defined in the paper.)
8
Acknowledgements
We would like to thank Michael Goodrich, Christian Duncan, and Alon Efrat for helpful discussions. The conversion from C++ to C is due to Roman Yusufov who also wrote the user manual.
Figure 13: Small graphs: (a) dodecahedron (20 vertices); (b) C60 – bucky ball (60 vertices); (c) 3D cube mesh (216 vertices).
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
219
Figure 14: Cubes in 3D: (a) a 4D cube (16 vertices); (b) 5D cube (32 vertices); (c) 6D cube (64 vertices).
Figure 15: Trees: (a) a complete binary tree of depth 9 (511 vertices); (b) complete 3-ary tree of depth 7 (1093 vertices); (c) complete 4-ary tree of depth 6 (1365 vertices).
Figure 16: Cycles of 100, 200, and 400 vertices.
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
220
Figure 17: Graph from “real-world data”, as given by Knuth [17]: (a) miles2, (128 vertices, 368 edges); (b) miles3 (128 vertices, 518 edges) (c) miles4 (256 vertices, 312 edges
Figure 18: Rectangular (degree 4) meshes of 1600, 2500, and 10000 vertices.
Figure 19: Knotted rectangular (degree 4) meshes of 1600, 2500, and 10000 vertices.
Figure 20: Cylinders of 1000, 4000, and 10000 vertices.
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
221
Figure 21: Tori of various length and thickness: 1000, 2500, and 10000 drawn in four dimensions and projected down to three dimensions.
Figure 22: Triangular (degree 6) meshes of 496, 1035, and 2016 vertices.
Figure 23: Knotted triangular (degree 6) meshes of 496, 1035, and 2016 vertices.
Figure 24: Sierpinski graphs in 2D and 3D (a) 2D Sierpinski of order 7 (1,095 vertices); (b) 3D Sierpinski of order 6 (2,050 vertices); (c) 3D Sierpinski of order 7 (8,194 vertices). The last drawing took 15 seconds on a 500Mhz Pentium III machine.
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
222
Figure 25: 4D Sierpinski graph of order 8 on 32,770 vertices and 196,608 edges. The drawing took 58 seconds on a 500Mhz Pentium III machine.
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
223
References [1] J. Barnes and P. Hut. A hierarchical O(N log N) force calculation algorithm. Nature, 324:446–449, Dec. 1986. Institute for Advanced Study, Princeton, New Jersey. [2] Brandes and Cornelsen. Visual ranking of link structures. In WADS: 7th Workshop on Algorithms and Data Structures, volume 2125 of Lecture Notes in Computer Science, pages 222–232, 2001. [3] I. Bruß and A. Frick. Fast interactive 3-D graph visualization. In F. J. Brandenburg, editor, Graph Drawing (Proc. GD ’95), volume 1027 of Lecture Notes Computer Science, pages 99–110. Springer-Verlag, 1996. [4] J. D. Cohen. Drawing graphs to convey proximity: An incremental arrangement method. ACM Transactions on Computer-Human Interaction, 4(3):197– 229, Sept. 1997. [5] T. H. Cormen, C. E. Leiserson, and R. L. Rivest. Introduction to Algorithms. MIT Press, Cambridge, MA, 1990. [6] I. F. Cruz and J. P. Twarog. 3d graph drawing with simulated annealing. In F. J. Brandenburg, editor, Graph Drawing (Proc. GD ’95), volume 1027 of Lecture Notes Computer Science, pages 162–165, 1996. [7] R. Davidson and D. Harel. Drawing graphics nicely using simulated annealing. ACM Trans. Graph., 15(4):301–331, 1996. [8] P. Eades. A heuristic for graph drawing. Congressus Numerantium, 42:149–160, 1984. [9] A. Frick, A. Ludwig, and H. Mehldau. A fast adaptive layout algorithm for undirected graphs. In R. Tamassia and I. G. Tollis, editors, Graph Drawing (Proc. GD ’94), LNCS 894, pages 388–403, 1995. [10] T. Fruchterman and E. Reingold. Graph drawing by force-directed placement. Softw. – Pract. Exp., 21(11):1129–1164, 1991. [11] P. Gajer, M. T. Goodrich, and S. G. Kobourov. A multi-dimensional approach to force-directed layouts. In Proceedings of the 8th Symposium on Graph Drawing (GD 2000), pages 211–221, 2000. [12] R. Hadany and D. Harel. A multi-scale algorithm for drawing graphs nicely. In Proc. 25th International Workshop on Graph Teoretic Concepts in Computer Science (WG’99), 1999. [13] D. Harel and Y. Koren. A fast multi-scale method for drawing large graphs. In Proceedings of the 8th Symposium on Graph Drawing (GD 2000), pages 183–196, 2000. [14] M. Himsolt. Gml: A portable graph file format. Technical report, Universit¨ at Passau, 1994. [15] T. Kamada and S. Kawai. Automatic display of network structures for human understanding. Technical Report 88-007, Department of Information Science, University of Tokyo, 1988. [16] T. Kamada and S. Kawai. An algorithm for drawing general undirected graphs. Inform. Process. Lett., 31:7–15, 1989.
Gajer and Kobourov, GRIP, JGAA, 6(3) 203-224 (2002)
224
[17] D. E. Knuth. The Stanford GraphBase: A Platform for Combinatorial Computing. ACM Press, New York, NY 10036, USA, 1993. [18] B. B. Mandelbrot. The Fractal Geometry of Nature. W.H. Freeman and Co., New York, rev 1983. [19] A. Quigley and P. Eades. FADE: graph drawing, clustering, and visual abstraction. In Proceedings of the 8th Symposium on Graph Drawing (GD 2000), pages 197–210, 2000. [20] C. Walshaw. A multilevel algorithm for force-directed graph drawing. In Proceedings of the 8th Symposium on Graph Drawing (GD 2000), pages 171–182, 2000.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 6, no. 3, pp. 225-254 (2002)
A User Study in Similarity Measures for Graph Drawing Stina Bridgeman Department of Computer Science Colgate University Hamilton, NY 13346 http://cs.colgate.edu/faculty/stina/ [email protected]
Roberto Tamassia Center for Geometric Computing Department of Computer Science Brown University Providence, RI 02912–1910 http://www.cs.brown.edu/~rt/ [email protected] Abstract The need for a similarity measure for comparing two drawings of graphs arises in problems such as interactive graph drawing and the indexing or browsing of large sets of graphs. Many applications have been based on intuitive ideas of what makes two drawings look similar — for example, the idea that vertex positions should not change much. In this paper, we formally define several of these intuitive ideas of similarity and present the results of a user study designed to evaluate how well these measures reflect human perception of similarity.
Communicated by Michael Kaufmann: submitted February 2001;revised January 2002 and June 2002.
Research supported in part by the National Science Foundation under grants CCR– 9732327, CCR–0098068 and CDA–9703080, and by the U.S. Army Research Office under grant DAAH04-96-1-0013. Work completed while the first author was at Brown University.
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 226
1
Introduction
The question of how similar two drawings of graphs are arises in a number of situations. One application is interactive graph drawing, where the graph being visualized changes over time and it is important to preserve the user’s “mental map” [12] of the original drawing as much as possible so the user does not need to spend a lot of time relearning the drawing after each update. Having to relearn the drawing can be a significant burden if the graph is updated frequently. Animation can be used to provide a smooth transition between the drawings and can help compensate for greater changes in the drawing, but it is still important to maintain some degree of similarity between the drawings to help the user orient herself to the new drawing. Related to interactive graph drawing is layout adjustment, where an existing drawing is modified so as to improve an aesthetic quality without destroying the user’s mental map. Another application is in indexing or browsing large sets of graphs. An example of a graph browser is contained the SMILE graph multidrawing system of Biedl et. al. [1]. The SMILE system tries to find a good drawing by producing many drawings of the graph and letting the user choose among them, rather than trying to code the properties of a good drawing into the algorithm. The graph browser arranges the drawings so that similar ones are near each other, to help the user navigate the system’s responses. Related to this is the idea of using similarities between drawings as a basis for indexing and retrieval. Such a system has applications in character and handwriting recognition, where a written character is transformed into a graph and compared to a database of characters to find the closest match. Let M be a similarity measure defined so that M ’s value is always nonnegative and is 0 when the drawings are identical. In order to be useful, M should satisfy three properties: Rotation: Given drawings D and D0 , M (D, Dθ0 ) should have the minimum value for the angle a user would report as giving the best match, where Dθ0 is D0 rotated by an angle of θ with respect to its original orientation. Ordering: Given drawings D, D0 , and D00 , M (D, D0 ) < M (D, D00 ) if and only if a user would say that D0 is more like D than D00 is like D. Magnitude: Given drawings D, D0 , and D00 , M (D, D0 ) = 1c M (D, D00 ) if and only if a user would say that D0 is c times more like D than D00 is like D. This paper describes a user study performed in order to evaluate several potential similarity measures with respect to rotation and ordering, and to test a possible method for obtaining data to be used for evaluating measures with respect to magnitude. Data cannot be collected directly for the magnitude part as it can be for rotation and ordering because it is very difficult to assign numerical similarity values to pairs of drawings; Wickelgren [18] observes that it is more difficult to assign numerical values than to judge ordering. As a result, other data must be gathered — for example, response times on a particular task —
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 227 with the hope that the data is sufficiently related to the actual similarity values to be useful. This can be partially tested by using the data (e.g., response times) to order the drawings, and determining whether the results are consistent with user responses on the ordering part. This study improves on our previous work [3] in several ways: • More Experimental Data: A larger pool of users (103 in total) was used for determining the “correct” behavior for the measure. • Refined Ordering Part: Users made only pairwise judgments between drawings rather than being asked to order a larger set. • Addressing of Magnitude Criterion: The previous experiment did not address magnitude at all. • More Realistic Drawing Alignment: The previous drawing alignment method allowed one drawing to be scaled arbitrarily small with respect to the other; the new method keeps the same scale factor for both drawings. • Refinement of Measures: For those measures computed with pairs of points, pairs involving points from the same vertex are skipped. • New Measures: Several new measures have been included. We describe the experimental setup in Section 2, the measures evaluated in Section 3, the results in Sections 4 and 5, and conclusions and directions for future work in Section 6.
2
Experimental Setup
This study focuses on similarity measures for orthogonal drawings of nearly the same graph. “Nearly the same graph” means that only a small number of vertex and edge insertions and deletions are needed to transform one graph into the other. In this study, the graphs differ by one vertex and two or four edges. The focus on orthogonal drawings is motivated by the availability of an orthogonal drawing algorithm capable of producing many drawings of the same graph, and by the amount of work done on interactive orthogonal drawing algorithms. (See, for example, Biedl and Kaufmann [2], F¨ oßmeier [8], Papakostas, Six, and Tollis [14], and Papakostas and Tollis [15].) Producing multiple drawings of the same graph is important because it can be very difficult to judge if one pair of drawings is more similar than another if the graphs in each pair are different.
2.1
Graphs
The graphs used in the study were generated from a base set of 20 graphs with 30 vertices each, taken from an 11,582-graph test suite. [7] Each of 20 base graphs was first drawn using Giotto [17]. Each of the Giotto-produced base drawings was modified by adding a degree 2 and a degree 4 vertex, for a total of 40 modified
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 228 drawings. Each modified drawing is identical to its base drawing except for the new vertex and its adjacent edges, which were placed in a manner intended to mimic how a user might draw them in an editor. Because InteractiveGiotto (used in the next step) preserves edge crossings and bends, routing the edges realistically avoids introducing a large number of extra crossings. Finally, a large number of new drawings were produced for each modified drawing using InteractiveGiotto [4], and four drawings were chosen from this set. The four drawings chosen range from very similar to the base drawing to very different.
2.2
Definition
The experiment consisted of three parts, to address the three evaluation criteria. In all cases, the user was asked to respond as quickly as possible without sacrificing accuracy. To promote prompt responses, each trial timed out after 30 seconds if the user did not respond. Rotation Part The rotation part directly addresses the rotation criterion. The user is presented with a screen as shown in Figure 1. The one drawing D on the left is the base drawing; the eight drawings D1 , . . . , D8 on the right are eight different orientations of the same new (InteractiveGiotto-produced) drawing derived from D. The eight orientations consist of rotations by the four multiples of π/2, with and without an initial flip around the x-axis. For orthogonal drawings, only multiples of π/2 are meaningful since it is clear that rotation by any other angle is not the correct choice. The vertices are not labelled in any of the drawings to emphasize the layout of the graph over the specifics of vertex names. The user’s task is to choose which of D1 , . . . , D8 looks most like the base drawing. A “can’t decide” button is provided for cases in which the drawings are too different and the user cannot make a choice. The user’s choice and the time it took to answer are recorded. Ordering Part The ordering part directly addresses the ordering criterion. In this part, the user is presented with a screen as shown in Figure 2. The one drawing D on the left is the base drawing; the two drawings D1 and D2 on the right are two different (InteractiveGiotto-produced) new drawings of the same modified drawing derived from D. The user’s task is to choose which of D1 and D2 looks most like the base drawing. A “can’t decide” button is provided for cases in which the drawings are too different and the user cannot make a choice. The user’s choice and the time it took to answer are recorded. Difference Part The difference part addresses the magnitude criterion by gathering response times on a task, with the assumption that a greater degree of similarity between the drawings will help the user complete the task more quickly. The screen presented to the user is shown in Figure 3. The drawing
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 229 D on the left is the base drawing; the drawing D1 on the right is one of the InteractiveGiotto-produced new drawings derived from D. The user’s task is to identify the vertex present in the right drawing that is not in the left drawing. The vertices are labelled with random two-letter names — corresponding vertices in drawings in a single trial have the same name, but the names are different for separate trials using the same base drawing to prevent the user from simply learning the answer. Displaying the vertex names makes the task less difficult, and mimics the scenario where the user is working with a dynamically updated graph where the vertex labels are important. The user’s choice and the time it took to answer are recorded.
2.3
Methodology
The three parts were assigned to students as part of a homework assignment in a second-semester CS course at Brown University. A total of 103 students completed the problem. Before being assigned the problem, the students had eight lectures on graphs and graph algorithms, including one on graph drawing. They had also been assigned a programming project involving graphs, so they had some familiarity with the subject. The homework problem made use of an online system which presented the displays shown in Figures 1, 2, and 3. A writeup was presented with the problem explaining how to use the system, and the directions were summarized each time the system was run. Each of the three parts was split into four runs, so the students would not have to stay focused for too long without a break. The graphs used were divided into 10 batches: the first batch (the practice batch) contained two modified drawings along with their associated new drawings, and each of the other nine batches contained three modified drawings and the associated new drawings. All of the students were assigned the practice batch for the first run of each part, and were randomly assigned three of the other batches for later runs so that each batch was completed by 1/3 of the students. A given student worked with the same batches for all three of the parts. Within each run of the system, the individual trials were presented in a random order and the order of the right-hand drawings in the rotation and ordering parts was chosen randomly. On average, students spent 6.9 minutes total on all four runs the rotation task (out of 22 minutes allowed), 8.3 minutes on the ordering task (out of 33), and 12.9 minutes on the difference task (out of 22). After the students completed all of parts, they answered a short questionnaire about their experiences. The questions asked were as follows: 1. (Ordering and Rotation) What do you think makes two drawings of nearly the same graph look similar? Are there factors that influenced your decisions? Did you find yourself looking for certain elements of the drawing in order to make your choice?
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 230
Figure 1: The rotation part.
Figure 2: The ordering part.
Figure 3: The difference part.
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 231 2. (Difference) What factors helped you locate the extra vertex more quickly? Did you compare the overall look of the two drawings in order to aid your search, or did you just scan the second drawing? 3. (All Parts) As you consider your answers, think about what this means for a graph drawing algorithm that seeks to preserve the look of the drawing. What types of things would it have to take into account?
3
Measures Evaluated
All of the measures evaluated in this study are described below. Most are the same as or similar to those described in [3]; the primary difference is that all of the measures have been scaled so that 0 means the drawings are identical and 1 is the maximum difference. The upper bound is frequently based on the worst-case scenario for point positioning and may not be achievable by an actual drawing algorithm. (For example, the upper bound may only be achieved when all of the vertices are placed on top of each other, an impossible situation with most drawing algorithms.)
3.1
Preliminaries
Corresponding Objects Most of the measures make use of the fact that the graph in the drawings being compared is the same. (If the graphs are not the same, those parts that are different are ignored and only the common subgraphs used.) This means that each vertex and edge of G has a representation in each of the drawings, and it is meaningful to talk about the corresponding vertex or edge in one drawing given a vertex or edge in the other drawing. Point Set Selection All measures except for the shape measures are defined in terms of point sets derived from the edges and vertices of the graph rather than the edges and vertices themselves. Like vertices and edges, each point in one drawing has a corresponding point in the other drawing. Points can be selected in a variety of ways; inspired by North [13], one point set contains the four corners of each vertex. Inspired by feedback from the study (section 5.2), a second “borders-only” point set was also considered. This is a subset of the “full” point set which contains only those points outside an ellipse centered within the drawing’s bounding box and with radii 90% of the width and height of the bounding box, or whose corresponding point in the other drawing meets this criterion. A change from the previous experiment [3] is that the computation of the nearest neighbor measures skips pairs of points derived from the same vertex. This can have a great effect because a point’s nearest neighbor will often be another corner of the same vertex, which does not convey much information about how that vertex relates to other vertices in the drawing. In this study, a point’s nearest neighbor is the nearest point from a different vertex. This is not
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 232 explicitly written in the definitions below for clarity of notation, but it should be assumed. Drawing Alignment For the measures involving the comparison of coordinates between drawings, the value of the measure is very dependent on how well the drawings are aligned. Consider two identical drawings, but let the x-coordinate of each point in the second drawing be one bigger than the xcoordinate of the corresponding point in the first drawing. The average distance moved by each point will be reported as 1, even though the drawings actually are the same. Aligning the drawings before comparing the coordinates removes this effect. In the previous experiment [3], alignment was done by simultaneously adjusting the scale and translation of one drawing with respect to the other so as to minimize the distance squared between corresponding points. This had the effect of potentially reducing one drawing to a very small area if the drawings did not match well. This has been replaced by a new alignment method which separates the determination of the scale and translation factors into two steps. First, the scale factor is set to ensure that the two drawings are drawn to the same scale. Since the drawings are orthogonal drawings, there is a natural underlying grid which can be used to adjust the scale. Once scaled, the translation factor is chosen so as to minimize the distance squared between corresponding points. The new alignment method is intended to better match how a person might try to match up the drawings — it does not seem likely that someone would mentally shrink or enlarge one drawing drastically with respect to the other, but rather would work with the current scale and try to adjust the translation. Suitability for Ordering vs. Rotation and Ordering Some of the measures do not depend on the relative rotation of one drawing with respect to the other. This means that they fail the rotation test, however, they are included because there may be situations in which the measure is not being used to determine the proper rotation for the drawings. Furthermore, a successful ordering-only measure could be combined with one which is successful at rotation but less so at ordering to obtain a measure which is good at both. Measures suitable for ordering only are marked [order only] below. Notation In the following, P and P 0 will always refer to the point sets for drawings D and D0 , respectively, and p0 ∈ P 0 will be the corresponding point for p ∈ P (and vice versa). Let d(p, q) be the Euclidean distance between points p and q.
3.2
Degree of Match
The following measures measure a degree of matching between the point sets by looking at the maximum mismatch between points in one set and points in
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 233 another. The motivation for these measures is straightforward — if point sets are being used to represent the drawings, then classical measures of point set similarity can be used to compare the drawings. Undirected Hausdorff Distance The undirected Hausdorff distance is a standard metric for determining the quality of the match between two point sets. It does not take into account the fact that the point sets may be labelled. haus(P, P 0 ) =
1 max { max min d(p, q 0 ) , max min d(p0 , q) } p∈P q0 ∈P 0 p0 ∈P 0 q∈P UB
UB is the maximum distance between a corner of the bounding box of P and a corner of the bounding box of P 0 . Maximum Distance The maximum distance is an adaptation of the undirected Hausdorff distance for labelled point sets, and is defined as the maximum distance between two corresponding points: maxdist(P, P 0 ) =
1 max d(p, p0 ) UB p∈P
UB is the maximum distance between a corner of the bounding box of P and a corner of the bounding box of P 0 .
3.3
Position
These measures are motivated by the idea that the location of the points on the page is important, and points should not move too move far between drawings. Average Distance tween drawings.
Average distance is the average distance points move be-
dist(P, P 0 ) =
1 X d(p, p0 ) |P | p∈P
Nearest Neighbor Between Nearest neighbor between is based on the assumption that a point’s original location should be closer to its new position than any other point’s new position. nnb(P, P 0 ) =
1 X weight(nearer(p)) UB p∈P
where
nearer(p) = {q | d(p, q 0 ) < d(p, p0 ) , q ∈ P , q 6= p}
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 234 Unweighted In the unweighted version, the score for p counts only whether or not there are points in P 0 between p and p0 . 0 if |S| = 0 weight(S) = 1 otherwise UB = |P | Weighted In the weighted version, the number of points in P 0 between p and p0 is taken into account. weight(S) UB
3.4
= |S| = |P | (|P | − 1)
Relative Position
These measures are based on the idea that the relative position of points should remain the same. There are two components to relative position — the distance between the points, and the orientation. All of the measures except for average relative distance are concerned with changes in orientation. Orthogonal Ordering Orthogonal ordering measures the change in orientation between pairs of points. Imagine compass roses centered on p and p0 , with north oriented towards the top of the page. Let θq and θq0 be the directions associated with q and q 0 , respectively. (Z 0 ) Z θq θq X 1 min weight(θ) dθ, weight(θ) dθ order(P, P 0 ) = W θq θq 0 p,q∈P
Constant-Weighted In the constant-weighted version, all changes of direction are weighted equally. weight(θ) W
= =
1 π
Linear-Weighted In the linear-weighted version, changes in the north, south, east, west relationships between points are weighted more heavily than changes in direction which do not affect this relationship. The weight function grows linearly with the distance between θ and north, south, east, or west. ( (θ mod π/2) if (θ mod π/2) < π/4 π/4 weight(θ) = π/2−(θ mod π/2) otherwise π/4 W = π/2
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 235 Ranking The ranking measure considers the relative horizontal and vertical position of the point. This is a component of the similarity measure used in the SMILE graph multidrawing system. [1] Let right(p) and above(p) be the number of points to the right of and above p, respectively. rank(P, P 0 ) =
1 X min{ | right(p)−right(p0 ) |+| above(p)−above(p0 ) | , UB } UB p∈P
where UB = 1.5 (|P | − 1) Of note here is that the upper bound is taken as 1.5 (|P |−1) instead of 2 (|P |−1), the actual maximum value occurring when a point moves from one corner of the drawing to the opposite corner. The motivation for this is simply that it scales the measure more satisfactorily. Average Relative Distance [order only] The average relative distance is the average change in distance between pairs of points. rdist(P, P 0 ) =
X 1 | d(p, q) − d(p0 , q 0 ) | |P | (|P | − 1) p,q∈P
λ-Matrix [order only] The λ-matrix model is used by Lyons, Meijer, and Rappaport [10] to evaluate cluster-busting algorithms. It is based on the concept of order type used by Goodman and Pollack [9], where two sets of points P and P 0 have the same order type if, for every triple of points (p,q,r), they are oriented counterclockwise if and only if (p0 ,q 0 ,r0 ) are also oriented counterclockwise. Let λ(p, q) be the number of points in P to the left of the directed line from p to q. 1 X | λ(p, q) − λ(p0 , q 0 ) | lambda(P, P 0 ) = UB p,q∈P
where the upper bound for a set of size n is: (n − 1)2 UB = n 2
3.5
Neighborhood
These measures are guided by the philosophy that each point’s neighborhood should be the same in both drawings. The measures do not explicitly take into account the point’s absolute position, and considers its position relative to other points only in the sense of keeping nearby points together.
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 236 Nearest Neighbor Within [order only] For nearest neighbor within, a point’s neighborhood is its nearest neighbor. Let nn(p) be the nearest neighbor of p in the p’s point set and nn(p)0 be the corresponding point in P 0 to nn(p). Ideally, nn(p)0 should be p0 ’s nearest neighbor. nnw(P, P 0 ) =
1 X weight(nearer(p)) UB p∈P
where nearer(p) = { q | d(p0 , q 0 ) < d(p0 , nn(p)0 ) , q ∈ P , q 6= p , q 6= nn(p) } Unweighted The unweighted version considers only whether or not nn(p)0 is p0 ’s nearest neighbor. 0 if |S| = 0 weight(S) = 1 otherwise UB = |P | Weighted The weighted version takes into account the number of points in P 0 closer to p0 than nn(p)0 . weight(S) UB
= |S| = |P | (|P | − 1)
-Clustering [order only] -clustering defines the neighborhood for each point to be its -cluster, the set of points within a distance , defined as the maximum distance between a point and its nearest neighbor. The -cluster for each point is guaranteed to contain at least one other point. The measure considers the ratio of the number of points in p’s -cluster in both drawings to the number of points in the -cluster in at least one of the drawings; ideally, this ratio would be 1 because the same points would be in both clusters. eclus = 1 −
|SI | |SU |
where SI SU clus(p, P, )
= max min d(p, q) p∈P q∈P,q6=p
= { (p, q) | p ∈ P , q ∈ clus(p, P, ) and q 0 ∈ clus(p0 , P 0 , 0 ) } = { (p, q) | p ∈ P , q ∈ clus(p, P, ) or q 0 ∈ clus(p0 , P 0 , 0 ) } = { q | d(p, q) ≤ , q ∈ P , q 6= p }
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 237 Separation-Based Clustering [order only] In the separation-based clustering measure, points are grouped so that each point in a cluster is within some distance δ of another point in the cluster and at least distance δ from any point not in the cluster. The intuition is that the eye naturally groups things based on the surrounding whitespace. Formally, for every point p in cluster C such that |C| > 1, there is a point q 6= p ∈ C such that d(p, q) < δ, and d(p, r) > δ for all points r 6∈ C. If C is a single point, only the second condition holds. Let clus(p) be the cluster to which point p belongs. |SI | sclus = 1 − |SU | where SI SU
3.6
= { (p, q) | p, q ∈ P , clus(p) = clus(q) and clus(p0 ) = clus(q 0 ) } = { (p, q) | p, q ∈ P , clus(p) = clus(q) or clus(p0 ) = clus(q 0 ) }
Edges
Shape The shape measure treats the edges of the graph as sequences of north, south, east, and west segments and compares these sequences using the edit distance. 1 X edits(e,e’) shape = UB e∈E
Regular The edit distance is not normalized for the length of the sequence, and the upper bound is as follows: X | length(e) − length(e0 ) | + min{ length(e) , length(e0 ) } UB = e∈E
Normalized The edit distance is normalized for the length of the sequence using the algorithm of Marzal and Vidal [11], and the upper bound is as follows: UB = |E|
4
Results: Rotation and Ordering
Figures 4(a) and 4(b) show the results for the rotation and ordering tasks, respectively. The measures are grouped according to the categorization of section 3. These results are explained and discussed in the following sections.
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 238
1 position
degree of match
0.9
edges
relative position
0.8 0.7
correctness
0.96
0.96
0.96
0.96
0.96
0.96
0.96
0.91
0.6 0.5
0.93
0.93
0.94
0.95
0.94
0.94
0.88 0.78
0.4
0.86
0.82 0.50
0.3
0.82
0.81
0.76
0.82 0.76
0.63 0.43
0.2
0.53
0.1 0
Hausdorff maximum unweighted weighted nearest neighbor distance distance between
mode
all
similar
average distance
linear- normalized constantweighted weighted shape orthogonal ordering
ranking
contradictory
features
(a) Rotation task.
1 0.9
degree of match
position 0.99
neighborhood
relative position
0.99
1.00
1.00
1.00
0.96
1.00
0.97
1.00
0.92 0.88
0.91
0.8
0.85
0.86
correctness
0.7 0.6
edges
0.99
0.88
0.84
0.83
0.89
0.91
0.92
0.93
0.93
0.91
0.92
0.91
0.93
0.89 0.88
0.85
0.5 0.4 0.3 0.2 0.1 0
mode Haus. max dist. dist. all
sep.- norm. unw. weighted ave. const.- linear- ranking λ-mat. relative unw. weighted orthogonal dist. neighbor neighbor -clus. based shape dist. ordering cluster within between
similar/features
similar/contradictory
features/features
features/contradictory
contradictory/contradictory
(b) Ordering task.
Figure 4: Average measure correctness for the rotation and ordering tasks. Numbers by columns show average relative correctness for that group; for (b), relative correctness is shown only for the “similar” and “not” trial groups.
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 239
4.1
Correctness
The success or failure of the candidate similarity measures is determined by how well they match observed user responses. A measure’s “correctness” is the fraction of the time the measure correctly predicted user responses on the tasks. For the rotation task, let an individual trial Trot be described by the tuple (D, D1 , . . . , D8 ), where D is the base drawing and the Di are the eight orientations the user must choose between. There are only two drawings that the user must choose between for the ordering task, so an ordering trial Torder can be described by the tuple (D, D1 , D2 ). Let TM be the measure’s choice for a rotation or ordering trial T : Dk if M (D, Dk ) < M (D, Di ) ∀i 6= k tie if ∃ j, k such that M (D, Dj ) = M (D, Dk ) ≤ M (D, Di ) TM = ∀i 6= j, k (j 6= k) Also, let Tk denote user k’s response for trial T : Dk if the user chose drawing Dk Tk = tie if the user clicked the “can’t decide” button Note that Tk is only defined if user k was presented with trial T — each trial was completed by about one-third of the users. Define the correctness of the measure M with respect to user k for T as C(M, T, k): 1 if TM = Tk or if Tk = tie C(M, T, k) = 0 otherwise C(M, T, k) is undefined if Tk is undefined. Any TM is considered to be correct for those trials where the user’s response is “can’t decide” because it is assumed that if the user has no preference as to the correct response, she will be happy with any of the choices. Let K be the set of users k for which Tk is defined for a particular trial T . Then the correctness CM,T of measure M for a trial T is X C(M, T, k) CM,T =
k∈K
|K|
The solid shaded areas behind the columns in Figures 4(a) and 4(b) show the average correctness for each measure over all rotation and all ordering trials, respectively. Only the results for the full point set (for point-based measures) are shown in Figures 4(a) and 4(b); the results for the borders-only point sets are discussed in section 4.4. Also, only results for the normalized shape measure are included because there is little difference in the performance of the two shape measures (p = .95). Unless otherwise specified, the performance of different measures over a set of trials is compared using Student’s t-test to determine the probability that the measures have the same average correctness for those trials.
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 240 Observations For the rotation task, the average correctness over all trials for even the best measures is disappointingly low — below 50%! — meaning that even the best of the tested measures will tend to rotate drawings incorrectly much of the time. For both rotation and ordering, a striking result is that no one measure stands out as being significantly better than the others. There is little difference between the angle-sensitive relative position measures (constant- and linear-weighted orthogonal ordering, ranking, λ-matrix) and the nearest neighbor within measures; distance, weighted nearest neighbor between, and shape also have similar good performance on the rotation task. On the other hand, several measures stand out as being noticeably worse than the others. Hausdorff distance, the clustering neighborhood measures (-clustering and separationbased clustering), unweighted nearest neighbor between, and to a lesser degree maximum distance have the poorest performance over all trials. Figures 5 and 6 summarize the significant similarities and differences in measure performance.
4.2
Correctness By Drawing Category
Some trials were easier than others — one might expect that in the rotation task it might be easier to choose the “correct” rotation when the new drawing is very similar to the old, and that in the ordering task it might be easier to pick the most similar drawing of two when one is very similar to the base. As a result, the measures under consideration may perform better or worse in these circumstances. To evaluate this, the new drawings were separated into categories: similar for drawings very close to the corresponding base, features for drawings somewhat different from the base but with noticeable recognizable features to help identification, contradictory for drawings with recognizable features but where those features contradicted each other (for example, when one feature was rotated with respect to another), and different for drawings that are very different from the base. The trials were also grouped according to the type of drawing(s) involved: rotation trials were considered to be “similar”, “features”, or “contradictory” according to the category of the new drawing used in the trial, and ordering trials were considered to be “similar” or “not” depending on whether or not one of the new drawings in the trial was classified as “similar”. Since only two drawings were classified as “different”, the results from trials involving these drawings were included only in the “all trials” results and not in the results from any other subgroup of trials. The multiple columns for each measure in Figures 4(a) and 4(b) show the average correctness for each category of trials. Figure 4(b) breaks down the trials beyond the two “similar” and “not” groupings, but the discussion is only in terms of the two groups. There were no ordering trials in which both drawings were similar, so that combination is not shown. The categorization used is based on human judgment and the assumption that features play a key role in similarity. The latter assumption is supported
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 241 edges
relative position
degree of match
position
angle−sensitive relative position
normalized shape
average distance weighted nearest neighbor between
ranking orthogonal ordering
maximum distance
unweighted nearest neighbor between
Hausdorff distance
Figure 5: Similarities and differences in measure performance for the rotation task. The vertical position of the measure name indicates its average correctness over all trials, with the lowest at the bottom. Gray-shaded areas group related measures. Measures with similar performance are grouped by ovals; arrows indicate differences between measures or groups of measures. The line style indicates the significance level: solid for p = .01/p = .99, dashed for p = .05/p = .95. by the feedback portion of the study (section 5.2). It is intended that the ordering “similar”, “features”, and “contradictory” represent groups of new drawings that are increasingly different from the base drawing to which they are compared. This goal seems to have been met: in the ordering task, users picked the drawing from the most similar group in 80% of the trials involving drawings from different groups, and the most common user response was the drawing from the most similar group in 90% of the trials. Also, using Student’s t-test to compare the distances between base and new drawings in each group shows that, for all of the similarity measures under consideration except Hausdorff distance, the means of the groups are significantly different and follow the expected pattern (p = .01). Since most of the measures being tested seem to capture at least some of the users’ ideas of similarity, this lends support to the categorization.
unweighted nearest neighbor between
Hausdorff distance
epsilon−clustering
clustering neighborhood maximum distance normalized shape
relative distance
distance−sensitive relative position
separation−based clustering
weighted nearest neighbor between
unweighted nearest neighbor within
non−clustering neighborhood
weighted nearest neighbor within orthogonal ordering lambda matrix
ranking
relative position edges
angle−sensitive relative position
degree of match
neighborhood
position
average distance
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 242
Figure 6: Similarities and differences in measure performance for the ordering task. Observations Within measures, the expected drop in performance between “similar” and “features” trials and between “features” and “contradictory” trials for rotation, and between “similar” and “not” trials for ordering is significant for nearly every measure (p = .01). The only exceptions are for Hausdorff distance in the rotation task (differences are not significant, and average correctness is
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 243 higher for “contradictory” than for “features”) and -clustering for the ordering task (drop in performance is significant only at p = .05).
4.3
Mode Correctness
The “correct” answer for any given trial is based on a user’s opinion, and because approximately 34 students gave responses for each set of drawings, there was the potential for getting different “correct” user responses for the same set of drawings. Since each measure always chooses the same response for the same set of drawings, the best correctness score a measure could receive is if it always makes the choice that was most common among the users. Let f (T, r) be the frequency with which the users completing trial T picked response r from the choices Di . Also define the most common response Tmode as the response for which f (T, r) is maximized, and the correctness of the most common response for trial T and user k as 1 if Tmode = Tk or Tk = tie C(mode, T, k) = 0 otherwise Then the “best possible score” for a measure for trial T is: X C(mode, T, k) Cbest,T =
k∈K
|K|
where K is the set of users completing trial T . The “mode” columns of Figures 4(a) and 4(b) show the average value of Cbest over the various groups of trials. The relative correctness for a given measure and trial is the ratio of the measure’s correctness to the mode correctness for that trial. The numbers listed by the measure columns in Figure 4(a) give the average relative correctness for each group of trials for which the average correctness is given; the numbers shown in Figure 4(b) give the average relative correctness for the “similar” and “not” trial groups. Observations The first observation is that, as one might expect, the average mode correctness drops for the less similar trials. The differences in average mode correctness between “similar”, “features”, and “contradictory” trials in the rotation task and between “similar” and “not” trials in the ordering task are significant (p = .01). The drop in correctness between the more similar and more different trials is due to an increase in user disagreement over the correct answer for each trial. Table 1 summarizes the degree to which users preferred some drawings to others for different groups of trials. The mode correctness is also affected by the number of users choosing “can’t decide” for each trial — a large number of “can’t decide” answers will raise the value of the mode correctness. For rotation, the percentage of “can’t decide” answers grew from 1.1% for “similar” drawings to 3.9% for “features” drawings
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 244 rotation preference no preference
all trials 92% -
similar 100% -
ordering preference no preference
all trials 70% 1.9%
similar 94% -
features 94% -
contradictory 83% not 61% 2.6%
Table 1: Percentage of trials for which users preferred one or more choices over the others, and for which there was no preference. Preference was determined using the χ2 test to compare the distribution of frequencies for each possible choice in a trial with a uniform distribution (the expectation if there was no preference among the choices in the trial). “Preference” indicates a significant difference between the distribution of user responses and the uniform distribution (p = .05); “no preference” indicates no difference between the distribution of user responses and the uniform distribution (p = .95). and 6.7% for “contradictory” drawings. For ordering, the percentage grew from 2.7% for trials involving “similar” drawings to 6.1% for trials not involving “similar” drawings. The increase in “can’t decide” answers partially offsets the drop in mode correctness due to increased user disagreement, but did not cancel out the effect. A second observation concerns the relative correctness. While the average correctness is low for all measures, the relative correctness results are better. For both rotation and ordering, the average correctness is at least 90% of the average mode correctness for most measures. (Exceptions are Hausdorff distance, unweighted nearest neighbor between, and the clustering neighborhood measures (-clustering and separation-based clustering).) This indicates that low correctness values for these measures, especially in the rotation task, are primarily due to disagreements between users about the correct answer rather than major failings on the part of the measures. An interesting note is that the average relative correctness of most measures drops with the more difficult trials — the lower performance for these trials is not due only to increased user disagreement about the correct answer. Table 2 lists the measures for which the drop is significant. The drop in relative correctness, combined with the presence of some user preference for many of even the most different trials, suggests that there are more subtle similarities that users are picking up on that the measures do not capture. The good relative performance for “similar” trials is the result of the drawings in those trials being similar in many ways — including those ways captured by the measures — while the poorer relative performance for more different trials is the result of the measures’ missing something that the users are seeing.
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 245 ordering rotation maximum distance maximum distance unweighted nearest neighbor between weighted nearest neighbor between average distance ranking constant-weighted orthogonal ordering normalized shape linear-weighted orthogonal ordering ranking λ-matrix relative distance unweighted nearest neighbor within weighted nearest neighbor within Table 2: Measures for which the average relative correctness is significantly lower between “similar” or “features” trials and “contradictory” trials (rotation) or between “similar” and “not” trials (ordering); p = .05.
4.4
Border vs. Full Point Sets
Based on user feedback (see section 5.2), a second point set using only those points near the borders of the drawing was tested for point-based measures. There was no significant difference in performance between the two point sets for any measure (p = .95), and so results for the borders-only point set are not included in Figures 4(a) and 4(b).
4.5
Per-User Correctness
The low correctness for even the mode (65% for the most similar drawings) in the rotation task indicates that not all users agree on what the “correct” answer is for a given trial. This suggests that users have different ideas about what factors make drawings look more similar, or different ideas about the relative importance of different aspects of similarity. Let Tk be the set of trials for which Tk is defined, i.e., the set of trials user k completed. Then the correctness of measure M for user k is X C(M, T, k) CM,k =
T ∈Tk
|Tk |
Figure 7 shows CM,k for each measure/user combination in the rotation task. Observations The most striking observations from Figure 7 are that the measures that do badly overall (Hausdorff distance and unweighted nearest neighbor between) perform badly for every user, and the measures that perform well overall tend to all perform well or all perform badly for an individual user. The results are similar, but less dramatic, for the ordering task.
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 246
normalized shape ranking orthogonal linear-weighted ordering constant-weighted average distance nearest neighbor weighted between unweighted
99
38
81
36
97
90
40
87
72
82
59
58
27
54
70
63
22
37
66
89
29
101
6
92
74
7
46
30
61
42
98
26
78
48
maximum distance Hausdorff distance
users
Figure 7: Average correctness per user for the rotation task. Colors indicate the average correctness, from light gray (1) to black (0). Each measure label (except normalized shape) spans two rows, where the top row shows the borders-only point set and the bottom row the full point set. rotation borders-only better full better no difference
all trials 5.8% 2.0% 23%
similar 100%
ordering borders-only better full better no difference
all trials 6.9% 8.8% 1.0%
similar 4.9% 8.8% 40%
features 54%
contradictory 7.1% 39% not 6.9% 9.8% 2.9%
Table 3: Percentage of users which are significantly better predicted by one of the point sets used (p = .05), and the percentage for which there is no difference (p = .95). Of interest, though, is that there is a small group of users who are significantly better- or worse-predicted by the borders-only point set than the full point set. The CM,k values for a user k for selected measures were compared for the full and borders-only point set using Student’s t-test. The measures used were for the better measures: all of the point-based measures except Hausdorff distance, unweighted nearest neighbor between, and the clustering neighborhood measures (-clustering and separation-based clustering). Table 3 summarizes the results. The cases for which the borders-only point set performs better meshes well with the feedback from the study (section 5.2), though many more users commented on the importance of the borders than had a significant improvement for that point set. One possibility for this is that the change in the border may be representative of the change in the drawing as a whole, so that full point set performs well for users even if they are focusing primarily on the borders of the drawing. For the rotation task, another possibility is that many of the measures
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 247 are already more sensitive to changes in the border regions than in the centers of the drawings because rotation moves points near the borders farther than those near the center. This means that the full point set versions will tend to perform similarly to the border-only sets for rotation. Another interesting note is that a larger number of users were betterpredicted by the border point set for more different trials than for the similar trials. This suggests that the borders become important when the obvious similarities disappear — when the drawings are similar, users can easily select their responses based on the overall look of the drawing, but when the drawings become more different, they begin focusing on the borders to look for distinguishing characteristics. Focusing on cases where the borders-only point set outperforms the full point set ignores those instances where the reverse is true. In fact, more users are predicted better by the full point set than by the borders-only point set for the ordering task — a pattern which is not seen in the results from the rotation task. This may be the result of users looking for different things in each task — the overall look may be more important in the ordering task, while users gravitate towards the borders when looking for hints as to the proper orientation in the rotation task. The border-sensitivity of many measures under rotation may also explain this difference — if both full and border-only point sets are sensitive to the same things, they will tend to perform in the same way and thus the full point set will not perform better.
4.6
Other Rotation Angles
The rotation task focused on differences of π/2 in the rotation angle — a very large difference, though it is the only meaningful difference for orthogonal drawings since a user can easily tell that a rotation by some other angle is not the best match. Ideally, there would be no change in a measure’s correctness if additional rotation angles are considered, since the user’s “correct” answer would not change. Figure 8 shows the average correctness over all trials for three sets of orientations: the π/2 multiples (with and without an initial flip around the x-axis) discussed so far (labelled “π/2”), the π/2 multiples augmented by the four additional multiples of π/4 (labelled “π/4”), and the π/2 multiples augmented by the four additional rotations π/36, π/2 + π/36, π + π/36, and 3π/2 + π/36 (labelled “π/36 offsets”). (The shape measure is not included in the figure because it is defined only in terms of orthogonal drawings.) The π/4 set adds several additional orientations, though the angle between successive rotations is still relatively large; the π/36 offsets add rotation angles which are very close to angles a user would consider. The additional rotations were not presented to the users, as it was assumed that no one would pick one of them. Observations Clearly the ideal outcome did not happen — over all trials, there is a drop in the average correctness with the addition of the extra orienta-
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 248 1 position
degree of match
0.9
relative position
0.8
correctness
0.7 0.6 0.5 0.4 0.3 0.2 0.1 0
mode
Hausdorff distance
average maximum unweighted weighted distance nearest neighbor between distance π/2
π/4
π/36 offsets
ranking
linearconstantweighted weighted orthogonal ordering
Figure 8: Measure correctness for rotation with other sets of orientations. tions and the drop is greater for the π/36 offsets group than for the π/4 group. Table 4 summarizes the significant results. If the correctness criterion is relaxed so that measures are only expected to choose a rotation near the correct one, the drop in performance is eliminated. The expanded definition of “correct” is as follows: Cnear (M, T, k) = 1 if Tk is “tie” or if the rotation angle of TM is within ±π/4 of the rotation angle of Tk for “π/4” and within ±π/36 for “π/36 offsets.” The improvement in the results indicates that when the wrong rotation is chosen, it tends to be near the right one. This suggests that while the measures would likely perform less satisfactorily when asked to pick the correct rotation in non-orthogonal applications, they would still perform reasonably well if the goal is only to obtain approximately the right orientation.
5 5.1
Other Results Difference Task
The goal in the difference part was to be able to use the user’s response times as an indicator of similarity, the idea being that a user can locate the new vertex faster if the drawings are more similar. As a test of the validity of this, the times on the difference part were used to order the pairs of drawings used in the ordering task. The results were very unsatisfactory, achieving only 45% correctness on average (compare to Figure 4(b), where even the worst of the
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 249 π/2 vs. π/4 Hausdorff distance maximum distance nearest neighbor between unweighted weighted average distance orthogonal ordering constant-weighted linear-weighted ranking
all trials
π/2 vs. π/36 offsets Hausdorff distance maximum distance nearest neighbor between unweighted weighted average distance orthogonal ordering constant-weighted linear-weighted ranking
all trials >> >>
similar
>> >> >>
> >
similar
>> > >
>> >> >>
features
contradictory
>>
>>
= == ==
>> >>
== == ==
> > >
>>
features > >>
contradictory
>> >> >>
> >> >>
>> >> >>
> > >>
>>
Table 4: Comparing the average performance for each group of trials for different sets of orientations. “>” and “>>” indicate a drop in performance with additional drawings; “=” and “==” indicate that the performance did not change. The number of symbols indicates the significance level: “>” and “=” for p = .05/p = .95, “>>” and “==” for p = .01/p = .99. measures under consideration reached 62% correctness). As a result, the times on the difference task are not a good indicator of similarity and are not suitable for evaluating measures with respect to the magnitude criterion.
5.2
User Feedback
The students’ responses to the final questionnaire yielded several interesting notes. As might be expected, the responses as to what makes two drawings look similar in the rotation and ordering parts included a sizable percentage (35%) who said preserving the position, size, number of large vertices was important and another large percentage (44%) who said they looked for distinctive clusters and patterns of vertices, such as chains, zigzags, and degree 1 vertices. More surprising was that 44% of the students said that borders and corners of the drawing are more important than the interior when looking for similarity. This is supported by research in cognitive science indicating that people often treat
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 250 filled and outline shapes as equivalent, focusing primarily on the external contour (Wickelgren [18]). A number of these students mentioned the importance of “twiddly bits around the edges” — distinctive clusters and arrangements of vertices, made more obvious by being on the border. Related comments were also that the orientation and aspect ratio of the bounding box should remain the same, and that the outline of the drawing should not change. Another sizable group (34%) commented that the “general shape” of the drawing is important. For the question about the difference part, several users expressed frustration at the difficulty of the task. The usefulness of the “big picture” view — looking at the overall shape of the drawing — was contested, with nearly equal numbers reporting that the overall look was useful in the task, and that it was confusing and misleading. About 16% of the users mentioned limited use of the overall look, using it on a region-by-region basis to quickly eliminate blocks that remained the same and falling back on simply scanning the drawing or matching corresponding vertices and tracing edges when the regions were too different. Another 24% reported using vertex-by-vertex matching from the beginning. A similar-sized group (20%) figured out shortcuts, such as that the edges added along with the new vertex frequently caused one of the neighboring vertices to have a degree larger than 4 and thus be drawn with a larger box, so they scanned for the neighbors of the large boxes to find the new vertex. Overall, just over a quarter of the users (28%) reported searching for vertices with extra edges rather than searching for new vertex directly. For the final question, about what a graph drawing algorithm should take into account if the look of the drawing should be preserved, the most common answers echoed those from the rotation/ordering question: maintaining vertex size and shape, the relative positions of vertices, the outline of the drawing, and clusters.
6
Conclusions and Future Work
Table 5 summarizes the best and worst of the measures evaluated. As groups, the angle-sensitive relative position measures (orthogonal ordering, ranking, and λ-matrix) and the non-clustering neighborhood measures (weighted and unweighted nearest neighbor within) performed significantly better than the degree-of-match measures (Hausdorff distance and maximum distance) and the clustering neighborhood measures (-clustering and separationbased clustering). As a result, the orthogonal ordering, ranking, λ-matrix, and nearest neighbor within measures are given the highest ranking. Two of the three position measures (weighted nearest neighbor between and average distance) also perform significantly better than the degree-of-match and clustering neighborhood measures, and so are also ranked well. They are given the second-level ranking because there was a slightly greater dropoff in their performance when additional rotation angles were introduced, suggesting that they might not perform quite as well for non-orthogonal drawings. Shape and relative distance are also given an above-average ranking be-
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 251 best measures angle-sensitive relative position non-clustering neighborhood position
n edges distance-sensitive relative position
ranking orthogonal ordering (constant- and linear-weighted) λ-matrix nearest neighbor within (weighted and unweighted) average distance weighted nearest neighbor between shape relative distance
middle-of-the-road n measures degree of match maximum distance worst measures clustering neighborhood n position n degree of match
-clustering separation-based clustering unweighted nearest neighbor between Hausdorff distance
Table 5: Overall ranking of the measures evaluated. Measures are listed in groups from best to worst; groups are separated by horizontal lines. There is little difference between measures in a single group. cause of their performance on the ordering task — while not significantly worse than the top-ranked measures, they were also not significantly better than the bottom-ranked measures. It should be noted that shape was among the best measures for the rotation task. Maximum distance received a middle-of-the-road ranking because of its middle-of-the-road performance in both tasks — while it performed as well the several top-ranked measures for the “similar” rotation trials, its average correctness was between the top- and bottom-ranked measures for both rotation and ordering. Also, when the degree-of-match measures were considered as a group, their performance was significantly worse than the top-ranked groups. The clustering neighborhood measures and the unweighted nearest neighbor between measure all performed significantly worse than the top-ranked groups of measures, and so are given a low ranking. Hausdorff distance is given the bottom ranking because it performs significantly worse than most other measures in most groups of trials. Several other conclusions can be drawn from this study: • The difference in relative correctness between the more similar and more different trials for both rotation and ordering task suggests that there are
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 252 more subtle notions of similarity which are being missed by the measures tested, and which, if incorporated, would improve their performance. • The per-user analysis suggests that while it is meaningful to talk about “good” measures and “bad” measures in overall terms, to get the maximum performance it may be necessary to tailor the specific similarity measure used to a particular user. • The difficulty of the difference part suggests that the amount of difference between the drawings that is considered reasonable varies greatly with the task — when the user simply needs to recognize the graph as familiar, the perimeter of the drawing and the position and shape of few key features are the most important. On the other hand, when trying to find a specific small change, the drawings need to look very much alike or else the user needs some other cues (change in color, more distinctive vertex names, etc.) in order to highlight the change. The students’ responses on the questionnaire suggest several possible directions for future investigation. • The number of students who mentioned focusing on drawing borders was surprising, and additional study is needed to further investigate the importance of borders. • Large vertices are identified as being especially important, which could lead to a scheme in which changes in the position and size of large vertices are weighted more heavily than other vertices. • Another major focus was clusters of vertices — both the presence of clusters in general, and the presence of specific shapes such as chains and zigzags. The relatively poor showing of the clustering measures indicates that they are not making use of clusters in the right way. The fact that the students reported looking for specific shapes suggests an approach related to the drawing algorithms of Dengler, Friedell, and Marks [6] and Ryall, Marks, and Shieber [16]. These algorithms try to produce drawings which employ effective perceptual organization by identifying Visual Organization Features (VOFs) used by human graphic designers. VOFs include horizontal and vertical alignment of vertices, particular shapes such as “T” shapes, and symmetrically placed groups of vertices. VOFs can also be used not to guide the creation of drawings from scratch, but to identify features in an existing drawing that may be important because they adhere to a particular design principle. This is related to the work of Dengler and Cowan [5] on semantic attributes that humans attach to drawings based on the layout — for example, symmetrically placed nodes are interpreted as having common properties. A similarity measure could then measure how well those structures are preserved, and an interactive graph drawing algorithm could focus on preserving the structures.
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 253
References [1] T. Biedl, J. Marks, K. Ryall, and S. Whitesides. Graph multidrawing: Finding nice drawings without defining nice. In S. Whitesides, editor, Graph Drawing (Proc. GD ’98), volume 1547 of Lecture Notes Comput. Sci., pages 347–355. Springer-Verlag, 1998. [2] T. C. Biedl and M. Kaufmann. Area-efficient static and incremental graph drawings. In R. Burkard and G. Woeginger, editors, Algorithms (Proc. ESA ’97), volume 1284 of Lecture Notes Comput. Sci., pages 37–52. Springer-Verlag, 1997. [3] S. Bridgeman and R. Tamassia. Difference metrics for interactive orthogonal graph drawing algorithms. Journal of Graph Algorithms and Applications, 4(3):47–74, 2000. [4] S. S. Bridgeman, J. Fanto, A. Garg, R. Tamassia, and L. Vismara. InteractiveGiotto: An algorithm for interactive orthogonal graph drawing. In G. Di Battista, editor, Graph Drawing (Proc. GD ’97), volume 1353 of Lecture Notes Comput. Sci., pages 303–308. Springer-Verlag, 1997. [5] E. Dengler and W. Cowan. Human perception of laid-out graphs. In S. H. Whitesides, editor, Graph Drawing (Proc. GD ’98), volume 1547 of Lecture Notes Comput. Sci., pages 441–443. Springer-Verlag, 1998. [6] E. Dengler, M. Friedell, and J. Marks. Constraint-driven diagram layout. In Proc. IEEE Sympos. on Visual Languages, pages 330–335, 1993. [7] G. Di Battista, A. Garg, G. Liotta, R. Tamassia, E. Tassinari, and F. Vargiu. An experimental comparison of four graph drawing algorithms. Comput. Geom. Theory Appl., 7:303–325, 1997. [8] U. F¨ oßmeier. Interactive orthogonal graph drawing: Algorithms and bounds. In G. Di Battista, editor, Graph Drawing (Proc. GD ’97), volume 1353 of Lecture Notes Comput. Sci., pages 111–123. Springer-Verlag, 1997. [9] J. E. Goodman and R. Pollack. Multidimensional sorting. SIAM J. Comput., 12(3):484–507, Aug. 1983. [10] K. A. Lyons, H. Meijer, and D. Rappaport. Algorithms for cluster busting in anchored graph drawing. J. Graph Algorithms Appl., 2(1):1–24, 1998. [11] A. Marzal and E. Vidal. Computation of normalized edit distance and applications. IEEE Transactions on Pattern Analysis and Machine Intelligence, 15(9):926–932, Sept. 1993. [12] K. Misue, P. Eades, W. Lai, and K. Sugiyama. Layout adjustment and the mental map. J. Visual Lang. Comput., 6(2):183–210, 1995.
Bridgeman and Tamassia, Similarity Measures, JGAA, 6(3) 225-254 (2002) 254 [13] S. North. Incremental layout in DynaDAG. In Graph Drawing (Proc. GD ’95), volume 1027 of Lecture Notes Comput. Sci., pages 409–418. SpringerVerlag, 1996. [14] A. Papakostas, J. M. Six, and I. G. Tollis. Experimental and theoretical results in interactive graph drawing. In S. North, editor, Graph Drawing (Proc. GD ’96), volume 1190 of Lecture Notes Comput. Sci., pages 371–386. Springer-Verlag, 1997. [15] A. Papakostas and I. G. Tollis. Interactive orthogonal graph drawing. IEEE Trans. Comput., C-47(11):1297–1309, 1998. [16] K. Ryall, J. Marks, and S. Shieber. An interactive system for drawing graphs. In S. North, editor, Graph Drawing (Proc. GD ’96), volume 1190 of Lecture Notes Comput. Sci., pages 387–393. Springer-Verlag, 1997. [17] R. Tamassia, G. Di Battista, and C. Batini. Automatic graph drawing and readability of diagrams. IEEE Trans. Syst. Man Cybern., SMC-18(1):61– 79, 1988. [18] W. A. Wickelgren. Cognitive Psychology. Prentice-Hall, Inc., Englewood Cliffs, NJ, 1979.
Journal of Graph Algorithms and Applications http://www.cs.brown.edu/publications/jgaa/ vol. 6, no. 3, pp. 255–279 (2002)
Graph Layout Aesthetics in UML Diagrams: User Preferences Helen C. Purchase
Jo-Anne Allder
David Carrington
School of Information Technology and Electrical Engineering The University of Queensland Brisbane 4072, Australia {hcp,joanne,davec}@itee.uq.edu.au Abstract The merit of automatic graph layout algorithms is typically judged by their computational efficiency and the extent to which they conform to aesthetic criteria (for example, minimising the number of crossings, maximising orthogonality). Experiments investigating the worth of such algorithms from the point of view of human usability can take different forms, depending on whether the graph has meaning in the real world, the nature of the usability measurement, and the effect being investigated (algorithms or aesthetics). Previous studies have investigated performance on abstract graphs with respect to both aesthetics and algorithms, finding support for reducing the number of crossings and bends, and increasing the display of symmetry. This paper reports on preference experiments assessing the effect of individual aesthetics in the application domain of UML diagrams. Subjects’ preferences for one diagram over another were collected as quantitative data. Their stated reasons for their choice were collected as qualitative data. Analysis of this data enabled us to produce a priority listing of aesthetics for this domain. These UML preference results reveal a difference in aesthetic priority from those of previous domain-independent experiments.
Communicated by Michael Kaufmann: submitted April 2001; revised December 2001 and June 2002.
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)256
1
Introduction
The success of automatic graph layout algorithms which display relational data in a graphical form is typically measured by their computational efficiency and the extent to which they conform to aesthetic criteria (for example, minimising the number of crossings, maximising orthogonality). In addition, designers of these algorithms often claim that by conforming to these aesthetic criteria, the resultant graph drawing helps the human reader to understand the information embodied in the graph. However, little research has been performed on the usability aspects of such algorithms: do they produce graph drawings that make the embodied information easy to use and understand? Is the computational effort expended on conforming to conventional aesthetic criteria justifiable with respect to better usability? As automatic graph layout algorithms are increasingly being used in information visualisation systems (for example, for the visualisation of social networks or data-flow diagrams), it is important that the effectiveness of these algorithms from a user point of view is investigated, to ensure that the algorithms used are appropriate for the domain being modelled. In defining a framework for experimentation in this area, we identify three dimensions of usability studies investigating the merit of graph drawing algorithms from a human perspective: the nature of the graph (syntactic or semantic), the type of usability measurement (preference or performance), and the effect being investigated (algorithms or aesthetics). • Syntactic graph drawing experiments use a graph structure that has no meaning in the real world: it is merely an abstract collection of nodes with relationships between them. Semantic graph drawing experiments use a graph within a particular application domain: in this case, the graph has meaning in the real world (for example, a transport network, or a dataflow diagram), and the experimental tasks are performed in relation to the information represented. • Preference experiments ask the subjects to state their preference of one drawing over another. Subjects may or may not be able to explain the reasons for their preference: sometimes it may be based on an inexplicable personal view. A more quantifiable measurement of usability can be determined in performance experiments, where subjects are required to perform a particular task (or tasks) using a given graph: the data collected in performance experiments is the extent of the subjects’ success in performing the task. • Two possible effects on usability may be investigated in graph drawing experiments: the effect of individual aesthetics (e.g. reducing crossings, maximising orthogonality) and the effect of the use of different algorithms (producing drawings conforming to different aesthetics to varying degrees). In the case of investigating aesthetics, the experimental drawings need to be produced by hand, with appropriate manipulation of the variables; in
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)257 the case of investigating algorithms, the experimental drawings would be produced by existing layout algorithms, Two previous studies have investigated syntactic performance. The first experiments considered the effect of individual aesthetics, and found support for reducing the number of crossings and bends, and increasing the display of symmetry. However, no support was found for maximising the minimum angle or increasing orthogonality (Purchase, 1997). The second experiment considered the effect of eight different algorithms, and revealed that it is difficult to say that one algorithm is ‘better’ than another in the context of syntactic understanding of the abstract graph structure (Purchase, 1998). This paper reports on two semantic, preference experiments that investigated the effect of individual aesthetics. The application domains are the presentation of two types of UML diagrams: class diagrams and collaboration diagrams. Performance experiments are left for a later study. All these experiments are part of a larger project, the aim of which is to perform a thorough empirical investigation of the aesthetics underlying graph layout algorithms, and the algorithms themselves, in an attempt to influence the future design of graph layout algorithms through empirical human (rather then computational) experimentation.
2 2.1
Experimental scope and definition The application domain: UML diagrams
Many different methods and models have been proposed to capture a complete specification of requirements and a comprehensive design representation in a formal software engineering process. The Unified Modeling Language (UML) (Booch, Rumbaugh and Jacobson, 1998) was chosen as the semantic domain for these preference, aesthetics experiments, as it is rapidly becoming the de facto standard for modelling object oriented systems. UML provides a mainly graphical notation to represent the artifacts of software systems. The notation is relatively new but it is rapidly being adopted as the accepted notation for object-oriented analysis and design. UML incorporates notations to describe systems at various levels of abstraction. UML diagrams can be used to model requirements, designs, implementations and tests. Since these diagrams are a means of communication between customers, developers and others involved in the software engineering process, it is critical that the notation is standardised, and that the diagrams present information clearly. Appropriate layout of these diagrams can assist in achieving this goal. UML uses several different types of graph drawings that aim to describe a system to meet the users’ needs at reasonable cost. Two UML diagram types, class and collaboration, were selected for the experiments reported here. Class diagrams describe the types of objects in the system, and the static relationships between them. These relationships are either subtypes (representing
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)258 inheritance) or associations (representing other types of relationship). Collaboration diagrams indicate how the objects in a system collaborate. They show the interaction of objects and the sequence of events by numbering the events in the order in which they occur (along the arcs), referring to objects as nodes in the graph. While other studies (for example Irani and Ware, 2000) address user performance with UML, they do not do so from the perspective of automatic graph layout algorithms and aesthetics.
2.2
Aims
The aim of the experiment is to identify an ordered list of the aesthetic features preferred by subjects when embodied in UML class and collaboration diagrams. Such a list can indicate to interface designers of CASE tools the most suitable way to lay out their diagrams for the best response from users. It will also form the basis for more extensive experiments concentrating on performance of users in software engineering tasks. The study aimed to identify the ‘subjectively pleasing’ aesthetics in graph drawings. Evaluation of the graph drawings was done solely according to human, individual preference. Performance with respect to a task or correctness of interpretation has been left for a further study.
2.3
Aesthetics investigated
Using graphs from a semantic domain instead of an abstract graph structure introduces additional secondary notations that are particular to the formal semantic notation. Secondary notations are layout or graphical cues that tend not to be part of the formal notation (e.g. adjacency, clustering, white space) (Petre, 1995). Thus, while this experiment included some graph drawing aesthetics as advocated by designers of generic layout algorithms, it also included investigation of other layout features specifically related to the standard UML notation. For each experiment (class and collaboration), a suitable subset of aesthetic features was identified. These were selected based on emphases in the literature (e.g. Colman and Stott Parker (1996), and Petre (1995)), and as ones that could feasibly be applied to UML diagrams. Many of them were also considered in the prior experiments (Purchase 1997, 1998) and most could be used for both types of diagram. Six aesthetics were evaluated for both class and collaboration diagrams: • minimize bends (the total number of bends in polyline edges should be minimized (Tamassia, 1987)) • minimize edge crossings (the number of edge crossings in the drawing should be minimized (Reingold and Tilford, 1981))
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)259
taught by teaches
teach
(a)
(b)
Figure 1: The UML class diagram secondary notation features investigated, showing both alternatives: (a) inheritance, (b) directional indicators. • orthogonality (fix nodes and edges to an orthogonal grid (Tamassia, 1987; Papakostas and Tollis, 2000)) • width of layout (the physical width of the drawing should be minimised (Coleman and Stott Parker, 1996)) • text direction (all text labels should be horizontal, rather than a mixture of horizontal and vertical) (based on Petre, 1995) • font type (all text fonts should be the same, rather than using different fonts for different types of labels) (based on Petre, 1995) For UML class diagrams, two additional secondary notation features were investigated. Both versions of each notation have been found in published examples of UML notation (See Figure 1). • inheritance (inheritance lines should be joined prior to reaching the superclass, rather than being represented as separate arcs) • directional indicators (arcs should be labelled with two relationship labels and directional indicators, rather than one) For UML collaboration diagrams, two additional secondary notation features were investigated. In both cases, the one option (long arrows adjacent to the arcs) is standard UML notation (See Figure 2). • adjacent arrows (all arcs are undirected with an adjacent arrow indicating the direction of the message sent, rather than all arcs being directed) • arrow lengths (the arrows adjacent to the arcs should be the same length as the arcs, rather than shorter than the arcs) 2.3.1
Usability measuring method
As these were our first experiments performed on layout aesthetics and secondary notations for UML diagrams, preference was chosen as the method of
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)260
(a)
(b)
Figure 2: The UML collaboration diagram secondary notation features investigated, showing both alternatives: (a) adjacent arrows, (b) arrow lengths. usability measurement. While increased preference does not necessarily correspond with improved performance, beginning with a preference study enables the most important layout features to be identified before a more substantial performance study can be performed. The subjects were chosen as being people who had seen and used diagrams of this nature before. Thus, it is a reasonable assumption that, by asking whether they prefer one UML drawing to another, they are likely to be anticipating the use of these drawings for a software engineering task: their responses are therefore likely to be related to their perceived usefulness of the diagrams. Three experiments were performed: Experiment 1 determined the preferences for eight aesthetics embodied in UML class diagrams (70 subjects). Experiment 2 determined preferences for aesthetics embodied in UML collaboration diagrams (90 subjects). In both cases, the quantitative data was the percentage of subjects who preferred one diagram over another, and the qualitative data was the subjects’ stated reasons for their choice. The qualitative data was used to determine whether the reasons for preference were linked to the aesthetics under consideration, or whether there were any other unexpected reasons for the choice. Experiment 3 was a more focussed study which refined the results of the first two experiments, emphasising particular aesthetics that had given surprising results. 6 subjects participated, and extensive qualitative data was collected.
2.4
Methodology
A basic UML class diagram (depicting the relationships between students, lecturers, tutors and administrative staff, see Figure 3) and a basic UML collaboration diagram (depicting the procedure followed for organising honours students’ seminars, see Figure 4) were created. In both cases, the graph structures were complex enough to enable an appropriate and varied manipulation of the nodes and arcs within the diagram, but not so complex that the diagram would take a long time to read. The class diagram had 14 classes and 18 relationships, and the collaboration diagram had 12 objects and 17 messages. Each diagram was drawn 16 times (twice for each aesthetic), with all the information within the drawing remaining constant: only the layout of the dia-
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)261
Figure 3: A UML class diagram used in experiment 1. grams was altered. Each representation of the graph was drawn with attention to a specific graph-drawing aesthetic or secondary notation choice. Figures 9 to 12 shown in the appendix present examples of some of the drawings. Graph drawings were grouped in pairs emphasising the contrast between the diagrams: one graph drawing in the pairwise comparison contained a higher presence of the aesthetic while the other graph drawing contained a lower pres-
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)262
Figure 4: A UML collaboration diagram used in experiment 2. ence. For example, one diagram was highly orthogonal while the paired diagram had minimal orthogonality. In the absence of computational metrics for measuring the presence of the UML and secondary notation features in the drawings, and due to the large number of aesthetics being investigated concurrently, the other aesthetics in each contrasting pair could not be controlled. We were aware that not controlling the other aesthetics could have resulted in confounding factors: for example, the diagram with lots of bends may have differed from its paired diagram in both the number of bends as well as in the extent of its perceived orthogonality; the diagram with joined inheritance may have had an increased number of bends. A more robust experiment would have controlled all variables: but this was impossible. Therefore, to prevent our overall conclusions being affected by potential confounding factors which may have biased the simple preference
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)263 quantitative data, we collected additional qualitative and ranking data. This additional data enabled us to see where subjects may have made a preference choice that was unrelated to the aesthetic being considered, and to consider the quantitative data in the light of these possible confounds. We anticipated that this qualitative data therefore would prove very important in determining our final priority list. 2.4.1
Subjects
Seventy student volunteers from the University of Queensland participated in the class diagram evaluation; ninety students participated in the collaboration diagram evaluation. The same experimental methodology and materials were used for both experiments. All participants were third or fourth year Information Technology students who, although not generally proficient with UML, have experience with similar notations (e.g., Fusion, dataflow diagrams, entity relationship diagrams and Booch diagrams). The experiments took place during lecture sessions, and participation was voluntary. Some students may have participated in both experiments. Prior to both experiments, pilot experiments with a small number of subjects were performed to check for problems in experimental materials and procedures. 2.4.2
Materials
Each subject was presented with an individual evaluation booklet designed to be completed without evaluator assistance and without a time limit. The booklet had the following structure: • Instructions, including the aim of the project, an explanation of the procedure, and an example. • A questionnaire requesting information about the subject (prior knowledge and use of graph drawings, year of study etc.). • A UML tutorial sheet, identifying the key points of the diagram under consideration (class or collaboration). This sheet was detached from the booklet so that subjects did not have to turn back to refer to it. • Eight (facing) pairs of graphs drawings were presented in turn, each pair consisting of a diagram referred to as A, and a diagram referred to as B. At the bottom of the A diagram, the statement “I prefer diagram A to diagram B” was presented (and a comparable, reversed, statement was presented at the bottom of the B diagram). Students were asked to select one of these two statements, and there was a space for them to write a brief explanation for their choice. The explanation was intended to identify any issues influencing the choice that had not been considered, and to provide qualitative data to support the quantitative data. The diagram pairs were presented in a random order in the booklet, in an attempt to counter any
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)264 familiarity effect: after seeing several different representations of the same UML diagram, the subject may develop a deeper understanding of the information, and may therefore make different preference choices. • A ranking sheet where subjects needed to rank the three diagrams that they most preferred (1-3), and the three that they least preferred (14-16). A separate large sheet, showing all 16 (reduced in size) diagrams on one page, was provided to assist in this ranking. There was no time limit, and the subjects could go back and change any previous answers if they wished. Most subjects completed the task in about 20 minutes. 2.4.3
Data Analysis
The preference questions were analysed by calculating a percentage preference for each aesthetic, with the significance of the result computed using a standard binomial distribution. A result was considered significant (i.e., not attributable to chance or random selections) if its probability was less than 0.05. The written explanations for preferences were analysed by determining the percentage of subjects who stated that the targeted aesthetic comparison influenced their choice: this allowed us to identify whether there were any possible confounds (i.e., other aesthetics unintentionally affecting the result) in the quantitative data obtained by the subjects’ preferences. The final ranking question was analysed to identify preferred diagrams by computing an overall weighted preference value for each diagram. A weight of 3 was given for a first choice, a weight of 2 for a second choice, a weight of 1 for a 3rd choice, a weight of -1 for a 14th choice, a weight of -2 for a 15th choice and a weight of -3 for a 16th choice.
3 3.1
Results Results: UML class diagrams
The quantitative results for UML class diagrams are shown in tabular form in Figure 5. Crosses: 93% of the subjects preferred the diagram with fewer crosses. Of the subjects who chose the diagram with fewer crosses, 88% made direct reference to the number of crossing lines: “Fewer lines crossing”, “The other diagram has too many crossing lines.” Of the subjects who chose the diagram with many crosses, none indicated that the crosses aesthetic playing any part in their choice; rather, their preference was for the arrangement of the classes “type of students are close, clear, regardless of the crossing lines.”
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)265
aesthetic choice fewer crosses fewer bends horizontal labels only joined inheritance arcs narrower more orthogonal no font variation directional indicators
% preference 93% 91% 86% 76% 73% 61% 61% 60%
Figure 5: Aesthetic preference results for UML class diagrams (all results significant).
Figure 6: Weighted ranking values for all sixteen class diagrams.
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)266 Bends: 91% of the subjects preferred the diagram without bends. Of the subjects who chose the diagram without bends, 52% made direct reference to the bends: “straight lines are better than bent lines”; “Less bends and therefore faster and easier to understand”, while 13% commented on the hierarchical layout of this diagram: “Better sorting out of classes (same sort of classes grouped together”). Of the subjects who chose the diagram with bends, none indicated that the bends feature affected their choice: the relationship of classes to one another was a deciding factor (“more common information stored in center”). Text direction: 86% of the subjects preferred horizontal text to a mixture of horizontal and vertical text. Of the subjects who chose the horizontal text diagram, only 20% commented on the text direction: “It is harder to read vertical writing”, while 34% commented on inheritance direction “Prefer to follow inheritance from top/left to bottom down.” Most of the subjects who chose the combination of vertical and horizontal referred to direction of inheritance flow: “Because most arrows are going down and that is the way we are used to reading things.” Inheritance notation: 76% of the subjects preferred the joined inheritance lines (i.e., as the notation specifies) over the graph drawing method of using separate arcs. Of those who chose the joined inheritance lines, 53% made direct reference to the way in which inheritance was depicted: “shows inheritance more clearly”, “more structure.” Of the subjects who chose the separate lines, 47% referred to the representation of inheritance: “having individual arrowheads makes it easier to see number of inheritance”, “This is more compact.” Overall width: 73% of the subjects preferred a narrower layout over a wide layout. All the subjects who preferred the narrow layout referred directly to the width of the diagram: “the closeness allows you to view more association which helps in following the class diagram”; “[wide] is too hard to follow as the lines are too long.” Of those who preferred the wider layout, 90% referred to the width: “[narrow] is too cluttered – it’s harder to see the details”, “makes it easier to take things in with a quick glance.” Orthogonality: 61% of the subjects preferred the more orthogonal drawing over the non-orthogonal one. Of those who preferred the orthogonal drawing, 62% referred to the underlying grid: “straight and 90 degree angle lines are easier to follow”, while an additional 33% referred to structure: “overall layout is more structured.” Of those who liked the non-orthogonal drawing, 63% referred to the bends that were introduced in the orthogonal drawing: “lines with bends require more tracing”, “straight diagonals are better than L shaped lines.” Font type: 61% of the subjects preferred the use of the same font over varying fonts. Of those who preferred the use of the same font, 63% referred to the
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)267 use of fonts: “same font allows less distraction”; other subjects referred to the grouping of classes. 65% of those who preferred the use of varying fonts stated this feature as the reason for their choice: “different fonts make it easier to separate sections.” Directional indicators: 60% of the subjects preferred having directional indicators associated with every labelled relationship, rather than not having the directional indicators at all. Of those who liked the directional labels, 88% stated that this was the reason for their choice: “directional labels make arcs more readable”, “clearer, precise.” Of those who did not like these labels, 75% referred to them : “having two labels on the association lones only complicates it. It’s obvious how the relationships work”; “Less complex.”
3.2
Discussion: UML class diagrams
By analysing the subjects’ stated reasons for their preferences, the only class diagram aesthetic result that appeared to be affected by confounding factors was horizontal labels, where many subjects who preferred the horizontal labels drawing referred to direction of information flow. Both the crosses and bends aesthetic results were unaffected by other factors, while those subjects who did not like the orthogonal diagram did so because of the increased number of bends. Most of those subjects who preferred independent inheritance arcs, a wider diagram, variation in font, or no directional indicators did so merely because of personal preference, rather than because there were other factors that affected their choice. The stated preference reasons indicated that the direction of flow was an important consideration: this was an aesthetic that had not been included in this initial experiment. The results of the ranking question (with the ranks scaled with values from 3 to -3) are shown in Figure 6, which presents the weighted overall ranking value for each of the 16 drawings. It shows a distinct dislike for the diagram with many crosses, and preference for joined inheritance lines.
3.3
Results: UML collaboration diagrams
The results for UML collaboration diagrams are shown in tabular form in Figure 7. Crosses: 91% of the subjects preferred the diagram with no crosses. Of those who preferred the cross-free diagram, 82% referred explicitly to the crosses: “Crossed arcs make it difficult to interpret”, “there are no intersections.” None of the students who preferred the diagram with crosses did so because of the crosses — direction of flow appeared to be more important: “it filters down”; “I prefer arrows pointing down rather than up.”
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)268
aesthetic choice fewer crosses no adjacent arrows longer arrows no font variation more orthogonal narrower horizontal labels only fewer bends
% preference 91% 90% 82% 70% 63% 57% 54% † 53% †
Figure 7: Aesthetic preference results for UML collaboration diagrams († indicates a non-significant result).
Figure 8: Weighted ranking values for all sixteen collaboration diagrams.
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)269 Directional indicators: 90% of the students preferred having a single edge connecting the nodes, rather than an additional directional arc alongside the connecting edge. Of those who favoured not having the additional arrow, 61% made reference to the number of arcs “single connecting line also indicates direction of relationship”, “single lines are less confusing, especially at any intersections”, “less cluttered.” There were no comments on the number of arcs from those subjects who preferred the alternative diagram; 66% referred to direction of flow: “actor at top is more intuitive.” Arrow lengths: 82% of the subjects preferred having longer adjacent arrows. However, of those who preferred the diagram with longer arrows, 57% referred to structure (“neater, better structure”, “more ordered”), while only 11% referred explicitly to the arrows: “arrows are longer so easier to see what message is passed.” Of those who liked the shorter arrows, 25% referred to the arrows: “shorter arrows still convey the meaning but don’t clutter up the diagram”, while 19% commented on flow “I like the graph from left to right and top to bottom.” Font type: 70% of the subjects preferred the use of the same font throughout the diagram, rather than different fonts for different label types. Of those who preferred the same fonts, 81% made direct reference to font: “don’t like the mixture of fonts/boldness; while 6% referred to crossings “less crossed lines.” 62% of the subjects who preferred the different fonts did so because of their personal preference for different fonts: “the change in font makes it easy to see the difference.” Orthogonality: 63% of the subjects preferred the highly orthogonal diagram. 35% of those who preferred the orthogonal diagram referred to the grid structure: “arrows aren’t on angles, they are all square”; 51% said they preferred the “more structured” look. Many of those subjects who did not like the orthogonal drawing referred to the increased number of bends (52%) “lines with corners are difficult to follow visually”; “easier to read because you don’t have to go around corners when you look at the arrows.” Width of layout: 57% of the subjects preferred a wider layout. Of these, 62% referred to better utilisation of space: “more spread out”, while 8% referred to the existence of bends in the alternate diagram: “no jagged lines.” Of those who preferred the narrower diagram, 43% referred to the width directly: “it’s more compact - easier to take in”; others (24%) referred to the direction of flow: “actor at left, mostly top-to-bottom and left-to-right message passing.” Text direction: 54% of the subjects preferred the use of horizontal labels only (this is a statistically insignificant result). 65% of the subjects who preferred the horizontal text only made reference to the text: ‘this diagram does not have vertically positioned text which makes it easier to read”. 10% referred to
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)270 space: “less cluttered.” Of the subjects who preferred the diagram with both vertical and horizontal text, none mentioned the text at all: the comments were concerned with structure: “squarer”, “structured”, “straight lines.” Bends: 52% of the subjects preferred the diagram with few bends (this is a statistically insignificant result). Of those who preferred the diagram with few bends, 38% referred to bends: “prefer straight arrows”, while 29% mentioned space considerations“less cluttered and more spread out.” The subjects who preferred the diagram with bends made no mention of the bends in the diagram at all. Their comments were related to the single arc cross (24%) “crossing lines is bad”, space: “shorter distances between objects” (31%) and flow: “left/right and top/down approach” (19%).
3.4
Discussion: UML collaboration diagrams
By analysing the subjects’ stated reasons for their preferences, the only collaboration diagram result that appeared to be affected by confounding factors was longer arrows, where many subjects who preferred the longer arrows referred to diagram structure. Both the crosses and adjacent arrows aesthetic results were unaffected by other factors, while those subjects who did not like the orthogonal diagram did so because of increased bends. Most of those subjects who preferred a wider diagram or variation in font did so merely because of personal preference. The results for the use of horizontal labels only and bends were not significant, so no conclusions can be drawn for these two aesthetics as these results could be attributable to chance. Like the class diagrams, the effect of flow on the subjects’ preferences was evident. The results of the ranking question (with the ranks scaled with values from 3 to -3) are shown in Figure 8, which presents the weighted overall ranking value for each of the 16 drawings. It shows a distinct dislike for the diagram with many crosses, and preference for orthogonality.
4
Addressing the confounds: the third experiment
It was clear from the comments that the subjects provided as to their preferences that in a few cases, their decision had been made according to factors other than the targeted aesthetic. For example, some subjects preferred the collaboration diagram with both horizontal and vertical text because it appeared more orthogonal. Experiment 3 was a follow-up experiment that focussed on the aesthetics common to both class and collaboration diagrams, targeting particular aesthetics for which the preference results may have been affected by confounding
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)271 factors. Its aim was to investigate some of the unexpected results from experiments 1 and 2 that may have been due to confounding factors in the diagrams, and to create a final priority list of aesthetics.
4.1
Direction of flow
The subjects’ comments had indicated that the direction of flow of information had sometimes influenced their preference. Direction of flow was an aesthetic feature that had not originally been targeted and which was introduced into experiment 3, with the following definition: • flow (directed arcs should point in a consistent direction, preferably topto-bottom and left-to-right) (Eades and Sugiyama, 1990)
4.2
The focussed experiments
Six separate smaller experiments comprised this investigation. They were performed in intensive, focussed interviews where each subject was questioned about which aspects of a set of diagrams influenced their preferences. Six subjects took part, each being questioned about all six diagram sets, and providing extensive qualitative data with which to form a prioritised list of aesthetics. None of these subjects had participated in the prior two experiments. The format of each of the six experiments differed according to the specific investigation of the experiment 1 and 2 results that were being considered. The general procedure was that subjects were shown three or four different diagrams, and were asked questions about their layout preferences. Most of the diagrams used in experiment 3 were ones that had been used in experiment 1 or 2, although some were altered to target specific aesthetics, or to correct any obvious confounding factors. For example, the original collaboration diagram with few bends had some crossing arcs that had been identified as influencing some subjects’ preference for the diagram with more bends and no crossing arcs. Two categories of unexpected quantitative results were investigated in these six smaller, focussed interview experiments. First, we investigated some surprising overall weighted ranking values. Second, we investigated some aesthetics for which the percentage preferences differed between the class and collaboration diagrams. In each case, we reviewed the diagrams that had been used for experiments 1 and 2 and tried to determine whether there were any confounding factors that may have led to these surprising results. 4.2.1
Overall weighed ranking values:
In both the class and collaboration diagram experiments, the weighted ranking for the diagram with least crosses was negative. It was unlikely that this diagram was ranked according to its lack of crosses: careful inspection of both “least crosses” diagrams revealed that both appeared to be less orthogonal than the
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)272 other fifteen diagrams in the corresponding set. The first two experiments of experiment 3 focussed on these diagrams. In experiment 3.1, the original collaboration diagram with no crosses was used, as well as two other diagrams which had no crosses: one which had consistent flow, and one which had high orthogonality. Subjects were asked to rank the three diagrams, and explain their choice. We thought that the original diagram with no crosses had not been favoured by subjects because of its lack of orthogonality, and the outcomes of experiment 3.1 confirmed this: the orthogonal diagram was highly preferred, even though its flow was inconsistent. Some support for flow was demonstrated. Experiment 3.2 took a similar form, with class diagrams. We thought that the original “least crosses” diagram may not have been favoured because of its single crossed arc and its lack of orthogonality. Two crossless drawings were introduced for comparison and ranking, one which was highly orthogonal, and one which had consistent flow. Like experiment 3.1, the subjects showed preference for orthogonality over consistent flow, and clearly stated that they did not like the single crossed arc. 4.2.2
Difference in percentage preference between class and collaboration diagrams:
Four differences in the preferences for the aesthetics in experiments 1 and 2 were addressed: bends, font variations, text direction and width. Bends: The results for experiment 2 did not indicate a significant preference for the collaboration diagram with the least bends. Inspection of the pair of collaboration diagrams related to the bends aesthetic revealed that the diagram with more bends had a more consistent direction of flow, and the one with no bends had a single crossed arc. The third experiment of experiment 3 focussed on these diagrams. Experiment 3.3 used both the original collaboration diagrams with bends, and with no bends. A third diagram was introduced: it was the same as the original diagram with no bends, but with the confound of the crossing arc removed. The fourth diagram used was the same as the original diagram that had bends, but with the bends removed: this diagram had a more consistent flow, and we wanted to determine whether it was because of this flow that the subjects preferred the diagram with no bends. The results of this experiment supported our view that the direction of flow and the presence of the single cross had influenced subjects’ preference decisions in experiment 2. Font variation: Using consistent font was preferred more in the collaboration diagram than in the class diagram, and it was felt that this could have been because the collaboration diagram that used a variety of fonts included a more unusual font (cursive) than the corresponding class diagram (italic). This issue
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)273 was addressed in the fourth experiment by producing identical diagrams with no font variation, and with more subtle font variation (bold). In experiment 3.4, three collaboration diagrams of identical layout were used: the first used the same font throughout, the second used a cursive font for the object names, and the third used a bold font for the object names. The results supported our view that the subjects’ dislike of font variation is dependent on the type of fonts used, and that the cursive font was particularly disliked by the subjects. Text direction: The diagram that only used horizontal text was preferred to a much greater extent in class diagrams than in collaboration diagrams. On inspection of the collaboration diagram with both vertical and horizontal text, it appeared to have a more orthogonal shape. We addressed the possibility of these initial results being confounded by this orthogonal structure in experiment 3.5. In this case, we used exactly the same layout for two diagrams, the only difference being the font direction, where one of the diagrams used both vertical and horizontal text. The third diagram had both horizontal and vertical text, but was more orthogonal. The fifth experiment confirmed that orthogonality could have affected the subjects’ preferences in the first experiment, and was considered as a more important feature than text direction. Width: There was a stronger preference for narrow width in class diagrams than in collaboration diagrams. Although the qualitative data from experiments 1 and 2 suggested that preference for width may be an inexplicable subjective opinion, we also thought the amount of information associated with arcs in the collaboration diagram may have affected this preference decision. Experiment 3.6 used two class diagrams with identical object and association layout, one of which was much smaller than the other. The scaling was performed by reducing the arc lengths only: the node sizes remained the same. Two collaboration diagrams with similar size variation were also used. Subjects were asked which they preferred from each pair. The sixth experiment confirmed that the amount of information on the arcs in collaboration diagrams makes smaller diagrams less attractive. While some subjects could not explain why they preferred the narrower or wider diagram, those that could explain their preference did so by referring to the amount of information in the collaboration diagram. 4.2.3
Conclusions
The follow-up experiments provided rich qualitative data which shed insight on the initial quantitative data. By analysing the extensive interview comments provided by the subjects, we were able to identify which of the aesthetics were most important to them when presented with diagrams that embodied more than one.
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)274 We concluded that the priority order of the aesthetics common to both diagram types is: arc crossings, orthogonality, information flow, arc bends, text direction, width of layout and font type. Of the UML-specific aesthetics, we concluded that joined inheritance arcs and directional indicators are preferred for class diagrams. For collaboration diagrams, no adjacent arrows are preferred (although this preference is incompatible with UML notation). This list provides a useful starting point for further studies on UML diagram layout aesthetics with respect to performance in a related task.
5
Discussion
The previous syntactic performance experiment (Purchase, 1997) found support for reducing the number of crossings and bends, and for increasing the symmetry. Information flow and width were not considered. The results of this semantic preference experiment confirm that the evidence is overwhelmingly in favour of reducing the number of arc crossings as the most important aesthetic to consider. While the results of the syntactic experiments did not highlight orthogonality as being important, in the domain of UML diagrams, this aesthetic moves up the priority list to second place. In addition, while bends were deemed more important than orthogonality in the syntactic experiments, this was not the case in these UML diagrams. This is an important point when there is an obvious direct relationship between the extent of orthogonality and the number of bends in a diagram. This difference between the results of the prior syntactic experiments and these semantic experiments is a clear signal that algorithms that are designed for abstract graph structures, without consideration of their ultimate use, will not necessarily produce useful visualisations of semantic information. This preference study is only the first step in assessing the usability of graph drawings produced by layout algorithms when used in application domains. While preference is a useful start, the real measure of effectiveness of aesthetics is their impact on task performance. Future work includes investigating aesthetics and algorithms with respect to measures of performance in UML related tasks, and extensions of this methodology to other domains. Graph-based domains like software engineering, social and transport network analysis, and database design are increasingly requiring tools to assist with network visualisation and design. If graph layout algorithms are to be of any use in these areas, it is important that empirical research like that reported here is performed, so that the most appropriate algorithms can be matched with the application domains.
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)275
Acknowledgements We are grateful to the students in the School of Information Technology and Electrical Engineering at The University of Queensland who participated in these experiments. This research was partly funded by an Australian Research Council grant.
References [1] G. Booch, J. Rumbaugh, and I. Jacobson. The Unified Modeling Language User Guide. Addison-Wesley, 1998. [2] M. Coleman and D. Stott Parker. Aesthetics-based graph layout for human consumption. Software – Practice and Experience, 26(12):1415–1438, 1996. [3] P. Eades and K. Sugiyama. How to draw a directed graph. Journal of Information Processing, 13(4):424–437, 1990. [4] P. Irani and C. Ware. Diagrams based on structural object perception. In Proceedings of the Conference on Advanced Visual Interfaces, Palermo, Italy, pages 61–67, 2000. [5] A. Papakostas and I. Tollis. Efficient orthogonal drawings of high degree graphs. Algorithmica, 26(1):100–125, 2000. [6] M. Petre. Why looking isn’t always seeing: Readership skills and graphical programming. CACM, 38(6):33–44, June 1995. [7] H. C. Purchase. Which aesthetic has the greatest effect on human understanding? In G. Di Battista, editor, Proceedings of Graph Drawing Symposium 1997, pages 248–259. Springer-Verlag, Rome, Italy, 1997. LNCS, 1353. [8] H. C. Purchase. Performance of layout algorithms: Comprehension, not computation. Journal of Visual Languages and Computing, 9:647–657, 1998. [9] E. Reingold and J. Tilford. Tidier drawing of trees. IEEE Transactions on Software Engineering, SE-7(2):223–228, 1981. [10] R. Tamassia. On embedding a graph in the grid with the minimum number of bends. SIAM J. Computing, 16(3):421–444, 1987.
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)276
Appendix
Fig. 9. The collaboration diagram with no arrows.
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)277
Fig. 10. The class diagram with directional indicators.
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)278
Fig. 11. The collaboration diagram with both horizontal and vertical text.
H.C. Purchase et al., Layout Aesthetics in UML, JGAA, 6(3) 255–279 (2002)279
Fig. 12. The class diagram with many crosses.
Journal of Graph Algorithms and Applications http://jgaa.info/ vol. 6, no. 3, pp. 281–311 (2002)
Visualization of the High Level Structure of the Internet with Hermes Andrea Carmignani1 Giuseppe Di Battista1 Walter Didimo2 Francesco Matera1 Maurizio Pizzonia1 1 Dipartimento di Informatica e Automazione, Universit` a di Roma Tre, via della Vasca Navale 79, 00146 Roma, Italy. {carmigna,gdb,matera,pizzonia}@dia.uniroma3.it http://www.dia.uniroma3.it/ 2 Dipartimento di Ingegneria Elettronica e dell’Informazione, Universit` a di Perugia, Via G. Duranti 93, 06125 Perugia, Italy. [email protected] http://www.diei.unipg.it/
Abstract Hermes is a system for exploring and visualizing the Internet structure at the level of the Autonomous Systems and their interconnections. It relies on a three-tier architecture, on a large repository of routing information coming from heterogeneous sources, and on sophisticated graph drawing engine. Such an engine exploits static and dynamic graph drawing techniques, specifically devised for the visualization of large graphs with high density.
Communicated by Michael Kaufmann: submitted February 2001; revised December 2001 and May 2002.
Research supported in part by the European Commission – Fet Open project COSIN IST-2001-33555.
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
1
282
Introduction and Overview
Computer networks are an endless source of problems and motivations for the Graph Drawing and for the Information Visualization communities. Several systems aim at giving a graphical representation of computer networks at different abstraction levels and for different types of users. To give only some examples (an interesting survey can be found in [17]): 1. Application level: Visualization of Web sites structures, Web maps [18, 16], and Web caches [10]. 2. Network level: Visualization of multicast backbones [23], Internet traffic [24], routes, and interconnection of routers. 3. Data Link level: Interconnection of switches and repeaters in a local area network [2]. We deal with the problem of exploring and visualizing the interconnections between Autonomous Systems. An Autonomous System (in the following AS) is a group of networks under the same administrative authority. Roughly speaking, an AS can be seen as a portion of the Internet, and Internet can be seen as the totality of its ASes. To maintain the reachability of any portion of the Internet each AS exchanges routing information with a group of other ASes mainly selected on the basis of economic and social considerations. Several tools have been developed for analyzing and visualizing the Internet topology at the ASes level [9, 12, 24, 30]. However, in our opinion, such tools are still not completely satisfactory both in the interaction with the user and in the effectiveness of the drawings. Some of them have the goal of showing large portions of Internet, but the maps they produce can be difficult to read (see e.g. [9]). Other tools point the attention on a specific AS, only showing that AS and its direct connections (see e.g. [24]). In this work we describe a new system, called Hermes, that provides a publicly accessible service over the Web1 . It has a three-tier architecture which allows the user to visually explore the Internet topology by means of automatically computed maps. Such maps are computed by a graph drawing module based on the GDToolkit library [21] whose main features are the following: • Its basic drawing convention is the podevsnef [20] model for orthogonal drawings having vertices of degree greater than four. However, since the handled graphs have often many vertices (ASes) of degree one connected with the same vertex, the podevsnef model is enriched with new features for representing such vertices. • It is equipped with two different graph drawing algorithms. In fact, at each exploration step the map is enriched and hence it has to be redrawn. Depending on the situation, the system (or the user) might want to use a 1 http://www.dia.uniroma3.it/∼ hermes
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
283
static or a dynamic algorithm. Of course, the dynamic and the static algorithms have advantages and drawbacks. The dynamic algorithm allows the user to preserve its mental map [19, 27] but can lead, after a certain number of exploration steps, to drawings that are less readable than those constructed with a static algorithm. • The static algorithm is based on the topology-shape-metrics approach [14] and exploits recent compaction techniques that can draw vertices with any prescribed size [13]. The topology-shape-metrics approach has been shown to be very effective and reasonably efficient in practical applications [15]. • The dynamic algorithm is a new dynamic graph drawing algorithm that has been devised according to three main constraints. (1) It had to be completely integrated within the topology-shape-metrics approach in such a way to be possible to alternate its usage with the usage of the static algorithm. (2) It had to be consistent with the variation of the podevsnef model used by Hermes. (3) It had to allow vertices of arbitrary size. Several algorithms have been recently proposed in the literature on dynamic graph drawing algorithms. A linear time algorithm for orthogonal drawings is presented in [5]. In this algorithm the position of the vertices cannot be changed after the initial placement. Four different scenarios for interactive orthogonal graph drawings are studied in [29]. Each scenario defines the changes allowed in the common part of two consecutive drawings. An interactive version of Giotto [33] is described in [8]; it allows the user to incrementally add vertices and edges to an orthogonal drawing in such a way that the shape of the common part of two consecutive drawings is preserved and the number of bends is minimized under this constraint. A dynamic algorithm for orthogonal drawings that allows us to specify the relative importance of the number of bends vs. the number of changes between two consecutive drawings is given in [6]. Other algorithms for constructing drawings of graphs incrementally, while preserving the mental map of the user, are for example [26, 11, 28]. Also, a study on different metrics that can be used to evaluate the changes between drawings in an interactive scenario is presented in [7]. However, as far as we know, none of the cited dynamic algorithms enforces all the constraints (1), (2), and (3). The paper is organized as follows. In Section 2 we give basic definitions about graph drawing and AS level networking which are needed to understand the rest of the work. The reader that is not interested in networking may skip Section 2.1. In Section 3 we explain how the user interacts with Hermes and provide a high level description of the functionalities of the system. In Section 4 we give some details about the three-tier architecture of Hermes. Section 5 shows the results of a study on the ASes interconnection graph. Such a study has been performed in order to design the drawing convention and the drawing algorithms of Hermes. In particular, we analyze the density of the graph and its distribution, and we give measures on the average degree of the vertices.
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
284
In Section 6 we describe in detail the drawing convention and the algorithms used by system. The techniques we adopt are not limited to the application domain described in this paper, but they are suitable for exploring and visualizing general large graphs with high density. In Section 7 some statistics about the effectiveness of Hermes as a Web service are provided. Conclusions and open problems are given in Section 8.
2 2.1
Background Networking
Each AS groups a set of networks. An AS is identified over the Internet by an integer number while each network is identified by its IP address. A route is a (directed) path on the Internet that can be used to reach a specific set of (usually contiguous) IP addresses, representing a set of networks. A route is completely described by its destination IP addresses, its cost, and by the ordered set of ASes that it traverses (usually called AS-path). Routes can be seen as advertisements, from an AS to its adjacent ASes, meaning “through me you can reach a certain set of networks, with a certain cost and traversing a certain set of other ASes”. In order to exchange information about the routes, the ASes adopt a routing protocol called BGP (Border Gateway Protocol) [31]. Such a protocol is based on a distributed architecture where border routers that belong to distinct ASes exchange information about the routes they know. Two border routers that directly exchange information are said to perform a peering session, and the ASes they belong to are said to be adjacent. We define the ASes interconnection graph as the graph having a vertex for each AS and one edge between each pair of adjacent ASes. Note that, according to our definition, the ASes interconnection graph is not a multigraph. Each route is incrementally built. A route is originated by an AS and initially it contains only such AS, then it is propagated to adjacent ASes which append their identifiers to the AS-path of the route and propagate it again. Hence, in the AS-path of a route two consecutive ASes are always adjacent.
2.2
Graph Drawing
We assume familiarity with elementary graph theory and graph connectivity [22]. A plane drawing Γ of a graph G maps each vertex of G to a point of the plane, and each edge of G to a Jordan curve between the two points associated with the end-vertices of the edge. A drawing Γ of G is planar if any two edges never intersect except at common end-vertices. A graph is planar if it admits a planar drawing. A planar drawing Γ of G induces for each vertex v of G a circular clockwise ordering of the edges incident on v. Also, Γ subdivides the plane into topologically connected regions, called faces. Exactly one of these
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
285
faces is unbounded; it is called external face. The other faces are said to be internal. Two planar drawings of G are said to be equivalent if (i) for each vertex v of G they induce the same ordering of the edges around v, and (ii) they have the same external face. Note that two equivalent drawings of G have the same set of faces. An embedding φ of G is a class of equivalent planar drawings of G. In other words, we can regard an embedding of G as the choice of a clockwise ordering of the edges around every vertex plus the choice of the external face. An embedded graph Gφ is a planar graph G with a given embedding φ. An orthogonal drawing of G is a drawing of G such that all edges are represented as polygonal lines of horizontal and vertical segments. Clearly, an orthogonal drawing of G exists if and only if G is 4-planar, that is, each vertex of G has at most four incident edges. An orthogonal representation (or shape) of G is an equivalence class of planar orthogonal drawings such that the following hold: 1. For each edge (u, v) of G, all the drawings of the class have the same sequence of left and right turns (bends) along (u, v), while moving from u to v. 2. For each vertex v of G, and for each pair {e1 , e2 } of clockwise consecutive edges incident on v, all the drawings of the class determine the same angle between e1 and e2 . Roughly speaking, an orthogonal representation defines a class of orthogonal drawings that may differ only for the length of the segments of the edges. In order to orthogonally draw graphs of arbitrary vertex degree, different drawing conventions have been introduced in the literature. Here we recall the podevsnef (planar orthogonal drawing with equal vertex size and not empty faces) drawing convention, defined by F¨ oßmeier and Kaufmann [20]. In a podevsnef drawing (see Figure 1 (a)): 1. Vertices are points of an integer coordinate grid (but it is easier to think of them in terms of squares of half unit sides centered at grid points). 2. Two segments that are incident on the same vertex may overlap. Observe that the angle between such segments has zero degree. 3. All the polygons representing the faces have area strictly greater than zero. 4. If two segments overlap they are presented to the user as two very near segments. An algorithm that computes a podevsnef drawing of an embedded planar graph with the minimum number of bends is presented in [20] . Further, the authors conjecture that the drawing problem becomes NP-hard when Condition 3 is omitted. The podevsnef drawings generalize the concept of orthogonal
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
1
286
3
2 4
5
6
7
(a)
3 1
vertex
2 4 5 6
7
1 2 3 4 5 6 7
width 1 2 0 0 0 0 0
height 1 0 0 0 1 0 0
(b)
Figure 1: (a) A podevsnef drawing; (b) A podavsnef drawing with the same shape as the drawing in (a); the sizes of the vertices are specified in the table. representation, allowing angles between two edges incident to the same vertex to have a zero degree value. The consequence of the assumption that the polygons representing the faces have area strictly greater than zero is that the angles have specific constraints. Namely, because of Conditions 2 and 3, each zero degree angle is in correspondence with exactly one bend [20]. An orthogonal representation corresponding to the above definition is a podevsnef orthogonal representation. A drawing convention that allows the user to draw graphs in which each single vertex has a prescribed size (width and height) has been introduced in [13]. Such a drawing convention is referred to as podavsnef (planar orthogonal drawing with assigned vertex size and non-empty faces). A podavsnef drawing has the following properties (see also Figure 1 (b)): 1. Each vertex is a box with specific width and height (assigned to each single vertex by the user).
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
287
2. Two segments that are incident on the same vertex may overlap. Again, the angle between such segments has zero degree. 3. Consider any side of length l ≥ 0 of a vertex v and consider the set I of arcs that are incident on such side. (a) If l + 1 > |I| then the edges of I cannot overlap. (b) If l + 1 ≤ |I| then the edges of I are partitioned into l + 1 non-empty subsets such that all the edges of the same subset overlap. 4. The orthogonal representation constructed from a podavsnef drawing by contracting each vertex into a single point is a podevsnef orthogonal representation. A polynomial time algorithm for computing podavsnef drawings of an embedded planar graph with the minimum number of bends over a wide class of podavsnef drawings is also described in [13].
3
Using Hermes
The user interacts with Hermes through a map (subgraph) of the ASes interconnection graph. A map is initially constructed using two possible starting primitives. AS selection An AS is chosen. The obtained map consists of such an AS plus all the ASes that are connected to it. See Fig. 2(a). Routes selection A set of routes is selected. The user has three possibilities: (1) selection of all the routes traversing a specific AS (see Fig. 3(a)); (2) selection of the routes starting from a specific AS (see Figs. 3(b)); (3) selection of all the routes traversing a specific pair of ASes. The obtained map consists of all the ASes and connections traversed by the selected routes. The user can explore and enrich the map by using the following primitive: AS exploration an AS u among those displayed in the current map is selected. The current map is augmented with all the ASes that are connected to u. Further, for each AS v connected to u an edge (u, v) is added. Observe that, according to this definition, a map is a subgraph of the ASes interconnection graph but in general it is not an induced subgraph. Fig. 2 shows a sequence of exploration primitives applied to the map of Fig. 2(a). ASes 5583, 5484, and 6715 are explored in Fig’s. 2(b), 2(c), and 2(d), respectively. Fig. 2 highlights several features of Hermes. Hermes can construct new drawings either using a static or a dynamic graph drawing algorithm. The drawing of Fig. 2(b) has been constructed with a dynamic algorithm starting
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
(a) Selection of AS 12300.
(b) Exploration of AS 5583.
(c) Exploration of AS 5484.
(d) Exploration of AS 6715.
288
Figure 2: Exploration steps in the ASes graph. The selected AS is always drawn red.
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
(a) Map containing all the routes traversing AS 137.
(b) Map containing only routes starting from AS 137.
Figure 3: Selection of the routes traversing AS 137.
289
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
290
Figure 4: A map obtained with several exploration steps.
from the drawing of Fig. 2(a), and the drawing of Fig. 2(d) has been constructed with the same algorithm starting from the drawing of Fig. 2(c). Conversely, the drawing of Fig. 2(c) is obtained with a static algorithm. The choice of the algorithm to be applied can be done by the system (see Section 6) or forced by the user. Since the ASes degree can be large (see Section 5), in the project of the drawing algorithms of Hermes, special attention has been devoted to the representation of vertices of high degree. Fig. 2 shows how the vertices of degree one are placed around their adjacent vertices. A more complex map obtained with Hermes is depicted in Fig. 4. It contains more than 150 ASes. Working on a map, independently on the way it has been obtained, the user can get several information on any AS: General Info name, maintainers, and description of the AS. See Fig. 5. Routing Policies For each connected AS, an expression describing the policy and its cost. See Fig. 5. This is possible both for in and for out policies. The default AS is also displayed. Internal Routers List of the known border routers with the IP-numbers of the interfaces. Peering sessions with other routers are displayed.
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
291
Figure 5: General Info and routing policies for AS 5484.
Routes List of the routes originated by the AS (see Fig. 6). It is also possible to visualize the propagation of a given route in the ASes composing the map. AS Macros List of the macros [3] including the AS.
4
A Three-Tier Architecture
Hermes has a three-tier client/server architecture. The user interacts with a top-tier client which is in charge of collecting user requests and showing results. The requests are forwarded by the client to a middle-tier server which is in charge to process the raw data extracted from a repository (bottom-tier). The client is a multi-document GUI-based application. It allows the user to carry-on multiple explorations of the ASes interconnection graph at the same time. The Java technology has been used to ensure good portability. Snapshots of the GUI have been shown in Section 3. In Hermes the middle-tier server maintains the state of the session, that is the current map, for each connected user. The client communicates with the
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
Figure 6: Routes through AS 5583.
292
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
293
server opening a permanent TCP connection for each user. This permits to amortize the inefficiency of the connection set up over all the requests of session. The protocol transported by such connections is specifically tailored for our application. In particular, the server sends its reply in the form of serialized software objects describing ASes, links, and related geometric information. The Java run-time environment transparently encodes objects into bytes on the middle-tier server and consistently decodes them on the client side. The repository is updated off-line from a plurality of sources. At the moment we access the following databases adopting, for representing data, the RPSL language [1]: ANS, APNIC, ARIN, BELL, CABLE&WIRELESS, CANET, MCI, RADB, RIPE, VERIO. Further, we access the routing BGP data provided by the Route views project of the Oregon University [25]. However, the repository is easily extensible to other data sources. Data are filtered so that only the information used by Hermes are stored in the database, but no consistency check or ambiguity removal is performed in this stage. The overall size of the repository is about 50 MB. The adopted DBMS technology is currently mysql. The crucial part of the system is mainly located in the middle-tier. The top-tier requests two types of service to the middle-tier. General info services the top-tier queries about ASes, routes, and path properties. Topology services the top-tier queries for a new exploration and gets back a new map. Info services requests are independent of each other and hence are independently handled by the middle-tier. On the contrary, topology services requests are always part of a drawing session. Each client may open one or more drawing sessions. Each drawing session is associated with a map that can be enriched by means of exploration requests. Info services requests are directly dispatched to a mediator. The mediator module is in charge to retrieve the data from the repository and to remove ambiguities on-the-fly. Topology services requests are handled by the kernel of the middle-tier. It gets information from the mediator and inserts new edges and vertices into the map. The drawing is computed by the drawing engine module (see Section 6). The drawing engine is based on the GDToolkit [21] library.
5
AS Interconnection Data from a Graph Drawing Perspective
In order to devise effective graph drawing facilities for Hermes, we have analyzed the ASes interconnection graph G. The data at our disposal2 show the following structure for G. 2 Observation
of May 2000.
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
294
Number of ASes
1000
100
10
1
50
100
150
200
250
300
350
400
450
Degree
Figure 7: AS degree distribution (log. scale)
10000
Number of ASes
1000
100
10
1 0
5
10
15
20
25
Local density
Figure 8: AS local density distribution (log. scale)
30
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
295
100
percentage of ASes
80
60
40
20
0 0
5
10
15
20
25
30
density
Figure 9: Percentage of ASes adjacent to an AS whose local graph has at least a given value of density
The number of vertices of G is 6, 849 and the number of edges is 27, 686. Fig. 7 illustrates the distribution of the degree of the vertices. The figure shows that while there are many vertices (about 75%) with degree less than or equal to 4, there are also several vertices whose degree is more than 100. For improving the readability of the chart, we have omitted two vertices with degree 862 and 1, 044, respectively. Further, consider that G contains 473 isolated vertices. The density of G is 4.04. However, the “local” density can be much greater. In order to estimate such a local density, we have computed, for each vertex v, the density of the subgraph induced by the vertices adjacent to v. We call such graphs local graphs. Fig. 8 illustrates the distribution of the densities of the local graphs. From the figure it is possible to observe that about 5% of the local graphs have density greater than 10. We have also tried to estimate the probability, for a user that explores G, to encounter a portion of G that is locally dense. Fig. 9 shows, for each value d of density, what is the percentage of vertices that are adjacent to a vertex whose local graph has density at least d. Note that more than 30% of the vertices are adjacent to a vertex whose local graph has density at least 10. Concerning connectivity, the graph has 480 connected components, including the above mentioned 473 isolated vertices. One of them has 6, 360 vertices; each of the remaining 6 components has less than 6 vertices.
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
6
296
Drawing Conventions and Algorithms
We recall that the user interacts with the maps of the ASes interconnection graph G by means of the AS exploration primitive, described in Section 3. Namely, each time such a primitive is applied on a vertex u of the current map M , such a map is enriched with the vertices and the edges that are directly connected to u in G and that were not present in M . Then a drawing of the new current map is computed and displayed. The choice of our exploration primitive for G is mainly motivated by the analysis performed on the structure of G (see Section 5). In particular, since G has many vertices that are adjacent to a vertex whose local graph has high density, we decided to discard a classical exploration approach based on induced subgraphs, because it is often lead to extremely dense maps. In Section 6.1 we describe the drawing convention we adopt for visualizing the maps of G throughout a sequence of exploration steps performed by the user. In Section 6.2 we provide two different strategies for computing drawings of the maps within the defined drawing convention.
6.1
Drawing Convention
When the AS exploration primitive is applied on the current map M of G, the vertices of G − M added to M will have degree one in the new current map. Also, these vertices of degree one are often numerous, due to the structure of G. Hence, for drawing a map we use a specific drawing convention that allows us to optimize the space occupied by the vertices of degree one. Such a drawing convention is based on a variation of the podevsnef model for orthogonal drawings with high degree vertices (see Section 2.2). We modify the podevsnef model as follows. Each vertex of degree one adjacent to a vertex v is appropriately positioned on an integer coordinate grid around v and connected to v with a straight-line edge. Namely, as shown in Figure 10, vertex v is associated with a box partitioned into nine rectangles arranged into three rows and three columns. Denote these rectangles as Bij , (i, j ∈ {1, 2, 3}). Rectangle B22 is used for drawing v centered on a grid point. Rectangles B11 , B13 , B31 , and B33 are used for drawing the degree-one vertices adjacent to v. Their incident edges are represented with straight-line segments, possibly overlapping other degree-one vertices. Actually, they are drawn on the back of the vertices. Rectangles B12 , B21 , B32 , and B23 are used for hosting the connections of v to the other vertices. The height hc of the center row is equal to one grid unit as well as the width wc of the center column. Rectangles B11 , B13 , B31 , and B33 have all the same width w and height h. The values of h and w are expressed in terms of grid units and must guarantee enough room for placing all the degree-one vertices. How w and h are computed will be detailed in Section 6.3.
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
w
wc
h
B11
B12
B13
hc
B 21
B 22
B23
h
B31
B32
B33
297
w
(a)
(b)
Figure 10: Using a box to make room around a vertex. (a) The nine rectangles that partition the box. (b) Using the nine rectangles to place the degree-one vertices. Each vertex in the box is centered on an integer grid point.
6.2
Algorithms Overview
In this section we describe two different strategies for computing drawings of the maps within the defined drawing convention, during a sequence of exploration steps. Namely, at each exploration step Hermes computes a new drawing of the current map, by applying one of the two following algorithms: Static algorithm The current map is completely redrawn, after the new vertices and edges have been added. Dynamic algorithm The new vertices and edges are added to the current drawing in such a way that the shape of the existing edges and the position of the existing vertices and bends are preserved “as much as possible”. Both the dynamic and the static algorithms have advantages and drawbacks. The dynamic algorithm allows the user to preserve its mental map but can lead, after a certain number of exploration steps, to drawings that are less readable than those constructed by the static algorithm. In fact, the dynamic algorithm makes use of local optimization strategies. The optimization strategies of the static algorithm are global and more effective. However, with the static algorithm, the new drawing can be quite different from the previous one and the user’s mental map can be lost. Because of the above motivations, Hermes automatically chooses between the static algorithm and the dynamic algorithm, according to the following criteria. Suppose v is the vertex that the user wants to explore. Hermes computes
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
298
a dynamic exploration cost associated with v. Such a cost represents an estimate of the efficiency and effectiveness of the dynamic algorithm with respect to the new exploration. In the current implementation of Hermes it simply depends on the kind and the number of drawing primitives (see Section 6.5) that would be needed for constructing the drawing of the new map with the dynamic algorithm and on how many consecutive times the dynamic algorithm has been invoked before the exploration of v. Once the exploration cost has been computed, Hermes compares it with a threshold value that can be set-up in a configuration menu of the system. If the exploration cost is lower than the threshold value, Hermes applies the dynamic algorithm, else it applies the static algorithm. In the next two subsections we give details on how the static and the dynamic algorithms work in practice.
6.3
The Static Algorithm
Let G be the ASes interconnection graph and let M be the current map. We recall that M is a subgraph of G. Let v be the vertex of M explored by the user at the generic step. Map M is enriched with the vertices and the edges of G that are not present in M and are directly connected to v in G. The new map, which we still call M for simplicity, is fully redrawn according to the static algorithm, which consists of the following steps. 1. (Degree-one Vertex Removal ) Vertices of degree one are temporarily removed from M . We call M the new map. Each vertex u of M is labeled by the number δ(u) of vertices of degree one that were attached to it. 2. (Planarization) A standard planarization [14] technique is applied to M . In this phase a planar embedding of M is computed and crossings among edges are represented by dummy vertices that will be removed later. We call such vertices cross vertices. 3. (Orthogonalization) A podevsnef representation of M is constructed within the computed embedding. 4. (Compaction) A drawing for M is computed from its orthogonal representation by assigning coordinates to vertices and bends. Since for each vertex u, our drawing convention requires that δ(u) vertices of degree one are placed around u, we must guarantee enough room for them (see Section 6.1). To do that we compute a podavsnef drawing by applying the algorithm described in [13]. Each vertex u is drawn as a box whose height h and width w depend on δ(u). We set w = δ(u)/2 . The height h is set equal to = w − 1 if this ensures enough room for all the vertices to be placed; else we set h = w. If δ(u) = 0 then we set h = w = 0. We recall that w and h are expressed in terms of grid units. For example, referring to Figure 10, we have that δ(u) = 32 (u is the vertex on the center of the box and has 32 vertices of degree one connected to it) and
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
299
then w = 3. Also, h = 2 is not sufficient for hosting all the 32 vertices into the four rectangles B11 , B13 , B31 , B33 (in fact, if h = 2 we can place at most w × h × 4 = 3 × 2 × 4 = 24 vertices inside the box). Hence h is set equal to 3 (in this way we can place up to 36 vertices inside the box; we use 32 positions for placing vertices and 4 positions will be not used). We also have to guarantee that the edges that connect u to non degree-one vertices are always incident on the middle points of the sides of the box. The basic version of the algorithm described in [13] allows the edges to freely shift along the side they are incident on. However, it is possible to easily adapt such an algorithm so that each edge is incident on a pre-assigned point. Finally, cross vertices are removed. 5. (Degree-one Vertex Re-insertion) The drawing is completed by replacing the box of each vertex u such that δ(u) > 0 with a half unit square (edges that are incident on u are stretched). Also, the vertices of degree one that are incident on u are distributed in the rectangles B11 , B13 , B31 , and B33 and connected to u, according to the adopted drawing convention (see Figure 10(b)).
6.4
The Dynamic Algorithm
As in the case of the static algorithm, we denote by G the ASes interconnection graph and by M the current map. Also, denote by D the current drawing of M . Let v be the vertex of M explored by the user at the generic step. The dynamic algorithm enriches M and D incrementally, by adding the vertices and the edges of G that are not present in M and are directly connected to v in G, in such a way that the user mental map is preserved as much as possible. Before describing how the dynamic algorithm works, we need to introduce some further notation. Denote by ∆Ev and by ∆Vv the set of the edges and the set of the vertices to be inserted for exploring v. We recall that all the edges in ∆Ev are incident on v and that the vertices in ∆Vv will be degree-one vertices attached to v in the final drawing. For simplicity, we always use the notation M and D to denote the intermediate maps and drawings during the execution of the dynamic algorithm. In other words, we are assuming that M and D change dynamically throughout the algorithm execution. However, at the generic step of the dynamic algorithm, some of the vertices of M might be not explicitly represented in D. Namely, each vertex u of D might absorb all the degree-one vertices adjacent to it and implicitly represent the number of these vertices by a label δ(u), as in the case of the static algorithm. We call V1 the set of degree-one vertices of M that are not explicitly represented in D, and V2 all the vertices of M that are also explicitly represented in D. Note that, V1 and V2 partition the set of vertices of M , and that at the beginning of the dynamic algorithm V1 is empty. Sets ∆Vv , V1 , and V2 are modified during the algorithm execution. A high level description of the dynamic algorithm is as follows (refer to Figure 11):
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
300
v v 7
u1
6
4
4
2
u2
2
u2
u2
(a)
(b)
v
(c)
v
6
v
6
3
2
3
u1 2
u2
u1 u2
u2
(d)
u1
(e)
(f)
Figure 11: An example of the dynamic algorithm. (a) The initial drawing of a map; the user chooses to explore vertex v; suppose that v is directly connected to u1 and u2 in the ASes interconnection graph. (b) In the first step of the dynamic algorithm all the degree-one vertices of the drawing are temporarily removed; the remaining vertices are labeled with the number of vertices of degree one that were connected to them. (c) Vertex v is reinserted by using the Attach-Vertex primitive. (d) Vertex u1 is reinserted by using the Attach-Vertex primitive and then edge (v, u1 ) is inserted by using the New-Edge primitive. (e) Edge (v, u2 ) is inserted by using the New-Edge primitive. (f) The compaction step is applied and the removed degree-one vertices are completely reinserted. Step 1 We temporarily remove from D all the degree-one vertices. Each vertex u of D is labeled with the number δ(u) of vertices of degree one that were attached to it (see Figure 11 (b)). The deleted vertices are moved from V2 to V1 . Note that, D is now a podevsnef drawing in the standard sense, where edge crossings are still replaced by cross vertices. Step 2 We incrementally add to M the edges of ∆Ev and the vertices of ∆Vv . At the same time, specific subsets of edges and vertices of M are added to D, by applying on D a sequence of two primitives that modify the drawing within the podevsnef standard. The two primitives are as follows: New-Edge(u,z) A new edge is added to the drawing between the two vertices u and z; vertices u and z must be already explicitly represented in D.
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
301
Attach-Vertex(u) A new vertex z is added to D and connected to u with a new edge (u, z); vertex u must be already explicitly represented in D. How such primitives work in practice will be detailed in Section 6.5. The insertion of vertices and edges in M and D is performed according to the following ordered set of rules: • If the explored vertex v belongs to V1 (that is, if v is a one-degree vertex in M ), we call w the vertex of V2 that is connected to v in M . We reinsert v in D (that is, we explicitly represent v in D) by performing primitive Attach-Vertex(w) (see Figure 11 (c)). Consistently, we decrease δ(w) by a unit, set δ(v) = 0, and move v from V1 to V2 . • For each edge e = (v, u) of ∆Ev we insert in M vertex u, if it is not already present in M , and edge e. After that, drawing D is modified according to the following three cases: 1. If u is in V1 , we reinsert (explicitly represent) u in D by performing primitive Attach-Vertex(z), where z is the vertex of V2 connected to u in M ; then we add e to D, by applying primitive New-Edge(v,u) (see Figure 11 (d)). Consistently, we decrease δ(z) by a unit, set δ(u) = 0 and move u from V1 to V2 . 2. If u is in V2 , we add edge e to D by performing primitive NewEdge(v,u)(see Figure 11 (e)). 3. If u is in ∆Vv we just increase δ(v) by a unit, and move u from ∆Vv to V1 (u will be implicitly represented in D). Once all edges in ∆Ev have been considered ∆Vv is empty, M is completely updated with the vertices and edges selected for insertion by the exploration of v, and the only vertices that remain to be added to D (those in V1 ) are all the vertices (different from v) that have degree one in M . Step 3 We perform on D the Compaction step and the Degree-one Vertex Reinsertion step described for the static algorithm. The degree-one vertices reinserted are those in V1 (see Figure 11 (f)).
6.5
Primitives of the Dynamic Algorithm
In this section we conclude the description of the dynamic algorithm by explaining how primitive New-Edge and Attach-Vertex work. We recall that these primitives modify a podevsnef drawing D preserving this drawing standard. Both the primitives compute the position of the new vertices and edges trying to optimize, at the same time, the following measures: number of crossings, number of bends, and edge length. Each of these measures has a prescribed cost that can be passed as a parameter to the primitives.
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
6
4
2
302
1
Figure 12: Collapsing the edges incident on the same side of a vertex. The labels represent the thickness of the edges. The small circles are the chain vertices. In this way it is possible to decide the priority of each measure in the whole optimization. Once any of the primitives has been applied, the new drawing is guaranteed to have the same shape as the previous one, for the common parts. The two primitives use two auxiliary data structures to perform their work. These data structures are a simplified orthogonal representation of the current drawing and a directed network associated with this orthogonal representation. We now describe these two data structures. After that, we shall describe how they are used by the primitives. Let H be the orthogonal representation of D. The first data structure is an orthogonal representation H obtained from H in the following way: • H is simplified so that all vertices have degree less than or equal to four. This is done with a standard technique adopted in the podevsnef model [4], where all the edges incident on the same vertex from the same side are collapsed into a chain of edges (see Fig. 12). Each edge of the chain replaces a certain number of edges (possibly only one). We associate with each edge a thickness representing the number of edges replaced by it. We call the new vertices inserted by this operation chain vertices. • Each face of H (including the external one) is decomposed into rectangles by adding a suitable number of dummy edges and vertices, with the linear time algorithm described in [32]. We call dashed the dummy edges and solid the edges of the original orthogonal representation. The second data structure is a directed network N associated with H . We call such a network the incidence network of H . N is used to implicitly describe all the orthogonal paths that a new edge can follows in H . Further, N is defined so that each path has an associated cost that reflects the cost of the new edge in terms of bends, edge crossings, and edge length. We denote by χ, β, and λ the costs of one crossing, one bend, and one edge length unit, respectively. As already mentioned at the beginning of this section, these costs can be set-up by the user in order to determine the priority level of the three different measures during the optimization. Network N is defined as follows (see Fig. 13(a)):
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
303
• N has a node v associated with each edge e (solid or dashed) of H . Also, v has an associated cost that represents the cost of crossing e. Namely: – If e is a solid edge then the cost of v is set-up equal to the thickness of e multiplied by χ (see Fig. 13(a)). This reflects the fact that a path of N traversing v corresponds to a new edge of H traversing edge e, and hence to a new edge of H that crosses a number of edges equal to the thickness of e. – If e is a dashed edge then the cost of v is set-up equal to zero. This is because dashed edges of H are dummy and will be removed in the final drawing. Hence, they do not really originate edge crossings. • N has an arc between every pair of nodes associated with two edges e1 and e2 in the same face f of H . Such an arc represents an orthogonal path inside f , which can be used to reach e2 from e1 (or vice-versa) in H . We distinguish three different kinds of arcs of N with respect to a face f of H (refer to Fig. 13): – An arc a between nodes associated with two horizontal (vertical) edges that lie on different sides of f (see, for example, arc a1 in Fig. 13(a)). In this case, we associate with a a straight-line path p (a path with no bends) inside f , because it suffices to move from a side of f to its opposite in the orthogonal representation (see Fig. 13(b)). Hence, denoted by d1 , d2 (d3 , d4 ) the lengths (in terms of number of edges) of the vertical (horizontal) sides of f , we assign cost dλ to arc a, where d = max{d1 , d2 } (d = max{d3 , d4 }). Such a cost is a lower bound on the length of p. – An arc a between a node associated with a horizontal edge eh and a node associated with a vertical edge ev of f (see, for example, arc a3 in Fig. 13(a)). In this case, we associate with a an orthogonal path p with exactly one bend, as depicted in Fig. 13(c). Denoted by sv the side of f on which ev lies, let dv be the number of edges of sv that are necessarily spanned (completely or partially) by the projection of p on sv . Analogously, denoted by sh the side of f on which eh lies, let dh be the number of edges of sh that are necessarily spanned by the projection of p on sh . Hence, the cost we assign to a is equal to β + (dv + dh )λ. In particular, (dv + dh )λ still represents a lower bound on the length of p, while β is the cost for one bend. – An arc a between the nodes associated with two edges e1 and e2 that lie on the same side of f (see, for example, arc a2 in Fig. 13(a)). In this case, we associate with a an orthogonal path p with two bends, as shown in Fig. 13(d). Denoted by s the side of f in which lie the two edges, let d be the number of edges of s that are necessarily spanned (completely or partially) by p. Hence, the cost we assign to a is equal to 2β + (d + 2)λ. The two extra units for the length are due
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
304
χ χ
a2 2β + 4 λ
a1 2λ
a3 β +3λ
3χ
χ
χ
2χ
(a) Nodes (little squares) and three arcs of the incidence network for a face of a simplified orthogonal representation.
dh= 1
d4= 2
d1= 2
p
d2= 1
dv= 2 p
d3= 3
(b) The orthogonal path p associated with arc a1 .
(c) The orthogonal path p associated with arc a3 . d =2
p
(d) The orthogonal path p associated with arc a2 .
Figure 13: Example of construction of an incidence network and related orthogonal paths.
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
305
u
u
p
p
p
u
v
v
v
(a)
(b)
(c)
u
p
u
p
v
v
(d)
p
(e)
v
u
(f)
Figure 14: Possible cases of orthogonal paths between two vertices of the same face of an orthogonal representation. to the fact that p consists also of two (unit-length) segments having a direction (vertical or horizontal) orthogonal to the direction of s. We now explain how primitives New-Edge and Attach-Vertex perform on the current drawing D. • Primitive New-Edge(u,v) computes from D the simplified orthogonal representation H and the associated network N above described. Clearly, from the point of view of the primitive interface, H and N are transparent. It just needs to know u, v and D. After that, two different cases are possible: Case 1 Nodes u and v belong to two different faces of H . In this case, the primitive completes network N by adding two extra nodes representing u and v. For simplicity we still refer to these extra nodes as u and v. Also, for each edge e of H incident on u (resp. v) the primitive adds to N an arc between u (resp. v) and the node of N associated with e. All these extra arcs of N have zero cost. At this point, the primitive computes on N a shortest path between u and v. Such a path determines the route and the shape of the new edge (u, v) in H , according to the rules illustrated in the construction of N . Namely, the new edge is added to H following the arcs of the shortest path. Note that, the route and the shape of the new edge in H uniquely induces the route and the shape of the same edge in H. Hence, the primitive adds edge (u, v) to H and computes the new
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
306
drawing D by compacting H with a standard compaction algorithm for podevsnef orthogonal representations [20, 4]. Case 2 Nodes u and v belong to the same face. In this case the shape of edge (u, v) is simply chosen according to the set of cases shown in Figure 14. • Primitive Attach-Vertex(u) works much simpler then New-Edge. It must add a new edge e that connects a new node to u. The primitive looks in H for a side s of u such that either no edge is incident on s or a dashed edge is incident on s. If such a side s exists, the primitive add to H , and therefore to H, edge e as a straight edge incident on s. Otherwise, the primitive chooses an arbitrary side of u to insert edge e, and in this case edge e will have one bend in H. Finally, the new drawing D is computed by compacting H with a standard compaction algorithm for podevsnef orthogonal representations. Note that, if a sequence of consecutive dynamic primitives have to be applied before D is displayed (as it often happens in a single Hermes’s exploration step), the computation of D can be delayed until the end of the sequence. In this case, H and N can be kept up to date after each primitive is executed instead of reconstructing them each time.
7
Statistics on the Hermes Service
We implemented Hermes as a service publicly available on the Web3 . In this section we intend to show the effectiveness of the service. To this aim we provide several statistics obtained from data collected from September 2000 to November 2001. The total number of connections to the service during the considered period has been 4, 063. The number of distinct users (that is, distinct IP addresses) that accessed the service has been 860. Figure 15(a) shows how many connections (y-axis) have been performed by a certain number of users (x-axis). Such a chart provides hints about the loyalty of the users to the Hermes service. About 70 users have accessed the service more than 10 times. For several of them we observed usage peaks of one or two days at distance of months. Figure 15(b) shows the percentage of connections (y-axis) in which the user performed a certain number of exploration steps (x-axis). This chart provides information about the overall usability of the service which may be affected by drawing performances, reply speed, significance of the data, etc. A high number of exploration steps suggests that the quality of the drawing engine and its performance meet the user needs. However, consider that, due to the high local density of the ASes interconnection graph, after a certain number of exploration steps (usually 4 or 5) the visualized map often becomes quite large 3 http://www.dia.uniroma3.it/∼ hermes/
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
307
(more than 200 vertices) and the information difficult to read. In these cases, the user usually prefers to interrupt the exploration of the current map and restarts the whole exploration from another AS. The chart shows that for about 20% of the connections, the number of exploration steps has been greater than or equal to 3. In some cases the number of steps has been greater than 10. Figure 15(c) shows the distribution of the users within the Internet top level domains4 . About half of the users belongs to domains .net and .com and are mainly Internet service providers and companies with interests in networking. About 20% of domains .it is due to system development and testing.
8
Conclusions
In this work we presented Hermes, a system for exploring and visualizing the interconnections between Autonomous Systems. In particular, we discussed the architecture of Hermes and we described efficient algorithms used by the system to compute pleasing drawings of ASes interconnection subgraphs. We explained how the adopted drawing convention and algorithms have been motivated by the structure of the ASes interconnection graph. In the near future we plan to enrich Hermes with new functionalities for visualizing the internal structure of an AS, and with tools for evidencing inconsistency in the data sources. From the point of view of the drawing algorithms, there are several open problems that can be considered. A limited list of such problems follows: • Often, after many exploration steps the drawing tends to become very large, so increasing both the computational complexity of successive exploration steps and the difficulty for the user to understand and to interact with the map. Hence, it would be interesting to devise strategies for deleting “old vertices” in the maps throughout the exploration. • To increase the effectiveness of the visualization, it could be useful to assign to the vertices different sizes, depending on the different “importance” of the corresponding ASes. To this aim, an extension of the used convention and algorithms to drawings with vertices of prescribed size is needed. • It would be interesting to extend the applicability of our drawing algorithms to other domains, such as state diagrams, class diagrams, etc?
Acknowledgements We are grateful to Sandra Follaro and Antonio Leonforte for their fundamental contribution in the implementation of the dynamic algorithm. We are also grateful to Andrea Cecchetti for useful discussion on the repository. 4 The data are obtained from 60% of all users. The remaining part of the users is not associated to any domain.
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
308
(a)
(b)
(c)
Figure 15: (a) Number of connections (y-axis) performed by a certain number of users (x-axis). (b) Percentage of connections (y-axis) in which the user performed a certain number of exploration steps (x-axis). (c) Distribution of the users within the Internet top level domains.
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
309
References [1] C. Alaettinoglu, C. Villamizar, E. Gerich, D. Kessens, D. Meyer, T. Bates, D. Karrenberg, and M. Terpstra. Routing policy specification language (rpsl). On line, 1999. rfc 2622. [2] Aprisma. Spectrum. On line. http://www.aprisma.com. [3] T. Bates, E. Gerich, L. Joncheray, J. M. Jouanigot, D. Karrenberg, M. Terpstra, and J. Yu. Representation of ip routing policies in a routing registry. On line, 1994. ripe-181, http://www.ripe.net, rfc 1786. [4] P. Bertolazzi, G. Di Battista, and W. Didimo. Computing orthogonal drawings with the minimum numbr of bends. IEEE Transactions on Computers, 49(8), 2000. [5] T. C. Biedl and M. Kaufmann. Area-efficient static and incremental graph darwings. In R. Burkard and G. Woeginger, editors, Algorithms (Proc. ESA ’97), volume 1284 of Lecture Notes Comput. Sci., pages 37–52. Springer-Verlag, 1997. [6] U. Brandes and D. Wagner. Dynamic grid embedding with few bends and changes. In K.-Y. Chwa and O. H. Ibarra, editors, ISAAC’98, volume 1533 of Lecture Notes Comput. Sci., pages 89–98. Springer-Verlag, 1998. [7] S. Bridgeman and R. Tamassia. Difference metrics for interactive orthogonal graph drawing algorithms. In S. H. Withesides, editor, Graph Drawing (Proc. GD ’98), volume 1547 of Lecture Notes Comput. Sci., pages 57–71. Springer-Verlag, 1998. [8] S. S. Bridgeman, J. Fanto, A. Garg, R. Tamassia, and L. Vismara. InteractiveGiotto: An algorithm for interactive orthogonal graph drawing. In G. Di Battista, editor, Graph Drawing (Proc. GD ’97), volume 1353 of Lecture Notes Comput. Sci., pages 303–308. Springer-Verlag, 1998. [9] CAIDA. Otter: Tool for topology display. On line. http://www.caida.org. [10] CAIDA. Plankton: Visualizing nlanr’s web cache hierarchy. On line. http://www.caida.org. [11] R. F. Cohen, G. Di Battista, R. Tamassia, and I. G. Tollis. Dynamic graph drawings: Trees, series-parallel digraphs, and planar ST -digraphs. SIAM J. Comput., 24(5):970–1001, 1995. [12] Cornell University. Argus. On line. http://www.cs.cornell.edu/cnrg/topology aware/discovery/argus.html. [13] G. Di Battista, W. Didimo, M. Patrignani, and M. Pizzonia. Orthogonal and quasi-upward drawings with vertices of prescribed sizes. In J. Kratochvil, editor, Graph Drawing (Proc. GD ’99), volume 1731 of Lecture Notes Comput. Sci., pages 297–310. Springer-Verlag, 1999.
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
310
[14] G. Di Battista, P. Eades, R. Tamassia, and I. G. Tollis. Graph Drawing. Prentice Hall, Upper Saddle River, NJ, 1999. [15] G. Di Battista, A. Garg, G. Liotta, R. Tamassia, E. Tassinari, and F. Vargiu. An experimental comparison of four graph drawing algorithms. Comput. Geom. Theory Appl., 7:303–325, 1997. [16] G. Di Battista, R. Lillo, and F. Vernacotola. Ptolomaeus: The web cartographer. In S. H. Withesides, editor, Graph Drawing (Proc. GD ’98), volume 1547 of Lecture Notes Comput. Sci., pages 444–445. Springer-Verlag, 1998. [17] M. Dodge. An atlas of cyberspaces. On line. http://www.cybergeography.com/atlas/atlas.html. [18] P. Eades, R. F. Cohen, and M. L. Huang. Online animated graph drawing for web navigation. In G. Di Battista, editor, Graph Drawing (Proc. GD ’97), volume 1353 of Lecture Notes Comput. Sci., pages 330–335. SpringerVerlag, 1997. [19] P. Eades, W. Lai, K. Misue, and K. Sugiyama. Preserving the mental map of a diagram. In Proceedings of Compugraphics 91, pages 24–33, 1991. [20] U. F¨ oßmeier and M. Kaufmann. Drawing high degree graphs with low bend numbers. In F. J. Brandenburg, editor, Graph Drawing (Proc. GD ’95), volume 1027 of Lecture Notes Comput. Sci., pages 254–266. SpringerVerlag, 1996. [21] GDToolkit:. Graph drawing toolkit. On line. http://www.gdtoolkit.com. [22] F. Harary. Graph Theory. Addison-Wesley, Reading, MA, 1972. [23] B. Huffaker. Tools to visualize the internet multicast backbone. On line. http://www.caida.org. [24] IPMA. Internet performance measurement and analysis project. On line. http://www.merit.edu/ipma. [25] D. Meyer. University of oregon route views project. On line. http://www.antc.uoregon.edu/route-views. [26] K. Miriyala, S. W. Hornick, and R. Tamassia. An incremental approach to aesthetic graph layout. In Proc. Internat. Workshop on Computer-Aided Software Engineering, 1993. [27] K. Misue, P. Eades, W. Lai, and K. Sugiyama. Layout adjustment and the mental map. J. Visual Lang. Comput., 6(2):183–210, 1995. [28] S. North. Incremental layout in DynaDAG. In F. J. Brandenburg, editor, Graph Drawing (Proc. GD ’95), volume 1027 of Lecture Notes Comput. Sci., pages 409–418. Springer-Verlag, 1996.
Carmignani et al., Hermes, JGAA, 6(3) 281–311 (2002)
311
[29] A. Papakostas and I. G. Tollis. Interactive orthogonal graph drawing. IEEE Transactions on Computers, 47(11):1297–1309, 1998. [30] C. Rachit. Octopus: Backbone topology discovery. On line. http://www.cs.cornell.edu/cnrg/topology aware/topology/Default.html. [31] Y. Rekhter. A border gateway protocol 4 (bgp-4). IETF, rfc 1771. [32] R. Tamassia. On embedding a graph in the grid with the minimum number of bends. SIAM J. Comput., 16(3):421–444, 1987. [33] R. Tamassia, G. Di Battista, and C. Batini. Automatic graph drawing and readability of diagrams. IEEE Trans. Syst. Man Cybern., SMC-18(1):61– 79, 1988.
Journal of Graph Algorithms and Applications http://jgaa.info/ vol. 6, no. 3, pp. 313–351 (2002)
A Framework for the Static and Interactive Visualization of Statecharts Rodolfo Castell´o School of Engineering and Computer Science ITESM Campus Chihuahua http://www.chi.itesm.mx/ [email protected]
Rym Mili
Ioannis G. Tollis
Department of Computer Science The University of Texas at Dallas http://www.utdallas.edu/ [email protected] [email protected] Abstract We present a framework for the automatic generation of layouts of statechart diagrams. Statecharts [16] are widely used for the requirements specification of reactive systems. Our framework is based on several techniques that include hierarchical drawing, labeling, and floorplanning, designed to work in a cooperative environment. Therefore, the resulting drawings enjoy several important properties: they emphasize the natural hierarchical decomposition of states into substates; they have a low number of edge crossings; they have good aspect ratio; and require a small area. We also present techniques for interactive operations. We have implemented our framework and obtained drawings for several statechart examples.
Communicated by Michael Kaufmann: submitted April 2001; revised January 2002.
Research supported in part by Sandia National Labs and by the Texas Advanced Research Program under grant number 009741-040.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 314
1
Introduction
The representation and visualization of software requirements specification is very important in software engineering. Statecharts [16] is a graphical notation widely used for the requirements specification of reactive systems. Because of their hierarchical property, statecharts are prime candidates for visualization. Nice and intuitive drawings of statecharts would be invaluable aids to software engineers who would like to check the correctness of their design visually. In this paper, we study the problem of visualizing statecharts and present an algorithmic framework for producing clear and intuitive drawings. Our framework is based on several techniques that includes hierarchical drawing, labeling, and floorplanning, designed to work in a cooperative environment. Therefore, the resulting drawings enjoy several important properties: they emphasize the natural hierarchical decomposition of states into substates; they have a low number of edge crossings; they have good aspect ratio; and require a small area. There are several visualization tools for the specification and design of reactive systems available in the market [17, 27, 29, 36]. These tools are helpful in organizing a designer’s thoughts. However, they are mostly sophisticated graphical editors, and therefore, are severely inadequate for the modeling of complex reactive systems. For example, the Rational Rose (year 1999) tool [30] provides a feature to layout UML [5] statechart diagrams. Figure 1 shows an example of a statechart after the Rational Rose layout feature is applied. We notice that transition labels overlap; transition edges overlap with state boxes; and there is a large number of unnecessary edge bends and edge crossings. Figure 9 in Section 4 shows a drawing of the same diagram using our algorithmic framework. A comprehensive approach to hierarchical drawings of directed graphs is described in Sugiyama et al. [35]. Several extensions and variations of this approach have been introduced in the literature. A comprehensive survey is given in [1]. A first extension that takes into consideration cycles and dummy nodes for large edges (i.e., edges that span more that one level) was introduced by Rowe et al. [31]. Gansner et al. [14, 15] provide a technique to draw directed graphs using a simplex-based algorithm that assigns vertices to layers; at the same time, they provide an extension to the basic algorithm of Sugiyama et al. by drawing edge-bends as curves. A divide-and conquer approach is described by Messinger et al. [24] to improve the layout-time performance for large graphs consisting of several hundreds of vertices. More recently, a combination of the algorithm of [35] with incremental-orthogonal drawing techniques was proposed by Seemann [33] to automatically generate a layout of UML class diagrams. In [18], Harel and Yashchin discuss an algorithm for drawing edgeless hi-graph like structures. The problem of drawing clustered graphs without crossings was studied in [10, 11]. Most of the research addressing the labeling problem has focused on labeling features of geographical and technical maps, which have fixed geometry [20, 21]. Labeling is typically partitioned into smaller tasks: (a) labeling points, also known as the Node Label Placement (NLP) problem, and (b) labeling lines, also known as the Edge Label Placement (ELP) problem.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 315
Figure 1: A statechart example generated by Rational Rose (drawing rotated 90 degrees due space limitations).
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 316 A survey of algorithms for the labeling problem including simulated annealing techniques are presented in [8]. Approximation algorithms for restricted versions of the NLP problem are presented in [9, 13, 37]. Most of the research on the ELP Problem has been done on labeling graphs with fixed geometry, such as geographical and technical maps [21]. Kakoulis and Tollis [20] present an algorithm for the ELP problem that can be applied to hierarchical drawings with fixed geometry. Gansner et al. [14] utilize a simple approach to solve the ELP problem for hierarchical drawings: they assign labels to the middle position of edge lines. However, they assume that edge labels are small and do not consider the possibility of overlap with other drawing components. Here, we present a framework for the static and interactive visualization of statechart diagrams. The framework uses techniques for hierarchical drawing, labeling, and floorplanning. We also present algorithms for interactive operations (such as insertions and deletions) that preserve the mental map of the drawings. Our algorithm for hierarchical drawings is a variant of the algorithm by Sugiyama et al. [35] that is adapted to statecharts. In our work, we have developed edge labeling techniques to address the problem of graph drawings with flexible geometry. Finally, we apply floorplanning techniques in order to reduce the area and improve the aspect ratio of the statechart drawings. Our floorplanning techniques are inspired by the ones used for the area minimization of (a) VLSI layouts [23, 34] and (b) inclusion drawings of trees [12]. We have also incorporated our implementation into a complete system for visualizing software requirements [7]. Several drawings of statechart examples are included in the Appendix.
2
Statecharts
This graphical notation was developed by Harel [16] to specify the behavior of reactive systems. Statecharts are extended finite state machines. They provide mechanisms to represent hierarchical decomposition, concurrency and synchronization. In the statechart notation transitions (i.e., edges in a finite state machine) can be defined as function of a stimulus, and the truth-value of a condition. Output events can be attached optionally to the triggering event. Transition labels have the form E[C]/A, where E is the event that triggers the transition, C is a condition that guards the transition from being taken unless it is true, and A is an action that is executed when the transition is taken. Statecharts use the concept of superstate to overcome the exponential blow-up of states encountered in traditional finite state machines. They support the repeated decomposition of states into substates through the OR or the AN D decompositions. The OR decomposition reflects the hierarchical structure of state machines and is represented by encapsulation (see Figure 2). The AND decomposition reflects concurrency of independent state machines and is represented by splitting a box with lines. In our approach, a statechart is treated as a graph. Nodes 1 in the graph 1 In
the remainder of this paper we will use the words node and object interchangeably.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 317
Figure 2: State encapsulation. correspond to states, and arcs correspond to transitions between states. A node includes the following information: its name; its width and height; the coordinates of its point of origin; a pointer to its parent; the list of its children; its decomposition type (e.g., AND, OR or leaf); the list of incoming arcs; the list of outgoing arcs; a list of attributes; and finally its aliases. The underlying structure of a statechart is an AND/OR tree that we call decomposition tree. The root of a decomposition tree corresponds to the system state; leaves correspond to atomic states. Each object in the tree can be decomposed through the AND or OR decomposition. In the remainder of the paper, we assume that relevant information is extracted from a textual description of requirements, and stored in a decomposition tree.
3
Automatic Layout of Statecharts
In this section we describe our framework for the visualization of statecharts. The main algorithm that is the foundation of the framework proceeds as follows: 1. The decomposition tree T is traversed in order to determine the dimensions and point of origin of the drawing of every node, in a recursive manner. 2. If a node v is a leaf then a simple drawing procedure is called that produces a labeled rectangle. It returns the point of origin and the dimensions of the rectangle. 3. If v is an AND node then a recursive algorithm constructs the drawings of every child node of v and places the drawings next to each other. 4. If v is an OR node then a recursive algorithm:
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 318 • first constructs the drawings of every child of v; • then, it assigns each child to a specific layer. For the sake of simplicity, we generate our drawings horizontally, from left to right. A similar approach can be used to generate vertical drawings. The procedure that draws leaves is trivial: Each leaf is drawn as a rectangle that is wide enough to accommodate its label. The algorithms for drawing the AND and OR nodes are more complicated and one can choose among many choices. We have chosen to draw (a) AND nodes using techniques similar to floorplans [22, 34, 38], or inclusion drawings [12], and (b) OR nodes using a modified version of Sugiyama’s algorithm [35] for producing a hierarchical drawing. Our framework will work even if other implementors of a similar system decide to substitute their favorite technique/algorithm for any of the steps. In the next subsections, we will describe the algorithms that we chose for our implementation.
3.1
Drawing AND Nodes
An AND node reflects concurrency of independent state machines. The simplest approach to draw an AND node is to place the drawings of its children vertically next to each other. Then the height of the AND node is equal to the maximum height of its children’s rectangles and its width is equal to the sum of the widths of its children’s rectangles. This approach is very simple and thus very desirable. However, it is not very efficient in terms of area. The size of each node depends on the recursive drawings of the substate nodes that are nested in it. Hence, it is possible that certain AN D nodes of the decomposition tree are very large in one dimension or the other. This implies that an unfortunate combination of two subnode rectangles, one with large height and one with large width, will result in a drawing of the AN D node that occupies a very large area (which is mostly empty). This is clearly undesirable. Additionally, the aspect ratio of the drawing, another important aesthetic criterion, is not controllable. We tackle this problem by applying a technique similar to (a) floorplanning, a technique used for the minimization of area of VLSI chip [22, 34, 38], and (b) the technique for minimizing the area of drawing trees in the inclusion convention [12]. Floorplanning partitions a floor rectangle into floorplans using line segments called slices. Each slice is given as either a vertical or a horizontal slice. Floorplans are combined in such a way that the enclosing rectangle covers a minimum area (see Figure 3). A floorplan is slicing whenever the floorplan is an atomic rectangle 2 or there exists a slice that divides the rectangle into two. The floorplanning problem has an efficient solution when the floorplan is slicing [23, 34]. However, the slices in our problem are not fixed as either vertical or horizontal. This has to be decided by some algorithm. From this point of view, our problem is also similar to the tree drawing problem mentioned above. For the 2 one
that can not be further decomposed.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 319
3
2 5 4
1
6
Figure 3: A slicing floorplan. inclusion convention each non-leaf node is a rectangle that contains the rectangles of its subtrees. The problem of optimizing the area by choosing vertical and horizontal slices is NP-hard in general, see for example [12]. If the tree is binary and the sizes of the leaf nodes are restricted, then a dynamic programming type algorithm can be used to minimize the area of an inclusion drawing of the tree in about quadratic time [12]. Unfortunately, our trees are general and the size of the rectangles representing the subtrees depends heavily on the graph represented by the statechart. This is clearly the case for OR nodes. Although one could apply either (a) the general slicing floorplanning technique for drawing the AN D nodes [34], or (b) a modification of an inclusion drawing algorithm, none of them could give us any performance guarantees. Also, due to the special representation of statecharts, and the fact that the size of any OR node can be arbitrarily large we have decided to use some simple heuristics that can be applied to statecharts. To this effect, we define the following drawing criteria for statecharts: • Leaves are used to represent atomic states whose size depends solely on their labels. Since labels are usually written horizontally (for readability purposes), we will draw leaves horizontally. • The AND decomposition reflects concurrency, and is represented by splitting an AND-state rectangle into a number of concurrent substates. As discussed before, due to the recursive nature of each (sub)state, the dimensions of the various substates could be incompatible if placed next to each other. Thus we choose to slice AND-state rectangles either horizontally or vertically, in order to reduce the total area and control the aspect ratio. • OR states can be drawn in a hierarchical fashion using either a horizontal or a vertical layering depending on the slicing type of the parent node (i.e., horizontal / vertical slicing). This is discussed in the next subsection.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 320
AB A A2 A1
AB A
A5
OR Vertical Layering
B1
A1
AB
A3 A4
B B
AND
A
A1
A2
A3
A2
B
OR
A3
B2
A4
B3
B1
OR A4
B1
A5
(a)
B2
B3
B2
B4
B4
B5
B5
A5
B3
B5
B4
OR Horizontal Layering OR Horizontal Layering
OR Vertical Layering
(b)
(c)
Figure 4: AND-OR combination: (a) AND/OR decomposition tree, (b) AND vertical slicing with OR horizontal layering, (c) AND horizontal slicing with OR vertical layering. Our goal is to generate drawings that use the horizontal and vertical dimensions in a uniform way, in order to obtain drawings with small area and good aspect ratio. To this effect we define several heuristics: The AND/OR heuristic applies to the case where the parent is an AND node and the children are OR nodes (see Figure 4(a)). There are two cases: 1. The parent node (AND) is sliced vertically. Then the children nodes (OR) will be drawn on horizontal layers (see Figure 4(b)). In this case, the height of the parent object is the height of the highest child node; and the total width of the parent is the sum of the children’s widths. 2. The parent node (AND) is sliced horizontally. Then the children nodes (OR) are drawn on vertical layers (see Figure 4(c)). In this case the height of the parent node is the sum of children’s heights; and the width of the parent node is the width of the widest child. Clearly, the above algorithm for drawing AND nodes (excluding the drawing of OR nodes) has linear time-complexity with respect to the number of substates in such a node. Heuristics that handle the other cases (OR/AND, AND/AND, and OR/OR) are defined similarly. An extensive discussion of all cases appears in [6]. Finally, it is possible to further improve the area and aspect ratio of the resulting parent drawing at the expense of reducing the readability of the drawing. This can be done by allowing the drawings of the children of a node to have different orientations. For example most of them can be placed vertically, while the tallest one will be placed horizontally, in order to reduce the total height and hence the area requirement, if this is deemed appropriate. Several other similar heuristics can be implemented. The end result will be a drawing which
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 321
A-C
D
A
D-C A-B C
B
C1
B1 B1-B2 B2
C2-C1
C1-C2
B1-B3 B3
B3-C2 C2
Figure 5: Inter-level transitions. will be a general slicing floorplan, see Figure 3. However such a drawing of a statechart diagram may be unacceptable for several applications.
3.2
Drawing OR Nodes
An OR node reflects the decomposition of states into substates. The substates of an OR node are drawn as rectangles. The drawing (and hence the dimensions of the enclosing rectangle) of an OR node is obtained by recursively performing a hierarchical drawing algorithm [2] on the node and each of its substates. In the statechart notation [16], it is possible for transitions to cross superstate boundaries. We call these special edges inter-level transitions. For example, in Figure 5, we notice that transition B3-C2 crosses the boundaries of parent state B. In our approach, inter-level transitions are treated as follows: a) we define the final state of the transition as a GOTO node and place it in the parent state box; b) we label the GOTO node ”GOTO final-state-name” and we process it as a regular OR-node (see Figure 6). We believe that this approach improves the readability of the drawings. The algorithm that constructs the drawing of an OR node has the following steps: (i) substates are drawn recursively; and (ii) substates are assigned to layers by using a modified version of Sugiyama’s algorithm [35] (procedure realDimensionHierarchyDrawing). Procedure realDimensionHierarchyDrawing (see Figure 7) consists of two steps: 1. We construct a hierarchy of substates by treating each substate as a point by calling procedure hierarchyDrawing, which proceeds as follows: (a) We assign the node that corresponds to the initial state to the first
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 322
A
A-C
D
C
D-C
C1 B
C1-C2
C2-C1
B1 C2 A-B
B1-B2
B1-B3 B3
B2
B3-C2 GOTO C2
Figure 6: Goto State.
realDimensionHierarchyDrawing(ObjectList o.children) Begin hierarchyDrawing(o.children); hierarchy.height = 0; hierarchy.width = 0; for i = 1 to depth(hierarchyDrawing of o.children) do begin do 1. layer[i].largestWidth = largest width among the objects in layer[i]; 2. if (layer[i+1] ≤ depth(hierarchyDrawing of o.children)) then add layer[i].largestWidth as an offset to the origin x of every object in layer[i+1]; 3. layer[i].height = summation of each object’s height at layer[i]; 4. if (hierarchy.height layer[i].height;
<
layer[i].height)
then
hierarchy.height
=
5. hierarchy.width = hierarchy.width + layer[i].largestWidth; 6. Increase the origin y of each object in layer[i] in order to deal with the height of each object and avoid overlapping; end do; End
Figure 7: Procedure that generates the final hierarchy of an OR node.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 323 layer. (b) We apply a depth-first search to identify those edges that form graphcycles; then we temporarily remove them. (c) Once the cycles are removed, we assign every node v to a specific layer which is determined by the length of a longest path from the start node to v. At this stage, every node is assigned an x coordinate. (d) We add dummy vertices to deal with edges whose initial and final states are not in adjacent layers. (e) Finally, we apply a node ordering procedure whose purpose is to minimize edge crossings within each layer. This ordering provides the y coordinate for each node. 2. We incorporate into the hierarchy the dimensions (i.e., height and width) of each node in the drawing, as described in Figure 7. The resulting hierarchy is used to determine the height and width of the parent object/state, as well as the coordinates of the origin of the object’s rectangle. As described, the above algorithm produces drawings that are directed from top to bottom and their nodes are placed on horizontal layers. It is easy to modify it in order to produce drawings that are directed from left to right and their nodes are placed on vertical layers. Most of the steps of the algorithm have linear time-complexity with respect to the number of edges of the graph. The last step of procedure hierarchyDrawing attempts to beautify the obtained drawing by reducing the number of edge crossings. Our approach is based on the general layer by layer sweep paradigm [2]. The time-complexity of this step of the algorithm depends on the number of vertices that exist on each layer. If layer L contains |L| nodes, then the time required by the algorithm is O(|L|2 ). Clearly, the total time for this step depends upon the distribution of nodes into layers. Note that any algorithm used in any step of the above framework can be replaced by another algorithm (chosen by another designer) as long as it achieves results that are acceptable for the next step.
3.3
Final Drawing
The final drawing of the statechart represented by the decomposition tree is computed by performing the following steps: 1. Each non-leaf node of the decomposition tree is equipped with two (width, height) pairs as follows: OR node: (vertical layering width, vertical layering height), and (horizontal layering width, horizontal layering height). AND node: (vertical slicing width, vertical slicing height), and (horizontal slicing width, horizontal slicing height)
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 324 2. The horizontal/vertical drawing dimensions are computed in a recursive manner, by traversing the decomposition tree in a top-down fashion: for all nodei ∈ decomposition tree do begin for if (nodei .decompositionT ype ==AND) or (nodei .decompositionT ype ==OR) then Determine the dimensions for both, the vertical drawing and the horizontal drawing. else Determine the dimensions as a LEAF. end for
3. The root node of the decomposition tree will decide which is the best width/height pair: if (root.horizontal width * root.horizontal height < root.vertical width * root.vertical height) then generate drawing with root as horizontal layering (slicing) else generate drawing with root as vertical layering (slicing)
4. We generate the drawing by traversing the decomposition tree top down once more, assigning the correct layering/slicing option to every node. As described, the above algorithm keeps only two possible rectangles for each internal node of the tree: a horizontal and a vertical drawing of the graph corresponding to the tree node. Hence, once the children-node drawings are obtained, it takes time proportional to the number of children to compute the two possible drawings (vertical and horizontal) generated by our algorithm for the parent node. Of course, at the expense of extra computation time one can allow a higher number of possible drawings (rectangles) to be computed for each internal node, and several more level combinations during the recursive drawing of AND nodes can be computed. However, the number cannot be allowed to grow arbitrarily. In other words, if we allow all possible drawings and combinations of rectangles, for the children of each node, then there will be exponentially many combinations. Recall that the problem of optimizing the area of inclusion drawings of trees (which is a special case of our problem) by choosing vertical and horizontal slices is NP-hard in general [12].
4
Labeling
In the labeling literature, it is common to distinguish between node label placement (NLP) and edge label placement (ELP). In the Statecharts [16] notation, NLP depends primarily on the node type. Hence, the label placement for nodes in statecharts is rather simple: if a node is a leaf, then the label size will determine the node size. If a node is an AN D or an OR, then the label is placed in the top left corner of the enclosing rectangle.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 325 Now we discuss our solution to the ELP problem for statecharts. In cartography, the placement of an edge label must satisfy the following criteria [19, 20, 39]: 1. A label cannot overlap with any other graphical component except with its associated edge. 2. The placement of a label has to ensure that it is identified with just one edge in the drawing. Therefore it must be very close to its associated edge. 3. Each label must be placed in the best possible position among all acceptable positions. In the statecharts notation, an edge label consists of three components: event, condition and action (see Figure 8(a)). In order to satisfy the labeling criteria discussed above we have defined the following steps: 1. We fix the maximum length of the label to a constant, and we write the transition’s three components (i.e., events, conditions and actions) on three separate lines (see Figure 8(b)). If the size of a component is greater than the maximum length of the label, then we write it on several lines (see Figure 8(c)). 2. At the beginning of the execution of the drawing algorithm (see Section 3), we assign labels to sublayers (see Figure 8(d)). 3. We traverse the hierarchy from left to right, considering two adjacent layers L1 and L2 at a time (see Figure 8(d)). For each vertex a in L1 , we identify the set of edges Ea between a and the vertices in L2 . We order Ea in such a way that potential label crossings are removed. The time complexity of this step is linear with respect to the number of edges in the graph. Figure 9 shows the statechart diagram after we applied an implementation of our drawing framework to the diagram of Figure 1. We observe that both, the horizontal and vertical dimensions, grow in a uniform manner; edges do not overlap with any other drawing component; every edge crossing has been removed; and the number of edge bends has been reduced considerably.
5
Interactive Operations in Statecharts
The framework presented in this paper describes algorithms that produce drawings of static statecharts. The techniques try to optimize various aesthetics, such as bends, crossings, area, etc. This implies that even when a minor modification is performed on a drawing (e.g., addition of a node or a transition), the layout algorithms will re-order the nodes in such a way that these aesthetic criteria are met. Hence, the structure of the resulting drawing could be very
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 326
State A
Event [ Condition ] / Action
State A
State B
State B
(b)
(a)
State A
Edge Label Length State A
Event [ Condition ] / Action
Event [ Condition#1 AND Condition#2 AND Condition#3 ] / Action
State B
L1
(c)
Event: A - B [ Condition: A - B ] / Action: A - B
State B
Event: A - C [ Condition: A - C ] / Action: A - C
State C
Event: A - D [ Condition: A - D ] / Action: A - D
State D
Edge-Label SubLayer 1-2
L2
(d)
Figure 8: Edge label placement in statecharts: (a) label on a single line, (b) one label component per line, (c) label with fixed length, (d) edge label placement.
Figure 9: Same statechart diagram as in Figure 1, generated automatically by our drawing algorithm.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 327 different from the original one. In this section, we discuss a technique that can be used to preserve the mental map (i.e., the structure) of statecharts. This is important since the designer/specifier may find mistakes/omissions and hence may need to delete and/or insert states and/or transitions without loosing the mental map.
5.1
Previous Work
Misue et. al. [25] present three models for mental map maintenance, based on the position of the nodes in the diagram: the orthogonal ordering; the proximity relations; and the topology. They provide two layout adjustment techniques that preserve the mental map. The first technique aims at making nodes disjoint during the modification of the original diagram. The second technique is oriented towards displaying certain parts of the diagram like a view. North [26] presents a heuristic for hierarchical layouts of directed graphs that incorporates position and order node stability. This heuristic moves nodes between adjacent ranks based on median sort. Seemann [33] combines hierarchical with orthogonal techniques for the incremental layout of UML class diagrams. Ryall et. al. [32] present a constraint-based approach to layout small graphs. These constraints are enforced by a generalized spring algorithm. Several techniques for the preservation of the mental map in orthogonal drawings have been proposed [3, 4, 28]. Papakostas and Tollis [28] discuss a systematic approach that applies to interactive orthogonal graph drawings of vertices of degree at most 4. They describe the following scenarios: 1. Full-control scenario. When a new vertex is inserted in the current drawing, the user has full control over the vertex location. The edges can also be routed by the user. 2. Draw-from-scratch scenario. At the user’s request, the new graph is redrawn using any known technique. This scenario has two main disadvantages: first, it is slow; and second, it does not preserve the mental map. 3. Relative-coordinates scenario. This approach preserves the general shape of the current drawing by proportionally changing the coordinates of vertices and/or bends. An insertion of a new vertex results in the insertion of new rows and/or columns. 4. No-change scenario. The insertion of a new vertex/edge does not modify the coordinates of existing vertices, bends, and edges in the new drawing.
5.2
Our Approach
In this section we describe techniques for interactive operations in a statechart that preserve the mental map. Our approach is based on the relative coordinate and no-change scenarios:
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 328
Figure 10: Statechart diagram. • The delete operation allows to delete nodes and edges. The simplest way to implement the delete operation is to follow the no-change scenario. In other words, the node and/or edge are simply removed from the drawing without changing the coordinates of the rest of the nodes and edges. • The insert operation allows to insert nodes and edges. Here we use the relative-coordinates scenario. We apply a layout algorithm that preserves the relative position of the selected states (nodes). The main drawing features of the algorithm that are affected by the insert operation are: (1) the placement on layers of the substates of an OR decomposition, and (2) the position of these substates inside the layers. Let us consider the first feature, i.e., the placement of OR-substates on layers. When a new transition (edge) is added to the drawing, the insert operation works as follows: 1. Verify that the layout algorithm has been applied. 2. Select the set of states that need to preserve their mental map. 3. Add a new transition to the diagram. 4. Keep the direction of the transitions. 5. Do not identify new cycles, that is, disable the depth-first search algorithm. 6. Determine the direction of the new transition using the current layer assignments of its initial and final states. 7. If the transition is between two states in the same layer, then stop the interactive insert operation and apply the normal layout algorithm.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 329
Figure 11: Modified statechart diagram without mental map preservation.
Figure 12: Modified statechart diagram with mental map preservation. Figure 10 shows a statechart drawing generated by our layout algorithm. If we add a transition from 1g to 1c and apply again our layout algorithm, we notice (see Figure 11) that the drawing has completely changed. Now, if we select states 1b, 1c, 1e and 1f to be preserved and apply again the layout algorithm, we notice (see Figure 12) that the four states are kept in their original layers while the new transition 1g − 1c is drawn backwards. When a new state (node) is added to the drawing, insert operation for the placement of substates on layers works as follows: 1. Verify that the layout algorithm has been applied. 2. Select the set of states that need to preserve their mental map. 3. Add a new state: 4. Keep the direction of the transitions. 5. Do not identify new cycles, that is, disable the depth-first search algorithm.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 330
Figure 13: Adding a new state to a statechart diagram with mental map preservation: case (a). 6. Determine the new layers by applying the following criteria: (a) If the new state shifts the position of one selected state, then shift the position of the entire selected group. Figure 13 shows the drawing of Figure 10 after the insertion of state new. We notice that states 1b, 1c, 1e and 1d are shifted one layer to the right, and their relative position is unchanged. (b) If the new state is positioned in between selected states of the group, then keep the new state in its position, and shift the selected states positioned on subsequent layers to the right. Figure 14 shows the drawing of Figure 10 after the insertion of a new state. We notice that the selected group of states is divided in two parts. However, the relative position of the selected states within layers is preserved. For example, both 1b and 1c are placed on the same layer, at position 1 and 2 respectively. The same applies to nodes 1e and 1f . The second feature that is affected by the preservation of the mental map, is the placement of states on the same layers. Specifically, our edge crossing reduction algorithm (see [6] for details) is modified as follows: the selected group of states on a specific layer is treated as a single state; the edge crossing reduction algorithm shifts the complete group as needed, and inserts invisible nodes when necessary. We consider three cases that we illustrate through Figures 15 and 16. 1. Case 1. If the edge crossing reduction algorithm determines that state x is best placed below b (Figure 15(b)): (a) Insert an invisible state in x’s position. (b) Shift down all states below state b, e.g., states y and z.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 331
Figure 14: Adding a new state to a statechart diagram with mental map preservation: case (b).
invisible state
mental map set
L2
L1
L2
o
x
o
a
c
y
d
b
d
a
c
y
p
x
p
b
d
z
q
y
q
z
p
L1
L2
x
o
a
c
b
L1
z Original Drawing (a)
Case 1 (b)
invisible state
q
Case 2 (c)
Figure 15: Edge crossing reduction for mental map preservation: cases 1 and 2.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 332
invisible state
mental map set
L1
L2
L1
L2
x
o
x
o
p
y
q
a
c
a
c
b
d
b
d
y
q
z
p
z Original Drawing (a)
Case 3 (b)
Figure 16: Edge crossing reduction for mental map preservation: case 3. (c) Place x below b. 2. Case 2. If the edge crossing reduction algorithm determines that state y is best placed above a (see Figure 15(c)): (a) In layer L1 shift down the position of the selected states, e.g., a and b. (b) Place y above a. (c) For all the states in other layers that include part of the selection (e.g., layer L2): i. Shift down the position of the states in such a way that the original structure of the selection is preserved (e.g., states c, d, p, and q are shifted down). ii. Insert invisible states to fill the empty positions (e.g., above state c). 3. Case 3. In Figure 16(a), if the edge crossing reduction algorithm determines that state y is best placed above a and the position above a is occupied by an invisible state: (a) Move y to the position occupied by the invisible state. (b) Shift up the position of every state below the original position of y (e.g., z). (c) Delete the invisible state (see Figure 16(b)).
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 333
Figure 17: Statechart diagram before edge-crossing with layer mental map. Figure 17 shows a statechart drawing generated by our layout algorithm before the reduction of the edge crossings. In this diagram, we have selected states 1B, 1C, 1F , and 1G to preserve the mental map. Figure 18 shows the same statechart drawing of Figure 17 after the reduction of the edge crossings while preserving the mental map. This diagram shows the three invisible states that were added as a result of the required shifts generated by our algorithm. The preservation of the mental map has disadvantages: some edge crossings may not be removed; improper edges may be inserted; and the insertion of invisible states may increase the total drawing area. Hence, the mental map feature is offered as an option to the user.
6
Conclusions and Experimental Results
In this paper we presented an algorithmic framework for the automatic generation of layouts of statechart diagrams. Our framework is based on hierarchical drawing, labeling, and floorplanning techniques. The design of the framework is modular and thus any algorithm used for any step can be replaced with an improved algorithm thus resulting in an improved tool. Furthermore, we presented techniques for performing interactive operations (insertions and deletions) in the statechart while preserving the mental map of the drawing. Since the resulting drawings improve considerably the readability of the diagrams, they constitute an invaluable tool to the specifier who will shift his/her focus from organizing the mental or physical structure of the requirements to its analysis. We implemented a tool, called Vista, using the algorithms described in this paper, and ran the tool on two different sets of statechart examples. First, we created four statechart examples which we used as input for Rational Rose 1999, and Vista. Our results are summarized in Table 1 and the respective drawings are included in the Appendix.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 334
Figure 18: Statechart diagram after edge-crossing with layer mental map.
Aesthetic Criteria Edges Crossings Edge Bends Edge Label Overlap State-Edge Overlap
Example 1 Rational ViSta
Example 2 Rational ViSta
Example 3 Rational ViSta
Example 4 Rational ViSta
2
0
6
0
13
0
4
2
5
7
3
20
8
14
7
10
0
10
0
25
0
17
0
4
0
0
0
0
0
0
0
Table 1: Comparison of statecharts drawn by our algorithms
0
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 335 Aesthetic Criteria Edges Crossings Edge Bends Width Height W/H Ratio Area in pixels
Example 5
Example 6
Example 7
Example 8
Example 9
Figure 9
0
0
0
0
9
0
19
18
18
32
23
7
875 1,259 0.695
1,029 1,722 0.5975
861 1,593 0.54
1,632 1,424 1.44
992 1423 0.697
1077 683 1.57
1,102,884
1,771,938
1,371,573
2,323,968
1,411,616
735,591
Table 2: Comparison of statecharts drawn by our algorithms Secondly, we include drawings of five additional statecharts drawn by Vista in the Appendix. These statecharts show different attributes of Vista and cannot be automatically drawn by Rational Rose 1999. The statistics of these drawings are summarized in Table 2. We notice that, after the application of the tool, the drawings have: (1) few edge-crossings; (2) a low number of edge bends; (3) small area; and (4) a good aspect ratio. A limitation of our technique is related to the optimization of the drawing area obtained by our current floorplanning. The approach works well if the parent AND state is composed by a few children. If the AND state has a lot of children (as shown in Figure 19.a, which is obtained before applying our floorplanning technique) our algorithm will produce a drawing that will still use one dimension more that the other (see Figure 19.b). More research is needed in this direction.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 336
(a) Original Drawing
(b) Drawing after floorplanning
Figure 19: Statechart that shows the limitations of our tool.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 337
References [1] G. D. Battista, P. Eades, R. Tamassia, and I. G. Tollis. Algorithms for drawing graphs: an annotated bibliography. Comput. Geom. Theory Appl., (4):235–282, 1994. [2] G. D. Battista, P. Eades, R. Tamassia, and I. G. Tollis. Graph Drawing: Algorithms for the Visualization of Graphs. Prentice Hall, 1999. [3] T. Biedl and M. Kaufman. Area-efficient static and incremental graph drawings. In Proceedings of the 5th. Annual European Symposium on Algorithms, volume 1284, pages 37–52. Springer-Verlag, 1997. [4] T. C. Biedl, B. P. Madden, and I. G. Tollis. The three-phase method: A unified approach to orthogonal graph drawing. In G. D. Battista, editor, Graph Drawing (Proceedings GD’97), pages 391–402. Springer-Verlag, 1997. Lecture Notes in Computer Science 1353. [5] G. Booch, I. Jacobson, and J. Rumbaugh. The Unified Modeling Language User Guide. Addison-Wesley, 1998. [6] R. Castell´o. From Informal Specification to Formalization: An Automated Visualization Approach. PhD thesis, The University of Texas at Dallas., 2000. [7] R. Castell´o, R. Mili, and I. G. Tollis. Vista: A tool suite for the visualization of statecharts. to appear on Journal of Systems and Software., (0), 2002. [8] J. Christensen, J. Marks, and S. Shieber. An empirical study of algorithms for Point Feature Label Placement. ACM Trans. on Graphics, 14(3):203– 232, July 1995. [9] S. Doddi, M. V. Marathe, A. Mirzaian, B. M. Moret, and B. Zhu. Map Labeling and Its Generalizations. In Proc. 8th ACM-SIAM Sympos. Discrete Algorithms, pages 148–157, 1997. [10] P. Eades and Q.-W. Feng. Drawing clustered graphs on an orthogonal grid. In G. D. Battista, editor, Graph Drawing (Proceedings GD’97), pages 146–157. Springer-Verlag, 1997. Lecture Notes in Computer Science 1353. [11] P. Eades, Q.-W. Feng, and X. Lin. Straight-line drawing algorithms for hierarchical graphs and clustered graphs. In S. North, editor, Graph Drawing (Proceedings GD’96), pages 113–128. Springer-Verlag, 1997. Lecture Notes in Computer Science 1190. [12] P. Eades, T. Lin, and X. Lin. Two three drawing conventions. International Journal of Computational Geometry and Applications., 3(2):133–153, 1993. [13] M. Formann and F. Wagner. A packing problem with applications to lettering of maps. In Proc. 7th Annual ACM Sympos. Comput. Geom., pages 281–288, 1991.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 338 [14] E. R. Gansner, E. Koutsofios, S. C. North, and K.-P. Vo. A technique for drawing directed graphs. IEEE Transactions on Software Engineering, 19(32):214–230, March 1993. [15] E. R. Gansner, S. C. North, and K. P. Vo. Dag—a program that draws directed graphs. Software Practice and Experience, 18(11):1047–1062, November 1988. [16] D. Harel. Statecharts: A visual formalism for complex systems. Science of Computer Programming, 8(3):231–274, June 1987. [17] D. Harel, H. Lachover, A. Naamad, A. Pnueli, M. Politi, R. Sherman, A. Shtull-Trauring, and M. Trakhtenbrot. Statemate: A working environment for the development of complex reactive systems. IEEE Transactions on Software Engineering, 16(4):403–414, May 1990. [18] D. Harel and G. Yashchin. An algorithm for blob hierarchy layout. In Proceedings of International Conference on Advanced Visual Interfaces, AVI’2000, Palermo, Italy, May 1990. [19] E. Imhof. Positioning names on maps. 2(2):128–144, 1975.
The American Cartographer,
[20] K. G. Kakoulis and I. G. Tollis. An algorithm for labeling edges of hierarchical drawings. In G. D. Battista, editor, Graph Drawing (Proceedings GD’97), pages 169–180. Springer-Verlag, 1997. Lecture Notes in Computer Science 1353. [21] K. G. Kakoulis and I. G. Tollis. On the edge label placement problem. In S. North, editor, Graph Drawing (Proceedings GD’96), pages 241–256. Springer-Verlag, 1997. Lecture Notes in Computer Science 1190. [22] E. S. Kuh and T. Ohtsuki. Recent advances in VLSI layout. Proceedings of the IEEE, 78(2):237–263, 1990. [23] T. Lengauer. Combinatorial Algorithms for Integrated Circuit Layout. John Wiley & Sons, 1990. [24] E. B. Messinger, L. A. Rowe, and R. R. Henry. A divide-an-conquer algorithm for the automatic layout of large graphs. IEEE Transactions on Systems, Man, and Cybernetics, 21(1):1–11, February 1991. [25] K. Misue, P. Eades, W. Lai, and K. Sugiyama. Layout adjustment and the mental map. Journal of Visual Languages and Computing, 6(2):183–210, 1995. [26] S. C. North. Incremental layout in dynadag. In F. J. Brandenburg, editor, Graph Drawing (Proceedings GD’95), pages 409–418. Springer-Verlag, 1996. Lecture Notes in Computer Science 1027.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 339 [27] R. O’Donnel, B. Waldt, and J. Bergstrand. Automatic code for embedded systems based on formal methods. Available from Telelogic over the Internet. http://www.Telelogic.se/solution/techpap.asp. Accessed on April 1999. [28] A. Papakostas and I. G. Tollis. Interactive orthogonal graph drawing. IEEE Transactions on Computers, 47(11):1297–1309, 1998. [29] J. Peterson. Overcoming the crisis in real-time software development. Available from Objectime over the Internet. http://www.Objectime.on.ca/otl/technical/crisis.pdf. Accessed on April 1999. [30] Rational. Rose java. Downloaded from Rational over the Internet. http://www.rational.com. Accessed on November 1999. [31] L. A. Rowe, M. Davis, E. Messinger, and C. Meyer. A bowser for directed graphs. Software Practice and Experience, 17(1):61–76, January 1987. [32] K. Ryall, J. Marks, and S. Shieber. An interactive system for drawing graphs. In S. North, editor, Graph Drawing (Proceedings GD’96), pages 387–393. Springer-Verlag, 1997. Lecture Notes in Computer Science 1190. [33] J. Seeman. Extending the sugiyama algorithm for drawing UML class diagrams: Towards automatic layout of object-oriented software diagrams. In G. D. Battista, editor, Graph Drawing (Proceedings GD’97), pages 415– 424. Springer-Verlag, 1997. Lecture Notes in Computer Science 1353. [34] L. Stockmeyer. Optimal orientations of cells in slicing floorplan designs. Information and Control, (57):91–101, 1983. [35] K. Sugiyama, S. Tagawa, and M. Toda. Methods for visual understanding of hierarchical system structures. IEEE Transactions on Systems, Man, and Cybernetics, 11(2):109–125, February 1981. [36] A. S. Tools. Real-time studio: The rational alternative. Available from Artisan Software Tools over the Internet. http://www.artisansw.com/rtdialogue/pdfs/rational.pdf. Accessed on April 1999. [37] F. Wagner and A. Wolff. Map labeling heuristics: Provably good and practically useful. In Proc. 11th Annual. ACM Sympos. Comput. Geom., pages 109–118, 1995. [38] S. Wimer, I. Koren, and I. Cederbaum. Floorplans, planar graphs and layout. IEEE Transactions on Circuits and Systems, pages 267–278, 1988. [39] P. Yoeli. The logic of automated map lettering. The Cartographic Journal, 9(2):99–108, 1972.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 340
Appendix In this Appendix we show drawings of four example statecharts that were used in table 1. These drawings were automatically generated by Rational Rose and Vista.
A
A to C( Condition AC ) A to B( Condition AB )
B
C C1
A to D( Condition AD )
C1 to C3( Condition C1C3 ) C3 C31 C31
C1 to C2( Condition C1C2 ) C2
C31 to C33 C31 to C32 C33 C33
B to H( Condition BH )
C32 C32 C33 to C35
C2 to C5( Condition ) C2 to C6(C2C5 Condition C2C6 ) C2 to C4( Condition C2C4 ) C34 C34
C32 to C34
C35 C35
C3 to C4( Condition C3C4 ) C4
C5
C6
C to G( Condition CG )
G
H
D
C to E( Condition CE )
D to F( Condition DF ) H to F( Condition HF )
F
G to I( Condition GI ) G to E( Condition GE )
E
I
Figure 20: Example 1 generated by Rational Rose. We also show drawings (Figures 28,29,30,31,32) of five example statecharts that were used in table 2. These drawings were automatically generated by our implementation of the framework presented in this paper.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 341
Figure 21: Example 1 generated by ViSta.
A
A to D( Condition AD ) A to AB C( Condition AC ) A to B( Condition ) H to A( Condition HA ) C
B
D
F to A( Condition FA ) K to A( Condition KA )
B to E( Condition BE )
B to F( Condition BF ) C to H( Condition CH ) C to F( Condition CF ) D to G( Condition DG ) D to F( Condition DF )
F
E
E to I( Condition EI )
I
H
G
F to K( Condition FK ) G to J( Condition GJ )
J
H to K( Condition HK )
K
Figure 22: Example 2 generated by Rational Rose.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 342
Figure 23: Example 2 generated by ViSta.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 343
A
A to C( Condition AC ) A to B( Condition AB )
H to A( Condition HA ) F to A( Condition FA )
B
C
E to B( Condition EB ) B to E( Condition BE )
C to H( Condition CH ) B to F( Condition BF ) K to KAHCF )to )C( Condition HC ) C A( to Condition F( Condition
B toI to I( Condtion BI ) IB ) B( Condition N to A( Condition NA )
E
E to I( Condition EI ) E to L( Condition EL )
L
F
C to K( Condition CK )
H
F to K( Condition FK ) F to I( Condtion FI ) H to K( Condition HK )
I
K F to N( Condition FN )
L to N( Condition LNCondtion ) L to M( Condition LM ) I to N( IN ) K to N( Condition KN )
M
N
Figure 24: Example 3 generated by Rational Rose.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 344
Figure 25: Example 3 generated by ViSta.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 345
A
A to C( Condition AC ) A to B( Condition AB )
F to A( Condition FA ) H to A( Condition HA )
B
C
B to E( Condition BE )
C to H( Condition CH ) C to F( Condition CF )
F
E
H
H1 H1 to H4( Condition H1H4 ) H1 toH1H2 H3( Condition H1h3 ) H1 to H2( Condition ) H3 H3
H2
H4 H2 to H5( Condition H2H5 )
K to A( Condition KA )
H3 to H6( Condition H3H6 )
H4 to H5( Condition H4H5 ) H5
H6 H4 to H7( Condition H4H7 )
H5 to H7( Condition H5H7 ) E to I( Condition EI )
F to K( Condition FK )
H7 H7
H6 to H8( Condition H6H8 ) H7 to H8( Condition H7H8 )
H8
H8 to H9( Condition H8H( ) H9
H to K( Condition HK )
I
K
I to L( Condition IL ) K to L( Condition KL )
L
Figure 26: Example 4 generated by Rational Rose.
L to A( Condition LA )
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 346
Figure 27: Example 4 generated by ViSta.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 347
Figure 28: Example 5.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 348
Figure 29: Example 6.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 349
Figure 30: Example 7.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 350
Figure 31: Example 8.
R. Castell´ o et al., Visualization of Statecharts, JGAA, 6(3) 313–351 (2002) 351
Figure 32: Example 9.
Journal of Graph Algorithms and Applications http://jgaa.info/ vol. 6, no. 3, pp. 353–370 (2002)
Graph Drawing in Motion Carsten Friedrich
Peter Eades
Basser Department of Computer Science The University of Sydney Australia http://www.it.usyd.edu.au/ [email protected] [email protected] Abstract Enabling the user of a graph drawing system to preserve the mental map between two different layouts of a graph is a major problem. In this paper we present methods that smoothly transform one drawing of a graph into another without any restrictions to the class of graphs or type of layout algorithm.
Communicated by M. Kaufmann: submitted February 2001; revised February 2002.
Research supported in part by DSTO Australia.
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 354
1
Introduction
Graphs are a common way to communicate information. In many applications these graphs are not static but change their structure and layout according to user and application actions. Preserving the mental map during these changes has been identified to be crucial for the usability of a system [2]. There are two possible approaches to this problem: either develop graph drawing algorithms that try to minimize changes [3], or to communicate the changes in the form of an animation [7, 9, 10], that is, a smooth transition from the old drawing to the new drawing. While specialized algorithms work quite well in practice, general animation techniques tend to fail to actually improve usability in many situations. Figure 1 shows an example of a bad animation1 .
1
2
3 http://www.it.usyd.edu.au/~carsten/gd00/a.mpg Figure 1: Example of a bad animation. The nodes from the drawing on the left are moved to their new position in the drawing on the right using a linear interpolation. The drawing in the middle is a snapshot of the animation where nodes lie very close to each other. Individual node movements are difficult to follow at this stage. We introduce requirements for animations of graph drawings and methods which partially satisfy these requirements. These techniques have been implemented in the Marey system which will also be briefly introduced. 1 All examples, in the form of mpeg videos, and a free MPEG player for Windows-NT/95/98 as well as references to free players for Unix are available from http://www.it.usyd.edu.au/ ~carsten/gd00/.
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 355
2
Model for a good animation
An animation is a sequence of images called frames. This sequence is characterized by subtle but highly structured changes between consecutive frames over space and over time. The changes are perceived as movement of the corresponding objects in the image by the human brain. A detailed analysis of perceptional mechanisms is beyond the scope of this paper. For an introduction to human perception of moving pictures see, for example, [1, 5, 15]. In the case of a graph animation, the frames are drawings of graphs. The changes in the drawings are changes in the positions of the nodes and edges. The animation should help the user to maintain the mental map of a changing graph. Major changes to the drawing of a graph usually occur when the user applies a layout algorithm which provides a different view of the graph or when the structure of the graph changes in a way which makes it necessary to recompute the layout. Examples of structural changes in graphs are collapsing or expanding sub graphs in clustered graphs, navigation in infinite graphs2 or graphs such as graph A of the 1999 Graph Drawing Contest [4] which represents the changes in the cast of a soap opera.
2.1
Criteria for a good animation
We try to achieve the following goals with animation between two graph layouts. 1. Preserve the mental map 2. Communicate the structural changes in the graph. Firstly the system needs to tell the user that the graph has changed. Secondly, the system needs to indicate the nature of the change. The following aesthetic criteria have been identified to be critical to achieve these goals. 2.1.1
The movements of nodes and edges should be easy to follow.
2.1.2
The movements of the graph should be structured.
The human brain contains highly optimized mechanisms for recognizing and interpreting certain special kinds of movements. These movements include • Uniform movement. If the relative position of nodes in the initial frame is similar to those in the final frame, then it should be so in the intermediate frames. • Symmetrical movement. As with static images the brain shows a predisposition for conceiving symmetry in movement. 2 For
example www-based graphs
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 356
• Two-dimensional projections of movements of three-dimensional rigid objects. Humans can see three-dimensional movement in a two-dimensional moving image. Although humans are able to perceive three-dimensional images directly using stereo vision, the loss of the third dimension hardly poses any problems for us in everyday live. Even in situations where we only have access to a two-dimensional projection of the world around us, for example if using only one eye, or on a TV or computer screen, we have no problems identifying three-dimensional objects and their movement in all three dimensions. For a detailed discussion of these effects see [14]. The more we can exploit these mechanisms for which the brain is optimized, the easier it is for the user to preserve the mental map of the graph. 2.1.3
The transition from source to destination should be smooth.
The movements should be performed in small steps and adequately quickly to help the human brain to perceive and interpret the movement. 2.1.4
Display of non-existing structures should be avoided.
An often neglected problem in graph drawing is the case where the drawing suggests some structure which does not exist in the graph [17]. Figure 2 shows an example for two layouts of the same graph, where the second layout could lead the user wrongly to assume that the graph is a simple path. Similar problems can occur easily during an animation, as the human brain tends to be quite imaginative when it tries to interpret moving images [14].
Figure 2: Example of a misleading layout
2.1.5
The individual frames should satisfy the classical aesthetic criteria for good graph drawings
such as minimizing edge crossings, maximizing the smallest angle, etc; see [2] for details.
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 357
2.2
Measures for a good animation
To be able to actually evaluate how well an animation matches our criteria we derived the following possible measures. 2.2.1
Minimize temporary edge crossings.
Edge crossings in a graph drawing generally reduce readability. It seems that this is also valid for animations. If the animation avoids introducing unnecessary edge crossings on the way then it is easier for the user to follow the movements. 2.2.2
Maintain a minimal distance between nodes which do not move uniformly.
If nodes lie close to each other, it is more difficult to follow their individual movements than if they are further apart. Of course, if two nodes lie next to each other in the source drawing and in the target drawing, it would be better to move them uniformly close to each other to their destination than to separate them first. 2.2.3
Maximize structured movements.
• Maximize uniform movement Maximizing uniform movement can be done by measuring how much the relative positions of a nodes change from the initial to the final frame. • Maximize symmetry Symmetry in a drawing helps the user to understand the structure of a graph. In an animation symmetry of movement makes it easier to understand the structure of the movement. A formal measure for symmetric node movement can be derived by extending the model in [11]. • Maximize movement interpreted as movement of a rigid object The human is very good at interpreting two dimensional projections of movements of three dimensional rigid objects in IR3 . We should therefore try to do as much of the animation as possible in such a way. A detailed description of how to do this follows below. 2.2.4
Minimize the length of the path of a node.
A node which moves on a straight line between its source and destination clearly moves a minimal distance. However some criteria may prevent straight line movement. In such cases we require a minimum distance movement to help the user to follow and anticipate the node movement.
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 358
2.2.5
Provide smooth transitions and adequate speed.
Smooth transitions and an adequate speed are obvious criteria for a good animation. If the transition steps are too big then the user is no longer able to perceive a movement. If the speed is too slow the user will become impatient and stop following the animation. If it is too fast the user will not be able to keep track of the nodes and comprehend the movements. Formal metrics can be derived from the above. For example it is possible to count the number of temporary edges or compute the length of the node paths. Formalizations of some of these metrics are NP hard to optimize and often not all criteria can be achieved in one solution. For example it might be necessary to move nodes along a non-optimal path to avoid edge crossings, or it might be preferable to accept some edge crossings instead of watching the graph untangle in a complex and confusing way.
3
The animation process
The animation process we propose here splits the animation into two main stages. In the first stage we try compute an animation which moves the graph as close as possible to its destination in a way that is perceived as the motion of a rigid three-dimensional object in space. We then move the nodes the rest of the way in a direct linear interpolation. In addition we also animate changes in the structure of the graph and changes to graphical attributes like color or visibility. To make the animation process as independent as possible to a specific application we only require a very small and general set of information to be available from the embedding system. This information consists of the coordinates of the nodes in the first and final frame, how graphical attributes such as color and visibility change, as well as how the structure of the graph changes. The animation consists of the following steps. 1. Hide vanishing nodes and edges 2. The rigid motion stage 3. The linear interpolation stage 4. Show newly visible elements
3.1
Hide vanishing nodes and edges
Nodes and edges which do not exist in the final frame because they were either deleted or became invisible are hidden at the beginning. Various effects, for example fade out, are used to do this.
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 359
3.2
The rigid motion stage
In this stage we move the nodes and edges as close as possible to the final frame using only movements which are perceived as if the graph was moving as a rigid object in three-dimensional space. 3.2.1
Computing the rigid transformation.
Projecting tree-dimensional movements of rigid objects on two dimensions is identical to applying the operations translation, rotation, scaling and shearing in IR2 to the projection of the object. We interpret a shearing angle α of more than 90 degree as a flip followed by a shear of α − 90 degree. This set of operations is precisely the set of two dimensional affine linear transformations. As these movements are very easy to understand for humans we try to do as much of the total animation as possible in this stage. We use linear regression to find the best affine linear transformation of the graph between the first and final frame. This can be done in linear time as follows. Given a graph G and the coordinates (xv , yv ) for each node v ∈ G the linear transformation has the general form a11 a12 xv a f (v) = + 13 a21 a22 yv a23 In order to determine the linear function which transforms the graph as close as possible to the final frame we have to determine the aij which minimize the distance between the positions in the final frame and the positions after the linear transformation. We use the average the error between the individual node distances as a good approach in respect to the goal of preserving the mental map; that is we minimize the sum of the squared Euclidean distances. Given (x0v , yv0 ) as the original coordinates of a node v we aim to minimize the error function X e= |f (v) − (x0v , yv0 )| v∈G
with || being the squared Euclidean norm, that is
e=
X
(a11 ∗ xv + a12 ∗ yv + a13 − x0v )2 + (a21 ∗ xv + a22 ∗ yv + a23 − yv0 )2
v∈G
(1) Since (1) is always non negative, minimizing this quadratic function is done by deriving with respect to the aij and setting the resulting expressions to equal 0. We solve the system of equations for the aij . Assuming at least 3 non colinear pairs of node coordinates this will give us a unique solution for each aij :
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 360
Let
denom = (
X
x2v ) ∗ (n ∗
v∈G
X
yv2 − (
v∈G
(2 ∗ (
X
v∈G
yv ) ∗
X
yv )2 ) − n ∗ (
v∈G
X
xv ∗ yv )2 + (
v∈G
xv ∗ yv − (
v∈G
X
X
v∈G
xv ) ∗
X
X
xv )∗
v∈G
yv2 ).
v∈G
Then
a11
a12
a13
P P P P ( v∈G xv ∗ yv ) ∗ (n ∗ v∈G x0v ∗ yv − ( v∈G x0v ) ∗ v∈G yv ) = −( + denomP P P ( v∈G x0v ∗ xv ) ∗ (( v∈G yv )2 − n ∗ v∈G yv2 ) + P P denom P P P 0 2 ( v∈G xv ) ∗ (( v∈G xv ) ∗ v∈G yv − ( v∈G yv ) ∗ v∈G x0v ∗ yv ) ), denom P P P P ( v∈G x2v ) ∗ (n ∗ v∈G x0v ∗ yv − ( v∈G x0v ) ∗ v∈G yv ) = + P P denom P P 0 0 ( v∈G xv ∗ yv ) ∗ (( v∈G xv ) ∗ v∈G xv − n ∗ v∈G xv ∗ xv ) + denom P P P P P ( v∈G xv ) ∗ (( v∈G yv ) ∗ v∈G x0v ∗ xv − ( v∈G xv ) ∗ v∈G x0v ∗ yv ) , P P P denom P P 2 0 2 0 ( v∈G xv ) ∗ (( v∈G xv ) ∗ v∈G yv − ( v∈G yv ) ∗ v∈G xv ∗ yv ) − = denom P P ( v∈G x0v ) ∗ ( v∈G xv ∗ yv )2 + denom P P P P P ( v∈G xv ∗ yv ) ∗ (( v∈G yv ) ∗ v∈G x0v ∗ xv + ( v∈G xv ) ∗ v∈G x0v ∗ yv ) − denom P P P ( v∈G xv ) ∗ ( v∈G yv2 ) ∗ v∈G x0v ∗ xv . (2) denom
We can obtain a21 , a22 , and a23 from the solutions for a11 , a12 , and a13 respectively by replacing x0v with yv0 . 3.2.2
Quality of the transformation
The sum of the Euclidean squares is known to be statistically biased and to over-emphasize outlying samples. Other distance functions are much harder to minimize on the other hand [8, 13]. To increase statistic stability different approaches are imaginable. The median or centroid of the drawings could be added to the node set with a weight factor. Another promising approach would be to compute different transformations using random subsets of the nodes and using the best one.
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 361
3.2.3
Animating the affine linear transformation
After computing the affine linear transformation we have to generate an animation for the graph. The easiest approach would be to do a linear interpolation of each matrix entry from the identity matrix to the computed matrix. However the result would not produce the desired effect of being perceived as the movement of a rigid object in all cases. This can easily be seen in the case of a 180 degree rotation of the graph. The transformation matrix would be −1 0 tm = 0 −1 interpolating the entries from
1 0
0 1
0 0
0 0
to tm will produce the matrix
at some stage collapsing the graph to one point. This does not happen in a 180 degree rotation. Shoemake and Duff [16] show that the rotation part of the transformation is the only part not compatible with linear entry interpolation and propose polar matrix decomposition as an efficient way to separate the rotational part from the transformation. For a 2 × 2 matrix3 the decomposition takes constant time. We can now generate an animation by interpolating the rotation over the angle and at the same time do a linear interpolation of the matrix entries of the non-rotational part. 3.2.4
Adjusting the center of rotation
Using the approach described above still has a small problem. The rotation we compute is always done in respect to the coordinates (0, 0), generating a smaller or bigger arc depending on how the graph lies to the origin. To avoid this we modify our linear transformation before the decomposition to move the center of the graph to the origin at the beginning and back to the former position afterwards. This can easily done by multiplying the corresponding transformation matrices to each side of our matrix. The graph will now rotate around its center. Several definitions of center are possible, for example the center of the bounding box, or the barycenter. In our experience the decision of which definition to use had little influence on the overall animation. Computing the center takes linear time. 3 For
this purpose we can ignore the translation part
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 362
3.2.5
Complexity
The following computations have do be done: • The aij in (2) can be computed in one iteration over all nodes and is therefore linear in time. • The polar decomposition is done in constant time. • Adjusting the center of rotation takes again linear time to compute the center. All computations have to be done once at the start of the animation. The overall cost of this stage is therefore linear.
3.3
Move nodes to their final positions
For the final movements several algorithms are available. The easiest approach is to move the nodes the remaining way to their new positions on a linear path. Alternatively these movements can be restricted to certain general directions at a time or broken up into uniform movements. For example, we can first move to the x-positions and then to the y-positions. The advantage of these simple approaches is that the movements can be computed very fast. The disadvantage is that none of our criteria for a good animation is enforced. However more sophisticated approaches are more appropriate in some cases. We have developed an adaptation of the force directed layout approach described in [6] to move the nodes to their final positions. The repulsive forces are similar to the static version, whereas instead of attracting edges, nodes are attracted to their destination. This approach provides a minimal distance between nodes at all times in most cases and thereby increases traceability. Problems with this approach are to update the forces fast enough to be able to provide a fast and smooth animation and secondly to guarantee an efficient movement of the nodes to their final destination.
3.4
Show newly visible elements
The last step adds graph elements to the drawing which did not exist or were invisible at the start of the animation. As for the first step this can be done within one step or using a slower fade-in.
4
Examples
The following examples show typical use cases of the animation module. The static pictures in this section try to capture the animation process. Of course this is only possible to a certain degree. All examples are available as mpeg videos on the following web site: http://www.it.usyd.edu.au/~carsten/gd00
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 363
Note that some freely available mpeg display programs do not support the features necessary to play the movies. References to free and working mpegplayers for Windows NT and Unix are provided on this page.
4.1
Applying a new layout
The first example shows the animation between two force directed layouts. The structure of the drawing does not change much apart from a rotation of the graph of about 180 degree. A direct movement of the nodes from the source to the target would result in a confusing animation as shown in figure 1. Figure 3 shows how algorithm breaks up the movement into a rotation and a final movement of the nodes.
1
2
3
4
http://www.it.usyd.edu.au/~carsten/gd00/b.mpg Figure 3: The order of the frames is upper left corner, upper right corner, lower left corner, lower right corner. The animation is broken into a rotation of the graph and a subsequent movement of the node to their final position.
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 364
The second example shows the transition from a hierarchical type layout to an force directed layout of a graph. Snapshots of the animation are shown in figure 4.
1
2
3
4
http://www.it.usyd.edu.au/~carsten/gd00/c.mpg Figure 4: The order of the frames is upper left corner, upper right corner, lower left corner, lower right corner. Morphing between a hierarchical layout and a force directed layout using a linear interpolated path for the nodes.
4.2
Sub-graph expansion
The example in figure 5 shows a clustered graph. The center node, which represents a group of nodes is expanded and a new layout is computed using a force directed algorithm. The animation shows the change from the old layout to the new layout.
4.3
Adding visual clues
The example in figure 6 shows an animation with added visual effects. The modification of the canvas increases the impression of a movement of a rigid object. After the rigid motion stage the nodes are moved to their final position in the new layout using linear interpolation.
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 365
1
2
3
4
5
6
http://www.it.usyd.edu.au/~carsten/gd00/expand.mpg Figure 5: Sub-graph expansion. The order of the frames is upper row from left to right, then lower row from left to right. The node in the middle of the first image is expanded to a sub-graph. The sequence shows how the node is faded out, how the remaining nodes are moved to their new position, and how the new nodes are faded in.
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 366
http://www.it.usyd.edu.au/~carsten/gd00/clue.mpg Figure 6: Adding visual effects can increase the impression of the graph moving as a rigid object in space.
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 367
5
Architecture of Marey
The methods described above were implemented as a Java package of the name Marey and integrated in our experimental graph drawing tool JJGraph. The architecture of the system was developed following object oriented design patterns. The graph itself, the layout algorithms, the graph modifying algorithms, and the animation engine are implemented as separate modules. They exchange information and trigger actions using a defined API. In a typical use case the user invokes some action which results in major changes in the graph drawing, for example applying a layout algorithm or changing the graph structure followed by a layout algorithm. Figure 7 shows the data-flow for these cases.
User trigger aciton
Graph Modifier
Layout Algorithm
layout modified graph
forward modifications
forward modifications
Marey update graph
Graph
Figure 7: Architecture Note that there is typically no need for the user to directly access the animation module. In our prototype the user is able to access the Marey module to take snapshots of graphs and generate an animation between them. Figure 8 on the next page shows the control panel of the Marey module. A special Java class is used to store the changes which should be animated4 . 4 Currently only node movements and visibility of nodes and edges can be animated. The system is easily extensible and more features are currently being developed
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 368
Figure 8: Control Panel Modules can either provide instances of that class to the animation module or tell the animation module to take a snapshot of the current state of the graph and compute the differences to the last snapshot.
6
Future Plans
Our main focus currently is on developing more sophisticated methods for the non-structured part of the animation, incorporate mechanisms for handling edges with bends, especially the case where the number of bends varies between the initial and the final frame, as well as trying to identify and animate non-linear structured movements. At the same time we try to extend the Marey system to incorporate these new developments and finally release it as a publicly available Java package. A prototype is currently integrated into the InVision framework[12].
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 369
References [1] Edward Adelson. Mechanisms for motion perception. Optics and Photonics News, August:24–30, 1991. 2 [2] Giuseppe Di Battista, Peter Eades, Roberto Tamassia, and Ioannis G. Tollis. Graph drawing: algorithms for the visualization of graphs. Prentice-Hall Inc., 1999. 1, 2.1.5 [3] F. Bertault. A force-directed algorithm that preserves edge-crossing properties. Information Processing Letters, 74(1–2):7–13, 2000. 1 [4] Franz J. Brandenburg, Michael J¨ unger, Joe Marks, Petra Mutzel, and Falk Schreiber. Graph-drawing contest report. In Proc. of the 7th Internat. Symposium on Graph Drawing (GD’99), pages 400–409, 1999. 2 [5] Roger N. Shepard Eloise H. Carlton. Psychologically simple motions and geodesic paths. Journal of Mathematical Psychology, 34(2):127–228, 1990. 2 [6] Frick, Ludwig, and Mehldau. A fast adaptive layout algorithm for undirected graphs. In Proc. of the DIMACS International Workshop on Graph Drawing (GD’94), 1994. 3.3 [7] C. Friedrich. The ffGraph library. Technical Report 9520, Universit¨at Passau, Dezember 1995. 1 [8] F.R. Hampel, E.M. Ronchetti, P.J. Rousseeuw, and W.A. Stahe l. Robust Statistics: The Approach Based on Influence Functions. John Willey, NY USA, 1986. 3.2.2 [9] http://www.mpi sb.mpg.de/AGD/. The AGD-Library User Manual Version 1.1.2. Max-Planck-Institut f¨ ur Informatik. 1 [10] Mao Lin Huang and Peter Eades. Navigating clustered graphs using forcedierected methods. JGAA Special Issue on GD98, 4(3):157–181, 2000. 1 [11] J. Manning. Geometric Symmetry in Graphs. PhD thesis, Purdue University, Department of Computer Sciences, 1990. 2.2.3 [12] T.R. Pattison, R.J. Vernik, D.P.J. Goodburn, and M.P. Phillips. Rapid assembly and deployment of domain visualisation solutions. In Submitted to IEEE Visualisation 2000, 2000. 6 [13] P.J. Rousseeuw and A.M. Leroy. Robust regression and outlier detection. John Willey, NY USA, 1987. 3.2.2 [14] Robert Sekuler and Randolph Blake. Perception. McGraw-Hill Publishing company, 1990. 2.1.2, 2.1.4
Friedrich and Eades, Graph drawing in motion, JGAA, 6(3) 353–370 (2002) 370
[15] Roger N. Shepard. Ecological constraints on internal representation: Resonant kinematics of perceiving, imagining thinking, and dreaming. Psychological Review, 91(4):417–447, 1984. 2 [16] Ken Shoemake and Tom Duff. Matrix animation and polar decomposition. In Proc. of the 1992 Graphics Interface Conference, pages 245–254, 1992. 3.2.3 [17] Richard J. Webber. Finding the Best Viewpoints for three-dimensional graph drawings. PhD thesis, University of Newcastle (Australia), 1998. 2.1.4
Journal of Graph Algorithms and Applications http://jgaa.info/
vol. 6, no. 4, pp. 373−404 (2002)
A 6-Regular Torus Graph Family with Applications to Cellular and Interconnection Networks Mihaela Iridon
David W. Matula
Southern Methodist University Computer Science and Engineering Department [email protected]
[email protected]
Abstract This paper introduces a special graph family, together with an extensive characterization of some of its properties and two of its immediate applications. The graph denoted by Ti,j, is a regular hexavalent toroidal graph. The topological features of Ti,j include vertex symmetry, Hamiltonian decomposition, translation and rotation isomorphism. Topologically, the graph is a torus, while algebraically, it can also be expressed as a Cayley graph, defined on the cyclic group <1, k, k2, −1, −k, − k2>, where k can be determined from the (i,j) parameters defining graph Ti,j. As a direct consequence, the proposed graph, which has ρ i , j = i 2 + i ⋅ j + j 2 = (i + j ) 2 − i ⋅ j vertices, is vertex-symmetric. For the special case when i − j is a multiple of 3, the graph has a unique 3-coloring. The diameter of the graph can also be expressed as a function of i and j: d = (2i + j ) / 3 . As a result of its highly symmetric topology, the graph is employed in modeling and analysis of cellular and interconnection networks. A more appropriate way of modeling highly dense cellular networks is shown to be the model using the triangular lattice in which the nodes represent the transceivers of the network, rather than the traditional hexagonal lattice where coverage overlap regions cannot be explicitly represented. The toroidal embedding of the triangular lattice using the Ti,j, graph helps us model and simulate the functionality of a cellular network with strong overlap regions without inducing any artifacts due to boundary effects limitations, simultaneously preserving the regularity of the graph model. For the constructing parameters of Ti,j, such that j = i − 1, the graph is optimal with maximum connectivity and maximum number of vertices for a locally planar graph, given diameter d, which in this case will be equal to j. This feature makes the Ti,j graph desirable for interconnection networks topology, together with the graph vertices’ algorithmic labeling scheme, presented in this paper. Communicated by Balaji Raghavachari: submitted May 1999; revised May 2001 and August 2002.
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
374
1 Introduction and Summary Throughout its evolution, the theory of graphs had placed in the spotlight a relative large number of special graphs with distinctive features and properties, useful in particular application areas or just interesting from the point of view of the graph theoretician. In this context, the main contribution of this paper is the introduction of a special graph, together with a characterization of some of its properties and two of its immediate applications. The graph denoted by Ti,j is a regular triangulated toroidal graph and is characterized by remarkable properties such as Hamiltonian decomposition, translation and rotation isomorphism, and features two special cases with interesting coloring and vertex set cardinality properties. The paper is organized around six sections. In the next section, we introduce homomorphic repeat patterns on the infinite triangular lattice and we describe the construction of the Ti,j graph. Its properties are given in Section 3. Section 4 briefly describes some coloring issues and the computation of the diameter of Ti,j. In Section 5, we give a succinct presentation of the two applications of the regular toroidal graph: cellular and interconnection networks modeling. The proposed graph’s highly symmetric structure, high connectivity, and the interaction between the topological and combinatorial properties, confer upon Tij a rich set of properties, which makes it a desirable tool for modeling and simulating various network topologies. Due to its finiteness as well as its regularitypreserving structure, the graph model can be employed in cellular network simulations without inducing any boundary artifacts, in order to model metropolitan area cellular networks with strong overlap coverage regions. We conclude the paper with a summary of results in Section 6.
2 Homomorphisms of the Infinite Triangular Lattice and Graph Ti,j 2.1 The Infinite Triangular Lattice and Rhombic Numbers There are three basic regular infinite lattices: the triangular (6-regular), the rectangular (4-regular), and the hexagonal (3-regular) lattice. A planar (2D) rectangular lattice, also referred to as the 2-lattice, [Hara72] is a graph whose points are ordered pairs of integers (i,j) where i = 0, 1, ... and j = 0, 1, ... . Two of these points are adjacent whenever their distance in the Cartesian plane is 1. In a similar way, we can define the 2D triangular lattice. Even if there are 3 distinct directions x ,y ,z in the triangular lattice, it is obvious that only two are independent, such that any point is uniquely identified by its (x,y) coordinates. Then, two points P1(x1,y1) and P2(x2,y2) are adjacent iff one of the following conditions hold:
(i) (ii)
x1 = x2 y1 = y2
and y1 − y2 = 1 and x1 − x2 = 1
(iii) x1 − x2 = 1 and y1 − y2 = 1
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
375
The infinite triangular lattice is an infinite regular graph of degree 6. Each vertex is adjacent to 6 other vertices and 6 edges, each edge is adjacent to 2 vertices, and each face, which is an equilateral triangle, is adjacent to 3 vertices. Moreover, the infinite triangular lattice is the dual graph of the infinite hexagonal lattice. This is shown in Figure 1, and it represents an interesting observation for the application of this graph in the modeling of cellular networks. In both graph model cases the vertices of the triangular lattice represent centers of the broadcasting regions. However, only the triangular lattice can explicitly show transceiver coverage overlap regions, whereas the hexagonal lattice does not. Moreover, the duality of the two lattices allowed us to build cellular network models of same capacity, in terms of number of channels available and same geographic coverage, however with different number of transceivers. As shown in Figure 1, nodes in the dual graph generating the triangular faces, identify faces (hexagons) in the hexagonal lattice.
Figure 1 The infinite hexagonal lattice and its dual graph, the infinite triangular lattice
As Arnaud had shown in [Arna80], the regular lattice represents a powerful tool to achieve an efficient use of the frequency spectrum when assigning channels to broadcasting stations. Cellular networks consist of groups of cells serving as a region. Each cell is assigned a set of radio frequency channels and has to deal with calls that either originated within that cell or is a handoff call. A handoff call (also known as a handover call) occurs due to the mobility of the users as well as the load balancing implementations that transfer calls between cells. The number of frequency channels constitutes a limited resource and, moreover, the assignment of channels to geographical cells and regions has to follow certain distance
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
376
constraints due to possible interference. Therefore it is necessary to reuse the allocated frequency channels within the network service area to support as many users as possible. In trying to find a simple algebraic algorithm for cellular layout in the case of hexagonal cellular network models, MacDonald introduced the idea of shifting parameters [MacD79]. A year later, Arnaud used the same concept and applied it for frequency planning in triangulated broadcasting network models. He extended this idea and used the notion of rhombic numbers defined by the two shifting parameters [Arna80]. Let us consider the infinite triangular lattice and a coordinate system (x,y) with axes offset at 600, and with the x-axis along the horizontal direction. Also, let us define along each direction two parameters, i and j, called the shifting parameters. They represent graph distances along the x and y axes, accordingly. With i,j given, such that 1 ≤ j < i and i,j relatively prime (i.e., GCD(i,j) = 1), we denote the rhombic number ρ i, j by the following formula:
ρ i , j = i 2 + i ⋅ j + j 2 = (i + j ) 2 − i ⋅ j
(1)
Given these parameters, one can place origin repeat points on the infinite triangular lattice, as shown in Figure 2, for i = 3 and j = 1. By connecting the repeat points as depicted in the figure, we obtain a rhombic tiling of the infinite triangular lattice. Arnaud used the idea of rhombic tiling in his paper mentioned earlier, and it emerged as a solution to the problem of covering a given area in the plane with transmitters given a limited number of available channels and considering the distance constraint to avoid interference. The two shifting parameters, i and j, have to be relatively prime because otherwise, the rhombus given by these parameters can be decomposed into non-trivial sub-rhombii. This is desirable because we aim to identify a unique labeling algorithm for the vertices of a region consisting of distinct sets of frequency channels, where the labeling will then identify these sets. Transceivers are situated at the vertices of the underlying
Figure 2 The rhombic tiling of the triangular lattice for shifting parameters i=3 and j=1.
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
377
triangular lattice but all the sets of distinct frequencies are within a delimiting rhombus. In Figure 2, the enlarged nodes of the rhombic lattice represent repeating (or identical) sets of voice channels, and the edge of such a rhombus denotes thus the minimal distance for which interference would be avoided.
2.2 Tilings of the Infinite Triangular Lattice The rhombic tiling, given the shifting parameters i, j, is given in Figure 3. The following lemmas will help us identify the number of vertices, edges, and triangular faces covered by a region delimited through a given tiling, and show the equivalence of the presented tilings.
D 120 0
j
i
Figure 3 Two repeat origin points at distance D, and shifting parameters (i,j) Lemma 1. The side of the rhombus tile is equal to
ρ i , j , where (i, j) are
the shifting parameters, and ρ i, j is the rhombic number. Proof: Given i and j, the minimum distance between any two repeat-origin points, denoted by D, is computed from the triangle outlined in Figure 3 by applying Pythagoras’ generalized theorem: 1 D 2 = i 2 + j 2 − 2 ⋅ i ⋅ j ⋅ cos(120 o ) = i 2 + j 2 − 2 ⋅ i ⋅ j ⋅ − 2 ⇒
D 2 = i2 + j 2 + i ⋅ j = ρ
i, j
Lemma 2. The number of vertices contained by the rhombus tile constructed on the infinite triangular lattice with shifting parameters (i,j), including the corner (origin-repeat) vertex only once, is equal to ρ i, j . Proof: Let the triangular lattice be composed of equilateral triangles of side 1, i.e., d = 1 . Also, let the side of the rhombus be D. The area of an
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
elementary triangle in the lattice is Atriangle = rhombus is Arhombus =
3 4
378
and the area of the
3 2 D . 2
Given the shifting parameters i, j, and applying Lemma 1 we have:
Arhombus =
3 2 3 D = ρ i, j . 2 2
Thus, the number of triangles inside the rhombus is equal to:
3 ρ i, j Arhombus Nt = = 2 = 2 ⋅ ρ i, j . Atriangle 3 4 Since every triangle is adjacent to three vertices and each vertex is adjacent to six triangles, we can write 2 ⋅ V = 2 ⋅ N v = N t , where Nv and Nt represent the number of vertices and the number of triangular faces, respectively. Hence, the number of vertices inside the rhombic tile is:
V = Nv =
Nt = ρ 2
i, j
A special case of pseudo-rhombic tiling, or degenerate tiling, given the rhombic number ρ i, j , is the stripe, where all the ρ i, j vertices are placed on a horizontal line. The surface is delimited by a contiguous series of triangles situated above the points. This is shown in Figure 4, for the case ρ i, j = 7 .
0
1
2
3
4
5
6
0
Figure 4 A stripe tiling with 7 vertices and 14 triangles
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
379
0 0 0 0
D 0 -4
-5
0
7
6 -2
-8
-9
0
2
1
0
-6
-7 4
3
9
8
0
-1
0
-3
5
0
0 0
Figure 5 A hexagonal tile with 19 vertices constructed with the Voronoi diagram method. The repeat origin points labeled 0 are at i=3, and j=2. The darkened points, labeled 0, denote repeating points. The area of the stripe is the same as the area of a rhombus with the same number of vertices, i.e. with the same number of triangles. The last and most interesting type of tiling is the hexagonal tiling. If we consider the infinite triangular lattice with the origin repeat points placed at positions given by the shifting parameters (i,j), one can identify a triangulated tiling derived from the rhombic tiling by drawing also the short diagonal of all rhombii. If for each such triangle (half rhombus) we determine the center, we obtain a lattice of points. This is known as the Voronoi diagrams technique [Fort92], and it identifies a cluster of vertices that are closer to a repeat origin point than to any other origin point. The collection of these clusters forms a hexagonal tiling in the triangular lattice. Such a cluster is shown in Figure 5. The hexagonal tile (cluster) represented here contains 19 vertices and the origin repeat points are i=3, j=2. Thus, the rhombic number for this case is ρ 3,2 = 19 . A generic triangle (half rhombus) and its center are represented in the left upper corner with a dotted line. Lemma 3. The hexagonal tile constructed with shifting parameters (i,j) contains ρ i, j vertices. Proof: In the hexagon depicted in Figure 5, the distance from its center labeled 0 and any of its 6 corners (black dots) is equal to 2/3 of the median
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
380
of the generic triangle depicted with a dotted line, since the hexagon corners represent centers of triangles. Let us denote this distance by R (R is the radius of the hexagon, i.e., the radius of the circumscribed circle). Since each dotted triangle is equilateral (because the origin repeat points are equidistantly placed), the side of such a triangle is equal with the side of the rhombus for the same given deployment. Hence, we have R =
2 3
3 3 . ⋅ D = D 3 2
From this, if we divide the hexagon in 6 equilateral identical triangles by drawing the 6 radii from the center to the 6 corners. Now, we can compute the area of the hexagon as follows: 2 1 1 3 ⋅ D 3 ⋅ 3 = 3 D 2 . = ⋅ 6 Ahexagon = 6 ⋅ ⋅ R 2 3 2 2 2 2 2
Thus, A rhombus = A stripe = Ahexagon = D 2
3 , and V = ρ i, j . 2
2.3 Toroidal Embeddings. Homomorphism. The infinite triangular lattice has the important feature of being regular. This property makes it useful in applications such as interconnection and telecommunication networks. But in both cases one cannot perform modeling and simulation techniques because the lattice model is not finite. To preserve the regularity and still obtain a finite regular graph of degree 6, we take a finite region from the infinite triangular lattice, in this case the hexagonal tile from Figure 5, and embed it on a toroidal surface. Thus, the resulting graph is a regular triangulated toroidal graph. The embedding of a hexagonal shape on a torus is shown in Figure 6, as it is not a trivial operation. (The left identified triangle of the hexagon will be cut and pasted as the triangle on the top-right of the hexagon, and the triangle bottom-right will be cut and pasted as the top-left triangle, hence forming a rhombus which then can be embedded on a torus as shown in the figure to the right.) One can see that it is not evident the fact that the graph is toroidal if looking at Figure 9, as compared to Figure 8, representing the same graph. Moreover, the figure shows that the Ti,j graph is not simply a triangular mesh wrapped around a doughnut.
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
381
X
Y
X
Y
X
X
Y
Figure 6 The embedding of a hexagonal surface on a torus by cutting and pasting. Suppose now, for example. that a generic node a from a given tile is adjacent to a set of nodes A = {a 1 , a 2 ,.., a 6 } , some from the same tile as a and others from one or two adjacent tiles in the lattice. Then, after embedding the tile on a torus, node a will be adjacent to the same set of vertices. For example, in Figure 5, the node labeled -5 is adjacent to the nodes labeled -6, 2, and 3 in other tiles. In the finite toroidal graph, the node labeled -5 is adjacent to the nodes labeled -6, 2, and 3 in the same tile By embedding a finite repeat pattern (cluster) from the infinite triangular lattice on a torus, we defined in fact a mapping of all the clusters forming the lattice into a generic cluster. In other words, this represents a many-to-one mapping, in which all the nodes from the infinite triangular lattice map into the nodes of the toroidal graph. This introduces the notion of direct homomorphism, which is different from the notion found in [Hara72]. Definition: A ( d ir e ct ) h om o m or p h ism of a given graph G onto G' is a many-to-one mapping, ϕ, such that if two vertices labeled u and v are adjacent in G, then ϕu and ϕv are adjacent in G'. (Note that in G multiple distinct vertices may share the same label.) Both cases described in the previous section, the rhombus and the hexagon embedded on a torus, represent homomorphisms of the infinite triangular lattice. Adjacency is preserved, and as a consequence, regularity is also preserved. Hence, every vertex of the infinite triangular lattice maps onto the vertex set of the finite toroidal triangulated graph.
2.4 The Generation of Ti,j The following algorithm describes the labeling of the vertices, as depicted previously in Figure 5. The labeling scheme is a major contribution of this paper in the area of cellular networks and its practical importance will be discussed later.
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
382
The Labeling Algorithm (Ti,j Generation) Step 1: Place the origin repeat vertices, labeled with 0, at offsets of i steps on the horizontal x-axis and j steps on the 600 skew (counterclockwise) y-axis. Step 2: Label the vertices on every x-axis between repeat points with values:
ρ i, j 0,1,2,..., 2
ρ i, j , − 2
,..., − 2,−1,0 .
Step 3: Using the Voronoi diagrams, identify the hexagonal tiling. Step 4: Pick any tile and wrap it on a toroidal surface, preserving adjacency according to the direct homomorphism definition. The regular toroidal graph obtained, given the two shifting parameters (i,j), is denoted by Ti,j. The labeling scheme uses a symmetric residue numbering [HaWr79]. In Figure 5, the hexagonal tile (obtained from Steps 1 and 2 in the algorithm above) contains 19 vertices, labeled −9, −8 … −1, 0, 1… 8, 9. Notice that in this case, the shifting parameters were (3,2) yielding the rhombic number 19, equal to the number of vertices, as also shown in Lemma 3. It is important to note here that the above labeling scheme implies the actual drawing and geometrical identification of the hexagonal tile that defines the graph. However, there exists a direct relationship between any two adjacent vertices, and this relationship defines, as we shall see later in Lemma 6, the Hamiltonian decomposition of the graph. Two nodes i and j are adjacent in Ti,j if one of the following holds: j = (i ± 1) modr
ρ i, j ,
j = (i ± k) modr
ρ i, j ,
j = (i ± k2) modr
ρ i, j ,
where modr refers to the residual modulo function (see the definition given with Lemma 6). The constant denoted by k can be computed from the parameters of the graph, i and j, as shown below. The value of k is actually the value of the label on the vertex that is adjacent to the origin-repeat point along the positive direction of the y-axis. The Computation of k, given i and j. If we start from a given origin point labeled 0 on the infinite lattice, one needs to go an integer number of steps of i and j until it reaches the next closest origin repeat point that is located on the horizontal line below the starting point. This is shown in Figure 7. This is so because we want to reach in straight line the first vertex labeled k, i.e., the vertex adjacent to the
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
383
0 0 0
-
-
K 0 0
0 0
0 0 0
Figure 7 The graphic scheme for the computation of k origin in the positive direction of the y-axis. follows:
(x ⋅ i ) mod j = 1
or
x ⋅i − y ⋅ j = 1.
(2)
This can be expressed as
The two unknowns, x and y, in Equation (2) can be determined in a relatively small number of arithmetic operations, using the theory of continued fractions based on the Euclidean GCD algorithm [KoMa85], [MaKo80], [HaWr79]. Otherwise, this can be viewed as an integer programming problem, as formulated below, but which has no linear-time solution algorithm: minimize x + y s.t. y ⋅ j − x ⋅ i = 1 x,y > 0 x,y ∈ Ζ
After determining x and y, the constant k can now be calculated using the formula given below:
k = ( j ⋅ x + i ⋅ (x + y )) mod r ρ i , j
(3)
The following gives direct computation formulas for the constant k in some particular cases. Case 1: j=1. In this case, it is obvious that going only i steps to the left on the x-axis, we reach the closest vertex labeled k. Hence, for Ti,1, k = −i .
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
384
Case 2: j=2. Since GCD(i,j)=1, one needs to go i div 2 steps down the yaxis, after going once j=2 steps down the z-axis. This means that
i k = ⋅i + j . 2 Case 3: j=3. Following the same reasoning, and splitting into two subcases for i = 3 ⋅ m 1 + 1 , and i = 3 ⋅ m 1 + 2 , for some integer m1, the constant k is: i k = ⋅ i + 3, 3 i k = − + 1 ⋅ i + 3 , 3
∀ i = 3m 1 + 1, m 1 > 0 ∀ i = 3m 1 − 1, m 1 > 1
The above two formulas can be merged into one, such that
i 1 − sign( i mod r j ) k = sign (i mod r j ) ⋅ + ⋅ i + j , 2 3
(4)
where sign(x) is the sign function. Formula (4) holds also for the case j=2 if the first term in the parenthesis is replaced by i . However, a more general formula, covering all cases of j, j
could not be identified. Case 4: j=i−1. This is a special case that will be presented in more detail in the next chapter. Here, the constant k is simply (3i−1)modr ρ i, j . (The residual modulo is needed only for the minimal case of T2,1, which is an isolated case with k < 0. Moreover, T2,1=K7.)
3 Properties of the Ti,j Graph Family Lemma 4. Graph edges.
Ti , j has ρ i, j vertices, 2 ρ i, j triangular faces, and 3 ρ i, j
Proof: The first statement regarding the number of vertices in Ti, j has been proven in Lemma 3. Since each vertex in the graph is adjacent to 6 triangles and each triangle is adjacent to 3 vertices, the number of triangular faces is 6/3=2 times the number of vertices: F = 2V = 2 ⋅ ρ i , j . Moreover, since each vertex in the graph is adjacent to 6 edges and each edge is adjacent to 2 vertices, the number of edges in the graph is 6/2=3 times the number of vertices: | E |= 3 | V |= 3 ⋅ ρ i , j .
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
Lemma 5. Graph Ti , j α V : V ( Ti , j )→ V ( Ti , j ) ,
385
is vertex transitive, where the automorphism mapping
vertex
p
into
ρ i, j ρ i, j − , adds (q − p ) mod r ρ ≤ p < q ≤ 2 2 label.
vertex i, j
q,
for
to each vertex
Proof: According to the definition, a graph G is vertex transitive if for every pair p , q ∈ V (G ) there is an automorphism that maps p into q. Such a mapping is given above and we only need to show that the graph before the mapping is isomorphic to the one obtained after the mapping. For this reason, it is sufficient to prove that, since p will map into q, the adjacent vertices to p before the mapping will become, after the translation, the adjacent vertices to q as of before the mapping. Applying the αV transformation to the 6 neighbors of p, we obtain: α (p + k ) = (p α ( p + k − 1) = ( p α (p − k ) = (p α ( p − k + 1) = ( p α ( p + 1) = ( p α ( p − 1) = ( p
+ k ) + (q − p ) = q + k + k − 1) + (q − p ) = q + k − 1 − k ) + (q − p ) = q − k − k + 1) + (q − p ) = q − k + 1 + 1) + (q − p ) = q + 1 − 1) + (q − p ) = q − 1
The above is valid for any vertex p in the graph.
Hence, Ti , j is vertex-
transitive, with the automorphism mapping specified as above.
Observation: Since the graph is also a Cayley graph, it is inherently vertextransitive or vertex-symmetric [Aker89]. In certain applications, such as interconnection networks, the vertex-symmetry is an important property because it implies that every node (processor) in the network can be mapped into any other node. In other words, the network/graph looks the same from each node/vertex. Lemma 6. Graph Ti , j factors into three Hamiltonian cycles, given by: ρi, j ρi, j 0,1,2,..., ,− ,...,−2,−1,0 2 2 0, k,2k,3k,..., ( ρi , j − 1)k(modr ρi, j ) 0, k 2,2k 2,..., ( ρi , j − 1)k(modr ρi, j )
where k is the label value adjacent to the origin in the y-direction. function modr refers to the residual modulo function, defined as follows:
The
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
a mod b a mod r b = (a mod b ) − b
b if a mod b ≤ 2 b if a mod b > 2 3
2 4
-4
-2
1
-6
6
-2
-1 2
4
3
5
-5
-3 0
-1 2
1
-6
6
5 -5
-6
386
5 -5
6 -4
Figure 8 The Hamiltonian cycle along the y-axis, for T3,1 with 13 vertices. Proof: The Hamiltonian cycle along the y-axis can be identified in Figure 8. The complete Hamiltonian decomposition is shown in Figure 9, for the same graph T3,1 but drawn in a different fashion, to help visualizing the 3 edgedisjoint cycles. It is obvious that along the x-direction (in Figure 8), the labels in the sequence of vertices along the Hamiltonian cycle are incremented by 1, because of the construction of Ti , j itself.
0
-1
1
-2
2
-3
3
-4
4 -5
5 -6
6
Figure 9 The T3,1 graph with its Hamiltonian decomposition
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
387
Along the y-axis, suppose that we look at the first two vertices from the origin repeat point along the positive direction of the y-axis. The vertex adjacent to the origin is labeled k. According to the vertex-transitivity lemma, if we map vertex 0 into k, then k will map into (k+(k−0))modr ρ i, j , which is equal to (2k)modr ρ i, j . This implies that moving along the positive direction of the y-axis in increments of one, we add k to the labels of the vertices. Likewise, moving along the negative direction of y, we subtract k, but always applying the residual modulo function to the resulting label. Following the same reasoning as when determining the constant k, we now try to determine the constant k', which corresponds to the adjacent vertex to the origin along the positive direction of the z-axis. This is in actuality the vertex k-1, but now we try to prove that k−1=k2. Thus, staring from the origin and going up the y-axis, one has to jump x ⋅ j + y ⋅ (i + j ) + 1 steps to reach the first label k'. But each jump represents an addition by k to the vertex label. Now, since i ⋅ x = j ⋅ y + 1 , from (2), the number of steps in the formula above is equal to k. Hence, the vertex k' has a label value of (x ⋅ j + y ⋅ (i + j ) + 1) ⋅ k = k 2 . This implies that going along the positive direction of the z-axis, one can either add the value (k−1) to the vertex labels, or add k2. This explains the quantity added to the labels of the vertices in the third Hamiltonian cycle. Note that all three Hamiltonian cycles are edge disjoint since each follows a different direction. Moreover, since each cycle has a length of ρ i, j , equal to the number of edges/vertices in the cycle, and since all three cycles are edge disjoint, they form a 2factorization of Ti , j [Hara72].
Observation: Hamiltonian decomposition implies maximum connectivity and maximum fault tolerance — properties of central importance in interconnection networks. The Ti,j, graph is 6-regular and due to the Hamiltonian decomposition, it is characterized by 6 edge-disjoint paths between any two nodes in the graph. Hamiltonian decomposition has been a central area of research not only in graph theory and algebraic topology, but also in communication algorithms for interconnections networks, and even physics. An abundance of papers can be found, as early as the forties, and substantially increasing during the late 80s and mid 90s. To mention just a few names: V. Chvatal [Chva85], P. Erdos [ChEr72], B. Bollobas [BoEr76, Boll79], T.W. Tillson [Till80], C. Thomassen [Thom80], J. Sibeyn [SiKa94], and many others. Lemma 7. Graph Ti , j has an isomorphism corresponding to a 600 counterclockwise (geometric) rotation obtained by multiplying each label by the constant k, reduced modulo ρ i, j . It follows that k ≡ 1 modr ρ i , j . 6
Proof: As shown in Lemma 6, going in the positive direction of the y-axis, one has to add the value k to the labels, and going in the positive direction of
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
388
the z-axis, the value to be added is k2. This proves that the vertex labeled k will map into k2 after a 600 rotation counterclockwise. That is, the rotation mapping is to multiply the vertex label by k. Applying a series of such rotations, vertex k2 will map into vertex k3=−1, k3 maps into k4=−k, k 4 maps into k5=− (k−1), and finally, k6 maps back into the vertex labeled 1. To show that the rotated graph is isomorphic to the initial graph, a similar reasoning, based on the computation of the adjacent vertices, as presented in Lemma 4, can be used.
Observation: The above rotation mapping is actually a cyclic automorphism of the group Tij defining the (Cayley) graph. Given the generators of the group S = <1, k, k2> and their inverses (as defined by the group operation): <−1, −k, k2>, then the rotation automorphism, ω, will map ω(si) = si+1. Since graph Ti,j is a Cayley graph, and given it has a cyclic automorphism, we have that Ti,j is rotational [Heyd97a]. Moreover, Ti,j admits a complete rotation. This property could be very useful to derive optimal algorithms for interconnection networks, such as broadcasting and gossip algorithms [Heyd97b]. However, not all Cayley graphs are rotational, such as the cube-connected cycles, which are non-rotational Cayley graphs. Lemma 8. Graph Ti , j is edge-transitive, with the automorphism α E : E ( T i , j ) → E (T i , j ), mapping edge p 1 q 1 into edge p 2 q 2 determined by additions and multiplications on all labels. Proof: The automorphism mapping one edge into any other edge is described by the following steps: Step 1: First, since the graph is vertex-transitive, the vertex p1 will be translated in the origin according to the mapping αV, by subtracting from every vertex label the value p1 reduced modulo ρ i, j . Now p2 becomes
p2 ’ = (p2 − p1 ) modr ρ i, j .
Similarly, we obtain q2 ’ , q1’ and, of course,
p1 ’ = 0 . Step 2: Next, we perform a finite number of rotations, since the graph has a rotation isomorphism of 600. To determine the number n∈{0,..,5} of counterclockwise rotations needed, one has to solve the following equation: k n ⋅ ((q 1 ’+ p 2 ’ ) mod r ρ i , j ) = q 2 ’ mod r ρ i , j . It is as if we intend to map
first the vertex p1’ into p2’ and then see how many rotations are needed to map the new q1’ (=q1’+p2’ ) into q2’. Having determined n, one can now perform n rotations according to αE by multiplying each vertex label by kn reduced modulo ρ i , j . The new labels are: p 1 ” = 0,
q 1 ” = q 1 ’⋅k n mod r ρ
p 2 ” = p 2 ’⋅k mod r ρ n
i, j ,
i, j ,
q 2 ” = q 2 ’⋅k n mod r ρ
i, j
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
389
Step 3: Last, we perform the final translation of p2 steps, by adding this value to all vertices. The resulting labels are: p1 ”’ = p 2 q 1 ”’ = q 1 ”+ p 2 = ((q 1 − p1 ) ⋅ k n + p 2 ) mod r ρ
i, j
p 2 ”’ = p 2 ”+ p 2 = ((1 + k ) ⋅ p 2 − p1 ) mod r ρ
i,j
n
q 2 ”’ = q 2 ”+ p 2 = ((q 2 − p1 ) ⋅ k n + p 2 ) mod r ρ
i, j
The steps described above represent the edge automorphism mapping. To prove that the graphs, before and after the rotation, are isomorphic, one can follow a similar reasoning as in the case of the vertex-transitivity lemma and compute the new labels of the adjacent vertices of the two edges. This
concludes the proof that the graph Ti , j is edge-transitive. Just as in the case of the rotational isomorphism, not all Cayley graphs are characterized by edge-transitivity, with the same counterexample of the cube-connected cycle networks.
4 Coloring Issues and the Diameter of Ti,j 4.1 Discussion on the Coloring of Ti,j The vertices of graph Ti , j cannot be colored with less than 3 colors, since it has a complete sub-graph that is a cycle of length 3, i.e. the triangle. With each vertex having degree 6, the maximum number of colors needed for Ti , j is 7 (see Proposition derived from Greedy Coloring Algorithm in [West96]). Except for T2,1 which is a clique (K7), according to [Broo41], the chromatic number χ of a connected graph G of maximum degree ∆(G), which is not a clique or an odd cycle, satisfies the following: χ(G) ≤ ∆(G). In our case, we have χ(Ti,j) ≤ 6. We will show that for some cases there exists a 3-coloring, whereas for other cases, there exists a 5-coloring.
Case 1: i−j = 3m1, for m1>0 In this case, the number of vertices in the graph is equal to: i 2 + i ⋅ (3m1 − i ) + (3m1 )2 = 3(m1 + 3m12 ) = 3m2 , for some positive m2. In the case
of the regular triangulated graph, this is a necessary condition for it to have a 3-coloring, because all elementary cycles are of length three (triangles) and no larger.
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
390
Color 1
2
Color 2
6
5
Color 3
10
9 -8
-7
-6
2 6
9
8
9 -8
3
2 7
6 -10
10 -7
-2
-3
5
-6
-7
1
0 4
10
-8 -4
-5
3
-9
8 -9
-1
7 -10
7 -10
-2
-3
3
8 -9
-6
Figure 10 The coloring of T i , j when i− j =3 m for T4,1 This particular type of graph has all corner vertices of its hexagonal tile representation (see the tilings of the triangular lattice) corresponding to vertices in the infinite triangular lattice. All other Ti , j graphs, as the one shown in Figure 5, have the hexagonal corner vertices falling in centers of triangles in the infinite lattice. The two vertices mentioned above are repeating in an interleaved fashion, such that each appears three times at the corners of the hexagonal tile. An example of this particular case, when (i-j) mod 3 = 0, together with its unique 3-coloring is given in Figure 10. The graph displayed is T4,1 with 21 vertices. Notice that the graph has a multiple-of-three number of vertices. Also, the vertices 7 and –7 (i.e., ρ i, j /3 and − ρ i, j /3) are the vertices repeating on the corners of the hexagonal tile. The validity of the coloring can be checked by looking at the colors of the vertices with the same label, inside and outside the central hexagonal tile.
Case 2: i = 2 , j = 1 This case is an exceptional one for graph T2,1 and it is the only case when 7 colors are needed. Graph T2,1 is the clique on 7 vertices, K7, and thus has a chromatic number equal to the number of vertices: 2 2 ρ 2,1 = 2 + 2 ⋅ 1 + 1 = 7 .
Case 3: i > j > 0 , Case 2.
for all i,j with GCD(i,j)=1 not included in Case 1 and
In this case, no 3 or 4 coloring has been found. A reason why there is no 3coloring is because the graph is 6-regular, the length of the smallest cycle is 3, and the number of vertices is not a multiple of 3. Moreover, since the
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
391
triangular lattice is uniquely 3-colorable, the triangulated torus in this case cannot have a 3-coloring. A scheme that depicts the compulsion to use 5 colors is shown in Figure 11. Here the first step involves the coloring of the vertices around the 6 corners of the hexagonal tile. There are several possible combinations but no matter what combination we pick, when coloring the rest of the graph as shown in the second step, a fourth, and then a fifth color is necessary. The dotted labels mean that there is a choice to interchange the labels, but the cases are symmetric. The labels A, B, and C suggest the order of picking the colors, and in parentheses are the colors picked for this particular case. All cases are just permutations of the one displayed and one will obtain the same coloring result, i.e. that 5 colors are needed and sufficient for the coloring of the Ti,j, for i and j not included in the previous two cases. The coloring of the Ti,j graph is employed in the resource allocation problem for interconnection networks, where a limited number of resources need to be uniformly dispersed throughout the network [BaeB97]. T3,1 2
2 1 1
1
3
2
1
3
3
3
1
2 3
2
3
2
4
3
2 3
C(5) B(4) 4
2 1
1
3
A(1)
3
2 1
2 1
1
2
1
2 1
3
3
2 3
Figure 11 Two steps in the coloring procedure of the general case of Ti,j
4.2 The Computation of the Diameter of Ti,j The diameter of a graph is the length of any longest shortest path between any two vertices in the graph. Let us consider the repeat origin points highlighted on the triangular lattice in Figure 12. The diameter of the Tij graph can then be easily computed as the shortest graph distance from the origin labeled as A to the point P, which actually represents the physical corner of the hexagon in the hexagonal tiling using the Voronoi diagram, as shown in Figure 5. Note that P could coincide or not with a lattice point, in which case we will take the integral part of the AP distance. Hence,
AP =
1 AF 3
The graph distance, denoted by d(), between the points A and F can be computed using the construction depicted in Figure 12, as follows:
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
392
d(A, F ) = d(A, B ) +d (B, F ) = = (d (A,C ) − d (B,C )) + (d (C , D ) + d(D, E ) + d (E , F )) = = (i − j ) + ( j + i + j ) = = 2 ⋅i + j Hence, the diameter of the graph can be expressed, simply, as:
2 ⋅ i + j d = 3
(5)
Note: One can obtain the same result by using Euclidean geometry [IrTh99]. However, the proof would be rather lengthy.
4.3 Local Planarity The Ti,j graph is locally planar in the context that given the number of vertices ρi,j of the graph, then the formula
ρ i, j 3 ρ i, j −1 d0 = ⋅ −1 = 3 2 2 defines the diameter of the largest induced subgraph of Ti,j which is planar [IrTh99]. This subgraph defines a planar hexagonal tile inscribed in the bigger hexagonal (toroidal) tile representing the Ti,j graph.
0
A
P F j=1 E
B C
D
i=3
0
0 Figure 12 The computation of the diameter
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
393
The local planarity property allows us to represent the graph as a hexagon on the infinite triangular lattice, and showing the toroidal embedding along the pasting edges as duplicate nodes around the tile, just as we show the traditional rectangular torus as a rectangular tile embedded in the plane. As we shall see in the following section, the Ti,j graph has the maximum number of vertices for a 6-regular graph. This is valid for any 6regular graph that is embeddable on a surface of genus 1, i.e. the surface of a torus. This fact proved to be helpful in modeling and simulating cellular networks, since we could keep the model finite while preserving its regularity and avoiding undesired and artificial boundary effects. Being able to represent the graph in the plane in this fashion, helped us identify its topological properties, the most important being the fact that Ti,j is toroidal.
5 Applications 5.1 The Optimal Ti,j If j = i - 1 , according to (5) the diameter of the T
i, j
graph becomes
d = i − 1 . The number of vertices is equal to:
ρ
i, j
= 3 ( i − 1 )2 + 3 ( i − 1 ) + 1 = 3 ⋅ d 2 + 3 ⋅ d + 1 .
We can show by induction that this value represents the maximum number of nodes situated at distance d on the infinite triangular lattice, from any given point, as follows: Assume the starting point 0. We expand from 0 by determining the number of nodes at distance 1, 2, … from it. Let’s denote by N(d) the total number of nodes situated at distance less than or equal to d. Hence:
N (0) = 1 N (1) = 1 + 6 = 7 N (2) = 1 + 6 + 12 = 19 ... N (d) = 1 + 6 + 12 + ... + 6d d
= 1 + 6∑i = 1 + 6 i =1
d(d + 1) = 3d 2 + 3d + 1 2
Assuming N(d), we need to prove that
N (d + 1) = 3(d + 1)2 + 3(d + 1) + 1 . At distance d we are adding 6(d+1) vertices. Then,
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
394
N (d + 1) = N (d ) + 6(d + 1) = 3d 2 + 3d + 1 + 6d + 6 = 3d 2 + 6d + 3 + 3d + 3 + 1
.
= 3(d + 1)2 + 3(d + 1) + 1 This number is maximal because at any step at distance d while expanding from the origin point we cannot add more than 6d nodes, since the number of all vertices situated at distance exactly d from the point 0 is equal to 6d. In the context of the maximum number of nodes, given a diameter d, the graph Ti,i-1 is considered to be optimal. This property is very important especially in the design of interconnection networks where it is desirable to reduce the topological communication latency. Due to the relatively high degree of the graph and its Hamiltonian decomposition mentioned earlier, the Ti,j topology offers maximum connectivity and maximum fault tolerance, achieving 6 edge-disjoint paths between any two nodes/processors in the network. Figure 13 shows the smallest optimal Ti,j, the graph T2,1 which has 7 nodes and which, since it is regular of degree 6, it is the clique on 7 vertices, K7. 2 -3 -1
3
1
0 2
-1
-2
3
2 -3
-1
Figure 13 Graph K7 as the toroidal The duplicate nodes are T2,1. represented with light color
5.2 Applications to Interconnection Networks There is no exact way to compare different topologies of interconnection networks [Sieg96], [Bhuy97], [Mold93]. Still, there are some metrics for interconnection networks and these are useful to take into account when designing new topologies. These features are described below. N et w or k c on n ect i v it y : Network connectivity measures the resiliency of a network and is the ability to continue operation despite disabled components. In other words, the connectivity represents the minimum
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
395
number of nodes or links that must fail in order to partition the network into two or more disjoint networks (that is, to disconnect the network graph). N et w or k D i a m et er : Similar to the diameter definition of a graph, here the network diameter represents the minimum inter-node distance. It can be interpreted as the maximum number of links that must be traversed when sending a message to any node along the shortest path. B is ect i on W i dt h : Sometimes it is useful to measure the congestion of a network, that is the traffic along the links of the network). It is most useful when designing load-balancing algorithms. The bisection width, or narrowness, of a network can be calculated by partitioning the network into two sub-networks S1 and S2, each with N1 and N2 processors (with N1≤N2), and determining the ratio between N1 and the number of links between S2 and S1. In fact, this is a min.-cut max.-flow type of problem found in network flow theory [FoFu62]. N et w or k E x p an s i o n I n c r e m e n t s : Another goal that is very important when designing an interconnection network is scalability. It should be possible and easy to scale the network at any time at a user-required size (flexibly), i.e., to add new processors and new links with minimum effort and cost. Also, for cost reasons, it is desirable that the increments are small. This implies the possibility of upgrading the network to the desired size with a given budget. However, these are only a few characteristics to look at and they are mostly static features of a network but with direct implications in the dynamic behavior of the network. The wraparound (4-regular) mesh is the most common topologies used in this field, probably because the human mind finds it easy to imagine topologies in a Cartesian coordinate system. Although is expands to higher dimensions, complicating the visualization of the network, the hypercube is another common and well-known topology. Our extensive research in this area showed that only one research group at the University of Michigan, Ann Arbor, designed and implemented a 6-regular interconnection topology [Chen90]. However, the underlying graph (which is the same as the optimal Ti,j, that is j=i−1) has been employed on a rather empirical basis, without and theoretical justification. Moreover, it has not been shown nor mentioned that the topology is actually a torus, or that a more generalized topology exists, featuring the same properties derived from its symmetric structure. The optimal Ti,j is useful in the area of interconnection networks not only for its maximum connectivity and maximum fault tolerance, but also for the natural way of labeling the processors (vertices), scheme presented previously. As a direct result, this topology allows a constant time addressing (routing) scheme and a linear time algorithm, in terms of the diameter, for one-to-many broadcasting [Chen90]. This section intends to point out that a generalized topology is also possible, a topology which may be useful especially when expanding the network to larger diameters. The optimal case allows only increments of 6d when updating from diameter d-1 to d, whereas the generalized Ti,j allows variable increments, as shown in Table 1. However, the presented topology
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
396
has a smaller network expansion increment than many of the well-known topologies. According to the values of the diameter for various i and j, as shown in Table 1., in order to expand the topology of the network to a different diameter, one could both add or remove nodes in the network. For example, the network model T7,4 has 93 vertices and a diameter of 5. If we reconfigure the topology to T9,1, we obtain a network with a higher diameter, 6, but less nodes, 91. Notice also that for the same number of vertices, one could build two different topologies with different diameters, as shown in the above table for T6,5 and T9,1. In any case, we generate a very rich family of graphs on distinct number of vertices, all with remarkable properties, both topologically and algebraically.
Table 1 Some values of i
ρ
i, j
(diameter) for Ti,j for various i and j.
2
3
4
5
6
7
8
9
10
7(1)
13(2)
21(3)
31(3)
43(4)
57(5)
73(5)
91(6)
111(7)
19(2)
-
39(3)
-
67(5)
-
103(6)
-
37(3)
49(4)
-
79(5)
97(6)
-
139(7)
61(4)
-
93(5)
-
133(7)
-
91(5)
109(6)
129(6)
151(7)
-
127(6)
-
-
169(7)
193(8)
219(8)
217(8)
-
j
1 2 3 4 5 6 7 8 9
271(9)
A related issue here is the average distance, which for the maximal case, Ti,i-1 is equal to (2i−1)/3. Moreover, since the graph Ti,j is 6-connected, the topology possesses a high degree of fault tolerance in terms of connectivity. This implies that the triangulated toroidal network model, as opposed to most of the other existing topologies, can tolerate up to five node and link failures at a time. Table 2 shows the results for a comparative study among different interconnection topologies, including the regular triangulated toroidal graph (RTT). The optimal mesh refers to a 4-regular triangulated toroidal graph with a maximal number of nodes for a given diameter and which has been introduced in [IrTh99]. As it can be inferred from Table 2, the RTT is more scalable than the hypercube and, moreover, for a network embedded on a surface of genus 1 (torus), the RTT (i.e., Ti,i-1) has the maximum number of nodes possible for a given diameter and constant node degree 6. There exist
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
397
degree 6 network topologies with the same diameter and more nodes but which are not embeddable on a torus surface.
Table 2 Comparison among various multiprocessor architectures.
Parameter
|V| (nodes)
|E| (links)
Diameter
Degree
Connectivity
p
p(p-1)/2
1
p-1
p
p=2n
n2n-1
n
n
n
Cycle Cn
p
p
[p/2]
2
2
Chordal Ring
p
3p/2
O(p1/2)
3
3
N1xN2 Mesh
p=N1xN2
2p
O(p1/2)
4
4
Optimal Mesh
p=2n2+2n
2p
n= O((p/2)1/2)
4
5
RTT. Ti,i-1
p=3n2+3n +1
3p
n= O((p/3)1/2)
6
6
Topology Clique Kn Hypercube Qn
The topology of the generalized T i , j graph becomes very complex for analysis purposes, when i and j are arbitrary numbers with GCD(i,j)=1. This constituted and impediment in finding an efficient routing algorithm for this case. However, based on the translation isomorphism property and the symmetry along the x, y, and z axes, the following formula holds for any given node address (label) a.
a = x ⋅ 1 + y ⋅ k + z ⋅ (k − 1) (6) where x, y and z are the number of hops from the origin to the node labeled a along the three directions. Formula (6) actually determines the minimum number of routing hops between any two nodes (without enumerating the nodes in the route), based on the assumption of vertex-transitivity. That is, given two nodes s and d, the minimum number of hops between the two nodes (the shortest path) can be determined by solving the following integer problem: minimize
|x|+|y|+|z|
such that
x+yk+z(k−1)=d−s
−d0 ≤ x,y,z ≤ d0 where d0 is the diameter of the maximal Ti’,i’-1 inscribed in Ti,j and k is the parameter k computed earlier.
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
398
Given the properties shown earlier in this paper, the graph topology described here is also a Cayley graph based on the cyclic group
< 1, k , k 2 ,−1,−k ,−k 2 > , with k being the same parameter as above. Cayley graphs are frequently used in modeling and analysis of interconnection networks, due to certain symmetries that the Cayley graph representation manages to emphasize [DiMo96, GrMa64].
5.3 Applications to Cellular Networks Channel assignment for wireless mobile units is classically modeled by assuming the coverage regions of transceivers (T) partition the plane into disjoint hexagons [Hale80], [Katz96], [MacD79], [Poll96]. The overlap regions, as shown in Figure 14, incidental to the coverage regions being more like circles than hexagons are excluded from the fundamental hexagonal lattice. Overlap regions are separately identified with reference to methods of hand-off, but the size and variation in overlap regions is not easily investigated in this traditional model [Poll96]. Our research included the extensive modeling of various forms of overlap segments and their regularities in a cellular arrangement. A new approach to the channel assignment problem in the presence of extensive overlap between coverage regions was obtained by graph theoretic modeling of the cellular assignment [YaMa97], [Yang91], [MaIr98], [MaIr99] [Irid98]. The strong overlap arrangement of Figure 15b, as opposed to the weak overlap in Figure 15a, suggests a good approximation is simply to have the full triangles of the planar dual triangular lattice serve as the overlap 3segments, with no other cell segments admitted. The dual triangular lattice, whose vertices are now the transceivers, is shown in Figure 14.
Ti4 Ti1
Ti6 Ti3 Ti7
Ti2
Ti5
A cluster of k contiguous cells of the hexagonal lattice, where each cell has a distinct one of the k fixed subsets of the available frequency channels, is
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002) Ti1
T’i2
1 Ti2
4
4
1 3 2
T’i3
1 2 2
Ti1
2
399
3
2
Ti3
2 1 2
2 2 1
4
Ti2
1 Ti3
(a)
T’i1
(b)
termed a fr e q ue n c y r e p e at t il e. A covering of the plane by this frequency repeat tile is termed a fr eq u en c y r e p e at t il in g o f t h e p la n e . Frequency repeat patterns typically involve a relatively small number of cells, with k=7 often employed for examples in the literature. We shall in general be interested in m - ce ll repeat sample regions for larger values of m that may or may not be related to multiples of the frequency repeat. Here we focus on the m - c e ll sample region repeats that can be identified with simple polygonal shapes such as a rectangle, rhombus, or hexagon. The 7-cell repeat can be associated with a hexagon providing one important example, but many larger repeats will also be of interest. For m-cell repeats associated with a rectangle, rhombus, or a hexagon, as shown in Section 2, it follows that the infinite triangular lattice can be homomorphically mapped onto an m-vertex toroidal graph, such that the vertex, edge and face associations with hexagonal cells and overlap regions are preserved. When m is an appropriate multiple of k, the frequency channel set associations are also preserved. For homomorphisms corresponding to k-cell frequency repeats, the relatively small toroidal graph provides a sufficient model for investigating and displaying properties of the frequency channel distribution. The larger (m-vertex) toroidal graphs, derived from a sample region repeat, provide reasonable sized underlying structures for probabilistic mobile unit channel assignment studies. Theoretically and/or by simulation, channel assignment strategies, blocked regions, call cutoffs, and other probabilistic occurrences at load levels near full capacity, can be realistically studied in the m-vertex toroidal graph model without anomalies due to boundary effects. Loading patterns over multiple cell regions will be quite realistic for estimation of the infinite lattice cellular network, provided the multiple cell regions constitute planar subgraphs of the toroidal graph.
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
400
To simulate this cellular system without boundary effects, we take the repeat tile and embed it on a torus [CaIr99]. The toroidal model is a natural and pertinent way of simulating and analyzing the behavior of the infinite cellular network using a finite model. If the repeat tile is a hexagon, constructed as described previously, the toroidal model obtained is the Ti,j graph. The Voronoi diagrams technique identifies a cluster of vertices that are closer to a repeat origin point than to any other origin point. The hexagonal repeat pattern can be easily employed in a multitier system where we can identify two repeat levels: 1.
a frequency repeat, relatively small (the m i c r o - c el l);
2.
a toroidal repeat (the m a c r o- c el l).
Different rhombic numbers, as shown in Figure 16, characterize the micro-cell and the macro-cell. The toroidal embedding of the macro-cell will take care of the undesired boundary effect. The shifting parameters for the macro-cell, as shown in Figure 16, are (7,7) and for the micro-cell, they are (2,1). We can also identify the shifting parameters (4,1) for the macro-cell in terms of micro-cell units. It can be easily verified that 42+4⋅1+12 = 21, which is the total number of micro-cells contained in the macro-cell. The total number of transceivers covered by the macro-cell is equal to: 21x7=72 + 7⋅7+72= 147.
Observation: Any region of triangles, inside a macro-cell, of radius smaller than the macro-cell radius is planar. This follows from the sizes of the diameters of the two types of cells.
Figure 16 A toroidal embedding hexagonal repeat macrocell (T7,7), containing 21 micro-cells of 7-frequency hexagonal repeats (T2,1)
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
401
Hence, we can locally study a region within the macro-cell that is reasonably unrelated to the toroidal embedding. Moreover, we can take any contiguous region with the above-specified radius constraint from the toroidal macro-cell, without worrying about being too close to the “boundary” and thus introducing unrealistic behavior. All the contained micro-cells are similar and their behavior will not be influenced by their position within the macro-cell.
6 Conclusions In this paper we introduced a 6-regular toroidal graph, constructed from a hexagonal tiling of the infinite triangular lattice. The graph, denoted by Ti,j, where i, and j are the shifting parameters of the rhombic number ρi,j, represents a homomorphism of the triangular lattice and has a very symmetric structure. Some of its properties, such as vertex- and edgetransitivity, rotation homomorphism, Hamiltonian cycle decomposition, and coloring, have been presented and discussed. When the shifting parameter j is equal to i-1, the graph is optimal, in the sense that it features the largest packing of vertices for a 6-regular graph, embeddable on a surface of genus 1 (locally planar), for a given diameter. The computation of the diameter of the graph involves computational geometry tools and is also presented in this paper. Due to its highly symmetric topology, the Ti,j graph family, and especially the optimal case, Ti,i-1, has a series of applications in modeling and analysis of networks. In this paper we presented two of its applications, more specific, in interconnection and cellular networks. In interconnection networks, where one of the demands is to design topologies that feature high connectivity and fault tolerance, the optimal Ti,i-1 represents a very attractive topology, which is also characterized by a constant time routing scheme, due to the natural labeling scheme presented here. In cellular networks, the graph is used to model and simulate without boundary artifacts, cellular assignment in systems with extensive overlap of transceiver coverage regions. The Ti,j graph is employed in the modeling of micro- and macro-cell systems and it offers a systematic labeling scheme useful for frequency planning.
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
402
References [Arna80]
J.-F. Arnaud, Frequency Planning in Europe, IEEE Proc., Vol. 68, No. 12, Dec 1980
[Aker89]
B. Akers, B. Krishnamurthy, A Group Theoretic Model for Symmetric Interconnection Networks, IEEE Transactions on Computers, Vol. 38, No. 4, pp. 555-566, 1989
[BaeB97]
M. M. Bae, B. Bose, Resource Placement in Torus-Based Networks, IEEE Transactions on Computers, Vol. 46, No. 10, Oct. 1997
[Bhuy97]
L. N. Bhuyan, X. Zhang, Tutorial on Multiprocessor Performance Measurement and Evaluation, IEEE CS Press, 1997
[Boll79]
B. Bollobas, Graph Theory: An Introductory Course, N. Y. Springer-Verlag, 1979
[BoEr76]
B. Bollobas, P. Erdos, Alternating Hamiltonian Cycles, Israel J. Math., 23(1976)
[Broo41]
R. L. Brooks, On colouring the nodes of a network, Proceedings Cambridge Phil. Soc. 37, pp. 194-197, 1941
[CaIr99]
H. C. Cankaya, M. Iridon, D. W. Matula, Performance Analysis of a Graph Model for Channel Assignment in a Cellular Network, COMPSAC 1999
[Chen90]
M. S. Chen, K. G. Shin, Addressing, Routing, and Broadcasting in Hexagonal Mesh Multiprocessors, IEEE Transactions on Computers, Vol. 39, No. 1, Jan. 1990
[Chva85]
V. Chvatal, Hamiltonian Cycles, John Wiley & Sons Ltd., 1985
[ChEr72]
V. Chvatal, P. Erdos, A note on Hamiltonian circuits, Discrete Math, 2(1972)
[DiMo96]
J. Dixon, B. Mortimer, Permutation Groups, New York, Springer Verlag, 1996
[FoFu62]
L. R. Ford, Jr., D. R. Fulkerson, Flows in Networks, Princeton Univ. Press, 1962
[Fort92]
S. Fortune, Voronoi Diagrams and Delauny Triangulations, edited by D.-Z. Du and F. Hwang, Computing in Euclidean Geometry, Vol. 1, pp 193-234, World Scientific, 1992
[GrMa64]
I. Grossman, W. Magnus, Groups and Their Graphs, New York Random House, 1964
[Hale80]
J. Hale, Frequency Assignment, IEEE Proc., vol. 68, no. 12, Dec. 1980
[Hara72]
F. Harary - Graph Theory, Addison-Wesley, 1972
[HaWr79]
G. H. Hardy, E. M. Wright, An Introduction to the Theory of Numbers, Clarendon Press, Oxford, 1979
403
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002) [Heyd97a]
M.-C. Heydemann, N. Marlin, S. Perennes, Cayley Graphs with Complete Rotations, Research Report: INRIA 3624, 1997
[Heyd97b]
M.-C. Heydemann, Cayley Graphs and Interconnection Networks, Proceedings Graph Symmetry, Montreal, 1996, NATO ASI C, 1997
[Irid98]
M. Iridon, D. W. Matula, Symmetric Cellular Network Embeddings on a Torus, IEEE Proc. ICCCN, 1998, pp. 732-736
[IrTh99]
M. Iridon, Regular Triangulated Toroidal Graphs with Applications in Cellular and Interconnection Networks, Ph.D. Thesis, Southern Methodist University, May 1999
[Katz96]
I. Katzela, M. Nagshineh, Channel Assignment Schemes for Cellular Mobile Telecommunication Systems: A Comprehensive Survey, IEEE Personal Communications, June 1996
[KoMa85]
P. Kornerup, D. W. Matula, Finite Precision Lexicographic Continued Fraction Number Systems, IEEE Proc. 7th Symposium on Computer Arithmetic, June 1985
[MacD79]
V.H. MacDonald, The Cellular Concept, The BELL System Technical Journal, Jan 1979, Vol. 58, No. 1, p.15-41
[MaIr98]
D. W. Matula, M. Iridon, C. Yang, H. C. Cankaya, A Graph Theoretic Approach for Channel Assignment in Cellular Networks, 2nd International Workshop on Discrete Algorithms and Methods for Mobile Computing and Communications, Dallas, Oct. 1998. In conjunction with ACM/IEEE Mobicom’98
[MaIr99]
D. W. Matula, M. Iridon, C. Yang, A Graph Theoretic Approach for Channel Assignment in Cellular Networks, Wireless Networks Journal, Vol. 7, 2001, pp. 567-574
[MaKo80]
D. W. Matula, P. Kornerup, Formulations of Finite Precision Rational Arithmetic, Springer Verlag, 1980
[Mold93]
I.D. Moldovan, Parallel Processing - From Applications, Morgan Kaufmann Publishers, 1993
[Poll96]
G. P. Pollini, Trends in Handover Communications Magazine, March 1996
[Sieg96]
H. J. Siegel, C. B. Stunkel; Inside Parallel Computers: Trends in Interconnection Networks, IEEE CS&E, Vol. 3, No 3, Fall 1996, pp. 69-71
[SiKa94]
J. F. Sibeyn, M. Kaufmann, Deterministic l-k Routing on Meshes, STACS 1994, pp. 237-248
[Thom80]
C. Thomassen, Hamiltonian-connected Tournaments, Journal of Combinatorial Theory, B 28(1980).
[Till80]
T. W. Tillson, Hamiltonian Decomposition of K 2*m ,2m ≥ 8 , Journal of Combinatorial Theory, Ser. B, 29(1980).
Systems
Design,
to
IEEE
Iridon and Matula, A Torus Graph Family. JGAA 6(4) 373-404 (2002)
404
[West96]
D. B. West, Introduction to Graph Theory, Prentice Hall, 1996
[YaMa97]
C. Yang, D. W. Matula, A Multi-layered Arrangement for Load Sharing in a Cellular Communication System, U.S. Patent #5,633,915, May 1997.
[Yang90]
C. Yang, A Multi-Layer Design and Load Sharing Algorithm for Personal Communication Networks, Ph.D. Thesis, Aug. 1991