339 113 8MB
English Pages 398 [400] Year 2002
Lecture Notes in Computer Science Edited by G. Goos, J. Hartmanis, and J. van Leeuwen
2528
3
Berlin Heidelberg New York Barcelona Hong Kong London Milan Paris Tokyo
Michael T. Goodrich Stephen G. Kobourov (Eds.)
Graph Drawing 10th International Symposium, GD 2002 Irvine, CA, USA, August 26-28, 2002 Revised Papers
13
Series Editors Gerhard Goos, Karlsruhe University, Germany Juris Hartmanis, Cornell University, NY, USA Jan van Leeuwen, Utrecht University, The Netherlands Volume Editors Michael T. Goodrich University of California at Irvine Department of Information and Computer Science Irvine, CA 92697-3425, USA E-mail: [email protected] Stephen G. Kobourov University of Arizona Department of Computer Science Tucson, AZ 85721-0077, USA E-mail: [email protected]
Cataloging-in-Publication Data applied for A catalog record for this book is available from the Library of Congress. Bibliographic information published by Die Deutsche Bibliothek Die Deutsche Bibliothek lists this publication in the Deutsche Nationalbibliografie; detailed bibliographic data is available in the Internet at .
CR Subject Classification (1998): G.2, I.3, F.2 ISSN 0302-9743 ISBN 3-540-00158-1 Springer-Verlag Berlin Heidelberg New York This work is subject to copyright. All rights are reserved, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, re-use of illustrations, recitation, broadcasting, reproduction on microfilms or in any other way, and storage in data banks. Duplication of this publication or parts thereof is permitted only under the provisions of the German Copyright Law of September 9, 1965, in its current version, and permission for use must always be obtained from Springer-Verlag. Violations are liable for prosecution under the German Copyright Law. Springer-Verlag Berlin Heidelberg New York a member of BertelsmannSpringer Science+Business Media GmbH http://www.springer.de © Springer-Verlag Berlin Heidelberg 2002 Printed in Germany Typesetting: Camera-ready by author, data conversion by Steingr¨aber Satztechnik GmbH, Heidelberg Printed on acid-free paper SPIN: 10873154 06/3142 543210
Preface
The 10th International Symposium on Graph Drawing (GD 2002) was held on August 26–28, 2002, at Irvine, California. The conference attracted 74 participants from academic and industrial institutions in 14 countries. As in previous years, the review process was competitive: 24 out of 48 regular submissions were accepted. In addition, 9 short papers and 8 system demonstrations (1 withdrawn) were also accepted. Each submission was refereed by at least 4 members of the program committee, and detailed comments were returned to the authors. GD 2002 invited two speakers: Frank Ruskey, from the University of Victoria, gave a talk on drawing Venn diagrams; James Arvo, from the California Institute of Technology, gave a talk on techniques for interactive graph drawing. As usual, the Graph Drawing contest was held during the conference. The report on the contest is included in the proceedings. We would like to thank all the people who helped organize and run the conference. We would like to thank our sponsors: ILOG, MERL (Mitsubishi Electric Research Laboratories), sd&m (Software Design & Management), Tom Sawyer Software, and the University of California, Irvine. We would also like to thank all the contributors and participants who made GD 2002 a success. The 11th International Symposium of Graph Drawing (GD 2003) will be held on September 21–24, 2003 at Perugia, Italy, with Giuseppe Liotta as the conference chair.
August 2002
Michael T. Goodrich Stephen G. Kobourov
Organization
Program Committee Ulrik Brandes Franz Brandenburg Giuseppe di Battista Christian Duncan Michael T. Goodrich (Co-chair) Xin He Seok-Hee Hong Michael Kaufmann Stephen G. Kobourov (Co-chair) Giuseppe Liotta Anna Lubiw Petra Mutzel Stephen North Roberto Tamassia Ioannis Tollis Sue Whitesides
University of Konstanz University of Passau University of Rome University of Miami University of California, Irvine SUNY Buffalo University of Sydney University of T¨ ubingen University of Arizona University of Perugia University of Waterloo Vienna University of Technology AT&T Research Brown University University of Texas, Dallas McGill University
Steering Committee Franz Brandenburg Giuseppe di Battista Peter Eades Michael T. Goodrich Michael J¨ unger Stephen G. Kobourov Giuseppe Liotta Petra Mutzel Takao Nishizeki Pierre Rosenstiehl Roberto Tamassia Ioannis Tollis
University of Passau University of Rome University of Sydney University of California, Irvine University of Cologne University of Arizona University of Perugia Vienna University of Technology Tohoku University Ecole des Hautes Etudes en Sciences Sociales Brown University University of Texas, Dallas
External Referees Christian Bachmaier Vladimir Batagelj Carla Binucci
Sabine Cornelsen Emilio Di Giacomo Walter Didimo
Organization
Tim Dwyer Hugo do Nascimento Markus Eiglsperger Cesim Erten Michael Forster Carsten Friedrich Marco Gaertler Emden Gansner Jan-Willem Goossens Gunnar Klau Gabriele Kodydek Maria Flavia Mammana Alessandro Marcandalli Maurizio Patrignani Leon Peeters
Sponsoring Institutions
Andreas Pick Maurizio Pizzonia Marcus Raitner Thomas Schank Martin Sch¨ onhacker Falk Schreiber Frank Schulz Don E. Taylor Luca Vismara Dorothea Wagner Roland Wiese Ren´e Weiskircher Thomas Willhalm
VII
In Memoriam: Ivan Rival
The Graph Drawing community is saddened by the loss of Ivan Rival in January, 2002. Ivan was a Professor in the School of Information Technology and Engineering at the University of Ottawa, where he led the Algorithms Research Group. He was raised in Hamilton, Ontario, earned a Ph.D. in Mathematics at the University of Manitoba, and taught there until joining the University of Ottawa in 1986. He was internationally known for his outstanding research work in discrete mathematics and combinatorial geometry. Ivan had a profound interest in all aspects of ordered sets. In the 1980s, he organized a number of workshops on this topic; their proceedings, which he edited, are still in demand. He also founded a journal, Order, available from Kluwer Academic Publishers. Ivan’s interest in the applications of precedence constraints to scheduling and motion planning led him to a new kind of problem: how to visualize ordered sets. It was this interest that prompted his participation in the graph drawing community in its early days. He published various papers on graph drawing problems and he served on the program committee for GD 1994. His interest in precedence constraints also led him to design software that aids students in planning their course schedules. This software grew into a company, Decision Academic Graphics, which he founded. Its main product is the Degree Navigator software that is used by dozens of colleges and universities in North America. Ivan’s contributions to the graph drawing literature include the following papers: – “The Diagram,” in Graphs and Orders, Kluwer, 1985. – “Representing Orders on the Plane by Translating Convex Figures,” Order 4:319–339, 1988 (with J. Urrutia) – “Graphical Data Structures for Ordered Sets,” in Algorithms and Order, Kluwer, 1989 – “Bipartite Graphs, Upward Drawings, and Planarity,” Information Processing Letters 36:317–322, 1990 (with G. Di Battista and W.-P. Liu) – “Light Sources, Obstructions and Spherical Orders,” Discrete Mathematics 102:13–24, 1992 (with S. Foldes and J. Urrutia) – “Reading, Drawing, and Order,” in Algebras and Order, Kluwer, 1993 – “Upward Drawing on Surfaces,” Proc. GD 1993, 1993 – “Upward Drawings to Fit Surfaces,” Proc. ORDAL 1994, LNCS 831, 1994 (with S.M. Hashemi) – “Upward Drawing on the Plane Grid Using Less Ink,” Proc. GD 1994, LNCS 894, 1995 (with G.-V. Jourdan and N. Zaguia) – “Upward Drawings on Planes and Spheres,” Proc. GD 1995, LNCS 1027, 1966 (with S.M. Hashemi and A. Kisielewicz) – “Series-Parallel Planar Ordered Sets Have Pagenumber Two,” Proc. GD 1996, LNCS 1190, 1997 (with M. Alzohairi)
In Memoriam: Ivan Rival
IX
In addition to founding the journal Order, Ivan served on the editorial boards of Algebra Universalis, and Discrete Mathematics. He also edited the following books: – Ordered Sets, Reidel/Kluwer, 1982, ISBN 9027713960 – Graphs and Order, Kluwer, 1985, ISBN 9027719438 – Combinatorics and Ordered Sets, American Mathematical Society, 1986, ISBN 0821850512 – Algorithms and Order, Kluwer, 1989, ISBN 0792300076 These books are the proceedings of conferences Ivan organized (two NATO conferences, a joint AMS-IMS-SIAM summer research conference, and another NATO conference, respectively). Ivan’s interest in all aspects of order relations intersected naturally with the developing graph drawing community’s interest in graph layout and visualization. His support of the Graph Drawing Symposium in its early days and his passion for the subject greatly enriched our community. By dedicating the first invited talk of GD 2002 to his memory, we would like to honor Ivan’s research accomplishments and express our admiration and gratitude for the wide and lasting impact of his contributions to our field. August 2002
Sue Whitesides Roberto Tamassia
Table of Contents
Papers Sketch-Driven Orthogonal Graph Drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Ulrik Brandes, Markus Eiglsperger, Michael Kaufmann, Dorothea Wagner Maintaining the Mental Map for Circular Drawings . . . . . . . . . . . . . . . . . . . . 12 Michael Kaufmann, Roland Wiese Graphs, They Are Changing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Stephan Diehl, Carsten G¨ org Drawing Graphs on Two and Three Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Sabine Cornelsen, Thomas Schank, Dorothea Wagner Path-Width and Three-Dimensional Straight-Line Grid Drawings of Graphs 42 Vida Dujmovi´c, Pat Morin, David R. Wood Drawing Outer-Planar Graphs in O(n log n) Area . . . . . . . . . . . . . . . . . . . . . . 54 Therese Biedl Computing Labeled Orthogonal Drawings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Carla Binucci, Walter Didimo, Giuseppe Liotta, Maddalena Nonato Computing and Drawing Isomorphic Subgraphs . . . . . . . . . . . . . . . . . . . . . . . . 74 Sabine Bachl, Franz-Josef Brandenburg A Group-Theoretic Method for Drawing Graphs Symmetrically . . . . . . . . . . 86 David Abelson, Seok-Hee Hong, Donald E. Taylor A Branch-and-Cut Approach to the Directed Acyclic Graph Layering Problem . . . . . . . . . . . . . . . . . . . . . . . 98 Patrick Healy, Nikola S. Nikolov Geometric Systems of Disjoint Representatives . . . . . . . . . . . . . . . . . . . . . . . . . 110 Jiˇr´ı Fiala, Jan Kratochv´ıl, Andrzej Proskurowski An Efficient Fixed Parameter Tractable Algorithm for 1-Sided Crossing Minimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Vida Dujmovi´c, Sue Whitesides Simple and Efficient Bilayer Cross Counting . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 Wilhelm Barth, Michael J¨ unger, Petra Mutzel Orthogonal 3D Shapes of Theta Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 Emilio Di Giacomo, Giuseppe Liotta, Maurizio Patrignani
XII
Table of Contents
Separating Thickness from Geometric Thickness . . . . . . . . . . . . . . . . . . . . . . . 150 David Eppstein Book Embeddings and Point-Set Embeddings of Series-Parallel Digraphs . . 162 Emilio Di Giacomo, Walter Didimo, Giuseppe Liotta, Stephen K. Wismath Compact Encodings of Planar Orthogonal Drawings . . . . . . . . . . . . . . . . . . . . 174 Amrita Chanda, Ashim Garg Fractional Lengths and Crossing Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 Ondrej S´ykora, L´ aszl´ o A. Sz´ekely, Imrich Vrt’o Drawing Directed Graphs Using One-Dimensional Optimization . . . . . . . . . . 193 Liran Carmel, David Harel, Yehuda Koren Graph Drawing by High-Dimensional Embedding . . . . . . . . . . . . . . . . . . . . . . 207 David Harel, Yehuda Koren Advances in C-Planarity Testing of Clustered Graphs . . . . . . . . . . . . . . . . . . 220 Carsten Gutwenger, Michael J¨ unger, Sebastian Leipert, Petra Mutzel, Merijam Percan, Ren´e Weiskircher HGV: A Library for Hierarchies, Graphs, and Views . . . . . . . . . . . . . . . . . . . . 236 Marcus Raitner Rectangular Drawings of Planar Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 Md. Saidur Rahman, Takao Nishizeki, Shubhashis Ghosh Extended Rectangular Drawings of Plane Graphs with Designated Corners 256 Kazuyuki Miura, Ayako Miyazawa, Takao Nishizeki RINGS: A Technique for Visualizing Large Hierarchies . . . . . . . . . . . . . . . . . . 268 Soon Tee Teoh, Kwan-Liu Ma Applying Crossing Reduction Strategies to Layered Compound Graphs . . . 276 Michael Forster Crossing Reduction by Windows Optimization . . . . . . . . . . . . . . . . . . . . . . . . . 285 Thomas Eschbach, Wolfgang G¨ unther, Rolf Drechsler, Bernd Becker Geometric Graphs with No Self-intersecting Path of Length Three . . . . . . . 295 J´ anos Pach, Rom Pinchasi, G´ abor Tardos, G´eza T´ oth Two New Heuristics for Two-Sided Bipartite Graph Drawing . . . . . . . . . . . . 312 Matthew Newton, Ondrej S´ykora, Imrich Vrt’o Straight-Line Drawings of Binary Trees with Linear Area and Arbitrary Aspect Ratio . . . . . . . . . . . . . . . . . . . . . . . . . 320 Ashim Garg, Adrian Rusu
Table of Contents
XIII
Some Applications of Orderly Spanning Trees in Graph Drawing . . . . . . . . . 332 Ho-Lin Chen, Chien-Chih Liao, Hsueh-I Lu, Hsu-Chun Yen Improving Walker’s Algorithm to Run in Linear Time . . . . . . . . . . . . . . . . . . 344 Christoph Buchheim, Michael J¨ unger, Sebastian Leipert Semi-dynamic Orthogonal Drawings of Planar Graphs . . . . . . . . . . . . . . . . . . 354 Walter Bachl
Software Demonstrations Graph Layout for Workflow Applications with ILOG JViews . . . . . . . . . . . . 362 Gilles Diguglielmo, Eric Durocher, Philippe Kaplan, Georg Sander, Adrian Vasiliu InterViewer: Dynamic Visualization of Protein-Protein Interactions . . . . . . . 364 Kyungsook Han, Byong-Hyon Ju, Jong H. Park Some Modifications of Sugiyama Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 Danil E. Baburin A Framework for Complexity Management in Graph Visualization . . . . . . . 368 Ugur Dogrusoz, Burkay Genc A Partitioned Approach to Protein Interaction Mapping . . . . . . . . . . . . . . . . 370 Yanga Byun, Euna Jeong, Kyungsook Han Camera Position Reconstruction and Tight Direction Networks . . . . . . . . . . 372 Ileana Streinu, Elif Tosun Demonstration of a Preprocessor for the Spring Embedder . . . . . . . . . . . . . . 374 Paul Mutton, Peter Rodgers
Graph Drawing Contest Graph-Drawing Contest Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376 Franz J. Brandenburg
Invited Talks Techniques for Interactive Graph Drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380 James Arvo Drawing Venn Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 Frank Ruskey Author Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
Sketch-Driven Orthogonal Graph Drawing⋆ Ulrik Brandes1 , Markus Eiglsperger2 , Michael Kaufmann2 , and Dorothea Wagner1 1
2
Department of Computer & Information Science, University of Konstanz. {Ulrik.Brandes|Dorothea.Wagner}@uni-konstanz.de Wilhelm Schickard Institute for Computer Science, University of T¨ ubingen. {eiglsper|mk}@informatik.uni-tuebingen.de
Abstract. We present an orthogonal graph drawing algorithm that uses a sketchy drawing of the graph as input. While the algorithm produces an orthogonal drawing with few bends in the Kandinsky model it also preserves the general appearance of the sketch. Potential applications for this kind of drawing algorithm include the generation of schematic maps from geographic networks and interactive orthogonal graph drawing.
1
Introduction
Orthogonal drawings of graphs are common in many areas, but especially so in technical and engineering applications where their apparent tidiness seems to be appreciated. Typical examples include circuit schematics, entity-relationship diagrams and system plans. A commonality in these applications is that, quite often, a sketch of the drawing is already available, either because a user has created the graph in an editor, or because the vertices have some natural, e.g. geographic, position. In such cases, standard black-box algorithms for graph layout do not leave sufficient control over the appearance of the drawing with the engineer. We extend a successful approach for orthogonal graph layout to start from a sketch of the graph and produce a tidy, orthogonal drawing with few bends that preserves the overall appearance of the sketch. For the purpose of this paper, a “sketch” of a graph is a drawing that exhibits the main features to be conveyed, but is unsatisfactory from an aesthetic point of view. In practice, a sketch may for instance be a manual layout produced by the user of a database schema editor or a physically realized network, and it may but does not have to be orthogonal. Our approach can thus be viewed as a more general case of dynamic graph drawing, since we do not require that the sketch is drawn by a layout algorithm or even in the same representation as the target drawing. An alternative view is that an existing drawing is to be improved subject to user-supplied constraints or hints for the algorithm. There is a fair amount of research on dynamic graph layout (see [4] for an overview) and on utilizing user interaction for force-directed [22,14], quasivisibility [21] and layered layout [9], and while there are even attempts to learn ⋆
Partially supported by DFG under grants Br 2158/1-1 and Ka 812/8-1.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 1–11, 2002. c Springer-Verlag Berlin Heidelberg 2002
2
Ulrik Brandes et al.
parameters of layout objectives from example drawings [18,19], we know but one instance of a method for explicit clean-up of a given sketch. SCHEMAP is a system generating schematic maps for communication networks that was demonstrated at last year’s Graph Drawing Software Exhibition [17]. This system gradually orthogonalizes a given network layout (“ground plan”) into a schematic map while preserving the embedding (including crossings). Since it is based on a force-directed algorithm there is no guarantee that the result is indeed orthogonal, and running times are apparently far from interactive. We propose an efficient, dedicatedly orthogonal layout algorithm that extends the Kandinsky approach of [13] according to the Bayesian paradigm for dynamic layout of [2]. We therefore review briefly these two approaches in Sect. 2, before we describe our new algorithm in Sect. 3 and provide examples in Sect. 4. We conclude in Sect. 5.
2
Preliminaries
Our algorithm for sketch-driven orthogonal graph layout rests on two pillars: an orthogonal layout algorithm for general planar graphs, and a framework for extending (static) layout algorithms to dynamic graphs. We review briefly these foundations and refer to [8,15] for background reading. 2.1
Orthogonal Graph Layout and Kandinsky Models
We assume that the reader is familiar with the concepts of planarity and network flow. An embedded planar graph G(V, E, F ) is a planar graph with a specific circular order of edges around vertices and a specific external face, admitting a planar drawing that respects the given embedding. Unless otherwise specified, the planar graphs we consider are always embedded. A planar orthogonal box drawing of a planar graph is a planar drawing that maps each vertex to a box and each edge to a sequence of horizontal and vertical segments. We assume for the rest of this work grid drawings, i.e. drawings in which the center of the boxes and the bends along the edges have integer coordinates. An orthogonal shape Q is a mapping from the set of faces F of a graph G to clockwise ordered lists of tuples (ei , ai , bi ), 1 ≤ i ≤ |Q(f )|, where ei is an edge, ai ∈ {1, . . . , 4} represents the angle formed with the following edge inside the appropriate face in multiples of 90◦ , and bi is the list of bends of the edge. A quasi-orthogonal shape is an orthogonal shape with ai = 0 allowed, where a 0◦ angle means that the succeeding edge is adjacent to the same side of the vertex as the preceding edge. We denote with Q(f, i) the i-th tuple of Q(f ), with a(Q, f, i) the value of the angle field of Q(f, i), and with b(Q, f, i) the value of the bend field of Q(f, i). A quasi-orthogonal shape Q is called valid, if there is a planar orthogonal box drawing with quasi-orthogonal shape Q. Note that quasi-orthogonal shape are not related to quasi-orthogonal drawings as described in [16]. Different drawing conventions have been proposed for planar orthogonal box drawings. We will concentrate on Kandinsky models. All Kandinsky models impose
Sketch-Driven Orthogonal Graph Drawing
3
the following two constraints on the drawing which we call Kandinsky properties. The bend-or-end property is defined as follows: Let G=(V, E) be an embedded graph and consider a planar orthogonal box drawing of G. Let e1 and e2 be two edges adjacent to the same side of a vertex v, e1 following e2 in the embedding, and let f be the face to which e1 and e2 are adjacent. Then either e1 must have a last bend with a 270◦ angle in f or e2 must have a first bend with 270◦ angle in f . The non-empty face property forbids some degenerated cases for triangles in the graph. See [13] for a detailed description of the Kandinsky properties. An important consequence is stated in the following lemma. Lemma 1 ([13]). Every 0◦ angle of a Kandinsky drawing has a unique corresponding 270◦ bend. Bends which correspond to a 0◦ angle are called vertex-bends, all other bends are called face-bends. A Kandinsky drawing of a graph can be determined in the topology-shapemetrics framework [?, Ch. 2.3] by planarizing the graph (topology step), computing angles and bends (shape step), and finally determining the length of edge segments and size of vertex boxes (metrics step, also called compaction). Given an embedded planar graph, the shape of a Kandinsky drawing with the minimum number of bends is obtained from a minimum cost flow in a network that extends the well-known approach of [23] to account for 0◦ angles [13]. See Sect. 3 for details. 2.2
Dynamic Graph Layout and the Bayesian Paradigm
In dynamic graph drawing, the input is a sequence of graphs which represent the states of a single graph that is changing over time. Dynamic graphs can be visualized, e.g., in an animation or in a sequence of drawings, but it is important to keep changes between consecutive frames to a minimum in order not to destroy a viewer’s mental map of the graph [10]. Methods for dynamic orthogonal layout are proposed in [20,5,3,7]. The core modeling task of dynamic layout, i.e. the combination of criteria for good (static) layout with the requirement of small change, is therefore very similar to that of sketch-driven layout. For layout algorithms based on the optimization of an objective function, the Bayesian framework [2,1] suggests to incorporate a difference metric [6] as a penalty in the objective function. Optimization of the combined objective function thus naturally results in a trade-off between static layout criteria and stability. Since orthogonal drawing algorithms in the topology-shape-metrics framework heavily depend on the angles and bends computed in the shape step, it seems natural to use the change in angles and bends as a difference metric for orthogonal shapes [3,1].
4
Ulrik Brandes et al.
3
The Algorithm
Throughout this section, let Σ be an admissible drawing (a sketch) of a graph GΣ = (VΣ , EΣ ), where a sketch is admissible if there is no overlap between edges and non-incident vertices, and no more than two edges cross in single point. Any sketch can be transformed into an admissible one. Our objective is to determine an orthogonal box drawing of GΣ with the following properties: – – – –
the topology is preserved, the drawing is in the Kandinsky model, angles in the drawing deviate little from angles in the sketch (stability), and the drawing contains few bends (readability).
Our algorithm follows the topology-shape-metrics approach and proceeds as follows. First, a planarization G = (V, E, F ) of GΣ is determined. by replacing each crossing in the sketch by a dummy node, so that V = VΣ ∪ C where C is the set of dummy nodes. Since we do not change the embedding of G in the following steps, this ensures that the topology of GΣ is preserved. Next, a quasiorthogonal shape of G is determined from Σ by rounding angles in the sketch to the nearest multiple of 90◦ and classifying each edge bend as either a 900 or a 270◦ bend. Note that the resulting quasi-orthogonal shape S need not be valid. A valid quasi-orthogonal shape Q in the Kandinsky model is then determined so as to satisfy a trade-off between stability and bend-number. Finally, a compaction algorithm is applied on Q to compute a Kandinsky drawing of G, from which the final drawing is obtained by replacing dummy nodes with edge crossings. We concentrate on the problem of determining a quasi-orthogonal shape Q, since all other steps in the algorithm can be carried out using standard algorithms. The problem is stated in terms of an optimization problem for which we present a min-cost flow formulation based on [13]. 3.1
Problem Statement
The problem of finding a quasi-orthogonal shape Q is a bi-criteria optimization problem where the two objectives are readability (number of bends) and stability (change in shape). The readability of a shape Q is independent of the given sketch and defined as the total number of bends, namely B(Q) =
1 2
|b| .
f ∈F (e,a,b)∈Q(f )
The stability of an orthogonal shape Q is expressed in terms of the difference between angles in Q and corresponding angles in the shape S of the sketch ∆A (Q, S) = |a(S, f, i) − a(Q, f, i)| f ∈F 1≤i≤|f |
Sketch-Driven Orthogonal Graph Drawing
5
and the difference in edge bends ∆B (Q, S) = ∆(b(S, f, i), b(Q, f, i)) f ∈F 1≤i≤|f |
where ∆(s1 , s2 ) denotes a restricted edit-distance between two strings, in which only insert and delete operations are permitted. This is similar to the shape difference metric used in [6]. From these components we form a weighted compromise between the degree of change with respect to the given sketch and the number of bends in the quasi-orthogonal shape. Our objective function thus reads D(Q|S) = α · ∆A (Q, S) + β · ∆B (Q, S) + γ · (B(Q) − B(S)) stability
readability
where parameters α, β, and γ control the relative importance of angle or bend changes and bend number. We are now ready to state our problem formally. Problem 1. Given a quasi-orthogonal shape S of a planar graph G, find a valid quasi-orthogonal shape Q of G in the Kandinsky model such that D(Q|S) is minimum. 3.2
Bend-Minimum Kandinsky Shapes
Bend-minimum Kandinsky shapes for planar embedded graphs can be obtained by solving a path-based min-cost flow problem [13]. Since it is essential for our algorithm, we briefly review some important properties of the flow network, but assume that the reader is familiar with Tamassia’s min-cost flow formulation for creating bend-minimum drawings of embedded planar graphs with maximum degree four [23]. This formulation contains a node for each vertex (vertex-node), and for each face (face-node) of the input graph. The angle defined inside a face f between to consecutive edges a, b sharing a vertex v is determined by the flow on the network-edge that connects the vertexnode of v with the face-node of f . A flow of 0 defines an angle of 90◦ , a flow of 1 an angle of 180◦ and so forth. This is illustrated in Fig. 1. Since the sum of angles around a vertex must be 360◦ , each vertex-node is connected to the source of the network with an edge of capacity degree(v) − 4.
f
1
v 0
g
0
h
Fig. 1. A vertex v incident to faces f , g, and h, and the corresponding part of the min-cost flow network where arc labels indicate flow values according to the depicted shape
6
Ulrik Brandes et al.
Since zero flow represents an angle of 90◦ , an angle of 0◦ corresponds to negative flow which is not feasible in the network. In Kandinsky networks, this problem is solved as shown in Fig. 2 by introducing additional vertices and arcs which allow flow coming from a face-node to enter a vertex-node. Before a unit of flow can enter a vertex node, it crosses an edge and thus creates a bend. It follows that each 0◦ angle has the associated bend required by Lemma 1. For each vertex-node v we define the supply(v) as degree(v) − 4. A vertex-node v with positive supply is connected to the network source with capacity supply(v), and a vertex-node v with negative supply is connected to the network sink with capacity −supply(v).
2C+1
2C+1
2C+1
2C+1
2C+1
2C+1
2C+1
2C+1
2C+1
2C+1
Fig. 2. Kandinsky flow network for a node adjacent to five edges. Thick lines depict the original node and edges, thin lines depict network nodes and edges. All capacities are one except at pointed arcs which have capacity three. If not stated explicitly, arcs have zero cost except for dashed circular arcs which have cost −C
3.3
Sketch-Driven Kandinsky Shapes
In this section we describe modifications to the Kandinsky network that yield a network for Problem 1. The first modification concerns angles around a vertex v. We define for each angle defined by two consecutive edges e and e′ on a vertex v an angle-node ave,e′ . We create two arcs, one from ave,e′ to the vertex-node of v and one in the opposite direction. Both arcs have unconstrained capacity and cost α. We denote with UA (v) the set of angle-nodes of a vertex v. Angle-nodes are the only nodes connected to vertex nodes. All arcs which were connected to vertex-nodes in the original formulation are now connected to the corresponding angle-node. For each angle, and therefore for each angle-node w, there is a target angle a(w) defined by the shape S of the sketch. If a(w) > 0, then w is connected to the source with an arc of capacity a(w) and cost zero. If a(w) < 0, then w is
Sketch-Driven Orthogonal Graph Drawing
(1,w)
(2,0)
f
(1,w) g
f
(2,0)
(a) around a vertex
g
(1,0)
(2,0) s
7
(2,0) (1,2C)
s
(b) at regular and vertex-bends
Fig. 3. Modified Kandinsky network. Newly introduced arcs are dashed and labeled with capacity and cost in (b), where w = β − γ. Newly introduced nodes are marked gray. Node s is the global source
connected to the sink with an arc of capacity a(w) and cost zero. Additionally we remove a(w) from the supply of the vertex-node. Therefore the supply of a vertex node is now defined as supply ′ (v) = degree(v) − 4 − w∈UA (v) a(w). Our construction is illustrated in Fig. 3(a). The second modification concerns the modeling of bends. For each bend in S we create the device shown left in Fig. 3(b). A demand of 1 is added to both faces incident to the edge containing the bend. The effect of this device is, that either Q contains the bend at zero cost or the bend is removed at cost β − γ. Additionally we assign arcs between faces the cost β + γ. Note that the first and the last bend on an edge are potential vertex-bends. For this type of bends we create a different device as shown right in Fig. 3(b). This device ensures that vertex-bends can be confirmed at zero cost. Lemma 2. An optimal solution of the above path-based min-cost flow problem yields an optimal solution for Problem 1. Sketch of Proof. Observe that the original Kandinsky network is modified inside of boxes that represent vertices of the input graph. The total amount of supply in a box remains unchanged since supply ′ (v) + UA (v) a(w) = degree(v) − 4 = supply(v). The same holds for bend devices. Therefore the set of quasi-orthogonal shapes that correspond to a feasible flow in the network is the same as in the original formulation, namely the set of all valid quasi-orthogonal shapes. It remains to show that a min-cost flow in the network yields an optimal solution for D(Q|S). Let x be a feasible flow in the network, and Q the valid quasi-orthogonal shape corresponding to x. Consider the arc a(v, w) between an angle-node w and
8
Ulrik Brandes et al.
its vertex-node v in the flow network and a(w, v) the reverse edge. We assume that either x(a(v, w)) = 0 or x(a(w, x)) = 0. The angle-node w represents the angle between an edge e and its following edge in the embedding. Let (e, aS , bS ) be a tuple in S and (e, aQ , bQ ) be the corresponding tuple in Q describing this angle. Then aQ = aS − x(a(v, w)) + x(a(w, v)) and therefore α · |aS − aQ | = α · (a(w, v)) + α(a(v, w)). At bend devices there are two possibilities: either a bend is conserved at cost zero, or it is deleted at cost β − γ. A newly created bend has cost β + γ in x. Let bQ have minimum edit distance to bS with kD deletions and kI insertions. Then kD (β − γ) + kI (β + γ) = β(kD + kI ) + γ(kI − kD ) = ∆(bQ , bS ) + γ · (|bQ | − |bS |). ⊔ ⊓ Lemma 2 and [13] hence yield an efficient algorithm for an optimal trade-off between bend-reduction and sketch-preservation. Theorem 1. Problem 1 can be solved in time O(n2 log n).
4
Examples
While our approach works very well for graphs which are sufficiently connected, graphs with many tree like structures in the outer face are more difficult, because small angle changes result in major differences in appearance. We use an augmentation method in this case to improve the quality of the algorithm. The idea of the augmentation is to put a frame around the graph and connect vertices on the outer face to this frame by straight lines, see Fig. 4. We then execute the algorithm and finally remove the frame together with the augmentation edges. The introduced edges give the drawing a greater stability. We connect only vertices which are on the conex hull of the sketch drawing with the frame to avoid introducing new crossings. An experimental version of our approach has been implemented in Java using yFiles [24]. Figure ?? shows the result of our algorithm applied to the example used in the paper that initiated this work [17]. In contrast to the force-directed approach used there, our network-flow approach has negligible running time and is therefore truly interactive. A second application that we envision is the beautification of ER diagram sketches of which the designer wants certain features to be preserved. An example
Fig. 4. Ground plan from [17] and its framed sketch.
Sketch-Driven Orthogonal Graph Drawing
9
Fig. 5. Schematic map produced by our algorithm for ground plan from [17]. SchName
Schema
AttrName
DataType SchName
SCH_RELS
ATTRIBUTE
Schema
RelName
SCH_RELS
Relation
RelName
REL_ATTRS
Relation
DataType REL_ATTRS
KEY_ATTRS
d Query
AttrName
ATTRIBUTE
KEY_ATTRS
KeyNo
KEY
KEYS
INDEX_ATTRS
BASE_RELATION
KeyNo
INDEX_ATTRS
VIEW_RELATION DEFINES
KEY
BASE_RELATION
KEYS
d
RefRel DEFINES
FKEY
FKEY
VIEW_ATTRS
Indexes
RefRel
VIEW_RELATION
Query
VIEW_ATTRS
AttrName VIEW_ATTRIBUTE
AttrName
AttrNum
VIEW_ATTRIBUTE
INDEX
IndexName
IndexName
IndexType
INDEX
Indexes
AttrNum
IndexType
Fig. 6. ER diagram from [?, p. 577]) and an orthogonalized version
is given in Fig. 6. Note that some degree one vertices such as the one labeled “Query” change their relative position in order to avoid vertex-bends, which would have been necessary if the angles had been fixed. This a good example for the trade-off optimization.
5
Discussion
Our approach can be extended to a fully dynamic orthogonal graph drawing algorithm by considering the most recent drawing as a sketch. Note that the structure of the graph may since have changed, i.e. nodes and vertices may have been added or removed. The deletion of graph elements poses no problem, since we can simply remove them from the sketch as well. Additions to the graph require more care, since, e.g., newly created edges split an angle in the sketch drawing into two, and we can not infer the target values for those two angles in the network. We do have, however, a target value for the sum of these angles. Therefore merging the two angle-nodes into one and using the sum of the angles as the target value for the merged node solves this problem. See Fig. 7 for an illustration.
10
Ulrik Brandes et al.
Fig. 7. Edge insertion for dynamic layout
It is worth noting that the globally defined parameters α, β, and γ can be adjusted locally for every angle and bend. This may be useful in dynamic graph drawing, e.g. to give older parts of a drawing increased stability. An issue we have not addressed in this work is the compaction of sketch drawings. In our implementation we use the compaction algorithm described in [11] together with visibility postprocessing. However, sometimes it may be helpful to preserve some distances in the sketch drawing, especially in the dynamic scenario. Our future research will investigate this problem.
References 1. U. Brandes. Layout of Graph Visualizations. PhD thesis, University of Konstanz, 1999. http://www.ub.uni-konstanz/kops/volltexte/1999/255/. 2. U. Brandes and D. Wagner. A Bayesian paradigm for dynamic graph layout. Proc. Graph Drawing ’97. Springer LNCS 1353:236–247, 1997. 3. U. Brandes and D. Wagner. Dynamic grid embedding with few bends and changes. Proc. Algorithms and Computation ’98. Springer LNCS 1533:89–98, 1998. 4. J. Branke. Dynamic graph drawing. In Drawing Graphs: Methods and Models, Springer LNCS Tutorial 2025:228–246, 2001. 5. S. Bridgeman, J. Fanto, A. Garg, R. Tamassia, and L. Vismara. InteractiveGiotto: An algorithm for interactive orthogonal graph drawing. Proc. Graph Drawing ’97. Springer LNCS 1353:303–308, 1997. 6. S. Bridgeman and R. Tamassia. Difference metrics for interactive orthogonal graph drawing algorithms. Journal of Graph Algorithms and Applications, 4(3):47–74, 2000. 7. M. Closson, S. Gartshore, J. Johansen, and S. Wismath. Fully dynamic 3dimensional orthogonal graph drawing. Journal of Graph Algorithms and Applications, 5(2):1–35, 2001. 8. G. Di Battista, P. Eades, R. Tamassia, and I. G. Tollis. Graph Drawing: Algorithms for the Visualization of Graphs. Prentice Hall, 1999. 9. H. do Nascimento and P. Eades. User hints for directed graph drawing. Proc. Graph Drawing ’01. Springer LNCS 2265:124–138, 2002. 10. P. Eades, W. Lai, K. Misue, and K. Sugiyama. Preserving the mental map of a diagram. Proc. Compugraphics ’91, pp. 24–33, 1991. 11. M. Eiglsperger, and M. Kaufmann. Fast Compaction for Orthogonal Drawings with Vertices of Prescribed Size Proc. Graph Drawing ’01. Springer LNCS 2265:124–138, 2002.
Sketch-Driven Orthogonal Graph Drawing
11
12. R. Elmasri and S. Navathe. Fundamentals of Database Systems. Addison-Wesley, 3rd ed., 2000. 13. U. F¨ oßmeier and M. Kaufmann. Drawing high degree graphs with low bend numbers. Proc. Graph Drawing ’95. Springer LNCS 1027:254–266, 1996. 14. J. Ignatowicz. Drawing force-directed graphs using Optigraph. Proc. Graph Drawing ’95. Springer LNCS 1027:333–336, 1996. 15. M. Kaufmann and D. Wagner, editors. Drawing Graphs: Methods and Models. Springer LNCS Tutorial 2025, 2001. 16. G. W. Klau and P. Mutzel. Quasi-orthogonal drawing of planar graphs. TR 98-1013, Max-Planck-Institut f¨ ur Informatik, Saarbr¨ ucken, 1998. 17. U. Lauther and A. St¨ ubinger. Generating schematic cable plans using springembedder methods. Proc. Graph Drawing ’01. Springer LNCS 2265:465–466, 2002. 18. T. Masui. Graphic object layout with interactive genetic algorithms. Proc. IEEE Visual Languages ’92, pp. 74–87, 1992. 19. X. Mendon¸ca and P. Eades. Learning aesthetics for visualization. Anais do XX Semin´ ario Integrado de Software e Hardware, pp. 76–88, 1993. 20. A. Papakostas and I. G. Tollis. Issues in interactive orthogonal graph drawing. Proc. Graph Drawing ’95. Springer LNCS 1027:419–430, 1996. 21. G. Paris. Cooperation between interactive actions and automatic drawing in a schematic editor. Proc. Graph Drawing ’98. Springer LNCS 1547:394–402, 1998. 22. K. Ryall, J. Marks, and S. Shieber. An interactive system for drawing graphs. Proc. Graph Drawing ’96. Springer LNCS 1190:387–394, 1997. 23. R. Tamassia. On embedding a graph in the grid with the minimum number of bends. SIAM Journal on Computing, 16(3):421–444, 1987. 24. R. Wiese, M. Eiglsperger, and M. Kaufmann. yfiles: Visualization and automatic layout of graphs. Proc. Graph Drawing ’01. Springer LNCS 2265:453–454, 2002.
Maintaining the Mental Map for Circular Drawings Michael Kaufmann1 and Roland Wiese1,2 1
Wilhelm-Schickard-Institut f¨ ur Informatik, Universit¨ at T¨ ubingen, 72076 T¨ ubingen [email protected] 2 yWorks GmbH, Sand 13, 72076 T¨ ubingen [email protected]
Abstract. In this paper we present new ideas to extend the framework for circular drawing of networks by Six and Tollis [15] by some new concepts which makes the framework suitable for user interaction. The original approach displays each biconnected component in a circular way, and the blocktree of the graph as a tree drawn radially [9]. We introduce the concept of hicircular drawings, a hierarchical extension of the mentioned framework replacing the circles of single vertices by circles of circular or star-like structures. This concept is inspired by the works of Brandenburg on graph clustering, and the recursive concepts of series-parallel graphs, PQ- resp. SPQR-trees.
1
Introduction
Next to orthogonal layout, Sugiyama-style layout and springembedder-style layout, the circular layout style has gained increasing popularity. The original circular layout style assumes that the graph is partitioned into clusters, the nodes of each cluster are placed on the circumference of an embedding circle, and each edge is drawn with a straight line [16]. It has found more and more applications in network design and development, especially in the area of computer networks and telecommunication, but also in social networking [12]. The layout style has been introduced by Madden et. al [11,7] to the graph drawing community, the method used is a comparably simple heuristic. Six and Tollis [15,16] adapted the style but developed a scientific framework for the approach. The main idea is to display each biconnected component in a circular way, and the blocktree, i.e. the tree of biconnected components, of the graph as a radial tree of such circles. Other works on clustering include the approaches by Brandenburg [2,10], where a certain kind of subgraphs (cliques) are collapsed to nodes of a graph (cycle, tree) on a higher level of abstraction. An overview on clustering methods as well as on drawing clusters can be found in [4]. On the layout side, the basic concept of compound graphs [18] has been proposed to handle clusters. Compound graphs and also clustered graphs have two different representations, an adjacency representation and also an inclusion representation. The latter one is either done by an additional view of the inclusion tree, or a representation of the cluster by nested rectangles. See also [8] for a M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 12–22, 2002. c Springer-Verlag Berlin Heidelberg 2002
Maintaining the Mental Map for Circular Drawings
13
more advanced approach. Such a twofold representation is not very flexible, since it distracts the users attention, if it is not carefully used. Therefore we try to display clusteral structures, and also want to show the way a graph develops in a dynamic setting. While in the area of computer networks the graphs are mostly static, we recently met applications from the area of product management, where the structure is dynamically growing. The following figure shows the need of an interactive extension of the concept of Six and Tollis: First the graph consists of a chain of quadrangles, which are displayed nicely by the layout algorithm “Circular with Radial”. When we add just a single edge connecting the two outermost quadrangles, all the components collaps into one. Circular with Radial places the vertices on a circle, performs a crossing minimization heuristics but cannot avoid at least n/4 crossings, one from each of the quadrangles. Unfortunately, the angles that arise are very tiny such that the previous structure can hardly be recognized. An alternative layout for this graph is given in the next figure, it shows the complete ring of components as it arose from the construction. Since one can assume that the user has this structural view of the closed chain of quadrangles in mind, his mental map is somewhat maintained. Note that there is already extensive work been done on dynamic graph drawing and various concepts of mental maps. For an overview and related references see [3].
Fig. 1. The left figure shows the chain-like layout as constructed by the Six/Tollis’ algorithm. Adding a new edge from the lowest to the topmost node leads to the middle layout, destroying the mental map completely. A better alternative is shown to the right, where the mental map of the structure, namely a circle of smaller circles, is nicely maintained.
Regarding the example, the ring of quadrangles can be viewed as one big component with some subcomponents, which finally leads to a hierarchical concept. In section 3, we will give the ideas for a new more general approach, and explain the necessary operations that lead to hopefully suitable layouts even in a dynamic setting where vertices and edges can be inserted and deleted. We will keep the description on a rather sketchy level. First, we review the framework for circular drawings by Six and Tollis.
14
2
Michael Kaufmann and Roland Wiese
The Framework of Six and Tollis and Its Limitations
The framework of Six and Tollis can be summarized as follows: The graph G = (V, E) is decomposed into the biconnected components which form the resulting block tree. For the articulation nodes v which are not adjacent to a bridge between two components, v is assigned to one of the components. The nodes of each single component are placed on a circle such that the distance between neighboring nodes is fixed. This determines the circumference of each component, which is represented as a single supernode of large size in the following. Next an adaption of the algorithm for radial tree layout [9] taking into account the supernodes, which usually have different sizes, gives the final layout of the whole structure. In radial tree layouts, the non-root nodes are placed in concentric circles around the root. Note that some rotations are also necessary in order to obtain a nice final drawing and that the maintenance of a reasonable connection between two adjacent components is not trivial, but can be solved. Further note that the circular drawing of each single component can be enhanced by various techniques for crossing reduction. For more details on the crossing reduction step as well as on the framework see [14,15]. We have already seen in the introduction, that the concept of Six and Tollis is static, that and features that support user interactivity are not incorporated. The whole scheme works in only two major stages, with a strong focus on the biconnectivity structure, since the superstructure of the blocktree is drawn as a radial tree and the single biconnected components as circles. Furthermore, the drawing of single biconnected components is quite limited, the placement of the nodes on a circle hides structural properties like symmetries, on the other hand, the contingent property of outerplanarity can be displayed [14]. We try to develop a more structured layout of biconnected components especially if it consists of several finer structures, without loosing the benefits of the concept of Six and Tollis. Before we discuss the setting for interactivity, we introduce a slightly more complicated variant for static circular layout, but which provides more flexibility than the previous approach. Later on, we will extend this new approach to support user interactiveness.
3
The New Approach
The main idea is to extend the radial-circular framework by the ability of maintaining the mental map. The layout of the different parts will either stay unchanged, or just stretched or squeezed. The embedding will definitely not be changed. Only essential structural changes should be displayed. 3.1
Our Static Variant of the Approach of Six and Tollis
As before, the idea is to take the block tree of biconnected components and layout the root component R in a circular way. Then recursively layout the subtrees T adjacent to the root R. The layouts of the subtrees are approximately
Maintaining the Mental Map for Circular Drawings
15
represented by round supernodes of a size according of the size of the layout. To find appropriate positions for these supernodes, the available space around the layout of R is partitioned by straight lines starting from the center of the layout of R. These lines define certain sectors, the so-called wedges [15]. The size of the wedges is chosen appropriate to the size of the supernodes, while the position of the wedge relative to the layout of R is chosen such that afterwards the layout of T , here represented by a supernode, can be attached directly to its articulation point in R. This recursive concept gives a lot of flexibility as will be shown later. Note that R can also be a single node, i.e. if the input graph is a tree. Complete binary trees give also a good motivation of our variant, since the constructed layout is the well-known H-tree layout [13] which is linear with respect to the area. The original radial-tree construction covers an area of O(n2 ) in this case. 6
40
23
17
19 12
27
33
20 32
18 10
38
5
16
3
24
39
29 28 29
21 31
7 25
26
34
4
9
7
18
13
20 37 25
28 11
4
Root
Root
2
16
23
6 22
8
26
19
34
3 14
5
11
8
12
13
37
15
22
17 14
27
2
9
21
40 24
36
30 10
38 30 15
35
35
33 31
32 39
36
Fig. 2. A complete ternary tree laid out according to the radial-circular algorithm [15] and according to our alternative method where the subtrees are drawn recursively.
So, compared to the algorithms of Six and Tollis, the construction works very similar and also allows a lot of variations like the application of crossing minimization schemes. The decomposition into biconnected components form the block tree, the biconnected components are mapped to circles. The main difference lies in the interpretation of the (block) tree structure, which we now consider to be a recursive structure. For the subtrees of the root, we draw independent layouts of the same layout style which are then connected to the articulation points of the root components. 3.2
Detailed Hierarchical Structures
Next, we present the new concepts for refined structures. Intuitively, we allow to replace the nodes in the scheme above by supernodes that again represent tree-like or circular structures. We simulate the tree-like structures by the sim-
16
Michael Kaufmann and Roland Wiese
pler concept of stars. A star is a graph with a center component and some leg components adjacent to the center, but not connected otherwise. Each supernode represents an associated underlying subgraph and has a round shape of a size according to the layout size of the associated subgraph. We have two types of supernodes, namely star nodes and circle nodes. The underlying structure of a star node is a star, consisting of a circle node as center component and possibly a further (super)node at each leg of the star. A circle node represents a set of (super)nodes arranged in a circular way. This way, the hierarchical structure of the input graph G can be represented by a tree H consisting of star nodes, circle nodes and normal nodes at the leaves of the tree. We call H the hicircular tree. A convention of H is that the center component of each star node will always be the leftmost child of the corresponding star node in the tree. The elements of the smallest edge subset in E that can be represented by the same hicircular tree as the whole graph G are called structural edges. All other edges do not contribute to the hierarchical structure, they are nonstructural. In Figure 3, we give a graph and two possible representations by hicircular trees, depending on the interpretation of the structure. In this example, all the edges are structural.
S
N
C
C
N
N
C
N
N
N
N
N
N
N
N
C
N
N
N
N
N
C
N
N
N
N
N
N
N
N
C
C
N
C
N
S
N
N
N
N
N
C
C
N
S
N
N
S
N
N
N
N
N
N
N
N
N
N
Fig. 3. A graph and two alternatives for its hicircular tree. Circular nodes are denoted by C, star nodes by S and normal nodes by N. In the upper tree, the global structure is a star with a big circular component in the center and six little legs, while the lower structure is a circle, and the legs are on a lower hierarchy level.
Note that similar descriptions of hierarchies have been used in various other concepts like series-parallel graphs [13], PQ-trees [1] or SPQR-trees [6]. For the block tree of biconnected components as in the approach of Six and Tollis, the hicircular tree consists of a tree of star nodes, each with a circle node as the leftmost child (the center) and more star nodes or normal nodes as the
Maintaining the Mental Map for Circular Drawings
17
other children. All children of circle nodes are normal nodes, since circle nodes just represent biconnected components, which are not differentiated any further. From a given hicircular tree, it is natural to derive the corresponding hicircular layout. The layout technique for the underlying structure of a star node is the same as described in the last subsection. For a circle node we arrange the underlying (super)nodes in a circular way, similar as described by Six and Tollis, but having nodes of different sizes. The details are omitted. 3.3
The Dynamic Case
Based on our concepts developed so far, we use the hicircular tree for the actual graph G to represent its hierarchical structure. Our objective is to preserve the tree-like and cyclic structures, that we kept as the mental map of the user over time if possible. To achieve this goal we want to maintain the hierarchical structures as much as possible, keep the original layout as recognizable as possible, and still clearly distinguish between tree and cycle structures. We will now discuss the elementary update operations; more complex operations can be formulated by a concatenation of these elementary operations: 1. Append a new node v to another node w by a new edge e = (v, w) We consider the normal node w in the hicircular tree. w lies either on a circle, or it is the center of a star, or a normal node. In the two latter cases, v is appended as a leg to w. If w is a circle node, we change w’s status to ’star node’, such that it becomes the center of a star and gets the single circle node v as a leg. The actual layout is changed as follows: We determine the position of w, place v next to w and connect both nodes with edge e without changing the embedding besides the new edge. Then we run the layout algorithm again for the structural edges of G. This gives a layout where v is inserted as a ’leg’ of w. The remaining layout does not change considerably. The actual wedges around w are squeezed a bit, and some space for the wedge for v has been created. v has been placed as close as possible (minimal distance) to w within this wedge. Then the nonstructural edges are added as straight lines. Note that the complete relayout of the graph is not really necessary but it keeps the scheme simple. Alternatively, the layouts within the new smaller wedges can be squeezed by a affine transformation of the node positions. 2. Add a new edge e = (v, w). We consider the position of the single nodes v and w in the hicircular tree H, and determine the lowest common ancestor a in H. If a is a circle node, v and w lie already on a common cycle, which is displayed by supernode a. Hence we decide that e has no effect on the structure of G, e is nonstructural. The drawing for the old graph will not change at all, only the new edge will be inserted, possibly by a straight line. If a is a star node, the new edge joins two leaf nodes within H, such that a new node cycle v = vr , . . . , v0 = a = w0 , . . . , ws = w is formed, where vi (0 < i < r) are nodes on the path from a to v and wj (0 < j < s) are nodes on the path from a to w. We now remove all edges from H that lie on that newly formed circle and add a new circle node c to H. Then we relink all nodes on the circle such
18
Michael Kaufmann and Roland Wiese
v
Fig. 4. Appending the new black node to a center of a star node S means a squeezing of the other wedges of the subgraphs of S.
that they become children of c. Finally we remove the edge that connects a with its parent node p and add the edge (p, c) instead. This transformation yields a well-formed hicircular tree again. If a had more than two legs as it is the case in Figure 5, they remain the legs of their centers as before. From the new hicircular tree, a corresponding new layout can be computed. Compared to the previous layout, the new layout might considerably change, although the planar embedding of the structural edges remains the same except of the new edge. The new edge is embedded according to the previous tree structure, it might only cross some nonstructural edges. The supernodes on the new cycle will move such that a circular structure arise. The adjacent wedges have to be squeezed or even stretched depending on the embedding of the legs of the star nodes, that are involved in the operation. Note that some of the subgraphs associated to the legs of the stars nodes of the new circle will be located inside of the circle, others on the outside. Local adjustments help in this case again. 3. Delete a single node v by removing the connecting edge (v, w). This is exactly the reverse operation of operation 1. Eventually, we have to change the state of w from ‘star node’ to ‘circle node’. Furthermore, we have the freedom to widen the wedges around w, since the wedge for v could be removed. There is only a slight effect on the drawing of G. 4. Delete an edge e = (v, w). We assume that v, w lie in the same biconnected component. Otherwise, the operation is easy, since the layout is split into two components. We omit this case here. As in operation 2. we consider the lowest common ancestor a of v and w and determine, if the removal of e breaks a structural cycle C (a cycle which is displayed by a circle node). Otherwise, e is just removed from the drawing, while everything else remains unchanged. If cycle C is broken, the corresponding supernode a is split into two legs that contain either v or w but not both. The supernodes of the legs are again modeled as sequences of star nodes, similar to the original construction for the block tree. The effect is just reverse to that of operation 2., cf. Figure 6.
Maintaining the Mental Map for Circular Drawings
19
e1
e1
e2
e2
Fig. 5. Inserting two edges to the graph from Figure 3. Edge e2 does not change the structure, so it is just drawn straightline across the drawing. Edge e1 closes a cycle between two legs of a star. Note that this is only the case when our interpretation of the structure and its representing hicircular tree is the same as in the upper alternative of Figure 3. In this case, a new cycle has been established and we change the structure of the drawing accordingly.
S
C
N
N
S
N
S
N
N
C
N
N
S
N
S
N
N N
C
N
C
N
S
N
N
N
N
N
N
Fig. 6. The deletion of an edge from the outermost circle (Figure 3) shows a drastic effect of an edge deletion on the drawing and the hicircular tree
4
Extensions
Our scheme that we presented here is efficient and it contains a lot of flexibility. We will comment in this section on some variations: – Assume that we have inserted already many nonstructural edges, such that the more detailed structure cannot be seen anymore just because of the large number of edges. Then the scheme allows to collapse the refinement of the structure and then to display only the coarse structures, just the way as shown in Figure 7. – If a cycle is broken by the deletion of a structural edge, and there are additional nonstructural edges at present, they might become structural. The scheme now allows to just break the cycle and leave all the other edges as they are, or to remove the nonstructural edges at once and insert them
20
Michael Kaufmann and Roland Wiese
Fig. 7. The center component on the left-hand side with the finer resolution contains too many nonstructural edges such that the refined structural resolution is of no help anymore. Hence the user can decide to collapse a hierarchy level and draw the whole component on one circle as shown in the right figure.
again in the same order as before. This way, one of the nonstructural edges might become structural and the cycle or part of it might remain unbroken. This clearly is an expensive way of restructuring. There might be ways for improvements. – If a nonstructural edge is inserted, we have originally proposed to draw it straightline across the whole structure. Very often, there are much better alternatives like splines, and/or a clever rerouting of such an edge helps, especially if the drawing is not too crowded yet and edge overlappings can (largely) be avoided.
5
Concluding Discussion
We have presented ideas for an extension of the scheme for circular layouts proposed by Six and Tollis to support the display of fine-granular structures and maintain the mental map while dynamically changing the graph. We kept the description on a high level, our goal was to present the main concept, obviously, a lot of details have been omitted. The tool we used to represent our hierarchical structure, was inspired by series-parallel graphs, PQ-trees or SPQRtrees. The basic components are trees, which again are represented by stars, and cycles, which are represented by circles. The update operations on the graph are presented as elementary operations ’insert/delete single nodes/edges’. More complex operations can be simulated by splitting them. At several steps of our descriptions, we have advised a complete recomputation of the layout. This is mainly due a simple description of the scheme, more efficient alternatives can be thought. A major property of the approach is that the drawing reflects the way the graphs have evolved. So, the mental map of the user who is focused on treelike and cyclic structures is maintained. But the drawings of the static graphs
Maintaining the Mental Map for Circular Drawings
21
without having the history of operations, or the hicircular tree, might not so easy to be understood, since the layout heavily depends on the order of the operations. This effect is not particular due to our algorithm but because of the nature of dynamic algorithms that always try to reflect the evoluation of a structure over time [3]. As already been shown in Figure 2, the hicircular tree is not unique. Hence later operations like Inserting an edge might have different effects, as it has been shown in figure F. Fortunately, it can be brought into a standard form by some additional rules, which would support the upper alternative from Figure 2. One way would be to compute the blocktree of biconnected components, and represent this by a tree of C-nodes. Each biconnected component can eventually partitioned by identifying a (structural) edge whose removal would provides a chain-like structure of larger components C1 , ..., Ct . C1 , ..., Ct again form the substructures of the cycle, represented by the C-node from above. On the other hand, the hicircular layout is unique for a given hicircular tree. Note that the scheme supports tree- and circular structures, which are planar per se, and the structural edges are always drawn pairwise crossing-free, but it is also robust enough to work for non-planar graphs as indicated in the last section. Each operation can be executed in linear time, but it seems that advanced data structures similar to [6] should enable more efficient implementations, possibly with logarithmic running times per operation. The basics of the proposed scheme have already been integrated in the yFiles library [19]. In the future, we will consider the practicability of the proposed scheme, asking if it is robust enough to be used in practical applications, and which of the variants are worthwhile to be used. We consider this proposal as a first step in the right direction, since there is certainly demand for dynamic graph drawing. And for the circular layout style, nothing has been published yet in this direction.
References 1. Booth, K.S. and Lueker G.S., Testing for the consecutive ones property, intervals graphs and graph planarity testing using PQ-tree algorithms, J. Comput. System Sci.13, pp. 335-379, 1976. 2. Brandenburg F., Graph Clustering 1: Cycles of Cliques, Proc. GD’97, LNCS 1353, Springer, pp. 158-168, 1998. 3. Branke J., Dynamic Graph Drawing, in Kaufmann/Wagner (Eds.) Drawing Graphs: Methods and Models, LNCS 2025, Springer, pp. 228-246, 2001. 4. Brockenauer R. and S. Cornelsen, Drawing Clusters and Hierarchies, in Kaufmann/Wagner (Eds.) Drawing Graphs: Methods and Models, LNCS 2025, Springer, pp. 193-227, 2001. 5. Di Battista, G., Eades P., Tamassia R. and I. G. Tollis, Graph Drawing: Algorithms for the Visualization of Graphs, Prentice Hall, 1999. 6. Di Battista G., and Tamassia R., On-line graph algorithms with SPQR-trees, Proc. ICALP 1990, LNCS 442, Springer, pp. 598-611, 1990. 7. Dogrus¨ oz U., B. Madden and P. Madden, Circular Layout in the Graph Layout Toolkit, Proc. GD’96, LNCS 1190, Springer, pp. 92-100, 1997.
22
Michael Kaufmann and Roland Wiese
8. Duncan Ch., Goodrich M., and Kobourov St., Planarity-Preserving Clustering and Embedding of Large Graphs, Proc. GD’99, LNCS 1731, Springer, pp. 186-196, 2000. 9. Eades P., Drawing Free Trees, Bulletin of the Institute for Combinatorics and its Applications, 5, pp. 10-36, 1992. 10. Edachery, J., Sen A., Brandenburg F., Graph Clustering Using Distance-k Cliques, Proc. GD’99, LNCS 1731, Springer, pp. 98-106, 2000. . 11. Kar G., B. Madden and R. Gilbert, Heuristic Layout Algorithms for Network Presentation Services, IEEE Network, 11, pp. 29-36, 1988. 12. Krebs V., Visualizing Human Networks, Release 1.0: Esther Dyson’s Monthly Report, pp. 1-25, 1996. 13. Lengauer T., Combinatorial Algorithms for Integrated Circuit Layout, WileyTeubner, 1990. 14. Six, J.M. and I.G. Tollis, Circular Drawings of Biconnected Graphs, Proc. Alenex’99, LNCS 1619, Springer, pp. 57-73, 1999. 15. Six, J.M. and I.G. Tollis, A Framework for Circular Drawings of Networks, Proc. GD’99, LNCS 1731, Springer, pp. 107-116, 2000. 16. Six, J.M., Ph.D. Thesis, University of Texas at Dallas, 2000. 17. Sugiyama K., S. Tagawa and M. Toda. Methods for Visual Understanding of Hierarchical System Structures, IEEE Transactions on Systems, Man and Cybernetics, 11(2), pp. 109-125, 1981. 18. Sugiyama K., K. Misue. Visualisation of structural information: Automatic drawing of compound digraphs, IEEE Transactions on Systems, Man and Cybernetics, 21(4), pp. 876-892, 1991. 19. The yFiles library: http://www-pr.informatik.uni-tuebingen.de/yfiles/ and http://www.yworks.de
Graphs, They Are Changing Dynamic Graph Drawing for a Sequence of Graphs Stephan Diehl and Carsten G¨ org University of Saarland, FR 6.2 Informatik, PO Box 15 11 50, D-66041 Saarbr¨ ucken, Germany [email protected], [email protected]
Abstract. In this paper we present a generic algorithm for drawing sequences of graphs. This algorithm works for different layout algorithms and related metrics and adjustment strategies. It differs from previous work on dynamic graph drawing in that it considers all graphs in the sequence (offline) instead of just the previous ones (online) when computing the layout for each graph of the sequence. We introduce several general adjustment strategies and give examples of these strategies in the context of force-directed graph layout. Finally some results from our first prototype implementation are discussed.
1
Introduction Optimizing the layout adjustment for a sequence of graph changes, e.g. for an off-line animation, is still an open yet very challenging area – J¨ urgen Branke [3] of research.
Dynamic graph drawing addresses the problem of computing layouts of graphs which evolve over time by adding and deleting edges and nodes. This results in an additional aesthetic criterion known as “preserving the mental map” [13] or dynamic stability. The ad-hoc approach is to compute a new layout for the whole graph after each update using those algorithms developed for static graph layout. In most cases this approach produces layouts which do not preserve the mental map. The common solution is to apply a technique known from key-frame animations called inbetweening to achieve “smooth” transitions between subsequent graphs, i.e. animations show how nodes are moved to their new positions. This approach yields decent results if only a few nodes change their position or whole clusters are moved without substantially changing their inner layout or if the transition is subdivided into several phases [9]. But in most cases the animations are just nice and do neither convey much information nor help to preserve the mental map.
2
Mental Map and Mental Distance
A layout is a mapping of the nodes and edges of a graph onto a plane or into a volume. M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 23–31, 2002. c Springer-Verlag Berlin Heidelberg 2002
24
Stephan Diehl and Carsten G¨ org
The term mental map refers to the abstract structural information a user forms by looking at the layout of a graph. The mental map facilitates navigation in the graph or comparison of it and other graphs. In the context of dynamic graph drawing changes to this map should be minimal, in other words algorithms to draw sequences of graphs should preserve the mental map. Misue et. al. [13] discuss three models for the mental map – Orthogonality: The horizontal and vertical order of nodes should stay the same when changing node positions. – Proximity Relations: The distance to all or at least to all neighboring nodes should be about the same. – Topology: The dual graph should be maintained. Based on each of these models we can define metrics that indicate how close the mental maps of two given layouts are. For the purpose of this paper we call the resulting class of metrics mental distances. Let Layout be the set of all layouts, i.e. in the simplest case mappings from nodes to points in R2 . Definition 1 (Mental Distance). Let l1 , l2 ∈ Layout be two layouts. Then the function ∆ : Layout × Layout → R+ 0 is a metric for how good l2 preserves the mental map of l1 . In particular ∆(l1 , l2 ) = 0 means that l1 and l2 have the same mental map. Most metrics only compare the layouts for the common subgraph of the underlying graphs, but we could also have metrics which additionally consider the layout of those nodes and edges which are only present in one of the layouts. 2.1
Examples of Mental Distances
Many researchers proposed distance metrics, e.g. [12,4]. We give here two which we use in our current implementation. The metrics below are based on node positions only. There are other metrics which take clustering or edge routing into account. For an overview see for example [3]. Definition 2 (Euclidean and Orthogonal Mental Distance). Let l1 , l2 ∈ Layoutbe two layouts. Their Euclidean mental distance is defined as ∆ (l1 , l2 ) = dist(l1 (v), l2 (v)) where dist(p, q) yields the Euclidean disv∈V1 ∩V2
tance of two points. Let sgn(x) ∈ {−1, 0, +1} yield the sign of a (real) number x. Their orthogonal mental distance is ∆⊥ (l1 , l2 ) = |sgn(l1 (v1 ).x − l1 (v2 ).x) − sgn(l2 (v1 ).x − l2 (v2 ).x)| v1 ,v2 ∈V1 ∩V2 +|sgn(l (v ).y − l (v ).y) − sgn(l (v ).y − l (v ).y)| 1 1 1 2 2 1 2 2
3
The Offline Dynamic Graph Drawing Problem
Assume that the quality of a layout could be measured by a function Γ regarding aesthetic goals like compactness, even distribution of nodes, minimal number of edge crossings, etc [15]. Such formal criteria are the computational crutches to substitute real models of human cognition or simply taste.
Graphs, They Are Changing
25
Definition 3 (Layout Quality). Let l ∈ Layout be a layout. Then the function Γ : Layout → R+ 0 is a metric for the quality of a single layout. In particular Γ (l) = 0 means that l has minimal quality. Now we can state the problem of dynamic drawing of a sequence of graphs. In most applications the graphs in such a sequence will result from changes to the preceding graph and thus will share some nodes and edges. Definition 4 (The Offline Dynamic Graph Drawing Problem). Given a sequence of n graphs g1 , . . . , gn . Compute layouts l1 , . . . , ln for these graphs such that 1. ∆ = ∆(li , li+1 ) is minimal 2. Γ = Γ (li ) is maximal 1≤i 2, then g has at most one fixed point and all the other cycles have length m. Therefore, if we were looking for a 2-geometric automorphism of order 3, say, and if the group had an orbit of length 16, then we could confine our search to the stabilizer of a point in the orbit. These and similar considerations speed up the search considerably but for clarity we leave them out of our descriptions of the algorithms. 2-Geometric Subgroups. In two dimensions the only geometric groups are the cyclic groups Cn of order n and the dihedral groups Dn of order 2n. In all cases, the first step in finding these is to compute the automorphism group Aut(G), in short A, of the graph G. Algorithm for the 2-geometric cyclic groups 1. Use the orbit lengths of Aut(G) to compute an upper bound for the order of a 2-geometric element. 2. Find representatives for the conjugacy classes of Aut(G). 3. Accept all elements of order 2 found in the previous step and all elements of order m > 2 with at most one fixed point and all other cycles of length m. Every pair of elements of order 2 generates a dihedral group. We makes use of the elements found in the previous algorithm, as follows (The normalizer NA (H) of a subgroup H is defined to be set of elements a ∈ A such that a−1 Ha = H). Algorithm for the 2-geometric dihedral groups 1. Find representatives for the conjugacy classes of geometric elements using the previous algorithm. In this case we also require that any elements of order 2 fix at most one point. 2. For each element g found in the previous step, compute the normalizer N of g in Aut(G). 3. Find representatives for the conjugacy classes of elements of order 2 in N . 4. Accept those elements a found in the previous step that satisfy the relation (ga)2 = 1. The group g, a is a 2-geometric dihedral group. 5. Carry out some additional checking to choose a single representative for dihedral groups that are conjugate within N .
A Group-Theoretic Method for Drawing Graphs Symmetrically
91
3-Geometric Subgroups. There are five types of geometric groups that can be represented by rotations in R3 : cyclic groups Cn , dihedral groups Dn , the tetrahedral group T , the octahedral group O, and the icosahedral group I. Furthermore, Dn has presentation x, y | x2 = y 2 = (xy)n = 1 and the groups T , O and I have presentations x, y | x2 = y 3 = (xy)k = 1 , where k is 3, 4 or 5, respectively. Since D1 = C2 , we shall only use the type Dn when n is at least 2. From each rotation group B we get a larger group B ∗ by taking the direct product of B with the central inversion −I. If we have a geometric subgroup H of type B we find candidates for the groups of type B ∗ by looking inside the centralizer CA (H) = { a ∈ A | ah = ha for all h ∈ H } for elements of order 2 with at most one fixed point; such an element will be represented by the central inversion. This step is straightforward (but potentially expensive) and so we omit it from the descriptions that follow. In addition to the groups just described, there are four other types that do not consist entirely of rotations. They can be described by symbols (H | K). This means that the group itself is isomorphic to a group of type H and contains a subgroup (of rotations) of index 2 of type K. The possible types are (C2n | Cn ), (Dn | Cn ), (D2n | Dn ) and (O | T ). We note that it is possible for a permutation group A to be represented as a 3-geometric group in more than one way. For example, a cyclic group of order 4m that fixes at most one point and with all other orbits of length 4m has types C4m and (C4m | C2m ). Algorithm for the 3-geometric groups of types Cn and (C2n | Cn ) 1. Find representatives for the conjugacy classes of A and accept those elements g of order n all of whose cycles have length 1 or n. The group g is 3geometric of type Cn . But if we include the requirement that no vertex in a drawing lies on an edge joining two other vertices, then additional work needs to be done. 2. If n is even, find all elements h ∈ CA (g) with at most one fixed point and whose square is g. The lengths of the cycles of h will be 1, 2 and 2n. The subgroup h is 3-geometric of type (C2n | Cn ).
1. 2. 3. 4. 5. 6.
Algorithm for the 3-geometric groups of types Dn , (Dn | Cn ) and (D2n | Dn ) Find representatives for the conjugacy classes of geometric elements using the previous algorithm. For each element g found in the previous step, compute the normalizer N of g in Aut(G). Find representatives for the conjugacy classes of elements of order 2 in N . Accept those elements a found in the previous step that satisfy the relation (ga)2 = 1. The group H = g, a is a dihedral group. If H fixes more than one point we require all the orbits of H to have lengths 1, n or 2n. Then H is a group of type (Dn | Cn ). If H fixes at most one point and n = 2m, then it is of type (D2m | Dm ).
92
David Abelson, Seok-Hee Hong, and Donald E. Taylor
7. If H fixes at most one point and if the cycles of g have lengths 1 or n, then H is of type Dn and also of type (Dn | Cn ). 8. Carry out some additional checking to choose a single representative for dihedral groups that are conjugate within N . We give the details for type I. The other cases are similar except that a group with presentation x, y | x2 = y 3 = (xy)4 = 1 may correspond to a geometric group of type O or to one of type (O | T ) depending on the nature of its point stabilizers. Algorithm for 3-geometric groups of types T , O, I and (O | T ) 1. Find representative for the conjugacy classes of elements of order 5. These elements are necessarily 3-geometric. 2. For each element g found in the previous step, find representatives for the conjugacy classes of the elements of order 3 in A under the action of the centralizer CA (g); that is, we consider two elements h1 and h2 of order 3 to be equivalent if for some a ∈ CA (g) we have a−1 h1 a = h2 . 3. For elements g of order 5 and h of order 3 found in the previous steps check whether gh has order 2. If so, the group g, h is isomorphic to I. 4. For each group H = g, h found in the previous step, check that it fixes at most one point and check that it is geometric by determining whether the stabilizer of a representative for each of its orbits is of an allowed type. In the case of I the allowed subgroups are those of orders 1, 2, 3 and 5. This excludes the subgroups of orders 4 and 6, 10 and 12. 5. Carry out some additional checking to choose a single representative for groups that are conjugate within Aut(G). 3.2
Experimental Results
We implement the algorithm using Magma Version 2.8 [11], and conduct two types of experiments. The aim of the experiments is to test the runtime of the symmetry finding algorithm described above. The runtime, in general, depends more on the size of Aut(G) than the size of G, and thus we use test data with large automorphism groups. The first experiment is to find all the 2- and 3-geometric groups for a given graph and then find a geometric automorphism group of maximum size. We use three test data sets. The first two test sets are graphs generated from permutation groups. For a permutation group H acting on a set V we obtain a graph G = (V, E) by taking the edge set E to be an orbit of H on unordered pairs of vertices. That is, choose distinct elements u and v of V and set E = { {h(u), h(v)} | h ∈ H }. The graph created from H has an automorphism group that contains H. For each group, we choose at most one graph. We only choose graphs that are connected since disconnected graphs can be handled using similar methods in [7]. The groups were taken from a Magma database of primitive permutation groups of degree (that is, |V |) less than 50. The first test set has 67 graphs with | Aut(G)| < 1, 000 and a second test set has 34 graphs with 1, 000 < | Aut(G)|
1, 000 Time
Size
Max Av Max Av Max 820 0.0042 0.017 1812375 50803200 47 0.11 0.634 8.9 24 94 0.29 3.8 16.1 24 0.41 47 0.11 0.63 8.9 24 20 0.0058 0.033 7.3 24 6 0.34 5.0 8.5 12 94 0.35 5.0 16.1 24 94 0.373 5.26 16.1 24 94 0.362 5.1 16.1 24 8 0.678 8.7 15.7 28 12 0.23 2.9 12 12 0 0.0039 0.067 24 24 24 0.033 0.558 24 24 0 0.033 0.558 24 24 0 0.0029 0.05 48 48 0 0.048 0.617 60 60 0 0 0 120 120 2.58
Experimental results shows that our method is very efficient. In practice, it computes all 2- and 3-geometric automorphism groups very quickly. For example, for the first data set (|V | ≤ 50 with | Aut(G)| < 1, 000), it takes 0.022 seconds to compute all 2-geometric groups and 0.037 seconds to compute all 3-geometric groups on average. When | Aut(G)| becomes larger, then it takes longer. For example, for the second data set (|V | ≤ 50 with 1, 000 < | Aut(G)| < 51, 000, 000), it takes 0.41 seconds to compute all 2-geometric groups and 2.58 seconds to compute all 3-geometric groups on average. In fact, the computation of Aut(G) is very fast using nauty [12] inside of Magma. Most of the runtime is for looking
94
David Abelson, Seok-Hee Hong, and Donald E. Taylor Table 2. Results for highly symmetric graphs
Time Frequency Max Size Found # Non-Conjugate Groups Av Max Total Av Av Aut(G) 0.3125 6.069 33 51403.0909 Ck2 1.2103 24.05 30 8.6333 3.9666 Dk2 0.1125 2.859 28 17.3571 9.7857 Ck3 1.2187 24.14 33 8.3030 7.4545 (C2k |Ck3 ) 0.0051 0.111 26 7 4.8461 ∗ Ck3 0.1911 2.5675 20 8.4 2.8 Dk3 0.2558 4.6785 29 17.2413 13.7241 (Dk |Ck3 ) 0.3235 5.8675 31 16.3870 29.2580 (D2k |Dk3 ) 0.2489 3.8965 30 18.1333 6.3333 ∗ Dk3 0.3276 6.56 10 17.6 6.2 T 0.1721 4.039 14 12 1 T∗ 0.0032 0.021 9 24 1.1111 (O|T ) 0.0006 0.0055 9 24 1.3333 O 0.0006 0.0055 6 24 1.5 O∗ 0.0026 0.051 5 48 1.2 I 0.0051 0.15 4 60 1 I∗ 0.0015 0.03 4 120 1 Av Total for 3D 2.7568
for the subgroups within Aut(G). This is the reason that the runtime depends more on the size of Aut(G) than the size of G in general. The second experiment is to find a rotational symmetry of maximum order or a reflectional symmetry with the minimum number of fixed points. The aim of this experiment is to compare our method with a branch and cut method [2]. We use three test sets of [2] including the rome test suite with 11529 graphs [13]. The first set aut has 3000 graphs with |V | < 30, designed to have many automorphisms, but few of them are geometric. These are the so-called hard instances of [2]. The second set sym has 8000 graphs with |V | < 80, generated specifically to have rotational symmetries. The second experiment was done on a standard laptop, DELL Latitude C600 (750MHz, 256 MB RAM). Tables 3 and 4 display the experimental results from the second experiment with three test sets. The result shows that in general our method is much faster than the branch and cut method [2]. For example, Table 3(b) displays the result for aut. It takes 0.015 seconds to find best symmetry on average and 2.60 seconds in worst case. Note that it takes 21.6 seconds on average and 9197.55 seconds in worst case using the method of [2] (see Table 3 in [2]). Table 3(a) displays the result for sym. It takes 0.016 seconds to find best symmetry on average and 0.30 seconds in worst case. Table 4 displays the result for rome data. It takes 0.009 seconds to find best symmetry on average and 0.12 seconds in worst case. Note that it takes 4.26 seconds on average and 19.29 seconds in worst case using the method of [2].
A Group-Theoretic Method for Drawing Graphs Symmetrically
95
Table 3. Results for (a) 8000 graphs in sym and (b) 3000 graphs in aut (a) runtimes for sym, 1 ≤ n ≤ 80 (b) runtimes for aut, hard instances
Time (sec) n
Av Max
Time (sec)
1–10 0.0013 0.05
n
Av Max
11–20 0.0038 0.21
1–5
0.0008 0.01
21–30 0.0124 0.30
6–10 0.0027 0.05
31–40 0.0140 0.24
11–15 0.0056 0.22
41–50 0.0177 0.22
16–20 0.0115 0.70
51–60 0.0219 0.25
21–25 0.0362 1.58
61–70 0.0285 0.16
26–30 0.0356 2.60
71–80 0.0351 0.27 Table 4. Results for all 11529 graphs in rome Time Av Aut(G)
Max
4.1
Graph
Av
Max
Graph
0.00102125 0.011 grafo10316.100.lgr 5.0617 1920 grafo8507.75.lgr
BestCycle 0.00909117 0.12
4
Size
grafo5890.48.lgr 1.6825
3
grafo206.12.lgr
Displaying a Geometric Automorphism Group Choosing a Representation
It is possible to construct different drawings which display a given geometric automorphism group H, depending on the choice of the representation. Let H ⊆ Aut(G) be a 2- or 3-geometric group. We now describe how the choice of representation effects the drawing. We may consider only representations of H with a fixed image T ⊆ O2 (R) or O3 (R). Consider two different faithful representations φ, θ : H → T . Then φθ−1 is an automorphism of H. Hence choosing a different representation is equivalent to composing a fixed representation with an automorphism of H. Let G be a cycle of length 5 with a cyclic subgroup H = (12345)) = p . Figure 3 shows four different drawings that display H. Each uses a representation that takes a generator of H (p, p2 , p3 or p4 respectively) to a rotation by 2π/5. Note that Figure 3 1a) and 1d), 1b) and 1c) are the same up to relabeling. This is because p and p4 , and p2 and p3 are conjugate in Aut(G) by (25)(34). Furthermore p and p2 are conjugate by (2345) ∈ S5 \ Aut(G) thus the drawings that display them use the same points for vertices with different edges.
96
David Abelson, Seok-Hee Hong, and Donald E. Taylor 1
1
2
3
5
4 1a)
Fig. 3.
4.2
4 5
3
4
3
1
1
2
5 1b)
5
2 1c)
2
4
3 1d)
Using different representations to display the same group
Symmetric Drawing Algorithm
A simple drawing method for two dimensions is given by [3] where the main idea is to draw each orbit in a circle. We extend this method to three dimensions.
1. 2. 3. 4.
5.
6.
Algorithm to display a 3-geometric group Let v1 , v2 , . . . , vr be representatives for the orbits of H acting on the vertex set V of the graph. For each i: Find the stabilizer Hvi of vi . If Hvi = H, define D(vi ) to be the origin. If the dimension of φ(Hvi ) is one, define D(vi ) to be a vector of length i fixed by φ(Hvi ); that is, an eigenvector of length i for the eigenvalue 1. If the dimension of φ(Hvi ) is two, let r be the reflection generating φ(Hvi ). Choose D(vi ) to be a vector of length i fixed by r and not fixed by any other element in a subgroup of φ(H) containing r. If Hvi is the trivial group, define D(v) to be any vector of length i not in the fixed point space of any non-trivial element of φ(H). (These spaces of fixed points are known in advance and only need to be computed once.) For v in the orbit of vi , choose h ∈ H such that v = hvi and define D(v) to be φ(h)D(vi ).
Note that the points D(v) are not uniquely determined. At step 3, the orbit can be placed at a different radius and at steps 4 and 5 there is considerable choice for the selected point. The drawing algorithm has been implemented using magma, java and jjgraph. For smaple outputs, see Figure 4.
Fig. 4. Four-cube displaying (a) cyclic and (b) dihedral symmetry. (c) six-cube displaying cyclic symmetry (d) the dodecahedron displaying dihedral symmetry.
A Group-Theoretic Method for Drawing Graphs Symmetrically
5
97
Conclusion
In this paper, we present a group-theoretic method to find all 2- and 3-geometric automorphism groups of a graph. We implement the method using Magma and the experimental results show that our approach is very efficient in practice. We also present a simple drawing algorithm to display 2- or 3-geometric automorphism groups. To construct a maximally symmetric drawing of a graph, we need to choose a geometric automorphism group of a maximum size. In fact it is possible to construct different symmetric drawings of a graph, depending on the choice of the 2- or 3-geometric groups, the representation of a given geometric automorphism group, and ordering of the orbits with given representation.
References 1. D. Abelson, S. Hong and D. E. Taylor, A Group-Theoretic Method for Drawing Graphs Symmetrically, Technical Report IT-IVG-2002-01, School of Information Technologies, The University of Sydney, 2002. 2. C. Buchheim and M. J¨ unger, Detecting Symmetries by Branch and Cut, Graph Drawing 2001, Lecture Notes in Computer Science LNCS 2265, pp. 178-188, Springer Verlag, 2002. 3. P. Eades and X. Lin, Spring Algorithms and Symmetries, Theoretical Computer Science, 240, pp. 379-405, 2000. 4. H. Fraysseix, An Heuristic for Graph Symmetry Detection, Graph Drawing’99, Lecture Notes in Computer Science 1731, pp. 276-285, Springer Verlag, 1999. 5. S. Hong, P. Eades and S. Lee, An Algorithm for Finding Geometric Automorphisms in Planar Graphs, Algorithms and Computation, Lecture Notes in Computer Science 1533, pp. 277-286, Springer Verlag, 1998. 6. S. Hong, Drawing Graphs Symmetrically in Three Dimensions, Graph Drawing 2001, Lecture Notes in Computer Science LNCS 2265, pp. 189-204, Springer Verlag, 2002. 7. S. Hong and P. Eades, Drawing Planar Graphs Symmetrically IV: Disconnected Graphs, Technical Report CS-IVG-2001-03, Basser Department of Computer Science, The University of Sydney, 2001. 8. J. Manning, Geometric Symmetry in Graphs, Ph.D. Thesis, Purdue Univ., 1990. 9. Groups & Graphs, http://130.179.24.217/G&G/G&G.html. 10. W. Ledermann, Introduction to Group Theory, Longman, 1973. 11. Magma, http://magma.maths.usyd.edu.au. 12. nauty, http://cs.anu.edu.au/∼bdm/nauty. 13. Rome test suite ALF/CU, http://www.dia.uniroma3.it/∼gdt.
Path-Width and Three-Dimensional Straight-Line Grid Drawings of Graphs ⋆ Vida Dujmovi´c1 , Pat Morin2 , and David R. Wood2 1
2
School of Computer Science, McGill University, Montr´eal, Canada. [email protected] School of Computer Science, Carleton University, Ottawa, Canada. {morin,davidw}@scs.carleton.ca
Abstract. We prove that every n-vertex graph G with path-width pw(G) has a three-dimensional straight-line grid drawing with O(pw(G)2 ·n) volume. Thus for graphs with bounded path-width the volume is O(n), and it follows that for graphs with bounded tree-width, such as series-parallel graphs, the volume is O(n log2 n). No better bound than O(n2 ) was previously known for drawings of series-parallel graphs. For planar graphs √ we obtain three-dimensional drawings with O(n2 ) volume and O( n) aspect ratio, whereas all previous constructions with O(n2 ) volume have Θ(n) aspect ratio.
1
Introduction
The study of straight-line graph drawing in the plane has a long history; see [37] for a recent survey. Motivated by interesting theoretical problems and potential applications in information visualisation [35], VLSI circuit design [26] and software engineering [36], there is a growing body of research in three-dimensional straight-line graph drawing. Throughout this paper all graphs G are undirected, simple and finite with vertex set V (G) and edge set E(G); n = |V (G)| denotes the number of vertices of G. A three-dimensional straight-line grid drawing of a graph, henceforth called a three-dimensional drawing, represents the vertices by distinct points in 3-space with integer coordinates (called grid-points), and represents each edge as a line-segment between its end-vertices, such that edges only intersect at common end-vertices. If a three-dimensional drawing is contained in an axisaligned box with side lengths X − 1, Y − 1 and Z − 1, then we speak of an X × Y × Z three-dimensional drawing with volume X · Y · Z and aspect ratio max{X, Y, Z}/ min{X, Y, Z}. This paper considers the problem of producing a three-dimensional drawing of a given graph with small volume, and with small aspect ratio as a secondary criterion. Related Work: In contrast to the case in the plane, every graph has a threedimensional drawing. Such a drawing can be constructed using the ‘moment ⋆
Research supported by NSERC and FCAR.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 42–53, 2002. c Springer-Verlag Berlin Heidelberg 2002
Path-Width and Three-Dimensional Straight-Line Grid Drawings of Graphs
43
curve’ algorithm in which vertex vi , 1 ≤ i ≤ n, is represented by the grid-point (i, i2 , i3 ) . It is easily seen — compare with Lemma 4 to follow — that no edges cross. (Two edges cross if they intersect at some point other than a common end-vertex.) Cohen et al. [8] improved the resulting O(n6 ) volume bound, by proving that if p is a prime with n < p ≤ 2n, and each vertex vi is represented by the grid-point (i, i2 mod p, i3 mod p) then there is still no edge crossings. This construction is a generalisation of a twodimensional technique due to Erd¨ os [16]. Furthermore, Cohen et al. [8] proved that the resulting O(n3 ) volume bound is asymptotically optimal in the case of the complete graph Kn , and that every binary tree has a three-dimensional drawing with O(n log n) volume. Calamoneri and Sterbini [5] proved that every 4-colourable graph has a threedimensional drawing with O(n2 ) volume. Generalising this result, Pach et al. [30] proved that every k-colourable graph, for fixed k ≥ 2, has a three-dimensional drawing with O(n2 ) volume, and that this bound is asymptotically optimal for the complete bipartite graph with equal sized bipartitions. If p is a suitably chosen prime, the main step of this algorithm represents the vertices in the ith colour class by grid-points in the set {(i, t, it) : t ≡ i2 (mod p)} . The first linear volume bound was established by Felsner et al. [17], who proved that every outerplanar graph has a drawing with O(n) volume. Their elegant algorithm ‘wraps’ a two-dimensional layered drawing around a triangular prism; see Lemma 5 for more on this method. Poranen [32] proved that seriesparallel digraphs have upward three-dimensional drawings with O(n3 ) volume, and that this bound can be improved to O(n2 ) and O(n) in certain special cases. Recently di Giacomo et al. [11] proved that series-parallel graphs with maximum degree three have three-dimensional drawings with linear volume. Note that three-dimensional drawings with the vertices having real coordinates have been studied by Bruß and Frick [4], Chilakamarri et al. [6], Chrobak et al. [7], Cruz and Twarog [9], Eades and Garvan [15], Garg et al. [18], Hong [22], Hong and Eades [23, 24], Hong et al. [25], Monien et al. [27], and Ostry [29]. Aesthetic criteria besides volume which have been considered include symmetry [22–25], aspect ratio [7, 18], angular resolution [7, 18], edge-separation [7, 18], and convexity [6, 7, 15]. Tree-Decompositions: Before stating our results we recall some definitions. A tree-decomposition of a graph G is a tree T together with a collection of subsets Tx (called bags) of V (G) indexed by the vertices of T such that: – Tx = V (G), x∈V (T )
44
Vida Dujmovi´c, Pat Morin, and David R. Wood
– for every edge vw ∈ E(G), there is a vertex x ∈ V (T ) such that the bag Tx contains both v and w, and – for all vertices x, y, z ∈ V (T ), if y is on the path from x to z in T , then Tx ∩ T z ⊆ T y . The width of a tree-decomposition is the maximum cardinality of a bag minus one. A path-decomposition is a tree-decomposition where the tree T is a path T = (x1 , x2 , . . . , xm ), which is simply identified by the sequence of bags T1 , T2 , . . . , Tm where each Ti = Txi . The path-width (respectively, tree-width) of a graph G, denoted by pw(G) (tw(G)), is the minimum width of a path-decomposition (treedecomposition) of G. A graph G is said to have bounded path-width (tree-width) if pw(G) = k (tw(G) = k) for some constant k. Given a graph with bounded path-width (tree-width), the algorithm of Bodlaender [1] determines a pathdecomposition (tree-decomposition) with width pw(G) (tw(G)) in linear time. Note that the relationship between graph drawings and path-width or tree-width has been previously investigated by Dujmovi´c et al. [13], Hlin˘en´ y [21], and Peng [31], for example. Our Results: Our main result is the following. Theorem 1. Every n-vertex graph G has an O(pw(G)) × O(pw(G)) × O(n) three-dimensional drawing. Since pw(G) < n, Theorem 1 matches the O(n3 ) volume bound discussed above; in fact, the drawings of Kn produced by our algorithm are identical to those produced by Cohen et al. [8]. We have the following corollary since every graph G has pw(G) ∈ O(tw(G) · log n) [2]. Corollary 1. (a) Every n-vertex graph with bounded path-width has a threedimensional drawing with O(n) volume. (b) Every n-vertex graph with bounded tree-width has a three-dimensional drawing with O(n log2 n) volume. ⊓ ⊔ While the notion of bounded tree-width may appear to be a purely theoretic construct, graphs arising in many applications of graph drawing do have small tree-width. For example, outerplanar graphs, series-parallel graphs and Halin graphs respectively have tree-width 2, 2 and 3 (see [2, 12]). Thus Corollary 1(b) implies that these graphs have three-dimensional drawings with O(n log2 n) volume. While linear volume is possible for outerplanar graphs [17], our result is the first known sub-quadratic volume bound for all series-parallel and Halin graphs. Another example arises in software engineering applications. Thorup [34] proved that the control-flow graphs of go-to free programs in many programming languages have tree-width bounded by a small constant; in particular, 3 for Pascal and 6 for C. Other families of graphs having bounded tree-width (for constant k) include: almost trees with parameter k, graphs with a feedback vertex set of size k, partial k-trees, bandwidth k graphs, cutwidth k graphs, planar graphs of radius k, and k-outerplanar graphs. If the size of a maximum clique is a constant
46
Vida Dujmovi´c, Pat Morin, and David R. Wood
The proofs of Theorems 1 and 2 proceed in three steps. First, an ordered layering with no X-crossing is constructed from a given path-decomposition. The second step balances the number of vertices on each layer. The third step, which is essentially the converse of Lemma 1, takes an ordered layering with no X-crossing and assigns coordinates to the vertices to avoid edge crossings. The style of three-dimensional drawing produced by our algorithm, where vertices on a single layer are positioned on vertical ‘rods’, is illustrated in Fig. 1.
Fig. 1. A three-dimensional drawing of K6 .
Our algorithm for constructing an ordered layering makes use of the socalled normalised path-decompositions of Gupta et al. [20]. (The more general notion of normalised tree-decompositions was developed earlier by Gupta and Nishimura [19].) A path-decomposition T1 , T2 , . . . , Tm of width k is normalised if |Ti | = k + 1 for all odd i and |Ti | = k for all even i, and Ti−1 ∩ Ti+1 = Ti for all even i. The algorithm of Gupta et al. [20] normalises a path-decomposition while maintaining the width in linear time. Lemma 2. If a graph G has a normalised path-decomposition T1 , T2 , . . . , Tm of width k − 1, then G has an ordered k-layering with no X-crossing (see Fig. 2). Proof. For every vertex v ∈ V (G), let Tα(v) and Tβ(v) be the first and last bags containing v. Construct an ordered k-layering of G as follows. Let T1 = {v1 , v2 , . . . , vk }, and position each vi as the leftmost vertex on layer i, 1 ≤ i ≤ k. Since the path-decomposition is normalised, for all bags Tj with j even, there is a unique vertex xj ∈ Tj−1 \ Tj ; that is, β(xj ) = j − 1. Similarly, for all bags Tj with j > 1 odd, there is a unique vertex yj ∈ Tj \ Tj−1 ; that is, α(yj ) = j. The remainder of the ordered layering is constructed by sweeping through the bags of the path-decomposition as follows. For all odd j = 3, 5, . . . , m, position yj in the same layer as the vertex xj−1 and immediately to the right of xj−1 .
Path-Width and Three-Dimensional Straight-Line Grid Drawings of Graphs
47
Fig. 2. An ordered 5-layering with no X-crossing produced by Lemma 2.
Clearly, xj−1 was the rightmost vertex in the layer before inserting yj . Since j − 1 = β(xj−1 ) < α(yj ) = j, there is no bag containing both xj−1 and yj , and no edge xj−1 yj ∈ E(G). In general, two vertices in the same layer are not in a common bag and are not adjacent. Suppose there is an X-crossing between edges vw and xy. Without loss of generality, v ⌈ nl ⌉ vertices, replace it by ⌈q/⌈ nl ⌉⌉ ‘sub-layers’ each with exactly ⌈ nl ⌉ vertices except for at most one sub-layer with q mod ⌈ nl ⌉ vertices, such that the vertices in each sub-layer are consecutive in the original layer and the original order is maintained. There is no X-crossing between sublayers of the same original layer as there is at most one edge between such sublayers. There is no X-crossing between sub-layers from different original layers as otherwise there would be an X-crossing in the original layering. There are at most ⌊l⌋ layers with ⌈ nl ⌉ vertices. Since there are at most k layers with less than ⌈ nl ⌉ vertices, one for each of the original layers, there is a total of at most ⌊l + k⌋ layers. ⊔ ⊓ The third step of our algorithm is inspired by the generalisations of the moment curve algorithm by Cohen et al. [8] and Pach et al. [30]. Loosely speaking,
Path-Width and Three-Dimensional Straight-Line Grid Drawings of Graphs
45
k then chordal, interval and circular arc graphs also have bounded tree-width. Thus Corollary 1(b) pertains to such graphs. Since a planar graph is 4-colourable, by the results of Calamoneri and Sterbini [5] and Pach et al. [30] discussed above, every planar graph has a threedimensional drawing with O(n2 ) volume. Of course this result also follows from the classical algorithms of de Fraysseix et al. [10] and Schnyder [33] for producing plane grid drawings. All of these methods produce O(1) × O(n) × O(n) drawings, √ which have Θ(n) aspect ratio. Since every planar graph G has pw(G) ∈ O( n) [2] we have the following corollary of Theorem 1. √ √ Corollary 2. Every n-vertex√planar graph has an O( n)×O( n)×O(n) threedimensional drawing with Θ( n) aspect ratio. ⊓ ⊔ 2 This result matches the above O(n √ ) volume bounds with an improvement in the aspect ratio by a factor of Θ( n). Our final result examines the trade-off between aspect ratio and volume.
Theorem 2. Let G be an n-vertex graph. For every r, 1 ≤ r ≤ n/(pw(G) + 1), G has a three-dimensional drawing with O(n3 /r2 ) volume and aspect ratio 2r.
2
Proofs
We first introduce a combinatorial structure which is the basis for a twodimensional layered graph drawing. An ordered k-layering of a graph G consists of a partition V1 , V2 , . . . , Vk of V (G) into layers, and a total ordering C(σo ) and C(σP ) > C(σp ). We define Σ N = ∪ Σ ν . ν∈N
Finally, we need a notation for defining notions like “top”, “bottom”, “left” and “right” to express constraints that avoid intersection between our geometric objects. For an edge-label λ ∈ L, we define a 4-tuple t(λ), b(λ), l(λ), r(λ) where t(λ) is the top-most horizontal side of the rectangle representing λ, b(λ) is the bottom-most, l(λ) is the left-most vertical side, and r(λ) is the right-most. Similar definition for a vertex-label ν ∈ N and corresponding t(ν), b(ν), l(ν), r(ν). For a segment i ∈ S, if i ∈ S h then t(i) = b(i) = i, l(i) = inf (i), r(i) = sup(i); else, if i ∈ S v then t(i) = sup(i), b(i) = inf (i), l(i) = r(i) = i. 3.2
The ILP Model
We provide six properties which translate the definition of properly labeled orthogonal grid drawing by using the notation of Subsection 3.1. The constraints of the ILP model translate each property into a set of linear inequalities and integrality constraints. We use the notion of signed distance δ. For each ordered pair of parallel segments (i, j) in S ∪ Σ L ∪ Σ N let δ(i, j) = C(i) − C(j). Note that, δ(i, j) = −δ(j, i). The six properties are as follows. (PLD1) For each λ ∈ L, there exists exactly one triplet (λ, i, z) (λ ∈ L, i ∈ S(λ), z ∈ {p, P }) such that:
Computing Labeled Orthogonal Drawings
71
i,λ – If i ∈ S(λ) ∩ S v then δ(i, σzi,λ ) = w(λ) and δ(σO , σoi,λ ) = h(λ). i,λ – If i ∈ S(λ) ∩ S h then δ(i, σzi,λ ) = h(λ) and δ(σO , σoi,λ ) = w(λ). We call such a triplet the position of λ. i,λ (PLD2) If i is the segment of the position of λ, then C(f irst(sup(i))) > C(σO ) i,λ and C(f irst(inf (i))) < C(σo ). Also, ∀i ∈ S, C (f irst(sup(i))) − C (f irst(inf (i))) > 0. ν , σoν ) = (PLD3) Let ν ∈ N be the label associated with vertex v ∈ V , then δ(σO ν ν w(ν) and δ(σP , σp ) = h(ν). (PLD4) Let ν ∈ N be the label associated with vertex v ∈ V , then 0 ≤ Cx (v) − C(σoν ) ≤ w(ν) e 0 ≤ Cy (v) − C(σpν ) ≤ h(ν). (PLD5) Let α , β be two elements of S ∪ L ∪ N . At least one of the following conditions is verified: (1) δ (b(β), t(α)) > 0. (2) δ (l(β), r(α)) > 0. (3) δ (b(α), t(β)) > 0. (4) δ (l(α), r(β)) > 0. (5) α is an edge segment and β is a label drawn on α. (6) α is an edge segment incident on a vertex v, and β is the label associated with v. (PLD6) All vertices and bends have integer coordinates.
Theorem 1. Let G be a 4-planar graph, L be a set of labels for the edges of G, and N be a set of labels for the vertices of G. A labeled orthogonal grid drawing Γ of (G, L, N ) is properly labeled if and only if Properties (PLD1) - (PLD6) hold. Based on Theorem 1, an ILP model that minimizes the total edge length has the following objective function M in C (f irst(sup(i))) − C (f irst(inf (i))) i∈S
and about fifty groups of constraints which implement Properties (PLD1) (PLD6) (for details see the manuscript at [1]). In the implementation of the ILP problem we can omit the integrality constraints on the coordinates of vertices and bends, which improves the efficiency of the computations. With a technique similar to that presented in [12], it can be proved that the solutions of the resulting MILP problem are always grid drawings. The total number of variables and inequalities of the ILP model is O((n + b)2 ) where n and b are the number of vertices and bends of Γ , respectively. We remark that it is easy to modify the model in order to minimize the width or the height of the drawing. We denote by wΓ and hΓ the width and the height of the bounding box of Γ , expressed in terms of grid points. The model for width minimization is obtained by using the objective function M in(wΓ ) and by adding the following constraints: hmax > C(i) hmin ≤ C(i) ∀i ∈ S h , wmax > C(i) wmin ≤ C(i) ∀i ∈ S v , hΓ = hmax − hmin , wΓ = wmax − wmin .
72
4
Carla Binucci et al.
Optimizing the Area
In order to compute a labeled drawing of minimum area we exploit the ILP model of the previous section. Namely we set up a new objective function: M in(wΓ + 1 Mh · hΓ ) and add a new constraint hΓ < hm where Mh is an upper bound of the height of the drawing with optimal area. This corresponds to computing a drawing Γ with height no greater than Mh + 1 with minimum height among all drawings of minimum width. The algorithm iteratively searches for a new drawing with the same properties as Γ and lower height. The algorithm stops when the search fails. The idea relies on the fact that the minimum area drawing belongs to the set wΓ , where Γ of Pareto optimal solutions of the multiobjective function M in hΓ is a properly labeled orthogonal grid drawing. Our method returns a subset of this set which the optimal solution belongs to. In the following pseudo-code, Min-Width(hm ) is a subroutine that either returns a properly labeled orthogonal grid drawing with minimum width constrained to hm , if any, or it returns null. Algorithm OptArea Input: A triplet (G, L, N ) and an orthogonal representation HG Output: A properly labeled orthogonal grid drawing Γ opt of (G, L, N ) with minimum area within HG begin hm = Mh + 1 let Γ = Γ opt =Min-Width(hm ) hm = hΓ while (Γ is not null) let Γ =Min-Width(hm ) if (Γ is not null) then if (wΓ opt · hΓ opt > wΓ · hΓ ) then Γ opt = Γ hm = hΓ end Theorem 2. Let G be a 4-planar graph and let HG be an orthogonal representation of G. Let L and N be a set of labels for the edges and for the vertices of G respectively. Algorithm OptArea computes a properly labeled orthogonal grid drawing of (G, L, N ) with minimum area within HG . Since the widths of the drawingsiteratively computed by the algorithm are /w instead of hm = hΓ . We increasing, hm can be updated to wΓopt · hopt Γ Γ experimentally observed that in most cases the number of algorithm iterations reduces significantly. Moreover, the number of ILP solutions required by our algorithm is quite small (5 in the average) and this number does not seem to depend on the number of vertices of the input graph.
Computing Labeled Orthogonal Drawings
5
73
Open Problems
There are several open problems that we plan to investigate in the near future. Some of them are: (i) Refine our ILP model by valid inequalities in order to speed up the solution process. (ii) Extend the ILP model to graphs with high degree vertices. (iii) Design new heuristics for the graph drawing labeling problem.
References 1. C. Binucci, W. Didimo, G. Liotta, and M. Nonato. Computing labeled orthogonal drawings, manuscript: http://www.diei.unipg.it/PAG PERS/binucci/binucci.htm. 2. C. Binucci, W. Didimo, G. Liotta, and M. Nonato. Labeling heuristics for orthogonal drawings. In Symposium on Graph Drawing (GD’01), volume 2265 of LNCS, pages 139–153, 2002. 3. S. Bridgeman, G. D. Battista, W. Didimo, G. Liotta, R. Tamassia, and L. Vismara. Turn-regularity and optimal area drawings of orthogonal representations. Computational Geometry: Theory and Applications, 16:53–93, 2000. 4. R. Castello, R. Milli, and I. Tollis. An algorithmic framework for visualizing statecharts. In Symposium on Graph Drawing (GD’00), volume 1984 of LNCS, pages 139–149, 2001. 5. G. Di Battista, P. Eades, R. Tamassia, and I. G. Tollis. Graph Drawing. Prentice Hall, Upper Saddle River, NJ, 1999. 6. F. Harary. Graph Theory. Addison-Wesley, Reading, MA, 1972. 7. K. G. Kakoulis and I. G. Tollis. An algorithm for labeling edges of hierarchical drawings. In Symposium on Graph Drawing (GD’97), volume 1353 of LNCS, pages 169–180, 1998. 8. K. G. Kakoulis and I. G. Tollis. On the complexity of the edge label placement problem. Computational Geometry: Theory and Applications, 18:1–17, 2001. 9. M. Kaufmann and D. Wagner. Drawing Graphs. Springer Verlag, 2001. 10. G. Klau and P. Mutzel. Optimal labeling of point features in rectangular labeling models. Mathematical Programming, Series B, To appear. 11. G. Klau and P. Mutzel. Combining graph labeling and compaction. In Symposium on Graph Drawing (GD’99), LNCS, pages 27–37, 1999. 12. G. Klau and P. Mutzel. Optimal compaction of orthogonal grid drawings. In Integer Programming and Combinatorial Optimization (IPCO’99), volume 1610 of LNCS, pages 304–319, 1999. 13. G. Klau and P. Mutzel. Optimal labelling of point features in the sliding model. In In Proc. COCOON’00, volume 1858 of LNCS, pages 340–350, 2001. 14. S. Nakano, T. Nishizeki, T. Tokuyama, and S. Watanabe. Labeling points with rectangles of various shape. In Symposium on Graph Drawing (GD’00), volume 1984 of LNCS, pages 91–102, 2001. 15. T. Nishizeki and N. Chiba. Planar Graphs: Theory and Algorithms, volume 32 of Annals of Discrete Mathematics. North-Holland, 1988. 16. M. Patrignani. On the complexity of orthogonal compaction. Computational Geometry: Theory and Applications, 19:47–67, 2001. 17. T. Strijk and A. Wolff. The map labeling bibliography. on-line: http://www.mathinf.uni-greifswald.de/map-labeling/bibliography/.
Computing and Drawing Isomorphic Subgraphs Sabine Bachl1 and Franz-Josef Brandenburg2 1
sd&m AG, Thomas Dehler Str. 27, 81737 M¨ unchen, Germany [email protected] 2 University of Passau, 94030 Passau, Germany [email protected]
Abstract. The isomorphic subgraph problem is finding two disjoint subgraphs of a graph which coincide on at least k edges. Then the graph partitions into a large subgraph, its copy and a remainder. The problem resembles the NP-hard largest common subgraph problem. In [1,2] it has been shown that the isomorphic subgraph problem is NP-hard, even for restricted instances. In this paper we present a greedy heuristic for the approximation of large isomorphic subgraphs and introduce a spring algorithm which preserves isomorphic subgraphs and displays them as copies of each other. The heuristic has been tested extensively on four independent test suites. The drawing algorithm yields nice drawings which cannot be obtained by standard spring algorithms.
1
Introduction
Graph drawing is concerned with the problem of displaying graphs nicely. There is a wide spectrum of approaches and algorithms [4]. Nice drawings help in understanding the structural relation modelled by the graph. Bad drawings are misleading. This has been evaluated by HCI experiments [25,26], which have shown that symmetry is an important factor in the understanding of graph drawings and the underlying relational structure. Drawings of graphs in textbooks [27] and also the winners of the annual Graph Drawing Competitions and the logos of the symposia on Graph Drawing are often symmetric. In [5] symmetry is used for nice drawings without defining nice. Symmetry has two directions: geometric and graph theoretic. A graph has a geometric symmetry, if it has a drawing with a rotational or a reflectional invariant. This has first been studied by Manning [22,23], and is NP-hard for general graphs. For some subclasses of planar graphs there are polynomial time solutions [18,22]. As a pre-requisite such graphs need a non-trivial automorphism. This is the graph theoretic access to symmetry. It is less restrictive than the geometric symmetry, and is isomorphism complete. However, almost all graphs from applications have only a trivial automorphism. Hence, more flexibility is needed, and the notions of geometric symmetry and automorphism must be relaxed and generalized. This is achieved by restricting symmetry to subgraphs only. From another viewpoint there is the cut© operation, which first selects a portion of a graph, then creates a new copy thereof, attaches it to the original graph, M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 74–85, 2002. c Springer-Verlag Berlin Heidelberg 2002
Computing and Drawing Isomorphic Subgraphs
75
and connects the copy and the remainder by some edges. The reverse operation leads to the notion of isomorphic subgraphs, which has been investigated in [1,2]. The isomorphic subgraph problem is finding two large disjoint subgraphs of a given graph, such that one subgraph is a copy of the other. The generalization from graph automorphism to isomorphic subgraphs parallels the generalization from graph isomorphism to largest common subgraph. The difference between these problems lies in the number of input graphs. The coincidence or similarity of the subgraphs is measured in the number of common edges, which must be 100% for the automorphism and isomorphism problems, and which may be less for the more flexible generalizations. A related approach on symmetry by Chen et al. [7] reduces a given graph to a subgraph with a geometric symmetry by node and edge deletions and by edge contractions. The isomorphic subgraph problem and the largest common subgraph problem are NP-hard, even when restricted to forests, connected outerplanar graphs and 2-connected planar graphs [1,2,16]. Both problems are tractable, if the graphs have tree-width k and the graphs and the isomorphic subgraphs are k-connected [6]. In particular, isomorphic subtrees [1,2] and the largest common subtree of two rooted trees can be computed in linear time. For arbitrary graphs the isomorphic subgraph problem seems harder than the largest common subgraph problem. For the largest common subgraph problem we must find a matching between pairs of nodes which induce an isomorphism. For the isomorphic subgraph problem we must first partition the graph into two subgraphs and a remainder and then find the isomorphism preserving matching between the subgraphs. Recall that the graph isomorphism problem can be solved in linear time for almost all graphs [3]. The algorithm uses the degree of the nodes as an invariant and distinguishes nodes by their degree sequences. For subgraph isomorphism Ullmann’s algorithm [31] is well-known and is often used in computational biology for the search of molecular structures. Another method uses Levi’s transformation into a clique problem, which is also used for the largest common subgraph problem [19,20]. Our approach to the computation of large isomorphic subgraphs is a greedy heuristic. In fact, there is a collection of algorithms with different weighting parameters. So we capture both, the partition and the isomorphism problems. Our experiments are directed towards the appropriateness of the approach and the effectiveness of the chosen parameters. The measurements are based on more than 100.000 computations conducted by Bachl for her dissertation [2]. As a second step and an application we present a spring algorithm which preserves isomorphic subgraphs and displays them as copies of each other. The algorithm is an extension of the Fruchterman and Reingold approach [15]. Each node and its copy are treated identically by averaging the forces and moves. An additional force is used to separate the two copies of the subgraphs. With a proper setting of the parameters of the forces this gives rather pleasing pictures.
76
2
Sabine Bachl and Franz-Josef Brandenburg
Isomorphic Subgraphs
We consider undirected graphs G = (V, E) with a set of nodes V and a set of edges E. Edges are denoted by pairs e = (u, v). The set of neighbours of a node v is denoted by N (v). For convenience, we exclude self-loops and multiple edges. In applications graphs are generally attributed graphs with labels at the vertices and at the edges. This is discarded here, although labels may be a great help in the selection and association of nodes and edges for the isomorphic subgraph problem. Definition 1 (node- and edge-induced subgraphs). Let G = (V, E) be a graph and let V ′ ⊆ V and E ′ ⊆ E be subsets of nodes and edges. The nodeinduced subgraph G[V ′ ] = (V ′ , E ′′ ) consists of the nodes of V ′ and the edges of E between nodes of V ′ such that E ′′ = E ∩ V ′ × V ′ . The edge-induced subgraph G[E ′ ] = (V ′′ , E ′ ) consists of the edges of E ′ and the incident nodes V ′′ such that V ′′ = {u, v ∈ V |(u, v) ∈ E ′ }. An isomorphism between two graphs is a bijection on the sets of nodes that preserves adjacency. A common subgraph of two graphs G1 and G2 is a graph H that is isomorphic to G1 [E1 ] and G2 [E2 ]. More precisely, H is an edge-induced common subgraph of size k, where k = |E1 | is the number of edges. Accordingly, one may consider large node-induced common subgraphs. Definition 2 (isomorphic node-induced subgraph, INS). Instance: A graph G = (V, E) and an integer k. Question: Does G contain two disjoint node-induced common subgraphs H1 and H2 with at least k edges? Definition 3 (isomorphic edge-induced subgraph, IES). Instance: A graph G = (V, E) and an integer k. Question: Does G contain two disjoint edge-induced common subgraphs H1 and H2 with at least k edges? For INS and IES the graph G partitions into H1 , H2 , and a remainder R. Let V, V1 , V2 and VR denote the sets of nodes of G, H1 , H2 and R, respectively. Then V1 ∩ V2 = ∅ and VR contains all nodes from V \ (V1 ∪ V2 ). In the node-induced case, INS, the remainder contains all edges between the nodes of H1 and H2 and the edges with at least one endnode in R. In the edge-induced case, IES, R may also contain some edges between nodes from V1 or from V2 . IES is our most flexible version. Notice that also in the node-induced case the size of the common subgraphs must be measured in terms of the common edges. Otherwise, the problem may become meaningless. As an example consider an n × m grid graph with n, m even. If V1 consists of all even nodes in the odd rows and of all odd nodes in the even rows, and V2 = V \ V1 , then V1 and V2 have maximal size. However, their induced subgraphs are discrete with the empty set of edges.
Computing and Drawing Isomorphic Subgraphs
77
The isomorphic subgraph problems INS and IES have been investigated by Bachl [1,2]. These problems are NP-hard, in general. This has been shown by a directed reduction of 3-PARTITION. At present, there are no direct reductions between the isomorphic subgraph and the largest common subgraph problems, although these problems look similar. When restricted to trees, the isomorphic subtree problem is solvable in linear time. However, the isomorphic subtree problem requires trees as common subgraphs of a tree. This is not the restriction of the isomorphic subgraph problem to a tree. If the isomorphic subgraphs of a tree may be disconnected, then these instances of INS and IES become NP-hard. These results are summarized in Theorem 1. In [7] there are quite similar results for a related problem. Theorem 1. The isomorphic subgraph problems INS and IES are NP-hard. These problems remain NP-hard, if the graph G is – a tree and the subgraphs are forests [6] – outerplanar and the subgraphs are connected [1,2] – 2-connected outerplanar and the subgraphs are not 2-connected [6].
3
Computing Isomorphic Subgraphs
The isomorphic subgraph problem is NP-hard almost everywhere. The size of the largest isomorphic subgraphs can be regarded as a measure for the self-similarity of a graph in the same way as the size of the largest common subgraph is regarded as a measure for the similarity of two graphs. The isomorphic subgraph problem is different from the isomorphism, subgraph isomorphism and largest common subgraph problems. There is only a single graph, and it is a major task to locate and separate the two isomorphic subgraphs. Moreover, graph invariants such as the degree and adjacencies of isomorphic nodes are not necessarily preserved, since edges may end in the remainder or in the other subgraph or may be discarded, if they belong to only one of the edge-induced isomorphic subgraphs. Our approach is a greedy algorithm. The core are weighted graph parameters. If the algorithm has identified a pair of nodes as a copy of each other it finds new pairs among their neighbours. The correspondence between the neighbours is computed by a weighted bipartite matching. Let G = (V, E) be the given graph, and suppose that the subgraphs H1 and H2 have been computed as copies of each other. Consider a pair of nodes (v1 , v2 ) which are copies of each other. For each pair the following graph parameters are taken into account: – – – – – –
w1 w2 w3 w4 w5 w6
= degree(v1 ) + degree(v2 ) = |degree(v1 ) − degree(v2 )| = the number of common neighbours = the number of new neighbours of v1 and v2 which are not in H1 ∪ H2 = the graph-theoretical distance between v1 and v2 = the number of new isomorphic edges in (H1 ∪ v1 , H2 ∪ v2 ).
78
Sabine Bachl and Franz-Josef Brandenburg initialize(P ); while (P not empty) do (v1 , v2 ) = next(P); delete (v1 , v2 ) from P ; N1 = new neighbours of v1 ; N2 = new neighbours of v2 ; M = optimal weighted bipartite matching over N1 and N2 ; forall edges(u1 , u2 ) of M ) do if (G[V1 ∪ {u1 }] is isomorphic to G[V2 ∪ {u2 }]) then P = P ∪ {(u1 , u2 )}; V1 = V1 ∪ {u1 }; V2 = V2 ∪ {u2 }; Fig. 1. Heuristic for isomorphic node-induced subgraphs.
These parameters can be combined arbitrarily to a weight W (v1 , v2 ). The weights w2 and w3 are taken negative. Let w0 = wi . The algorithm iteratively selects a pair of nodes (v1 , v2 ) at random, which are identified by the isomorphism, and then matches their new neighbours in the bipartite graph with the sets of nodes N (v1 ) and N (v2 ). For each pair of neighbours (u1 , u2 ) let W (u1 , u2 ) be the weight of the edge (u1 , u2 ). Then compute an optimal weighted bipartite matching. The pairs of matched nodes are new pairs of identified nodes in V1 and V2 , provided that they pass the isomorphism test. The optimal weighted bipartite matching is computed by the Kuhn-Munkres algorithm (Hungarian method) [8], with a running time of O(n2 m) in our implementation. This can be improved, but it does not really matter, since these graphs are generally small. Figure 1 shows the algorithm for the computation of node-induced subgraphs. P consists of the pairs of nodes which have already been identified by the isomorphism. The isomorphism test is only local, since each time only one new node is appended to each subgraph. The matching edges are sorted by decreasing weights and are checked in this order. In the node-induced case, a matched pair of neighbours (w1 , w2 ) is skipped, if their addition to the intermediate subgraphs does not yield isomorphic subgraphs. In the case of edge-induced isomorphic subgraphs, the isomorphism test adds all pairs of matched nodes and all common edges. For each pair of starting nodes the algorithm runs in linear time except for the Kuhn-Munkres algorithm, which is used as a subroutine on bipartite graphs, whose nodes are neighbours of single nodes. In our experiments a single parameter wi or the sum w0 is taken as a weight. The unnormalized sum worked out because the parameters had similar values. The initialization of the algorithm is a critical point. What is the best pair of nodes to start with? We ran our experiments with three cases: – repeatedly for all O(n2 ) pairs of nodes – with the best pair of nodes according to the weighting function and – repeatedly for all pairs of nodes, whose weighting function is at least 90% of the weight of the best pair.
Computing and Drawing Isomorphic Subgraphs
79
With repetitions the largest subgraphs are kept. Clearly, the all pairs version has a O(n2 ) higher running time than the single pair version. The 90% best weighted pairs is a good compromise between the ellapsed time and the size of the computed subgraphs. The experiments were performed on four independent test suites [24]. – – – –
2215 random graphs with a maximum of 10 nodes and 14 edges 243 graphs generated by hand and 1464 graphs selected from the Roma graph library [28] 740 dense graphs.
These graphs where chosen by the following reasoning. For each graph from the first test suite the optimal result has been computed by an exhaustive search algorithm. This is doable only for small graphs. The graphs from the second test suite were constructed by taking a single graph from the Roma library, making a copy and adding some nodes and edges at random. The threshold is the size of the original graph. It is a good bound for the size of the edge-induced isomorphic subgraphs. The goal is to detect and reconstruct the original graph. For INS, the threshold is a weaker estimate because the few added edges may destroy node-induced subgraph isomorphism. Next, 1464 graphs from the Roma graph library were selected and inspected for isomorphic subgraphs with 10 to 60 nodes. These graphs are sparse with |E| ∼ 1.3|V |. The experiments of the first three test suites give a uniform picture. The heuristic finds the optimal subgraphs in the first test suite. In the second test suite the original graphs and their copies are detected almost completely when starting from the 90% best weighted pairs of nodes, see Figure 2. The weights w2 , w3 and w6 produce the best results. The total running time is in proportion to the number of pairs of starting nodes. For the 90% best weighted pairs of nodes it is less than two seconds for the largest graphs with 100 nodes and w0 , w1 , w4 and w5 , 30 seconds for w2 and 100 seconds for w3 and w6 , since in the latter cases the algorithm iterates over many to almost all pairs of starting nodes. In summary, the difference of degree w2 gives the best performance. For the third test suite the heuristic detects very large isomorphic subgraphs. Almost all nodes are contained in one of the node- or edge-induced isomorphic subgraphs which are almost trees. This surprising result is due to the sparsity of the test graphs. Again weight w2 performs best. [2] has the complete list of test results with more than 100 diagrams. Finally, we ran the heuristic on dense graphs with the 90% best weighted pairs of starting nodes. The dense graphs were generated at random. They have 10, 15, . . . , 50 nodes and 25, 50, . . . , 0.4 · n2 edges. For IES the heuristic finds isomorphic subgraphs which together contain almost all nodes and more than 1/3 of the edges. For INS each subgraph contains about 1/4 of the nodes and 1/20 of the edges, see Figure 3.
80
Sabine Bachl and Franz-Josef Brandenburg
threshold all weights (w0) degree (w1) difference of degree (w2) common neighbours (w3) new neighbours (w4) distance (w5) isomorphic edges (w6)
number of nodes in every subgraph
50
40
30
20
10 20
30
40
50
60
70
80
90
100
number of nodes in the graph
Fig. 2. Isomorphic edge-induced subgraphs of the second test suite for the 90% best weighted pairs of starting nodes.
These results are plausible, since for IES the heuristic adds pairs of matching nodes and ignores only isomorphism violating edges. For INS the isomorphic subgraphs turn out to be sparse.
16
all weights (w0) degree (w1) difference of degree (w2) common neighbours (w3) new neighbours (w4) distance (w5) isomorphic edges (w6)
number of nodes in every subgraph
14 12 10 8 6 4 2 10
15
20
25
30
35
40
45
number of nodes in the graph
Fig. 3. Isomorphic node-induced subgraphs of dense graphs
50
Computing and Drawing Isomorphic Subgraphs
81
The running time of one subgraph isomorphism detection from a single pair of nodes takes less than one second for our largest graphs. The total running time multiplies with the number of pairs of starting nodes, and is between two and 100 seconds for the largest graphs.
4
Drawing Isomorphic Subgraphs
In this section, we consider graphs with a pair of isomorphic subgraphs and their drawings. Sometimes, classical graph drawing algorithms preserve isomorphic subgraphs and display them symmetrically. The Reingold and Tilford algorithm [4,29] computes the tree drawing bottom-up, and so preserves isomorphic subtrees rooted at distinct nodes. It is readily seen that this is no more true for arbitrary subtrees. To stress this point, Supowit and Reingold [30] have introduced the notion of eumorphous tree drawings. However, eumorphous tree drawings of minimal width and integral coordinates are NP-hard. Also radial tree of ordered or embedded trees draw isomorphic rooted subtrees the same. The radial tree algorithm of Eades [10] squeezes a subtree into a sector with a wedge in proportion to the number of the leaves of the subtree. Hence, isomorphic subtrees get the same wedge and are drawn identically up to translation and rotation. It is well-known that spring algorithms tend to display symmetric structures. This comes from the nature of spring methods, and has been emphasized by Eades and Lin [12]. For special classes of planar graphs there are efficient algorithms for the detection and display of symmetries of the whole graphs [18]. For hierarchical graphs (DAGs) symmetry preserving drawing algorithms are unknown. This can be resolved by a three-phase method, which is generally applicable in this framework. If a graph G is partitioned into two node-induced isomorphic subgraphs H1 and H2 and a remainder R, first construct a drawing of H1 and take a copy as a drawing of H2 . Then H1 and H2 are replaced by two large nodes and the remainder together with the two large nodes is drawn by some algorithm in phase two. This algorithm must take the area of the large nodes into account. And it should take care of the edges entering the graphs H1 and H2 . Finally, the drawings of H1 and H2 are inserted at the large nodes and the edges to the nodes of H1 and H2 are locally routed on the area of the large nodes. The drawback of this approach is the third phase, and the difficulties in routing edges to the nodes of H1 and H2 . This may lead to bad drawings with node-edge crossings, parallel edges, and the destruction of symmetry. The alternative to the three-phase method is an integrated approach. Here the preservation of isomorphic subgraphs is built into the drawing algorithms. As said before, this goes automatically for some tree drawing algorithms, and is solved here for a spring embedder. Spring algorithms have been introduced to graph drawing by Eades [11]. Fruchterman and Reingold [15] have simplifed the forces to improve the running time, which is a critical factor for spring algorithms. Our algorithm is based on the advanced USE algorithm [13], which
82
Sabine Bachl and Franz-Josef Brandenburg
is included in the Graphlet system and is an extension of GEM [14]. In particular, USE supports individual distance parameters between any pair of nodes. Other spring algorithms allow only a uniform distance. Our goal are identical drawings of isomorphic subgraphs. The input is an undirected graph G and two isomorphic subgraphs H1 and H2 of G together with the isomorphism φ from the nodes of H1 to the nodes of H2 . If v2 = φ(v1 ) then v2 is the copy of v1 . In the initial phase, the nodes of H1 and H2 are placed identically on grid points (up to a translation). Thereafter the spring algorithm averages the forces imposed on each node and its copy and moves both simultaneously by the same vector. This guarantees that H1 and H2 are drawn identically. Large isomorphic subgraph should be emphasized. They should be separated from each other and distinguished from the remainder. The distinction can be achieved by a node colouring. This does not help, if there is no geometric separation between H1 and H2 , which can be enforced by imposing a stronger repelling force between the nodes of H1 and H2 . We use three distance parameters, k1 for the inner subgraph distance, k2 between H1 and H2 , and k3 otherwise, which k1 < k3 < k2 . Additionaly, H1 and H2 are moved by move subgraph(H, f ). The force f is the sum of the forces acting on the subgraph H and an extra repelling force between the barycenters of H1 and H2 . In a round, all nodes of G are selected in random order and are moved according to the emanating forces. The algorithm stops, if a certain termination criterion is accomplished. This is a complex formula with a cooling schedule given by the USE algorithm, see [13,14]. The extra effort for the computation of forces between nodes and their copies leads to a slow down of the USE algorithm by a factor of about 1.5, if the symmetry of isomorphic subgraphs is enforced.
Input: a graph G and its partition into two isomorphic subgraphs H1 and H2 , and a remainder R, and the isomorphism φ : H1 → H2 Initial placement(H1 , H2 ) while (termination is not yet accomplished) { forall nodes at random (v, V (G)) { f = force(v); if (v ∈ V (H1 ) ∪ V (H2 )) then f ′ = force(φ(v)); ′ f = f +f ; 2 move node(φ[v], f ); move node(v, f ); } move subgraph(H1 , f1 ); move subgraph(H2 , f2 ); } Fig. 4. Isomorphism keeping spring embedder.
Computing and Drawing Isomorphic Subgraphs
Fig. 5. 4 × 4-grid.
83
Fig. 6. Complete graph with 10 nodes.
Figure 4 describes the main steps of the isomorphism preserving spring algorithm. For each node v, force(v) is the sum of the forces acting on v and move node applies the computed forces to a single node. The examples shown below are computed by the heuristic and drawn by the spring algorithm. The most exciting drawings of graphs come from the second
Fig. 7. Graph of test suite 2. The original graph with 30 vertices and 35 edges was copied and then 2 nodes and 4 edges were added. Our algorithm has re-computed the isomorphic edge-induced subgraphs. The open nodes belong to the remainder.
84
Sabine Bachl and Franz-Josef Brandenburg
Fig. 8. Graph (number 06549 in [28]) of test suite 3 with 45 nodes, and the computed isomorphic edge-induced subgraphs.
and third test suites, see Figures 7 and 8. Many more drawings can be found in [2] or by using the algorithm in Graphlet. The algorithm produces many nice drawings. However there is space for improvements. In Figure 5, for example, if the left subgraph were reflected the grid were unfolded. The isomorphic subgraphs must therefore be drawn identically up to translation and reflection. This is an extension of isomorphic subgraphs.
References 1. S. Bachl. Isomorphic subgraphs. Proc. Graph Drawing’99, LNCS 1731 (1999), 286296. 2. S. Bachl. Erkennung isomorpher Subgraphen und deren Anwendung beim Zeichnen von Graphen. Dissertation, University of Passau, (2001), http://elib.ub.unipassau.de/index.html. 3. L. Babai and L.Kucera. Canonical labelling of graphs in average linear time. Proc. 20th IEEE FOCS (1979), 39–46. 4. G. Di Battista, P. Eades, R. Tamassia, and I.G. Tollis. Graph Drawing: Algorithms for the Visualization of Graphs. Prentice Hall, (1999). 5. T. Biedl, J. Marks, K. Ryall, and S. Whitesides. Graph multidrawing: Finding nice drawings without defining nice. Proc. Graph Drawing’98, LNCS 1547 (1998), 347-355. 6. F.J. Brandenburg. Pattern matching problems in graphs. Unpublished manuscript, (2000). 7. H.-L. Chen, H.-I. Lu and H.-C. Yen. On maximum symmetric subgraphs. Proc. Graph Drawing’00, LNCS 1984 (2001), 372–383. 8. J. Clark and D. Holton. Graphentheorie - Grundlagen und Anwendungen. Spektrum Akademischer Verlag, (1991). 9. D. Corneil and D. Kirkpatrick. A theoretical analysis of various heuristics for the graph isomorphism problem. SIAM J. Comput. 9, (1980), 281–297. 10. P. Eades. Drawing free trees. Bulletin of the Institute for Combinatorics and its Applications 5, (1992), 10–36.
Computing and Drawing Isomorphic Subgraphs
85
11. P. Eades. A heuristic for graph drawing. Cong. Numer. 42, (1984), 149–160. 12. P. Eades and X. Lin. Spring algorithms and symmetry. Theoret. Comput. Sci. 240 (2000), 379–405. 13. M. Forster. Zeichnen ungerichteter Graphen mit gegebenen Knotengr¨ oßen durch ein Springembedder-Verfahren. Diplomarbeit, Universit¨ at Passau, (1999). 14. A. Frick, A. Ludwig and H. Mehldau. A fast adaptive layout algorithm for undirected graphs. Proc. Graph Drawing’94, LNCS 894 (1995), 388–403. 15. T. Fruchterman and E.M. Reingold. Graph drawing by force-directed placement. Software – Practice and Experience 21, (1991), 1129–1164. 16. M.R. Garey and D.S. Johnson. Computers and Intractability: A Guide to the Theory of NP-Completeness. W.H. Freeman, San Francisco, (1979). 17. A. Gupta and N. Nishimura. The complexity of subgraph isomorphism for classes of partial k-trees. Theoret. Comput. Sci. 164, (1996), 287–298. 18. S.-H. Hong, B. McKay and P. Eades. Symmetric drawings of triconnected planar graphs. Proc. 13 ACM-SIAM Symposium on Discrete Algorithms (2002), 356–365. 19. I. Koch. Enumerating all connected maximal common subgraphs in two graphs. Theoret. Comput. Sci. 250, (2001), 1–30. 20. G. Levi. A note on the derivation of maximal common subgraphs of two directed or undirected graphs. Calcolo 9, (1972), 341–352. 21. A. Lubiw. Some NP-complete problems similar to graph isomorphism. SIAM J. Comput. 10, (1981), 11–21. 22. J. Manning. Geometric symmetry in graphs. Ph.D. thesis, Purdue Univ., (1990). 23. J. Manning. Computational complexity of geometric symmetry detection in graphs. LNCS 507, (1990), 1–7. 24. Passau Test Suite. http://www.infosun.uni-passau.de/br/isosubgraph. 25. H. Purchase, R. Cohen and M. James. Validating graph drawing aesthetics. Proc. Graph Drawing’95, LNCS 1027 (1996), 435–446. 26. H. Purchase. Which aesthetic has the greatest effect on human understanding. Proc. Graph Drawing’97, LNCS 1353 (1997), 248–261. 27. R.C. Read and R.J. Wilson An Atlas of Graphs. Clarendon Press Oxford (1998) 28. Roma Graph Library. http://www.inf.uniroma3.it/people/gdb/wp12/LOG.html. 29. E.M. Reingold and J.S. Tilford. Tidier drawings of trees. IEEE Trans. SE 7, (1981), 223-228. 30. K.J. Supowit and E.M. Reingold. The complexity of drawing trees nicely. Acta Informatica 18, (1983), 377-392. 31. J.R. Ullmann. An algorithm for subgraph isomorphism. J. Assoc. Comput. Mach. 16, (1970), 31–42.
A Branch-and-Cut Approach to the Directed Acyclic Graph Layering Problem Patrick Healy and Nikola S. Nikolov CSIS Department, University of Limerick, Limerick, Republic of Ireland {patrick.healy,nikola.nikolov}@ul.ie
Abstract. We consider the problem of layering Directed Acyclic Graphs, an N P-hard problem. We show that some useful variants of the problem are also N P-hard. We provide an Integer Linear Programming formulation of a generalization of the standard problem and discuss how a branch-and-bound algorithm could be improved upon with cutting planes. We then describe a separation algorithm for two classes of valid inequalities that we have identified – one of which is facet-defining – and discuss their efficacy.
1
Introduction
Drawing graphs in a hierarchical manner is a well-established style of presentation of relationships between entities, and in many disciplines it is the expected format. The most widely used method of drawing graphs hierarchically is, perhaps, the Sugiyama method [6]. Conceptually, the entities (nodes) should be drawn on a series of levels such that no two nodes that are related should be situated on the same layer and every entity relation (represented by a directed edge) should respect the direction of the relation by pointing in a uniform direction. To achieve this, the three main steps of the method are a) partitioning the node set into edgewise independent subsets so that all inter-partition edges can point the same direction; b) ordering the vertices of each subset in order to minimize edge crossings; and, c) determining a location on the level assigned to each vertex that maximizes clarity of the drawing. In this paper we focus on the first step. This is called the layering problem since the objective is to assign each node of the diagram to a (usually horizontal) layer such that all of the directions of the edges point in the same direction and thus preclude assigning to the same layer a pair of vertices that are related viz. connected by an edge. Currently three algorithms, Longest Path, Coffman-Graham and Gansner et al.’s, predominate for layering a graph. Healy and Nikolov [4] performed an experimental study of these three algorithms. Although the algorithms are fundamentally incomparable since they layer according to different objectives, Gans was found to produce the best layerings judged by a variety of measurements in this study. It is our contention that the algorithms currently in use are inadequate because of the simplified model that they assume, and evidence we have gathered M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 98–109, 2002. c Springer-Verlag Berlin Heidelberg 2002
Branch-and-Cut Approach to the Directed Acyclic Graph Layering Problem
99
on the algorithms’ performance supports this view [4]. In the same paper we proposed a polyhedral approach to the layering problem that reflected more of the problem’s complexities and we defined the graph layering polytope. We also proposed a system ULair which used the ILP solver of CPLEX 7.0. ULair in that context was used as a reference point for the other algorithms’ performance and its running time was not a central focus. In this paper we present a new branch-and-cut version of ULair which contains a cutting plane algorithm for generating cuts based on valid inequalities of the graph layering polytope. The next section describes the layering problem formally. In Section 3 we introduce an Integer Linear Programming model and discuss capacity-related facets of the graph layering polytope and a cutting-plane algorithm. Section 4 describes the experiments that we conducted to evaluate the performance of the branch-and-cut version of ULair. We make some concluding remarks in Section 5.
2
The Layering Problem
Consider a directed acyclic graph (DAG) G = (V, E) and a function w : V → Q+ which represents the widths of the smallest enclosing rectangles of the nodes of G. We layer a graph as follows. Partition the node set V of G into χ ≥ 1 layers V1 , V2 , . . . , Vχ , such that if (u, v) ∈ E with u ∈ Vj and v ∈ Vi then i < j. Then for each edge e = (u, v) ∈ E i+2 j−1 with u ∈ Vj and v ∈ Vi add so-called dummy nodes di+1 to e , de , . . . , de layers Vi+1 , Vi+2 , . . . , Vj−1 respectively, replacing edge (u, v) by the directed path (u, dj−1 , . . . , di+1 e e , v). The dummy nodes are normally not presented in the final drawing; their introduction is required by the algorithms applied at the next phases of the Sugiyama’s algorithmic framework. We assign width wed ∈ Q to all the dummy nodes contributed by edge e by extending the node width function w over the dummy nodes. We also consider wed as the width of edge e. Such a partitioning of the nodes of G is known as a layering of G and we denote it by L(G). A DAG with a layering is called a layered digraph. An algorithm that partitions the DAG node set into layers is called a layering algorithm. Once we have separated the nodes of G into layers the width and the height of the final drawing can be approximated by the width and the height of the layering. The height of a layering is the number of layers. We define the layering width as follows. Definition 1. The width of layer Vi is wi = v∈Vi w(v) and the width of layering L(G) is w = max{wi : i = 1, . . . , χ}. Usually, the width of a layering is defined as the maximum number of nodes in a layer [3,1]. Our definition generalizes this by allowing variable node and edge widths but if all the real nodes have unit width, and the edges (i.e. the dummy nodes) have zero width, then our definition for layering width is identical to the conventional one. We call the problem of finding a layering of a DAG with bounded sum of edge spans and bounded dimensions DAG layering. Considered as a decision problem, DAG layering can be formulated as follows.
100
Patrick Healy and Nikola S. Nikolov
DAG Layering Instance: A DAG G(V, E) with a width function w : V ∪ E → Q+ , and three numbers H, S ∈ N, W ∈ Q+ . Question: Is there a layering of G with sum of edge spans at most S, height at most H and width at most W ? DAG layering is N P-complete since the simpler decision problem when edge spans are ignored is N P-complete [3]. There is no known exact algorithm for solving DAG layering. If the widths of edges – and thus, the dummy nodes they generate – are significant then DAG layering becomes even more difficult [2]. The three layering algorithms referred to earlier solve DAG layering approximately by considering the DAG layering constraints only partially. DAG layering remains N P-complete when the relative order of two independent nodes (i.e. nodes without a direct path between them) is given. We consider the following two problems – to which partial solutions will be used later in our cutting-plane generation algorithm. Same-Layer DAG Layering. Instance: A DAG G(V, E) with a width function w : V ∪ E → Q+ , three numbers H, S ∈ N, W ∈ Q+ , and two independent nodes u, v ∈ V . Question: Is there a layering of G on at most H layers, with total sum of edge spans at most S, of width at most W , and with node u placed in the same layer as node v? Theorem 1. Same-layer DAG layering is N P-complete.1 Above DAG Layering. Instance: A DAG G(V, E) with a width function w : V ∪ E → Q+ , and three numbers H, S ∈ N, W ∈ Q+ , and two independent nodes u, v ∈ V . Question: Is there a layering of G on at most H layers, with total sum of edge spans at most S, of width at most W , and with node u placed in a layer above node v, i.e. if u ∈ Vj and v ∈ Vi then i < j? Theorem 2. Above DAG layering is N P-complete.
3
An ILP Model of the DAG Layering Problem
A starting point of our polyhedral approach to DAG layering as an optimization problem is the following ILP model – which we call WHS-Layering (W for width, H for height and S for spans).
1
Proofs of theorems not included here are available upon request.
Branch-and-Cut Approach to the Directed Acyclic Graph Layering Problem
3.1
101
The ILP Model WHS-Layering
Consider a DAG G = (V, E) and let x be the incidence vector of a subset of V × {1, . . . , H} then WHS-Layering is the following ILP model. ρ(u) ρ(v) min (1) kxuk − kxvk (u,v)∈E
k=ϕ(u)
k=ϕ(v)
ρ(v)
Subject to
xvk = 1
∀v ∈ V
(2)
xvi ≤ 1
∀k ∈ L(u) ∩ L(v), ∀(u, v) ∈ E
(3)
∀k = 1, . . . , H
(4)
∀k = 1, . . . , π(G)
(5)
k=ϕ(v) k
ρ(v)
xui +
i=ϕ(u)
i=k
wv xvk + Dk ≤ W
v∈Vk∗
xvk ≥ 1
v∈Vk∗
all xvk are binaries In this formulation W and H are upper bounds on the width and height of the layering respectively; π(G) is the number of nodes in the longest directed path in G; ϕ(v) and ρ(v) are respectively the lowest and the highest layer where node v can be placed in; L(v) = {ϕ(v), . . . , ρ(v)} and Vk∗ = {v ∈ V : ϕ(v) ≤ k ≤ ρ(v)}. The objective minimises the sum of edge spans, i.e. the number of dummy nodes. Equalities (2) force each node to be placed in exactly one layer; we call them assignment constraints. Inequalities (3) force each edge to point downwards; thus we call them direction constraints. Inequalities (5), called fixing constraints, introduce the additional requirement of having at least one node in the first π(G) layers. This reduces the number of identical layerings (but shifted vertically) if the height of the solution is less than the upper bound H. Inequalities (4), called capacity constraints, restrict the width of each layer (including the dummy nodes) to be less than or equal to W : the first term on the left hand side represents the contribution of the real nodes to the width of layer Vk while Dk represents the contribution of the dummy nodes. We set ρ(u) ρ(v) xul − xvl Dk = wed e=(u,v)∈E
l>k
l≥k
where wed is the width of the dummy nodes along edge e. The difference of the two sums in the parentheses is 1 if edge e = (u, v) spans layer Vk and 0 otherwise. We refer to the constraint polytope of WHS-Layering as the DAG layering polytope. To study its properties we relax it by allowing layerings of subgraphs
Patrick Healy and Nikola S. Nikolov
102 v0
v1
v1
v1
v2
v2
v4
v3
v0
v5 v3
v6
v7
(a) A random drawing of the DAG G2
v6
v0
k
v3
v4
v7
(b) Node v2 placed above layer Vk
v7
v6
v2
k
v4 v5
(c) Node v2 placed below layer Vk
Fig. 1. Node v1 placed above node v0 in a layering of the DAG G2
of the DAG G. We do this by replacing equalities (2) by “less-than-or-equal” inequalities. In the sections below when we refer to the DAG layering polytope we mean its relaxed version. 3.2
Generation of Valid Inequalities Related to the Layering Width
The upper bound W imposed on the width of the layering gives rise to a set of capacity-related valid inequalities for the DAG layering polytope. In previous work we identified strong relative ordering valid inequalities based on pairs of independent nodes, one of which had to be placed above the other; we called these strong RO inequalities [4]. In this section we show how, on the basis of heuristic algorithms which solve Same-layer DAG layering and Above DAG layering, we can strengthen them. Before we proceed we show an example, which gives an insight on our approach to finding capacity-related valid inequalities of the DAG Layering polytope. Example 1. Let G2 be the DAG depicted in Figure 1(a). Consider the problem of layering G2 of width at most 4 assuming all the nodes (including the dummy nodes) have a unit width. The drawings in Figure 1(b) and (c) show how placing node v1 in a layer above node v0 will affect the width of the layering. Let v0 be placed in layer Vk . Then its successors v3 , v4 , v6 and v7 must be placed in the layers below Vk . Thus the edges connecting v1 to them will cause three dummy nodes in layer vk (the dummy nodes are depicted by small rectangles in Figure 1(b) and (c)). Since node v2 is neither a predecessor nor a successor of v0 and v1 , placing v1 above v0 does not determine the relative position of v2 to layer Vk . There are three different cases which we should consider. The first case is when v2 is placed in layer Vk . Then layer Vk will have width at least 5, which makes this case impossible. Second, let v2 be placed above layer Vk . This case is depicted in Figure 1(b). Then edge (v2 , v6 ) will contribute another dummy node to layer Vk and this way making this case also impossible. The last alternative is to have node v2 placed below layer Vk . Then its successor v5 must be also below layer Vk . This case is depicted in Figure 1(c). Then edge (v1 , v5 ) will contribute
Branch-and-Cut Approach to the Directed Acyclic Graph Layering Problem
103
a dummy node to layer Vk , which shows that this case is not possible either. Thus v1 cannot be placed above node v0 for W ≤ 4. Consider two independent nodes u and v of a DAG G = (V, E) and assume we have a heuristic procedure PSAM E−LAY ER (u, v, S, H, W ) for solving Same-layer DAG layering, which takes a decision by considering only the width of the layer where nodes u and v are placed and the widths of its neighboring layers above and below. If PSAM E−LAY ER detects a layer of width greater than W it returns a negative answer and otherwise it returns a positive answer; clearly it will fail to detect some bad layerings due to its shortsightedness. If PSAM E−LAY ER returns a negative answer we say that it detects the pattern depicted in Figure 2(a) as an infeasible pattern in a layering of G. Similarly, assume we have a heuristic procedure PABOV E (u, v, γ, S, H, W ) for solving Above DAG layering for a given gap, γ, between the layers of u and v. We consider three cases of gaps between layers which correspond to three patterns which PABOV E may detect as infeasible in a layering of G. The three cases are: γ = 1 when u and v are in adjacent layers (illustrated in Figure 2(b)); γ = 2 when there is exactly one layer between the layers of u and v (illustrated in Figure 2(d)); and γ = 3 when there are two or more layers between the layers of u and v (illustrated in Figure 2(h)). PABOV E decides by considering only the widths of the two layers where nodes u and v are placed respectively and the widths of their adjacent layers. In all cases PABOV E considers the two adjacent layers above and below the layer of v and the two adjacent layers above and below the layer of u. Thus, the number of layers whose widths are considered are 4 (γ = 1), 5 (γ = 2), or 6 (γ = 3). We call the four patterns considered by PSAM E−LAY ER and PABOV E basic infeasible patterns. If more than one of the four infeasible basic patterns are detected simultaneously then that gives rise to combined infeasible patterns. Of the 15 possible combinations we consider the 11 illustrated in Figure 2 which correspond to generic types of valid inequalities for the DAG layering polytope. The first seven infeasible combined patterns give rise to the fixed-gap (FG) layering inequalities xuk +
2
αi xvk+i ≤ 1
(6)
i=0
2 with k ∈ L(u), αi ∈ {0, 1}, i=0 αi ≥ 1, and k + i ∈ L(v) if αi = 1. Similarly, the last four infeasible combined patterns give rise to the valid inequalities k
i=ϕ(u)
ρ(v)
xui +
xvi ≤ 1
(7)
i=k+γ
with k ∈ L(u), γ ∈ {0, 1, 2, 3}, and k + γ ∈ L(v). These are the inequalities that generalize the strong RO inequalities [4] and we call them simply RO inequalities in the remainder of this paper.
104
Patrick Healy and Nikola S. Nikolov
v u
k
v
k
u
(a) A (γ = 0)
(b) B (γ = 1)
v
v k
u
u
(d) C (γ = 2)
v v
u u u u
(h) D (γ = 3)
k
v
v
ρ(v )
k+3
k
ϕ(u )
k
(c) AB
v v k
u
(e) AC
v
v v
u
u
v
v
ρ(v )
v
v
v
v
v
v
v
v v
u u
k
u u
ϕ(u )
(i) CD
u u
k
u u
ϕ(u)
(j) BCD
k
(g) ABC
(f) BC
ρ(v )
v v v
u u
v v v
u u
ρ(v )
k
ϕ(u)
(k) ABCD
Fig. 2. The 11 infeasible patterns as a result of combining the four basic infeasible patterns Pattern A, Pattern B, Pattern C and Pattern D. Nodes enclosed in a dashed rectangle represent alternative positions of the same node.
Theorem 3. Let: G = (V, E) be a DAG with a width function w : V ∪ E → Q+ ; H, W ≥ 0; u and v be two independent nodes; and the sum of the widths of any two nodes be not larger than W . Then the RO inequality (7) is facet-defining for the DAG layering polytope. Proof. As background call LH G the derived graph with node set VL ⊆ V × {1, . . . , H} with unique nodes corresponding to each layer that q ∈ V could be placed and edge set EL where (p′ , q ′ ) ∈ EL ), p′ , q ′ ∈ VL and (p, q) ∈ E, where p′ (respectively q ′ ) corresponds to the placement of p (q) on some level 1, . . . , H. The dimension of the DAG Layering polytope is |VL | [5]. Let LH G = (VL , EL ). We construct |VL | subsets of VL which partially represent G, induce subgraphs of the LDAG LH G of width at most W , and whose incidence vectors satisfy (7) with equality and are linearly independent. We do this in five steps by choosing |VL | subsets of VL each corresponding to a different node λ ∈ VL . Step 1. For each node λui with ϕ(u) ≤ i ≤ k we choose the set {λui }, and for node λvj with k + γ ≤ j ≤ ρ(v) we choose the set {λvj }.
Branch-and-Cut Approach to the Directed Acyclic Graph Layering Problem
105
Step 2. If node z ∈ V is incident neither to u nor to v and is different from both u and v, then we can always choose the set {λuϕ(u) , λzi } for each ϕ(z) ≤ i ≤ ρ(z). Step 3. Let z be either u or v and let λzi be a node that has not been considered in a previous step. If z = u then we choose the set {λzi , λvρ(v) }; and if z = v then we choose the set {λzi , λuϕ(u) }. Step 4. Now consider node λzi with z ∈ / {u, v} and z incident to exactly one of nodes u and v. If there is an edge between z and u then we choose the set {λzi , λvρ(v) }. Otherwise if there is an edge between z and v then we choose the set {λzi , λuϕ(u) }. Step 5. Finally let λzi is a node with z incident to both u and v. The two cases are a) both u and v are predecessors of z, or b) both u and v are successors of z. We need to choose sets ensuring that they will not induce a subgraph of the LDAG LH G with an edge that does not point downwards. In case a) since ρ(v) > ρ(z), we can always choose the set {λzi , λvρ(v) }; in case b) since ϕ(u) < ϕ(z), we can always choose the set {λzi , λuϕ(u) }. For each node λui with ϕ(u) ≤ i ≤ k and each node λvj with k +γ ≤ j ≤ ρ(v) at Step 1 we have chosen a single one-element subset of VL containing it. Then at Steps 2-5 we have chosen a two-element subset for each other node of VL with a second element one of the nodes already placed in a one-element subset at Step 1. Clearly the incidence vectors of the chosen sets are linearly independent and satisfy (7) with equality. Moreover, we have chosen them to represent G partially and induce subgraphs of LH G of width at most W , given that the sum of the widths of any two nodes does not exceed W . The branch-and-cut algorithm for solving DAG layering which we propose consists of solving WHS-Layering in a branch-and-bound framework employing a cutting-plane algorithm at each node of the branch-and-bound tree for generating violated fixed-gap layering and RO inequalities. The cutting-plane algorithm consists of two parts: first, as a preprocessing step of the branch-and-cut algorithm we compute a list, c-list, of triples of two independent nodes u and v and the identifier of a pattern which is infeasible for u and v and any choice of k; then at each branch-and-bound node we simply scan c-list generating cuts based on violated fixed-gap layering and RO inequalities for a specific value of k. The computational time needed for building c-list is O(|V |2 ) and so is the size of c-list in the worst case. The main part of the preprocessing step for building c-list is a boolean function IsInfeasible which combines implementations of both PABOV E and PSAM E−LAY ER discussed above. IsInfeasible takes as input an ordered pair of independent nodes (u, v) and a number γ ∈ {0, 1, 2, 3} of a basic pattern. It returns true if it detects that basic pattern γ for nodes u and v leads to a layering of width greater than the upper bound W . Otherwise it returns false. In order to give a fast answer IsInfeasible considers only the widths of the layers where nodes u and v are placed and their adjacent layers as discussed above. IsInfeasible simply scans all DAG edges and all DAG nodes. For each edge whose both endpoints are related to (or coincide with) either u
106
Patrick Healy and Nikola S. Nikolov
or v IsInfeasible adds the width of the dummy nodes along it to the widths of the considered layers. Similarly for each node which is either u or v or a node related to any of u and v IsInfeasible adds their contribution to the widths of the considered layers. IsInfeasible works as a heuristic, i.e. it may not detect that a particular pattern would lead to a too wide pattern and return false. This is due to the fact that both problems Same-layer DAG layering and Above DAG layering are N P-complete. an infeasible pattern for the node pair (u, v) and IsInfeasible returns true. Otherwise IsInfeasible returns false.
4
Experimental Procedures and Results
The layering algorithm we have developed, ULair2 , follows the general framework of an ABACUS-based branch-and-cut algorithm to which we have added the cutting-plane algorithm discussed in the previous section. For computational evaluation of ULair we used a machine with an 800 MHz Intel Pentium III CPU. The LP solver required by ABACUS was the one of CPLEX 7.0. In all tests we assume that all real and dummy nodes have unit width. All the running times we report are in centiseconds (the time unit adopted by ABACUS). We applied ULair to the 1277 AT&T DAGs3 . To each test DAG we first applied Gansner et al.’s layering algorithm to compute a layering with minimum number of dummy nodes and stored its width and height as WGans (taking the dummy nodes into account) and HGans respectively. Then for each test DAG we ran ULair several times, each time with a different pair of upper bounds on the width and the height. Each pair of upper bounds had the form (fW WGans , fH HGans ) with fW , fH ∈ {0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4}. We observed that the running time of ULair is too long for some test DAGs and combinations of upper bounds, and we took 158 (12.37%) “hard-to-layer” DAGs out of the Test Set leaving 1119 DAGs. In the remainder of this section we present results of applying ULair to these 1119 AT&T DAGs. We experimented with disabling the cutting-plane generation in ULair. By doing this, we observed that for the majority of DAGs it took the same computational time (or slightly better) to solve DAG layering, but there were a few instances which could not be optimized in reasonable time. The number of such “bad” instances increases when the width bound becomes tighter and the height bound becomes larger. We have collected complete results for fH = 1.0 and fH = 1.1 and partial results for fH = 1.2 when cutting-plane generation is disabled. When fH ≥ 1.2 the running times for optimizing the “bad” instances becomes too long and much too resource-consuming, which shows that 2
3
In what follows, mention of ULair refers to the present branch-and-cut system, as opposed to a previous version of the system that relied on CPLEX’s mixed integer programming solver. We obtained the AT&T DAG set from http://www.graphdrawing.org.
Branch-and-Cut Approach to the Directed Acyclic Graph Layering Problem 600
1800 ULair without cutting-plane generation ULair with cutting-plane generation
ULair without cutting-plane generation ULair with cutting-plane generation
1600 Running Time (centiseconds)
500 Running Time (centiseconds)
107
400
300
200
1400 1200 1000 800 600 400
100 200 0
0 10
20
30
40
50 60 Node Count
70
80
90
100
(a) W = 0.9WGans , H = 1.1HGans
10
20
30
40
50 60 Node Count
70
80
90
100
(b) W = 0.7WGans , H = 1.2HGans
Fig. 3. Average running times of ULair with and without cutting-plane generation.
the generation of cutting planes in such cases is important for completing the computation in reasonable time. Two typical cases of how ULair runs with and without generation of cutting planes are illustrated in Figure 3. It can be seen how the cutting-plane generation eliminates some peaks in the average running time, which are present when the cutting-plane generation is disabled. We excluded from consideration one test DAG (attg.56.5) in Figure 3(a) and one test DAG (attg.94.0) in Figure 3(b), because the running times for layering them without generation of cutting planes were too large and did not fit nicely in the plots. The table in Figure 4 compares the running times of ULair with and without generation of cutting planes to the running times of the mixed integer programming solver (MIP) of CPLEX 7.0 for five DAGs which are hard to layer without generation of cutting planes. In order to build this table we constructed the
AT&T fH /fW attg. 23.37 1.2 / 0.7 1.2 / 0.8 29.2 1.2 / 0.7 1.2 / 0.8 32.1 1.2 / 0.7 1.2 / 0.8 56.5 1.2 / 0.7 1.2 / 0.8 94.0 1.2 / 0.7 1.2 / 0.8
Running time (centisec.) no cuts MIP cuts 45 11 15 330 9 17 235 174 29 172 186 115 16,919 85 24 524 78 137 9,852 60,000+ 945 60,000+ 60,000+ 945 38,478 4,237 585 9,009 3,882 631
Cutting planes A:1, AB:1, BC:3, ABC:4 A:6, AB:1, C:1, BC:4, ABC:9 AC:1, ABCD:17 A:3, BC:5, ABC:15, BCD:7 AB:1, ABC:8, ABCD:7 A:1, AB:9, AC:2, BC:2, ABC:1, ABCD:5 ABCD:94 ABCD:95 ABCD:157 ABCD:203
Fig. 4. Some DAGs which are hard to layer without cutting-plane generation.
108
Patrick Healy and Nikola S. Nikolov
WHS-Layering ILP model for each of the five DAGs and ran MIP for solving it, accepting its default settings. The first column contains the number of the DAG; the second column, fH /fW , contains the values of fH and fW respectively. The next three columns represent the CPU time for solving DAG layering (eventually reporting that there is no feasible solution) in centiseconds. Running times over 60,000 centiseconds (10 min) are presented as 60,000+. Column no cuts contains the running times of ULair when the generation of cutting planes is disabled. The next column, MIP, displays the running times of CPLEX’s MIP. Column cuts contains the running times of ULair when our cutting-plane strategy is applied. With a few insignificant exceptions the running times in column cuts are the best, which is a further evidence that our cutting-plane generation strategy helps for optimizing “hard” instances of DAG layering. The last column in Table 4, Cutting planes, contains for each infeasible pattern the number of generated cutting planes by ULair (when the cutting-plane generation is enabled). For example “AC:1, ABCD:17” means that one cutting plane corresponding to infeasible Pattern AC was generated and 17 cutting planes corresponding to infeasible Pattern ABCD were generated. The average number of cutting planes tends to be bigger for bigger values of fW and fixed fH when there is no optimal solution (on average up to 80 cutting planes per DAG with node count between 70 and 100), while in the case that an optimal solution was found average numbers of cutting planes greater than or equal to 2 appear only for tight bounds on the width and large height bounds. This suggests to us that our infeasible solution detection and cutting plane generation algorithms are in need of further development. It might be fruitful to consider triples of nodes instead of pairs as we currently do. While this implies a larger list of candidates to consider, the running time of checking a triple involves only a constant number of pairwise infeasibility checks. In Figure 5 we compare Gansner’s layering on a 62-node, 79-edge DAG to ULair’s layering with dimension bounds equal to 0.7 and 1.0 times Gansner’s width and height, respectively. Gansner’s layering has 39 dummy nodes (depicted as tiny rectangles along the edges), while ULair’s layering has 7 more dummy nodes, caused by tightening the width bound. After the layering phase, we applied exact crossing minimization and at the end manually adjusted the final position of the nodes and the final shape of the edges. Gansner’s layering resulted in 33 edge crossings, while ULair resulted into 30 edge crossings. Both drawings are drawn over the same drawing area. Because ULair’s layering has a smaller width, this allows larger distances between the nodes and as a result, ULair’s clearly has a better distribution of the nodes over the drawing area.
5
Conclusions
We have developed and implemented a branch-and-cut layering algorithm, ULair, which computes high quality layerings from aesthetic point of view. On the basis of our computational experience we conclude that ULair runs reasonably fast for DAGs having up to 100 nodes and it can be applied successfully when the quality
Branch-and-Cut Approach to the Directed Acyclic Graph Layering Problem
(a)
109
(b)
Fig. 5. (a) Gansner’s layering: height 10, width 23, 39 dummy nodes; (b) ULair’s layering: height 10, width 16, 46 dummy nodes
of a drawing is more important than fast computation. ULair can also provide a good initial layering for further manual adjustments and local improvements. With the current cutting-plane generation algorithm that considers only pairs of independent nodes, we have identified a number of DAGs where ULair performs faster than the mixed integer programming solver of CPLEX 7.0. By extending the cutting-plane generation algorithm, we believe that ULair can be made faster still. The performance of ULair can be further improved by employing tighter upper bounds on the sum of edge spans in bounded dimensions.
References 1. O. Bastert and C. Matuszewski. Layered drawings of digraphs. In M. Kaufman and D. Wagner, editors, Drawing Graphs: Method and Models, volume 2025 of LNCS, pages 87–120. Springer-Verlag, 2000. 2. J. Branke, S. Leppert, M. Middendorf, and P. Eades. Width-restriced layering of acyclic digraphs with consideration of dummy nodes. Information Processing Letters, 81(2):59–63, January 2002. 3. P. Eades and K. Sugiyama. How to draw a directed graph. Journal of Information Processing, 13(4):424–437, 1990. 4. P. Healy and N. S. Nikolov. How to layer a directed acyclic graph. In P. Mutzel, M. J¨ unger, and S. Leipert, editors, Graph Drawing: Proceedings of 9th International Symposium, GD 2001, volume 2265 of LNCS, pages 16–30. Springer-Verlag, 2002. 5. P. Healy and N. S. Nikolov. Facets of the directed acyclic graph layering polytope. In Ludˇek Kuˇcera, editor, Graph Theoretical Concepts in Computer Science: WG2002, LNCS. Springer-Verlag, (To appear.). 6. K. Sugiyama, S. Tagawa, and M. Toda. Methods for visual understanding of hierarchical system structures. IEEE Transaction on Systems, Man, and Cybernetics, 11(2):109–125, February 1981.
Geometric Systems of Disjoint Representatives⋆ Jiˇr´ı Fiala1 , Jan Kratochv´ıl1,⋆⋆ , and Andrzej Proskurowski2,⋆⋆⋆ Institute for Theoretical Computer Science† and Department of Applied Mathematics, Charles University, Prague {fiala,honza}@kam.mff.cuni.cz Department of Computer and Information Science, University of Oregon, Eugene [email protected] 1
2
Abstract. Consider a finite collection of subsets of a metric space and ask for a system of representatives which are pairwise at a distance at least q, where q is a parameter of the problem. In discrete spaces this generalizes the well known problem of distinct representatives, while in Euclidean metrics the problem reduces to finding a system of disjoint balls. This problem is closely related to practical applications like scheduling or map labeling. We characterize the computational complexity of this geometric problem for the cases of L1 and L2 metrics and dimensions d = 1, 2. We show that for d = 1 the problem can be solved in polynomial time, while for d = 2 we prove that it is NP-hard. Our NP-hardness proof can be adjusted also for higher dimensions.
1
Introduction
Take a universe X and a family of its subsets M = {Mi | i ∈ I, Mi ⊆ X}. The System of Distinct Representatives (SDR) for M selects from each Mi an element, such that sets are represented by distinct elements. Such assignment can be formally described by an injective mapping f : I → X satisfying the property f (i) ∈ Mi for all i ∈ I. Observe that such system can be equivalently formulated as a matching in bipartite graph, where vertices of the first block of the bi-partition correspond to the elements of X, the other vertices stand for the sets Mi and edges describe the incidence relation. The theory of Systems of Distinct Representatives is well known and very important for discrete optimization problems. Namely, in the case when the ⋆
⋆⋆ ⋆⋆⋆ †
The authors acknowledge support of joint Czech U.S. grants KONTAKT ME338 and NSF-INT-9802416 during visits of the first two authors to Eugene, OR, and of the third author to Prague. Research partially supported by Czech Research grant GAUK 158/99. Supported in part by the grant NSF-ANI-9977524. Supported by the Ministry of Education of the Czech Republic as project LN00A056.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 110–117, 2002. c Springer-Verlag Berlin Heidelberg 2002
Geometric Systems of Disjoint Representatives
111
family M and all its sets Mi are finite, the elegant Hall theorem [5] describes necessary and sufficient conditions for the existence of an SDR, and if it exists it can be found by a polynomial time algorithm (either the algorithm involving augmenting paths or the matching algorithm of Edmonds [3]). Though several generalizations of the concept have been studied, we believe that the concept of distant representatives is new. We assume that the universe X is equipped by a metric dist(a, b) and therefore we may ask for representatives that are sufficiently spaced in X. More formally: Definition 1. Given a parameter q > 0 and a family M = {Mi | i ∈ I} of subsets of X, a mapping f : I → X is called a System of q-Distant Representatives (Sq-DR) if (1) f (i) ∈ Mi for every i ∈ I, (2) dist(f (i), f (j)) ≥ q for every i, j ∈ I, i = j. The metric on the space X could be defined in several ways, for example: – The trivial metric: For arbitrary universe X we set dist(a, b) = 0 if a = b, and dist(a, b) = 1 otherwise. – The integral metric: X = N, dist(a, b) = |a − b|. – The graph metric: Take X = V (G) and set dist(a, b) to the length of the shortest path connecting vertices a and b in a graph G. – The plane Euclidean metric: X = R2 , distance is the length of the segment joining the points a and b in the plane. – The plane Manhattan distance is defined as the sum of coordinate differences |ax − bx | + |ay − by |. The universe X = R2 as in the previous case. Observe that in the case of trivial or integral or graph metric the System of q-Distant Representatives is equivalent to System of Distinct Representatives as far as q ≤ 1. This holds in slightly more general setting: Consider any universe X equipped by any metric for which dist(a, b) ≥ 1 whenever a = b. Then for q ≤ 1 the condition (2) merely says that f (i) = f (j), i.e., a System of q-Distant Representatives is a System of Distinct Representatives. For this case any further metric structure on X becomes irrelevant and in such a case an Sq-DR could be found by a polynomial-time algorithm. We address the computational complexity of the Sq-DR problem in [4] and show several NP-hardness results, mainly for the discrete spaces. Some cases provide a natural counterpart to the results of Aharoni and Haxell [1] who studied a more general concept of Systems of Disjoint Representatives on Hypergraphs. Though they derive necessary and sufficient conditions for the existence of such system on finite families M, the problem whether these conditions are satisfied is still NP-hard as we show in [4]. The aim of this paper is to show that for unit balls in the Euclidean plane the S1-DR problem is NP-hard for both Euclidean an Manhattan metrics. This is in contrast with the complexity of the corresponding Sq-DR problem for balls in the one dimensional Euclidean space, where it allows a polynomial-time algorithm.
112
2
Jiˇr´ı Fiala, Jan Kratochv´ıl, and Andrzej Proskurowski
Systems of Distant Representatives in the Euclidean Space
In this section we consider the case when the universe X is the d-dimensional Euclidean space Rd equipped with the Lp metric for some fixed p. (The Lp d metric is defined by the formula: distLp (a, b) = p j=1 |aj − bj |p ). Clearly, the collection M consists of sets of points. If all sets Mi are finite, we can transform such instance to a finite graph G (here vertices represent points, and pairs of them are adjacent when the corresponding points are at distance less than q) and look for 2-distant representatives in the graph metric. We omit for the moment this case and focus our attention on infinite sets Mi , namely unit diameter balls in Rd . From the computational complexity it is important that such infinite sets can be described in constant space, e.g. by the coordinates of the centers of the balls. Observe that in any Lp metric, two points a and b are at distance smaller than q, iff the two open balls of diameter q, one centered at a and the other at b, intersect. The Sq-DR problem for closed unit balls in Rd then has a nice geometric representation: replace each closed unit ball Mi of M by an open ball Mi′ of diameter 1+q and ask, whether each Mi′ can be assigned as a representative a ball of diameter q, completely placed inside Mi′ , all these representatives being pairwise disjoint. In the rest we use this representation M′ of the Sq-DR problem, rather than the original collection M. The reason is that in this representation we do not need to operate with the underlying distance: all essential properties are captured by the inclusion relation. A similar situation was considered for finite sets by Aharoni and Haxell in [1]. It is clear that such problems can naturally arise in practical applications like map labeling (for d = 2), where the sets Mi correspond to the possible label placement, and the disjoint representatives of diameter q correspond to the reserved places for labels. See [7,2] for hardness results on similar map labeling problems. The one-dimensional version of finding an Sq-DR for (unit) balls in R is equal to the following scheduling problem: Let a set I of tasks be given. These tasks require to be scheduled on one processor without preemption, such that each task is processed for the same time (q) and within the predetermined time bounds — the release date and the due date — that form intervals (ri , di ) (Mi = (ri + 2q , di − 2q )). The question is whether a feasible schedule exists. Clearly, the polynomial-time algorithm solving the scheduling problem due to Simons [8] provides also a solution for the Sq-DR problem on R with any Lp metric (the parameter p is irrelevant in the one-dimensional Euclidean space). We show in the next section that in the two-dimensional space (and hence in higher dimensions as well) the problem becomes NP-hard for both the Euclidean (L2 ) and the Manhattan (L1 ) metrics.
Geometric Systems of Disjoint Representatives
3
113
Systems of Distant Representatives in the Plane
In the Euclidean metric, balls correspond to disks, while in the Manhattan metric we get squares of diagonal length equal to the required diameter, and diagonals are parallel with the coordinate axes. For convenience, in the case of the Manhattan metric we consider that the plane and all its objects are rotated by π4 √ and scaled by the factor 2, hence all squares involved have side length 1 + q (in M′ ) or q (the representatives), and squares are oriented in the usual way. Theorem 1. The S1-DR problem is NP-hard for closed unit squares in the Manhattan metric. Proof. We show a reduction from the planar 3-SAT problem, whose NP-completeness was proved in [6]. An instance for this version of the satisfiability problem consists of a formula Φ = (V, C) in the conjunctive normal form, where each variable has one positive and two negative occurrences, each clause consists of two or three literals, and the incidence graph G of Φ is planar. The graph G has vertex set V (G) = V ∪ C and an edge (x, c) belongs to E(G) iff the clause c contains x or ¬x as a literal. The family M′ contains squares of side length 2. It can be split into three parts: one part represents clauses, the next variables, and the third part are connectors joining clause and variable gadgets together. The three-literal clause gadget consists of two squares of the same placement. It is clear, that only two of the four quadrants could be completely free whenever an S1-DR exists. Similarly, for a clause with only two literals we use three squares in the same position. The variable gadget is schematically depicted in Fig. 1. The dashed lines represent the unit grid in the plane. By black lines we depict 16 squares which we call active, the bold lines indicate two squares at the same position. The halftoned area cannot be used for a possible representative of an active square — it is fully occupied e.g. by four squares at the same position (hence each of them is represented by a different quadrant). The important property of the variable gadget is, that if any S1-DR exists, then either squares P1 and P2 or N1 and N2 will be partly occupied by the representatives for the vertex gadget. For example, if neither P1 nor P2 is hit by the representatives, then both N1 and N2 are, as depicted in Fig. 2. The small squares are representatives for the active squares of the gadget, their numbering corresponds to left-to-right ordering of the active squares from Fig. 1. The connector gadget corresponds to a chain of squares. These squares are grouped to triples and all squares in a triple have the same position (so Fig. 3 represents in fact 18 squares). Two consecutive triples in the chain share one quadrant. If we select two quadrants at the ends of the chain, like A and B in the figure, then at least one of them is fully occupied, if the chain has an S1-DR. The collection M′ contains for each clause c ∈ C a disjoint copy of the clause gadget placed on a grid according to the planar drawing of G. Similarly we place the variable gadgets for each variable x ∈ V . If a variable x occurs positively
114
Jiˇr´ı Fiala, Jan Kratochv´ıl, and Andrzej Proskurowski
N1 N2
P1 P2
Fig. 1. Variable gadget.
P1 P2
1 2 3 4 5
12 13 14 15 16 6
11 7 8 9 10
N1 N2
Fig. 2. S1-DR for the variable gadget corresponding to the truth assignment.
A B
Fig. 3. Connector gadget.
in a clause c, we include into M′ a connector joining a unique quadrant of the clause gadget representing c with a lower right quadrant of the square P1 related to the variable gadget of x. We similarly use left corners of N1 and N2 for the two (possible) occurrences of ¬x. The placement of all these objects in the plane follows the planar drawing of the graph G on the unit grid. All squares except those in the construction of the variable gadget coincide with the grid, so the entire collection M can be constructed such that its size is polynomial in the size of the formula Φ.
Geometric Systems of Disjoint Representatives
115
Assume that an S1-DR for M′ exists. No clause gadget cannot serve all its literals by a free quadrant, hence at least one these literals is forced to fully occupy the square P1 (for a positive literal) or some Ni (otherwise) of the corresponding variable gadget. As it was mentioned above, it is impossible to occupy both P1 and some Ni of the same gadget at the same time. Hence, we may define an assignment x = true if P1 is not occupied by the representatives for the active squares of the variable gadget for x and we put x = false otherwise. Such assignment is well defined and satisfies Φ. The construction of an S1-DR from a truth assignment of Φ is then straightforward. In the proof of Theorem 1 only few squares were placed out of the unit grid. We show, that in the case if all unit squares respect the grid, than the problem is solvable by a polynomial-time algorithm. Corollary 1. For any q of form k1 , k ∈ N it holds that the Sq-DR problem for closed unit squares can be solved in polynomial time, if all sides of squares in M coincide with the grid of span q. Proof. If any Sq-DR exists, then shift all the representatives to the left&downmost position. The resulting Sq-DR has the property that all representatives coincide with the grid points. Then we can without loss of generality restrict the universe X only to the grid points and solve the problem by finding a System of Distinct Representatives. We conclude this section by proving an analogous result for disks, i.e., for the Euclidean metric. Theorem 2. The S1-DR problem is NP-hard for unit disks in the Euclidean metric. Proof. The proof mimics the proof of the case of squares. We represent a planar formula Φ by a collection of disks that are partitioned into clause and variable gadgets, and connectors. As above we use the representation M′ , where representatives correspond to disks of diameter 1, while the disks in M′ have diameter 2. The first tool involved in the construction is the reserved halftoned area. Observe that the four disks depicted in Fig. 4 a) allow an S1-DR only as the four halftoned disks. The connectors are depicted in Fig. 4 b). In no S1-DR of the connector gadget both disks A and B may remain simultaneously empty. The vertex gadget is illustrated in the part c). As in the previous proof, it is impossible to find representatives for the vertex gadget where some Pi remains free together with some Nj . Similarly, if the disk P1 remains empty, the corresponding variable will be assigned the true value. Finally, clause gadgets are shown in the section d). At least one of the three or two, resp., dashed disks cannot be left free to saturate the adjacent connector’s end.
116
Jiˇr´ı Fiala, Jan Kratochv´ıl, and Andrzej Proskurowski
B a)
c)
b)
P1
N1
P2
N2
d) A Fig. 4. Gadgets for the S1-DR problem on disks.
The entire discussion follows in the exactly same manner as in the case of squares.
4
Conclusion
In higher dimensions, the construction of connectors and variable and clause gadgets is similar as in the plane. We avoid it here due to space limitations and a somewhat technical aspect of the argument. We also believe that both above constructions can be adjusted for other fixed values of q < 1. We present as an open problem what is the computational complexity for the Sq-DR geometric problem with the Euclidean or Manhattan metrics for q in the range (1, ∞). Finally, we believe that a uniform proof can be derived for the NP-hardness of the Sq-DR problem for unit balls in the d-dimensional Euclidean space for all Lp metrics (q > 0, d ≥ 2, p ≥ 1), It also remains as an open question whether the Sq-DR problem for unit balls belongs to the class NP. It is not straightforward to see whether the coordinates of the representatives — if they exist — can be described and verified in polynomial space and time.
References 1. Aharoni, R., P. Haxell, Hall’s theorem for hypergraphs, J. Graph Th. 35, (2000), pp. 83–88. 2. Doddi S., M. V. Marathe, A. Mirzaian, B. M. E. Moret, B. Zhu, Map labeling and its generalizations. Proc. 8th ACM-SIAM Symp. on Discrete Algorithms, (1997), pp. 148–157. 3. Edmonds, J., Paths, trees and flowers, Can. J. Math. 17, (1965), pp. 449–467. 4. Fiala, J., J. Kratochv´ıl, A. Proskurowski, Systems of sets and their representatives, manuscript 2002.
Geometric Systems of Disjoint Representatives
117
5. Hall, P., On representatives of subsets, J. London Math. Soc. 10, (1935), pp. 26– 30. 6. Kratochv´ıl, J., A special planar satisfiability problem and a consequence of its NP-completeness, Discrete Appl. Math. 52, (1994), pp. 233–252. 7. Marks, J., S. Shieber, The computational complexity of cartographic label placement, Technical Report TR-05-91, Harvard CS, 1991. 8. Simons, B., A fast algorithm for single processor scheduling, Proc. 19th Symp. Foundations of Computer Science, (1978), pp. 246–252.
An Efficient Fixed Parameter Tractable Algorithm for 1-Sided Crossing Minimization⋆ Vida Dujmovi´c and Sue Whitesides School of Computer Science, McGill University, 3480 University St., Montreal, Qu´ebec, Canada H3A 2A7, {vida, sue}@cs.mcgill.ca Abstract. We give an O(φk · n2 ) algorithm for the 1-Sided Crossing Minimization problem, thus showing that the problem is Fixed Parameter Tractable. The constant φ in the running time is the golden ratio √ φ = 1+2 5 ≈ 1.618. The constant k is the parameter of the problem: the number of allowed edge crossings.
1
Introduction
A common method for drawing directed acyclic graphs is to produce layered drawings or hierarchical drawings as introduced by Tomii et al. [17], Carpano [1], and Sugiyama et al. [16]. In these drawings, the vertices are arranged on two or more “layers”, i.e. on parallel horizontal lines, and edges are drawn straight between vertices on adjacent layers. Edges between vertices on the same layer are not permitted, and no point between layers may lie on more than two edges. Layouts of this kind have applications, for example, in visualization, in DNA mapping, and in row-based VLSI layout. The readability of layered drawings is believed to depend crucially on the number of edge crossings. Once vertices have been assigned to layers, this number is determined by the orderings of the vertices within the layers. Unfortunately, the problem of choosing vertex orderings that minimize the number of edge crossings in layered drawings is in fact an NP-complete problem [12] even if there are only two layers [11]. The problem of choosing vertex orderings that minimize the number of edges whose removal leaves the graph planar is also NP-complete, even for two layers [10]. Most techniques for producing layered drawings first assign vertices to layers (sometimes this is determined by the context), and then do a layer-by-layer sweep. A permutation π1 for the vertices in the top layer L1 is chosen and fixed. Then for each succeeding layer Li , a permutation πi is sought that keeps to a minimum the number of edge crossings among the edges between Li−1 and Li . A key step in this method is to minimize crossings between two adjacent layers when the ordering on one layer is fixed. This problem is called 1-Sided Crossing Minimization. Unfortunately, the 1-Sided Crossing Minimization problem is also NP-complete [11]. The problem is NP-complete even for ⋆
Research supported by FCAR and NSERC.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 118–129, 2002. c Springer-Verlag Berlin Heidelberg 2002
A Fixed Parameter Tractable Algorithm for 1-Sided Crossing Minimization
119
graphs with only degree-1 vertices in the fixed layer and vertices of degree at most 4 in the other layer [14], i.e. for a forest of 4-stars. The 1-Sided Crossing Minimization problem is the focus of this paper. Many heuristics have been proposed (e.g. [19,16,9,11,6,2,18]). J¨ unger and Mutzel [13] gave an exact integer linear programming algorithm for the 1-Sided Crossing Minimization problem. They also surveyed heuristics and made performance comparisons with optimal solutions generated by their methods. They reported that the iterated barycentre method of Sugiyama et al. [16] performs best in practice. However, from a theoretical point of view the median heuristic of Eades and Wormald [11]√is a linear 3-approximation algorithm, whereas the barycentre heuristic is a Θ( n)-approximation algorithm. When only a small number, k, of edge crossings is acceptable, then an algorithm for 1-Sided Crossing Minimization whose running time is exponential in k but polynomial in the size of the graph may be useful. The theory of parameterized complexity [5] addresses complexity issues of this nature, in which a problem is specified in terms of one or more parameters. Such a problem with input size n and parameter size k is fixed parameter tractable, or in the class FPT, if there is an algorithm to solve the problem in f (k) · nα time, where α is a constant independent of k and n, and f is an arbitrary function dependent only on parameter k. A problem in FPT is thus solvable in polynomial time for any fixed value of k. The more general h-Layer Crossing Minimization problem as well as the related h-Layer Planarization problem have been studied from the fixed parameter tractability point of view in [8]. Here h represents the number of layers and planarization means to remove some number k of edges so that the remaining graph can be drawn without crossings (see [10]). It has been proven in [8], using bounded pathwidth techniques, that both these general problems (which include 1-Sided Crossing Minimization) are in the class FPT. Unfortunately, the pathwidth-based approach is only of theoretical interest, since the running 3 time of the algorithms is O(232(h+2k) n). In [7], other FPT techniques are used k to derive an O(k · 6 + |G|) time algorithm for 2-Layer Planarization of a graph G, and an O(3k · |G|) time algorithm for 1-Layer Planarization. In this paper, we give an algorithm for 1-Sided Crossing Minimization that runs in O(φk |L2 |2 + |L1 ||L2 |) time, where L2 is the set of vertices on the free layer where the permutation π2 of vertices is to be chosen, L1 is the set of vertices on the fixed layer where the permutation π1 of vertices is fixed, and the constant φ is the golden ratio. The algorithm is based on the FTP technique called Bounded Search Tree. This technique relies on exploring some search space, and then proving that its size depends only upon the parameter k. The search space thus becomes constant size and the algorithm is then polynomial time for each fixed k. The remainder of this paper is organized as follows. After definitions and preliminary results in Section 2, we study properties of optimal drawings in Section 3. Our algorithm for the 1-Sided Crossing Minimization problem is then given in Section 4.
120
2
Vida Dujmovi´c and Sue Whitesides
Problem Statement, Notation, and Some Facts
A graph G = (V, E) with vertex set V and edge set E ⊆ V × V is called bipartite if there isa partition of V into two disjoint non-empty sets L1 and L2 such that V = L1 L2 and E ⊆ L1 × L2 . The number of vertices and edges of G are respectively denoted by n = |V | and m = |E|. Let dv denote the degree of a vertex v. We assume dv ≥ 1. In a 2-layer drawing of a graph G = (L1 , L2 ; E), the vertices in L1 and L2 are positioned on two distinct parallel lines (layers), and the edges are drawn straight. Since edges are not allowed within a layer, G must be bipartite. Let L1 denote the top, fixed layer, whose vertex ordering π1 is fixed. Let L2 denote the bottom, free layer, whose vertices are free to be permuted. We study the following problem: Problem:1-Sided Crossing Minimization Instance: a bipartite graph G = (L1 , L2 ; E), an integer k, and a fixed ordering π1 for the vertex set L1 on the top layer. Question: Is there a 2-layer drawing of G that respects π1 and that has at most k crossings?
L1 , π1 f ixed
L2 , π2 f ree Fig. 1. A 2-layer drawing. The ordering π1 of L1 is fixed. Vertices of L2 are free.
From now on, we assume that input graphs are bipartite, with minimum degree at least 1, and that an ordering π1 has been specified for the top layer. We do not consider multiple edges, although these are easy to handle. Let G, π1 , k denote an instance of the 1-Sided Crossing Minimization problem, and let (G, π1 , π2 ) denote a combinatorial representation of a 2-layer drawing of G, with π1 and π2 giving the permutations for the vertices on layers L1 and L2 , respectively. Let the number of crossings in the drawing (G, π1 , π2 ) be denoted by cr(G, π1 , π2 ), and let the minimum possible number of crossings subject to the vertices of L1 being ordered by π1 be denoted by cr(G, π1 , πopt ). Note that cr(G, π1 , πopt ) = minπ2 {cr(G, π1 , π2 ) }, where π2 ranges over all permutations for L2 . Let v < w denote an ordered pair of vertices on the same layer, and let v, w denote an unordered pair of vertices. Sometimes it is convenient to denote unordered pairs of vertices by (v, w), which is also used to denote an edge. The meaning will be clear from the context. Throughout the paper, the term “pair” refers to a pair of distinct objects.
A Fixed Parameter Tractable Algorithm for 1-Sided Crossing Minimization
121
Fact 1. [4] Two edges (v, v ′ ) and (w, w′ ), where v, w ∈ L2 and v ′ , w′ ∈ L1 , cross in a 2-layer drawing if and only if v < w and w′ < v ′ , or w < v and v ′ < w′ . Fact 2. [4] For vertices v and w in the free layer L2 , the number of crossings of the edges incident to v with the edges incident to w is completely determined by the relative ordering of v and w. Definition 1. Consider a problem instance G, π1 , k , and let v and w be vertices in L2 . The crossing number cvw is the number of crossings that edges incident with v make with edges incident with w in drawings having v < w; the crossing number cwv is for w < v. Fact 3. [4] The total number of crossings in a 2-layer drawing (G, π1 , π2 ) is: cr(G, π1 , π2 ) = cvw , (1) ∀v 0. Note that natural ordering is only defined for pairs of suited vertices. For general pairs, we say that v < w is the preferred ordering for a pair v, w if cvw < cwv . Thus the natural ordering is the preferred ordering for non-trivial suited pairs. The following Lemma is the basis for our algorithm. Lemma 1. For fixed π1 , let Γopt = (G, π1 , πopt ) be a drawing with the minimum possible number of crossings. Then all suited pairs appear in πopt in their natural ordering. To prove Lemma 1 the following straight forward lemma will be useful. Lemma 2. For 1 ≤ i ≤ |L2 |, let vi denote the vertex in the ith position in π2 of some drawing (G, π1 , π2 ) with π1 fixed. Moving any vertex vi ∈ L2 from its starting position i across the t consecutive vertices vi+1 , vi+2 , . . . , vi+t to the right creates a new drawing (G, π1 , π2′ ) with: cr(G, π1 , π2′ ) = cr(G, π1 , π2 ) +
t j=1
(cvi+j vi − cvi vi+j ).
(3)
Similarly, if vi is moved to the left over t consecutive vertices, then the above summation is from j = −1 to j = −t and the sign in front of the summation is “−”. Proof. Assume, without loss of generality, that vertex vi moves to the right across t consecutive vertices in (G, π1 , π2 ). This creates a new drawing (G, π1 , π2′ ). The only pairs of vertices in (G, π1 , π2 ) whose relative ordering changes in (G, π1 , π2′ ) are the pairs vi , vj for i + 1 ≤ j ≤ i + t. Hence by Fact 2, these are the only pairs whose crossing number might change. In particular, the crossing number for a pair vi , vj for j in the range [i + 1, i + t] changes from cvi vj to cvj vi . Substituting these changes into Equation 1 of Fact 3 gives Equation 3 above. ✷ Now we give the proof of Lemma 1. Proof of Lemma 1: The proof is by contradiction. Assume that in Γopt = (G, π1 , πopt ) there is a suited pair v, w whose ordering in πopt is not its natural
A Fixed Parameter Tractable Algorithm for 1-Sided Crossing Minimization
123
ordering. Note that v and w are not degree-1 vertices with a common neighbor, as both orderings would be natural in that case. Assume that v < w is the (unique) natural ordering of v, w. By Fact 5 the crossing number cvw = 0 and the crossing number cwv > 0. For a contradiction, we now prove that either v or w can be moved in Γopt such that the resulting drawing Γnew = (G, π1 , πnew ) satisfies cr(Γnew ) < cr(Γopt ). Let i and j denote the positions of w and v, respectively, in πopt . Here i < j since v and w appear in the order w < v in πopt . If |j − i| = 1, we can interchange v and w without affecting any other pair of vertices in Γopt . Equation 3 in Lemma 2 gives the number of crossings in the resulting drawing Γnew : cr(Γnew ) = cr(Γopt ) − cwv + cvw = cr(Γopt ) − cwv + 0. Since cwv > 0, we have cr(Γnew ) < cr(Γopt ), which contradicts the optimality of Γopt . If |j − i| > 1, let ui+1 , ui+2 , . . . , uj−1 denote the vertices between w and v in πopt , listed in order of appearance in πopt . Regard these vertices as a frozen block U inside which no changes are made. See Fig. 3. rv
lv
L1 , π1 f ixed
L2 , π2 f ree w
U
v
Fig. 3. Proof of Lemma 1
According to Lemma 2, moving v or w from one side of block U to the other may only affect the crossing number contributions of pairs of the form u, w and u, v for u ∈ U . Let cU p denote the number of crossings that the edges incident to vertices in U have with the edges incident to a vertex p to the right of U : cU p = Σu∈U cup . Similarly, let cpU denote this number of crossings when p lies to the left of U . Since Γopt is optimal, we claim we have the strict inequality (4) cU v < cvU . Otherwise, we could move v to the left side of U and then interchange v with w to obtain a drawing with the following total number of crossings: cr(Γnew ) = Γopt − cU v + cvU − cwv + 0. Since cwv > 0, if cU v ≥ cvU , then cr(Γnew ) < cr(Γopt ), a contradiction. observation: To conclude the case |j − i| > 1, and hence the proof of the lemma, it suffices to show that cU v < cvU implies cwU ≥ cU w , for this means
124
Vida Dujmovi´c and Sue Whitesides
we can move w to the right side of U without increasing the total number of crossings in the resulting drawing and then interchange w and v to produce a drawing with fewer crossings than Γopt . This gives a contradiction, and so proves that the assumption that πopt contains a suited pair not ordered by its natural ordering cannot hold. To establish the desired inequality cwU ≥ cU w , we first derive some intermediate inequalities for cU v , cvU , cwU , and cU w in terms of sizes of the following sets: ER = the set of edges in Γopt with one endpoint in U and the other endpoint strictly greater than rv in the ordering π1 ; EL = the set of edges with one endpoint in U and the other endpoint strictly less than rv in the ordering π1 ; Nv = the neighbors of v; and Nw = the neighbors of w. By the definition of ER , all the vertices in Nv occur in π1 strictly before the L1 endpoint of each edge in ER . By the definition of EL and by the fact that v, w is a suited pair with the natural ordering v < w, the vertices in Nw occur in π1 strictly after the L1 endpoints of the edges in EL . Fact 2 implies the following inequalities for crossing numbers: cU v ≥ dv · |ER | : The edges incident to v and the edges in ER all pairwise intersect, creating dv · |ER | crossings. Since ER is a subset of the edges incident to U , cU v ≥ dv · |ER |. cvU ≤ dv · |EL | : This holds because no edge incident to v crosses any edge incident to U that is not in EL . cwU ≥ dw · |EL | : The edges incident to w and the edges in EL all pairwise intersect, so cwU ≥ dw · |EL |. cU w ≤ dw · |ER | : This holds because no edge incident to w intersects any edge incident to U that is not in ER . Recall inequality (4), that cU v < cvU . Since cU v ≥ dv ·|ER | and cvU ≤ dv ·|EL |, we have dv · |ER | ≤ cU v < cvU ≤ dv · |EL |, which implies that |ER | < |EL |. This, and the fact that cwU ≥ dw · |EL |, and the fact that cU w ≤ dw · |ER | together imply that cwU > cU w . By the observation above, this completes the proof. ✷
4 4.1
An Efficient FPT Algorithm The Bounded Search Tree Approach for the Algorithm
One of the basic methods for developing FPT algorithms is the method of bounded search trees (BST) (see Downey and Fellows [5, Chapter 3.1]). In this method one builds a search tree which is exhaustively traversed for a solution. The critical observation for many parameterized problems is that, while the computation done at each node of the tree may depend on the problem size, the size of the tree itself depends only on the parameters. In this section we present an FPT algorithm for the 1-Sided Crossing Minimization problem based on the bounded search tree approach. The key observations for building a BST for this problem lie in Lemma 1 and Fact 4. Here is an overview of our algorithm.
A Fixed Parameter Tractable Algorithm for 1-Sided Crossing Minimization
125
Lemma 1 allows us, at the start, to fix the relative ordering of each nontrivial suited pair of vertices in L2 according to its unique natural ordering. The remaining unordered pairs of vertices in L2 are either trivial suited pairs, or unsuited pairs which will each, by Fact 4, create a crossing no matter which relative ordering is chosen. We build a bounded search tree (i.e., a BST) based on the unsuited pairs. (It turns out that the trivial pairs neighbours can be dealt with later in the algorithm.) The input to every node of the BST is a budget B giving the remaining number of allowed edge crossings, and a relation D containing all pairs of L2 ordered thus far. We will formally define relation D shortly. At each node of the BST some unordered pair (v, w) is chosen (i.e. a pair not in D) such that cvw = cwv . Then the node branches to two recursive subproblems. In one branch, the ordering of (v, w) is fixed to v < w and the budget B is reduced by cvw . In the other branch the ordering of (v, w) is fixed to w < v and B is reduced by cwv . Since we only work with unsuited pairs in building the tree, we know that cvw ≥ 1 and cwv ≥ 1. Therefore, since the initial budget B = k, the height of the BST is at most k. As a matter a fact the situation is better than that, for two reasons. Firstly, since cvw = cwv , then either cvw or cwv is at least 2, so one of the two branches of the BST node reduces B by at least 2. Secondly, since < is a transitive relation, fixing an ordering of the pair (v, w) at a node of the BST may in fact impose an ordering of another as yet unordered pair (p, q) in the relation D at that node. Hence B can be reduced not only by cvw but also by either cpq or cqp , depending on which relative ordering is imposed on (p, q). 4.2
The Algorithm
The following definitions will be useful for the description of the algorithm. Let D be a directed acyclic graph (digraph) that represents a binary relation “ < ” on the set of vertices L2 . In particular, the vertices of L2 are represented by nodes of a digraph D and an ordered pair of vertices v < w is represented by a directed edge from v to w (denoted henceforth by vw) in D. The digraph D is stored as an |L2 | × |L2 | matrix. We use D to denote both the set of pairs in the current binary relation “ < ” and the associated acyclic directed graph that represents these pairs as directed edges. The algorithm labels nodes in the BST with digraphs. The digraph associated with the root will be transitively closed, acyclic, and directed. As the algorithm progresses, it computes a digraph label for each child node it generates in the BST by choosing a directed edge to add to the digraph of the parent and then taking the transitive closure of this. The following algorithm solves the 1-Sided Crossing Minimization problem. Algorithm: 1-Sided Crossing Minimization Input: G, π1 , k Output: πopt if G, π1 , k is a YES instance, else NO
126
Vida Dujmovi´c and Sue Whitesides
Step 0. Computing crossing numbers: Compute the crossing numbers cvw and cwv for all pairs of vertices in L2 , stopping the computation of a particular crossing number as soon as it is known to exceed k. Step 1. Checking for extreme values: Compare k with the upper and lower bound as per Fact 3. if k < Σ(v,w) min(cvw , cwv ) then output NO and HALT; if k ≥ Σ(v,w) max(cvw , cwv ) then output an arbitrary π2 and HALT. Step 2. Initialization: Precompute the following information required by the bounded search tree. C = {(v, w)|cvw = cwv }; D0 = a directed acyclic graph (V, E), where V = L2 , and the directed edges vw ∈ E correspond to the naturally ordered pairs (v, w) that satisfy cvw = 0 and cwv = 0. (It is easy to check that D0 is transitively closed.); B0 = initial budget = k−Σvw∈D0 cvw −Σ(v,w)∈C cvw . Note that Σvw∈D0 cvw = 0. Also note that we reduce the budget k by the eventual cost of the pairs in C even though these pairs do not appear in D0 . Step 3. Building the search tree: A node of the search tree has at most two children. Each node has a label (D, B). The label D of a node represents a “possible” partial solution, i.e. a partial ordering of vertices of L2 . The label B represents the remaining budget for crossings. For instance the label of the root is: D= D0 and B = B0 . We now build the search tree as follows. Label the root of the tree with (D, B) where D = D0 and B = B0 . In general, for a non-leaf node labeled (D, B), choose a pair (v, w) such that D contains no edge joining v and w and such that cvw = cwv . A pair (v, w) is thus an unordered pair not in C. In any ordering π2 , the pair (v, w) is ordered as either vw or wv, so we create at most two children (D1 , B1 ) and (D2 , B2 ) of the non-leaf node (D, B) corresponding to these two possibilities. No child is created if its budget would be negative. Thus a node labeled (D, B) is a leaf if and only if, either it does not have an unordered pair (v, w) ∈ C; or there remains any pair (v, w) for which both B1 and B2 are negative. For a non-leaf node (D, B), we label one of its two children by (D1 , B1 ) where: D1 = transitive closure of D ∪ vw, and B1 = B − cvw − pq cpq . Here D ∪vw represents the addition of directed edge vw to D. The summation in B1 is over the directed edges that are added to D ∪ vw by the transitive closure and that have cpq = cqp . That is, the sum is over pq s.t. pq ∈ D1 and pq ∈ D ∪vw and cpq = cqp . Similarly, we label the other child of node (D, B) with (D2 , B2 ), where: D2 = transitive closure of D ∪ vw, and B2 = B − cvw − pq cpq . If a leaf is created whose label D has the property that ∀(v, w) if vw ∈ D and wv ∈ D then (v, w) ∈ C, then output π2 = topological sort of D. Also, update the minimum number of crossings found so far to k − B, where B is the budget of the leaf, and update the best ordering so far to π2 . We call such a node a solution leaf.
A Fixed Parameter Tractable Algorithm for 1-Sided Crossing Minimization
127
If after exploring the entire tree, no solution leaf is found, output NO and HALT; otherwise, output the best ordering found, which is πopt , and HALT. Remarks. In Step 0, we stop computing cvw as soon as it becomes k + 1, even though cvw may be bigger than that. This is because a child with v < w would have a negative budget. Hence it suffices to know that cvw ≥ k + 1. Step 3 of the algorithm effectively creates and explores the search tree simultaneously. This can be done by depth-first search, or by breath-first search. The depth-first way requires less space and is thus the preferred choice. Also notice that, when creating a child by choosing, say, to order v and w as vw, we reduce the budget for the child by an amount computed not only for the ordered pair vw, but also for the pairs that are newly ordered by the transitive closure of D ∪ vw. However, we only do this for newly ordered pairs whose two crossing numbers are not the same. Those whose crossing numbers are the same have already been accounted for in B0 . Theorem 6. Given a bipartite graph G = (L1 , L2 ; E), a fixed permutation π1 of L1 , and an integer k, algorithm 1-Sided Crossing Minimization(G, π1 , k) determines in O(φk · |L2 |2 + |L1 ||L2 |) time if cr(G, π1 , πopt ) ≤ k and if yes produces a 2-layer drawing (G, π1 , π2 ) with the optimum number of crossings. The constant √ φ in the running time is the golden ratio φ = 1+2 5 ≈ 1.618. Proof. Step 3 of the algorithm creates and explores the search tree simultaneously. For every node (D, B) of the search tree we maintain the following two invariants: (i) D is a transitively closed, directed, acyclic graph; (ii) The budget B at node (D, B) is B = k − vw∈C cvw − vw∈D&vw∈C cvw . This is true for the root node (D0 , B0 ). Suppose this is true for a node labeled (D, B). At this node, the algorithm chooses an unordered pair (v, w) with cvw = cwv . This pair is used to create up to two child nodes. We claim that both D ∪ vw and D ∪ wv are acyclic. Suppose, on the contrary, that D ∪ vw contains a directed cycle. Then D must contain a directed path from w to v. Since D is transitively closed, it contains edge wv, contradicting the fact that (v, w) is unordered in D. Similarly for D ∪ wv. Since the transitive closure of a directed acyclic graph is again acyclic, the graph labels D1 , D2 for any child nodes created at a node labeled D are again transitive and acyclic. Thus all the graph labels in the search tree are directed, acyclic, and transitively closed. The fact that labels B1 and B2 agree with formula (ii), follows directly from the formulas used to compute these two labels from the parent label B in Step 3 of the algorithm. As the tree is built, either a solution leaf is found, or the tree is completely explored without finding such a leaf. A solution leaf (D, B) has, by definition, a non-negative budget B. By the invariant (ii), the cost of all the crossings arising from the ordered pairs in D has been taken into account. By the definition of a solution leaf, all pairs (v, w) not ordered by directed edges in D are in C and satisfy cvw = cwv ; hence the total cost directly attributable to them has already been deducted from the initial budget k. Hence any topological sort of D produces a total ordering consistent with D and having total cost k−B, where
128
Vida Dujmovi´c and Sue Whitesides
0 ≤ B ≤ k. By the invariant (i), the label D of every node of the search tree is an acyclic graph and it necessarily has a topological sort. Based on this argument, a solution leaf (D, B) encodes an ordering π2 such that cr(G, π1 , π2 ) ≤ k. It is not difficult to verify that the solution leaves of the BST implicitly store all the orderings π2 for which cr(G, π1 , π2 ) ≤ k and in which all the suited pairs are ordered by their natural ordering. Lemma 1 implies that in order to decide if G, π1 , k is a YES or NO instance it is enough to consider only such orderings π2 . Therefore, if there is an ordering π2 such that cr(G, π1 , π2 ) ≤ k the algorithm finds one. In fact, since the algorithm updates the best solution found so far, when it terminates it outputs an optimal ordering πopt . We now discuss the running time of the algorithm. Only for an unordered unsuited pair v, w that has cvw = cwv are child nodes created, of which there are at most two. Therefore, in one child node the budget is reduced by at least 1 and in the other by at least 2. A node with B = 0 must be a leaf node, because any child of such a node would have a negative budget. Therefore, no further branching is allowed. At a node for which budget B = 1, at most one child can have a budget B1 that is non-negative, and in this case, B1 = 0 and the child must be a leaf. Thus a recurrence relation that generates an upper bound for the number of nodes in this search tree is: sB = sB−1 + sB−2 + 1 for k ≥ 2; s0 = 1, s1 = 2. It can be verified by induction that for B ≥ 0, sB = FB+2 + FB+1 − 1 where FB is the B-th Fibonacci number. From the bound on Fibonacci numbers and k k+2 − 1 < 1.9 · φk . Thus the given that B0 ≤ k, it follows that sB0 < φ√5 + φ√+1 5 search tree has O(φk ) nodes. The time taken at each node of the search tree is dominated by updating a transitive closure of its label D after insertion of one ordered pair v < w (or w < v). Updating the transitive closure after one insertion can be done in O(|L2 |2 ) time [3]. These updates are needed to generate the labels for the children, of which there are at most two. Thus the time taken in the third step of the 1-Sided Crossing Minimization algorithm is O(φk · |L2 |2 ). It can be shown that the time taken in steps 0 - 2 of the algorithm is no more than O(k · |L2 |2 + |L1 ||L2 |). Thus the total running time of the algorithm is O(φk · |L2 |2 + |L1 ||L2 |). ✷
5
Conclusion
We have proved that the 1-Sided Crossing Minimization problem is fixed parameter tractable by presenting a very easy-to-implement FPT algorithm for its solution. Moreover, the algorithm finds a drawing with the smallest possible number of crossings in the case that this number does not exceed k. The exponential part of the running time of the algorithm is 1.618k . In many instances the base of this exponent will be even smaller. The reason is that a pair of vertices v, w will often have both crossing numbers cvw and cwv bigger than 1, or at least one of them bigger than 2. Each time a node of the BST branches on such a pair of vertices, the resulting search tree will be even smaller.
A Fixed Parameter Tractable Algorithm for 1-Sided Crossing Minimization
129
An interesting investigation for future research would be to compare experimentally the performance of the two known methods for optimal 1-Sided Crossing Minimization, namely, integer linear programming [13] versus our FPT algorithm.
References 1. M. J. Carpano. Automatic display of hierarchized graphs for computer aided decision analysis. IEEE Trans. Syst. Man Cybern., SMC-10(11):705– 715, 1980. 2. C. Catarci. The assignment heuristic for crossing reduction. IEEE Trans. on Systems, Man, and Cybernetics, 25(3), 1995. 3. T. Corman, C. Leiserson, and R. Rivest. Introduction to Algorithms. MIT Press, 1990. 4. G. Di Battista, P. Eades, R. Tamassia, and I. G. Tollis. Graph Drawing: Algorithms for the Visualization of Graphs. Prentice-Hall, 1999. 5. R. G. Downey and M. R. Fellows. Parametrized complexity. Springer, 1999. 6. S. Dresbach. A new heuristic layout algorithm for directed acyclic graphs. In U. Derigs, A. Bachem, and A. B. A. Drexl, editors, Operations Research Proceedings (1994), pages 121–126. Springer, 1995. 7. V. Dujmovi´c, M. Fellows, M. Hallett, M. Kitching, G. Liotta, C. McCartin, N. Nishimura, P. Ragde, F. Rosemand, M. Suderman, S. Whitesides, and D. R. Wood. A fixed-parameter approach to two-layer planarization. In Mutzel [15], pages 1–15. 8. V. Dujmovi´c, M. Fellows, M. Hallett, M. Kitching, G. Liotta, C. McCartin, N. Nishimura, P. Ragde, F. Rosemand, M. Suderman, S. Whitesides, and D. R. Wood. On the parameterized complexity of layered graph drawing. In Proc. 9th European Symposium on Algorithms (ESA 2001), volume 2161 of Lecture Notes in Comput. Sci., pages 488–499. Springer, 2001. 9. P. Eades and D. Kelly. Heuristics for drawing 2-layered networks. Ars Combin., 21(A):89–98, 1986. 10. P. Eades and S. Whitesides. Drawing graphs in two layers. Theoret. Comput. Sci., 131(2):361–374, 1994. 11. P. Eades and N. C. Wormald. Edge crossings in drawings of bipartite graphs. Algorithmica, 11(4):379–403, 1994. 12. M. R. Garey and D. S. Johnson. Crossing number is NP-complete. SIAM J. Algebraic Discrete Methods, 4(3):312–316, 1983. 13. M. J¨ unger and P. Mutzel. 2-layer straightline crossing minimization: performance of exact and heuristic algorithms. J. Graph Algorithms Appl., 1(1):1–25, 1997. 14. X Mu˜ noz, U Unger, and I Vrˇto. One sided crossing minimization is np-hard for sparse graphs. In Mutzel [15]. to appear. 15. P. Mutzel, editor. Proc. Graph Drawing: 9th International Symposium (GD’01), volume 2265 of Lecture Notes in Comput. Sci. Springer, 2001. 16. K. Sugiyama, S. Tagawa, and M. Toda. Methods for visual understanding of hierarchical system structures. IEEE Trans. Systems Man Cybernet., 11(2):109– 125, 1981. 17. N. Tomii, Y. Kambayashi, and S. Yajima. On planarization algorithms of 2-level graphs. Papers of tech. group on elect. comp., IECEJ, EC77-38:1–12, 1977. 18. V. Valls, R. Marti, and P. Lino. A branch and bound algorithm for minimizing the number of crossing arcs in bipartite graphs. J. Operational Res., 90:303–319, 1996. 19. J. N. Warfield. Crossing theory and hierarchy mapping. IEEE Trans. Systems Man Cybernet., SMC-7(7):505–523, 1977.
Simple and Efficient Bilayer Cross Counting Wilhelm Barth1 , Michael J¨ unger2 , and Petra Mutzel1 1
Institut f¨ ur Computergraphik und Algorithmen, Technische Universit¨ at Wien Favoritenstraße 9–11, A-1040 Wien, Austria {barth, mutzel}@ads.tuwien.ac.at http://www.ads.tuwien.ac.at/ 2 Institut f¨ ur Informatik, Universit¨ at zu K¨ oln Pohligstraße 1, D-50969 K¨ oln, Germany [email protected] http://www.informatik.uni-koeln.de/ls juenger/
Abstract. We consider the problem of counting the interior edge crossings when a bipartite graph G = (V, E) with node set V and edge set E is drawn such that the nodes of the two shores of the bipartition are drawn as distinct points on two parallel lines and the edges as straight line segments. The efficient solution of this problem is important in layered graph drawing. Our main observation is that it can be reduced to counting the inversions of a certain sequence. This leads to an O(|E| + |C|) algorithm, where C denotes the set of pairwise interior edge crossings, as well as to a simple O(|E| log |Vsmall |) algorithm, where Vsmall is the smaller cardinality node set in the bipartition of the node set V of the graph. We present the algorithms and the results of computational experiments with these and other algorithms on a large collection of instances.
1
Introduction
Let G = (N, S, E) be a bipartite graph with disjoint node sets N and S and let all edges in E have one end node in N and one in S. Furthermore, let LN , LS ∈ IR2 be two disjoint parallel lines, a “northern” and a “southern” line. A bilayer drawing BLD(G) assigns all nodes ni ∈ N = {n0 , n1 , . . . , np−1 } to distinct points P (ni ) on LN and all nodes sj ∈ S = {s0 , s1 , . . . , sq−1 } to distinct points P (sj ) on LS . The edges ek = (ni , sj ) ∈ E = {e0 , e1 , . . . , er−1 } are assigned to straight line segments with end points P (ni ) and P (sj ), see Fig. 1 for an example. Given a bilayer drawing BLD(G) of a bipartite graph G = (N, S, E), the bilayer cross count is the number BCC (BLD(G)) of pairwise interior intersections of the line segments corresponding to the edges. The example in Fig. 1 has a bilayer cross count of 12. It is a trivial observation that BCC (BLD(G)) only depends on the relative positions of the node points on LN and LS and not on their exact coordinates. Therefore, BCC (BLD(G)) is determined by permutations πN of N and πS of S. Given πN and πS , we wish to compute BCC (πN , πS ) efficiently by a simple algorithm. For ease of exposition, we assume without loss of generality that there are no isolated nodes and that q ≤ p. M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 130–141, 2002. c Springer-Verlag Berlin Heidelberg 2002
Simple and Efficient Bilayer Cross Counting
131
Fig. 1. A bilayer drawing
In automatic graph drawing, the most important application of bilayer cross counting occurs in implementations of Sugiyama-style layout algorithms [11]. Such a procedure has three phases. In the first phase, the nodes are assigned to m parallel layers for some m ∈ IN such that all edges join two nodes of different layers. Edges that connect non-adjacent layers are subdivided by artificial nodes for each traversed layer. In the second phase, node permutations on each layer are determined with the goal of achieving a small number of pairwise interior edge crossings. In the third phase, the resulting topological layout is transformed to a geometric one by assigning coordinates to nodes and edge bends. See Fig. 2 for a typical Sugiyama-style layout in which an artificial node is assumed wherever an edge crosses a layer. In this example, the artificial nodes co¨ıncide with the edge bends.
Fig. 2. A typical Sugiyama-style layout
In phase two, popular heuristics approximate the minimum number of crossings with a layer by layer sweep. Starting from some initial permutation of the nodes on each layer, such heuristics consider pairs of layers (Lfixed , Lfree ) = (L0 , L1 ), (L1 , L2 ), . . . , (Lm−2 , Lm−1 ), (Lm−1 , Lm−2 ), . . . , (L1 , L0 ), (L0 , L1 ), . . . and try to determine a permutation of the nodes in Lfree that induces a small bilayer cross count for the subgraph induced by the two layers, while keeping Lfixed
132
Wilhelm Barth, Michael J¨ unger, and Petra Mutzel
temporarily fixed. These down and up sweeps continue until no improvement is achieved. The bilayer crossing minimization problem is NP-hard [4] yet there are good heuristics and it is even possible to solve this problem very quickly to optimality for instances with up to about 60 nodes per layer [6]. A common property of most algorithmic approaches is that a permutation of the nodes of the free layer is determined by some heuristic and then it must be decided if the new bilayer cross count is lower than the old one. This is the bilayer cross counting problem that we address in this paper. It has been observed in [12] that bilayer cross counting can be a bottleneck in the overall computation time of Sugiyama-style algorithms. Of course, it is easy to determine if two given edges in a bilayer graph with given permutations πN and πS cross or not by simple comparisons of the relative orderings of their end nodes on LN and LS . This leads to an obvious algorithm with running time O(|E|2 ). This algorithm can even output the crossings rather than only count them, and since the number of crossings is Θ(|E|2 ) in the worst case, there can be no asymptotically better algorithm. However, we do not need a list of all crossings, but only their number. The bilayer cross counting problem is a special case of a core problem in computational geometry, namely counting (rather than reporting) the number of pairwise crossings for a set of straight line segments in the plane. Let C be the set of pairwise crossings. The best known algorithm for reporting all these crossings is by Chazelle and Edelsbrunner [2] and runs in O(|E| log |E| + |C|) time and O(|E| + |C|) space; the running time is asymptotically optimum. The best known algorithm for counting the crossings is by Chazelle [1] and runs in O(|E|1.695 ) time and O(|E|) space. For the bilayer cross counting problem, a popular alternative in graph drawing software is a sweep-line algorithm by Sander [10] that runs in O(|E| + |C|) time and O(|E|) space. This algorithm is implemented, e.g., in the VCG tool [9] or the AGD library [5]. A breakthrough in theoretical and practical performance is an algorithm by Waddle and Malhotra [12] that runs in O(|E| log |V |) time and O(|E|) space, where V = N ∪ S. The authors report on computational experiments that clearly show that the improvement is not only theoretical but leads to drastic time savings in the overall computation time of a Sugiyama-style algorithm that is implemented in an internal IBM software called NARC (Nodes and ARC) graph toolkit. Their algorithm consists of a sweep-line procedure that sweeps the bilayer graph once, say from west to east, and maintains a data structure called accumulator tree that is similar to the range tree data structure that is common in computational geometry, e.g., when a finite set of numbers is given and the task is to determine the cardinality of its subset of numbers that lie in a specified interval, see Lueker [8]. The sweep-line procedure involves complicated case distinctions and its description takes several pages of explanation and pseudo-code. In Section 2 we give a simple proof of the existence of O(|E| log |V |) algorithms for bilayer cross counting by relating the bilayer cross count to the number of inversions in a certain sequence. This observation immediately leads to a bilayer cross counting algorithm that runs in O(|E| + |C|) time and O(|E|)
Simple and Efficient Bilayer Cross Counting
133
space like the algorithm by Sander [10] and another algorithm that runs in O(|E| log |V |) time and O(|E|) space like the algorithm by Waddle and Malhotra [12]. In Section 3, we present an even simpler algorithm that runs in O(|E| log |Vsmall |) time and O(|E|) space, where Vsmall is the smaller cardinality set of N and S. This algorithm is very easy to understand and can be implemented in a few lines of code. The question how the old and the new algorithms perform in direct comparison is addressed empirically in Section 4. It turns out that the algorithm presented in detail in Section 3 outperforms the others not only in terms of implementation effort, but in most cases also in terms of running time.
2
Bilayer Cross Counts and Inversion Numbers
In a sequence π = a0 , a1 , . . . , at−1 of pairwise comparable elements ai (i = 0, 1, . . . , t − 1), a pair (ai , aj ) is called an inversion if i < j and ai > aj . The inversion number INV (π) = |{(ai , aj ) | i < j and ai > aj }| is a well known measure of the degree of sortedness of the sequence π. In a bilayer graph with northern layer permutation πN = n0 , n1 , . . . , np−1 and southern layer permutation πS = s0 , s1 , . . . , sq−1 let πE = e0 , e1 , . . . , er−1 be sorted lexicographically such that ek = (nik , sjk ) < (nil , sjl ) = el in πE iff ik < il or ik = il and jk < jl . In Fig. 1, the edges are sorted like this. Let π = j0 , j1 , . . . , jr−1 be the sequence of the positions of the southern end nodes in πE . In our example, we have π = 0, 1, 2, 0, 3, 4, 0, 2, 3, 2, 4. Each inversion in π is in a 1-1 correspondence to a pairwise edge crossing in a bilayer graph drawing BLD(G) according to πN and πS . Therefore, BCC (πN , πS ) is equal to the number of inversions in π. It is well known that the number of inversions of an r-element sequence π can be determined in O(r log r) time and O(r) space, e.g., Cormen, Leiserson, and Rivest [3] suggest an obvious modification of the merge sort algorithm in exercise 1-3d. Since the lexicographical ordering that leads to π can be computed in O(|E|) time and space, this implies immediately the existence of an O(|E| log |V |) time and O(|E|) space algorithm for bilayer cross counting. More precisely, the (modified) merge sorting algorithm requires O(r log RUN (π)) time and O(r) space, where RUN (π) is the number of runs, i.e., the number of sorted subsequences in π. This appears attractive when RUN (π) is expected to be small. We will test this empirically in Section 4. The number of inversions of a sequence π can also be determined with the insertion sort algorithm with O(r + INV (π)) time and O(r) space consumption, and this immediately gives an O(|E| + |C|) time and O(|E|) space algorithm for bilayer cross counting. We will work out this idea in detail in the following section, and develop another algorithm with O(|E| log |Vsmall |) running time. An algorithm for counting the inversions of an r-element sequence π with elements in {0, . . . , q − 1}, q ≤ r, with running time better than O(r log r) would immediately improve the bilayer cross counting approaches based on counting inversions. We do not know if such an algorithm exists.
134
3
Wilhelm Barth, Michael J¨ unger, and Petra Mutzel
A Simple O(|E| log |Vsmall |) Algorithm
Our task is the efficient calculation of the number of inversions of the sequence π coming from a bilayer graph drawing according to πN and πS as described in Section 2. We explain our algorithm in two steps. In step 1, we determine the bilayer cross count by an insertion sort procedure in O(|E|2 ) time, and in step 2, we use an accumulator tree to obtain O(|E| log |Vsmall |) running time. We use the example of Fig. 1 to illustrate the computation. Here is step 1: (a) Sort the edges lexicographically according to πN and πS by radix sort as described in Section 2. This takes O(|E|) time. In Fig. 1, this step has already been performed and the edges are indexed in sorted order. (b) Put the positions of the southern end nodes of the edges into an array in sorted order of (a). In the example, we obtain 0, 1, 2, 0, 3, 4, 0, 2, 3, 2, 4. (c) Run the insertion sort algorithm (see, e.g. [3]) on the array and accumulate the bilayer cross count by adding the number of positions each element moves forward. In the illustration on our example in Fig. 3 we also show the nodes of N and the edges of E. This additional information is not needed in the algorithm, it just helps visualizing why the procedure indeed counts the crossings. In our example, the answer is 2 + 4 + 2 + 1 + 3 = 12 crossings. The correctness of this algorithm follows from the fact that whenever an element is moved, the higher indexed elements are immediately preceding it in the current sequence. This is the important invariant of the insertion sort algorithm. So the total number of positions moved is equal to the number of crossings. Insertion sort takes linear time inthe number of edges plus the number inversions in the worst case, we have of inversions, and since there are |E| 2 described an O(|E|2 ) algorithm for bilayer cross counting. Now in step 2 of our explanation we use an accumulator tree as in [12] in order to obtain an O(|E| log |Vsmall |) algorithm. Namely, let c ∈ IN be defined by 2c−1 < q = |S| ≤ 2c , and let T be a perfectly balanced binary tree with 2c leaves whose first q are associated with the southern node positions. We store the accumulator tree T in an array with 2c+1 −1 entries in which the root is in position 0 and the node in position i has its parent in position ⌊ i−1 2 ⌋. All array entries are initialized to 0. Our algorithm accumulates the number of the associated southern nodes in each tree leaf and the sum of the entries of its children in each internal tree node. It builds up this information by processing the southern end node positions in the order given by π. For each such position, we start at its corresponding leaf and go up to the root and increment the entry in each visited tree position (including the root) by 1. In this process, whenever we visit a left child (odd position in the tree), we add the entry in its right sibling to the number of crossings (which is initialized to 0). In Fig. 4, we demonstrate this for our example: Inside each tree node, we give its corresponding tree index, and to the right of it, we give the sequence of entries as they evolve over time. An entry vj indicates that value v is reached when the j-th element of the sequence π
Simple and Efficient Bilayer Cross Counting
135
Fig. 3. Counting crossings via insertion sort
is inserted. The bilayer cross count becomes 2, 6, 8, 9, and 12, when the southern end node positions of e3 , e6 , e7 , e8 , and e9 , respectively, are inserted. By our reasoning above, the correctness of the algorithm is obvious and, if we assume without loss of generality that |S| ≤ |N |, i.e., Vsmall = S, we have a running time of O(|E| log |Vsmall |). Fig. 5 displays a C-program fragment that implements the algorithm. The identifier names correspond to the notation
136
Wilhelm Barth, Michael J¨ unger, and Petra Mutzel
Fig. 4. Building the accumulator tree and counting the crossings
we have used above, or are explained in comments, respectively. The identifier southsequence points to an array corresponding to the sequence π of the southern end node positions after the radix sorting (not shown here) has taken place.
/* build the accumulator tree */ firstindex = 1; while (firstindex
2
Proof Outline
The overall outline of our proof is very similar t o our previous result, separating geometric thickness from book thickness, so as a warmup we review that result.
Theorem 1 (Eppstein [6]). For every t , a graph exists ,with geometric thickness two and book thickness > t .
+
Proof. For any 7% > 0, define a graph G 2 ( n ) having as its n )(; vertices the singleton and doubleton subsets of an n-element set, with an edge between two subsets when one is contained in the other. G 2 ( n )can be drawn with geometric thicksless two using a construction related t o a one-bend drawing algorithm of Wood [15]; a two-layer drawing of G2(8) is shown in Figure 1. However, G2(5) is nonplanar (it is formed by subdividing each edge of the nonplanar complete graph K 5 ) so it has book thickness greater than two. By Ramsey theory (Lemma I ) , there exists an no such that, if the edges of G 2 ( n o )are given t - 1 colors, one can find a two-colored G2(5) subgraph. If the (t - 1)-coloring is determined by a book embedding with t - 1 layers, the subgraph would have a twelayer book embedding. Since no such two-layer embedding exists, G2(no)does not have a (t - 1)-layer book embedding.
152
David Eppstein
Fig. 2. Graph G3 (5). The circular vertices represent singleton subsets, and the triangular vertices represent tripleton subsets.
Our main result is the following theorem. Theorem 2. For every t, a graph exists with thickness three and geometric thickness ≥ t. Proof. For any n > 0, define a graph G3 (n) having as its n + n3 vertices the singleton and tripleton subsets of an n-element set, with an edge between two subsets when one is contained in the other. G3 (4) forms the vertices and edges of a cube; G3 (5) is depicted in Figure 2. If we assign the edges of G3 (n) to three layers, in such a way that the three edges incident to each tripleton are assigned to different layers, then each layer will form a forest of stars, which is a planar graph, so G3 (n) has thickness at most three. We show that there exists an n1 such that G3 (n1 ) has geometric thickness more than three (Lemma 19). By Ramsey theory (Lemma 1), there exists n2 such that, if the edges of G3 (n2 ) are given t − 1 colors, it has a three-colored G3 (n1 ) subgraph. If the (t − 1)-coloring is determined by a (t − 1)-layer geometric embedding, the subgraph would have a three-layer geometric embedding. Since no such three-layer embedding exists, G3 (n2 ) does not have a (t − 1)-layer geometric embedding. ⊔ ⊓ The difficult part of our proof is Lemma 19, showing that some G3 (n) has geometric thickness greater than three. The proof involves a complicated case analysis, with Ramsey theory used again at several stages in order to show that, if a thickness-three drawing existed, one could find a drawing with a simplified form that can be shown not to exist.
3
Ramsey Theory
We use the following classical result from Ramsey theory [?, Theorem 2]: Lemma 1. For every three positive integers c, e, and ℓ there is an integer Re (ℓ; c) with the following property: if |S| ≥ Re (ℓ; c) and the e-element subsets of S are partitioned into c classes, then there exists a set T ⊂ S with |T | ≥ ℓ so that all e-element subsets of T belong to the same class.
Separating Thickness from Geometric Thickness
153
+ t − 1, e = 2, For instance, in the proof of Theorem 1, we choose c = t−1 2 and ℓ = 5. The set S is the set of singletons in G2 (n0 ), and the doubletons in G2 (n0 ) are partitioned into c classes by the colors of their two incident edges. The Lemma tells us that we can find a two-colored G2 (5) subgraph of G2 (n0 ). Similarly, in Theorem 2 we can find a three-colored G3 (n1 ) subgraph of G3 (n2 ). We also use another well-known Ramsey-theoretic result [?, pp. 24–25]: Lemma 2. For every integer k there is an integer N (k) with the following property: if N (k) points are placed in the plane with no three points colinear, then some subset of k points form the vertices of a convex polygon.
4
Coherent Drawings
Define a convex drawing of G3 (n) to be a drawing with geometric thickness three in which all singletons are in convex position. We do not restrict the positions of the tripletons. Lemma 3. If every graph G3 (n) has geometric thickness three, then every G3 (n) has a convex drawing. Proof. Small perturbations of the vertex locations in a layered drawing will not create or remove crossings, so we can assume no three vertices are colinear. To form a convex drawing of G3 (n), apply Lemma 2 to the singletons of G3 (N (n)), and form a G3 (n) subgraph from the resulting convex set of n singletons and their adjacent tripletons. ⊔ ⊓ We number the singleton vertices of a convex drawing in clockwise order from 0 to n − 1, starting from an arbitrarily chosen vertex. Using this numbering, we can partition the edges of G3 (n) into three classes: a low edge connects a tripleton to the adjacent singleton with the smallest number, a high edge connects a tripleton to the adjacent singleton with the largest number, and a middle edge connects a tripleton to the remaining adjacent singleton. Define a coherent drawing of G3 (n) to be a convex drawing in which these three classes form the three layers of the drawing. Lemma 4. If every graph G3 (n) has geometric thickness three, then every G3 (n) has a coherent drawing. Proof. By Lemma 3 we can assume G3 (n) has a convex drawing. Partition the tripletons of such a drawing into 27 classes according to the layers to which the incident low, middle, and high edges belong. By Lemma 1 with c = 27 and e = 3, we can find a drawing in which each of the three sets of edges belongs to a single layer. If this results in more than one set belonging to the same layer, we can move sets to distinct layers without introducing any crossings. ⊔ ⊓ In a coherent drawing, we will denote tripletons by triples of symbols abc, where each letter denotes the position of an adjacent singleton in the clockwise ordering of the drawing, and a < b < c according to the clockwise ordering.
154
David Eppstein
Fig. 3. Five tripletons crossing each other convexly (left) or concavely (right), from Lemma 6.
5
Restriction t o Outer Drawings
Define an inner drawing of G3(n) to be a coherent drawing such that some strictly convex curve C passes through all singletons and contains all tripletons. Similarly, define an outer drawing to be a coherent drawing such that some strictly convex curve C passes through all singletons and contains no tripletons. A drawing can be both inner and outer, for instance if all vertices are in convex position. In an inner drawing, all edges are contained in C; however an edge in an outer drawing may have portions inside C and portions outside C .
Lemma 5. Suppose two tripletons abc and def are part of a n inner drawing, with a < d < c < f . T h e n either the low edge of abc crosses the high edge of de f , or the high edge of abc crosses the low edge of de f . However, both types of crossing can not occur simultaneously. Proof. Consider the two paths formed by the low and high edges of each tripleton. These paths cross C and each path separates the endpoints of the other path; therefore the paths cross an odd number of times. However, each pair of edges can cross only once, and the only types of crossing permitted are those described in the lemma, so exactly one of these crossings occurs.
We say that the two tripletons cross convexly if the low edge of abc crosses the high edge of de f , and that they cross concavely in the other case of Lemma 5.
Lemma 6. There exists a n n3 such that G3(n3) does not have a n inner drawing. Proof. Let n be sufficiently large, and assume for convenience that n = 2 (mod 4). Consider the sequence of tripletons 2i, n/2, n/2 2i 2 for 0 i < n/2 - 2; each pair of tripletons meets the conditions of Lemma 5. By applying Lemma 1 with c = 2, e = 2, and t = 5, for sufficiently large n , we can obtain a set of five such triples that all cross convexly or all cross concavely. As Figure 3 shows, in either case, the low and high edges of these crossing triples form a grid
+ +
2 [12,5]. Can θ(G) be unbounded when θ(G) = 2? – Four-regular graphs have thickness at most two. Do random four-regular graphs have bounded expected geometric thickness? More generally, can one bound the geometric thickness of a graph as some function of its degree? – Due to our use of Ramsey theory, our lower bounds on geometric thickness grow only very slowly as a function of the number of vertices. Can we find good upper bounds for geometric thickness as a combination of the graphtheoretic thickness and a slowly growing function of the graph size? ¯ – What is the complexity of computing θ(G) for a given graph G [5]? – Thickness is NP-hard [12] but not difficult to approximate to within a constant factor; e.g., it is within a factor of three of the graph’s arboricity. Our new results imply that these approximations do not directly extend to geometric thickness. Is there an efficient algorithm for layered drawing of graphs without bends, using a number of layers within a constant factor of optimal? Acknowledgements This work was supported in part by NSF grant CCR-9912338.
References 1. V. B. Alekseev and V. S. Gonˇcakov. The thickness of an arbitrary complete graph. Math USSR Sbornik 30(2):187–202, 1976. 2. L. W. Beineke. The decomposition of complete graphs into planar subgraphs. Graph Theory and Theoretical Physics, chapter 4, pp. 139–153. Academic Press, 1967. 3. L. W. Beineke and F. Harary. The thickness of the complete graph. Canad. J. Math. 17:850–859, 1965. 4. F. Bernhart and P. C. Kainen. The book thickness of a graph. J. Combinatorial Theory, Ser. B 27(3):320–331, 1979. 5. M. B. Dillencourt, D. Eppstein, and D. S. Hirschberg. Geometric thickness of complete graphs. J. Graph Algorithms & Applications 4(3):5–17, 2000, arXiv:math.CO/9910185. 6. D. Eppstein. Separating geometric thickness from book thickness. arXiv.org, September 2001, arXiv:math.CO/0109195. 7. I. F´ ary. On straight line representation of planar graphs. Acta Sci. Math. Szeged. 11:229–233, 1948. 8. R. L. Graham, B. L. Rothschild, and J. H. Spencer. Ramsey Theory. Wiley, 1980. 9. N. Hartsfield and G. Ringel. Pearls in Graph Theory. Academic Press, Boston, MA, 1990. 10. B. Jackson and G. Ringel. Plane constructions for graphs, networks, and maps: Measurements of planarity. Selected Topics in Operations Research and Mathematical Economics: Proc. 8th Symp. Operations Research, pp. 315–324. Springer-Verlag, Lecture Notes in Economics and Mathematical Systems 226, August 1983. 11. P. C. Kainen. Thickness and coarseness of graphs. Abh. Math. Sem. Univ. Hamburg 39:88–95, 1973.
162
David Eppstein
12. A. Mansfield. Determining the thickness of a graph is NP-hard. Math. Proc. Cambridge Philos. Soc. 93(9):9–23, 1983. 13. J. Mayer. Decomposition de K16 en trois graphes planaires. J. Comb. Th., Ser. B 13:71, 1972. 14. J. Vasak. The thickness of the complete graph having 6m + 4 points. Manuscript, cited in [9] and [10]. 15. D. R. Wood. Geometric thickness in a grid of linear area. Proc. Euroconf. Combinatorics, Graph Theory, and Applications, pp. 310–315. Univ. Aut` onoma de Barcelona, Centre de Recerca Matem` atica, September 2001, http://www.cs.usyd.edu.au/∼davidw/papers/Wood-COMB01.ps.
Book Embeddings and Point-Set Embeddings of Series-Parallel Digraphs⋆ Emilio Di Giacomo1 , Walter Didimo1 , Giuseppe Liotta1 , and Stephen K. Wismath2 1
Dipartimento di Ingegneria Elettronica e dell’Informazione, Universit` a degli Studi di Perugia, Perugia, Italy. {digiacomo,didimo,liotta}@diei.unipg.it 2 Department of Mathematics and Computer Science, University of Lethbridge, Lethbridge, Alberta, Canada. [email protected]
Abstract. An optimal O(n)-time algorithm to compute an upward twopage book embedding of a series-parallel digraph with n vertices is presented. A previous algorithm of Alzohairi and Rival [1] runs in O(n3 ) time and assumes that the input series-parallel digraph does not have transitive edges. One consequence of our result is that series-parallel (undirected) graphs are necessarily sub-hamiltonian. This extends a previous result by Chung, Leighton, and Rosenberg [5] who proved subhamiltonicity for a subset of planar series-parallel graphs. Also, this paper investigates the problem of mapping planar digraphs onto a given set of points in the plane, so that the edges are drawn upward planar. This problem is called the upward point-set embedding problem. The equivalence between the problem of computing an upward two-page book embedding and an upward point-set embedding with at most one bend per edge on any given set of points is proved. An O(n log n)-time algorithm for computing an upward point-set embedding with at most one bend per edge on any given set of points for planar series-parallel digraphs is presented.
1
Introduction
A book consists of a line in Euclidean 3D space called the spine and some number of half-planes, called pages, having the spine as a boundary. A book embedding of a graph G is a linear ordering of the vertices along the spine of a book and an assignment of edges to pages such that edges assigned to the same page can be drawn as simple Jordan curves on that page without intersecting each other. The problem of computing a book embedding of a graph that uses the minimum number of pages has been the subject of intense research activities. (see e.g., [2,5,17]). In their seminal paper [2], Bernhart and Kainen prove that a planar ⋆
Research supported in part by the Natural Sciences and Engineering Research Council of Canada, and by “Progetto Giovani Ricercatori: Algoritmi per la Visualizzazione di Grafi di Grandi Dimensioni” of the University of Perugia, Italy.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 162–173, 2002. c Springer-Verlag Berlin Heidelberg 2002
Book Embeddings and Point-Set Embeddings of Series-Parallel Digraphs
163
graph has a book embedding on two pages if and only if it is sub-hamiltonian. Yannakakis [17] shows that all planar graphs have a book embedding on four pages and that four pages are necessary for some planar graphs. Also upward book embeddings of directed acyclic graphs and of posets have been widely investigated (see e.g., [1,11,12,13,15]). An upward book embedding of a digraph G is a book embedding of G such that the ordering of the vertices along the spine is a topological ordering of G. In contrast to the result by Yannakakis [17] concerning the book embeddability of undirected planar graphs, the minimum number of pages required by an upward book embedding of an upward planar digraph is not known [1,15]. Heath, Pemmaraju, and Trenk [13] show that oriented trees have a two-page upward book embedding. Alzohairi and Rival [1] show that a planar series-parallel ordered set has a two-page upward book embedding and that such an embedding can be computed in O(n3 ) time if the poset is a series-parallel planar lattice with n elements (note that the covering graph of a planar ordered set is an upward planar digraph). In this paper we study upward book embeddings and find relations between book-embeddability and another relevant graph drawing question, the point-set embeddability problem. Before giving an overview of our main results, we briefly digress on this second topic to better clarify our contributions. Let P be a set of n distinct points in the plane and let G be a planar graph with n vertices. A point-set embedding of G on P is a planar drawing of G such that each vertex is mapped to a distinct point of P and each edge is drawn as a polygonal chain connecting its endpoints (note that the mapping of the vertices to the points is not specified as part of the input). The problem of computing a point-set embedding of a graph while minimizing the number of bends per edge has been widely investigated (see e.g.[4,3,10,14]). Since outerplanar graphs are the largest class of graphs admitting a straight-line point-set embedding on any set of points [10], Kaufmann and Wiese [14] investigate the point-set embeddability problem for planar graphs allowing few bends per edge. They show that if a graph has a hamiltonian cycle with an edge on the external face then it admits a point-set embedding with at most one bend per edge on any set of points on the plane and present an O(n log n) time algorithm to compute it. Also, they show that for a planar graph G with n vertices and for any set of n points on the plane, a point-set embedding of G with at most three bends per edge can be computed in O(n log n) time and that the number of bends per edge can be reduced to be at most two at the expense of increasing the time complexity to O(n2 ). The research of Kaufmann and Wiese is extended in this paper to upward point-set embeddings. An upward point-set embeddings of an upward planar digraph G on a set P of points in the plane is a point-set embedding of G onto P such that the edges are drawn monotonically increasing in a common direction. An overview of our results follows. – An optimal O(n) time algorithm to compute a two-page upward book embedding of a planar series-parallel digraph with n vertices is presented. The best previously known algorithm runs in O(n3 ) time and assumes that the input graph does not have transitive edges [1].
164
Emilio Di Giacomo et al.
– The equivalence between the problem of computing a two-page upward book embedding and an upward point-set embedding with at most one bend per edge on any given set of points is proved. – The investigation is extended to the undirected book-embeddability and the point set embeddability problem. One consequence of our result is that seriesparallel (undirected) graphs are necessarily sub-hamiltonian.
2 2.1
Preliminaries Series-Parallel Digraphs and Their Decomposition Tree
Let u and v be two vertices of a digraph. We use the notation u → v to say that there is a directed path from u to v in the digraph. A two terminal series-parallel digraph (also called TTSP-digraph in the following) is a planar digraph recursively defined as follows [6,16]: – An edge joining two vertices is a TTSP-digraph. – Let G′ and G′′ be two TTSP-digraphs; the digraph obtained by identifying the sink of G′ with the source of G′′ (Series Composition) is also a TTSPdigraph. – Let G′ and G′′ be two TTSP-digraphs; the digraph obtained by identifying the source of G′ with the source of G′′ and the sink of G′ with the sink of G′′ (Parallel Composition) is also a TTSP-digraph. A TTSP-digraph has one source and one sink that are called its poles. The undirected underlying graph of a TTSP-digraph is called a two terminal seriesparallel graph or TTSP-graph for short. We recall the definition of the SPQR-tree of an st-graph G, also called the decomposition tree of G [7]. A split pair of G is either a separation pair or a pair of adjacent vertices. A split component of a split pair {u, v} is either an edge (u, v) or a maximal subgraph C of G such that C is an uv-graph and {u, v} is not a split pair of C. A maximal split pair {u, v} of G is such that there is no other split pair {u′ , v ′ } in G such that {u, v} is contained in a split component of {u′ , v ′ }. The SP QR-tree T of an st-graph G is a rooted ordered tree whose nodes are of four types: S,P ,Q, and R. Each node µ of T has an associated planar st-graph (possibly with multiple edges), called the skeleton of µ and denoted by skeleton(µ). Also it is associated with an edge of the skeleton of the parent ν of µ, called the virtual edge of µ in skeleton(ν). Tree T is recursively defined as follows (see Figure 3(b)): Trivial case: If G consists of a single edge from s to t, then T consists of a single Q-node whose skeleton is G itself. Series case: If G is not biconnected, let c1 , . . . , ck−1 (k ≥ 2) be the cutvertices of G. Since G is planarly biconnectible, each cutvertex ci is contained in exactly two blocks Gi and Gi+1 such that s is in G1 and t is in Gk . The root of T is an S-node µ. Graph skeleton(µ) consists of the chain e1 , . . . , ek , where edge ei goes from ci−1 to ci , c0 = s, and ck = t.
Book Embeddings and Point-Set Embeddings of Series-Parallel Digraphs
165
Parallel case: If s and t are a split pair for G with split components G1 , . . . Gk (k ≥ 2), the root of T is a P -node µ. Graph skeleton(µ) consists of k parallel edges from s to t, denoted e1 , . . . , ek . Rigid case: If none of the above cases applies, let {s1 , t1 }, . . . , {sk , tk } be the maximal split pairs of G (k ≥ 1), and for i = 1, . . . , k, let Gi be the union of all the split components of {si , ti }. The root of T is an R-node µ. Graph skeleton(µ) is obtained from G by replacing each subgraph Gi with edge ei from si to ti . Note that for a TTSP-graph, the Rigid case never applies and thus the decomposition tree of a TTSP-graph does not contain any R-node. 2.2
Two Page Book Embeddings
Let G be a graph. Without loss of generality, we assume that in each drawing of a two-page book embedding of G, the spine is always vertical, and we call the half-plane to the left and to the right of the spine, the left page and the right page respectively. Also, we denote by LG the linear ordering of the vertices of G on the spine, and, for each edge e of G, we denote by de the page (left or right) to which e is assigned. The following theorem gives a simple characterization of two-page upward book embeddings of planar digraphs, that will be useful in the following. Theorem 1. Let G be a planar digraph. The linear ordering LG and the assignment de for every edge e of G define a two-page upward book embedding of G if and only if the following two properties hold: UBE1: If (u, v) is a directed edge of G then u precedes v in LG . UBE2: There are no two edges e1 = (u, v) and e2 = (w, z) (with u, v, w, z all distinct) for which de1 = de2 and u, w, v, z occur in this order in LG . Proof. Given an upward book embedding of G, the ordering LG of the vertices of G along the spine is a topological ordering of the vertices of G, hence Property UBE1 is verified. Also, suppose for a contradiction that Property UBE2 is not satisfied. This implies that there exist two edges e1 = (u, v) and e2 = (w, z) (with u, v, w, z all distinct) for which de1 = de2 and u, w, v, z occur in this order in LG . In this case, however, e1 and e2 can not be drawn on the same page without intersecting each other (see Figure 1(a)), which is a contradiction. Hence, also Property UBE2 is verified. Suppose that LG and the assignment de (for every edge e of G) are such that Properties UBE1 and UBE2 hold. Property UBE1 implies that LG defines a topological ordering of the vertices on the spine. Also, consider any two edges e1 = (u, v) and e2 = (w, z) of G. From Property UBE1, u precedes v, and w precedes z in LG . – If de1 = de2 , that is, the two edges are assigned to different pages, then it is always possible to draw e1 and e2 without intersecting each other (see for example Figure 1(b)).
166
Emilio Di Giacomo et al.
– If de1 = de2 , from Property UBE2, only the following sub-cases are possible (we do not examine symmetric sub-cases): (i) Edges e1 and e2 have no common vertex, and u, v, w, z occur in this order in LG . Edge e2 can be drawn completely above e1 (see Figure 1(c)). (ii) Edges e1 and e2 have no common vertex, and u, w, z, v occur in this order in LG . Edge e2 can be drawn nested into e1 (see Figure 1(d)). (iii) Edges e1 and e2 have one common vertex. The two edges can be drawn either nesting one edge into another (see Figure 1(e)) or putting one edge completely above the other (see Figure 1(f)).
z
z
v
v
w
z
z
v
w
u
u
u
(b)
(c)
z
v
w
u
(a)
v
w
(d)
z
v=w
u=w
(e)
u
(f)
Fig. 1. Illustration of the cases of Theorem 1
Given a two-page book embedding of G, a drawing of this book embedding can be easily computed mapping the vertices of G at consecutive points on a vertical line (the spine of the book), according to the ordering LG , and drawing each edge e as a semi-circle between its end-vertices on page de with a diameter chosen as the distance between the end-vertices of e (see Figure 3(d)).
3
Two-Page Upward Book Embeddings of Series-Parallel Digraphs in Linear Time
In this section we describe a linear time algorithm for computing a two-page upward book embedding of a TTSP-digraph G. We can assume that edge (s, t) exists in G. If it does not exist, we temporarily add such an edge and then remove it at the end of the algorithm. Finally, since s and t are on the external face, edge (s, t) can always be embedded on the external face. Algorithm SP-Book Embedder Input: A TTSP-digraph G with edge (s, t) on the external face. Output: A two-page upward book embedding of G, defined by a linear ordering LG and by a page assignment de for each edge e of G. Step 1: Compute the SP QR-tree T of G. Since G is a TTSP-digraph, T has no R nodes.
Book Embeddings and Point-Set Embeddings of Series-Parallel Digraphs
167
– For each node µ of T denote by Gµ the pertinent digraph of µ, and let Lµ be a linear list used to define a linear ordering of the vertices of Gµ . – Define the following merge operation ◦ between two ordered vertex lists Lµ =< u1 , u2 , . . . , uk > and Lν =< v1 , v2 , . . . , vh >: • Lµ ◦ Lν =< u1 , u2 , . . . , uk , v1 , v2 , . . . , vh >, if uk = v1 . • Lµ ◦ Lν =< u1 , u2 , . . . , uk , v2 , . . . , vh >, if uk = v1 . Step 2: Denote by {µ1 , µ2 , . . . , µh } the nodes of T ordered according to a postorder visit. Step 3: For i = 1, . . . , h do: Case 1 µi is a Q-node (see Figure 2(a)). Let e = (u, v) be the directed edge represented by µi . – Set Lµi =< u, v >. – Set de = lef t. Case 2 µi is an S-node (see Figure 2(b)). Let (u = u1 , u2 ), (u2 , u3 ), . . . , (uk , uk+1 = v) be the edges of the skeleton of µi where u → v in G, and let νj , (j = 1, . . . , k) be the child of µi in T corresponding to edge (uj , uj+1 ). Node νk will be called the top child of µi in the following. – Set Lµi = Lν1 ◦ Lν2 ◦ . . . ◦ Lνk . – If νk is a Q-node representing an edge ek of G, then set dek = right. Case 3 µi is a P -node (see Figure 2(c)). Let u, v be the poles of the skeleton of µi , such that u → v. Let ν1 , ν2 , . . . , νk be the children of µ in T and assume that if the edge (u, v) exists in Gµi , the corresponding Q-node is νk . Also, denote by L− νj the list Lνj without the first vertex u and the last vertex v, (j = 1, . . . , k). − − – Set Lµi =< u > ◦L− νk ◦ Lνk−1 ◦ . . . ◦ Lν1 ◦ < v >. – If νk is a Q-node representing an edge ek and if µi is the top child of an S-node in T , set dek = right. Step 4: Set LG = Lµh .
v
u k+1= v 111 000 νk 000 111 000 111 000 111 uk
00 ν2 11 003 11 00 11 00 11 u2 111 000 ν1 000 111 000 111 000 111 u= u u
u
(a) Case Q
1
(b) Case S
1111 0000 v 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 0000 1111 νk ν1 1111 ν2 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 0000 1111 u
(c) Case P
Fig. 2. Illustration of the cases of Algorithm SP-Book Embedder
In order to prove the correctness of Algorithm SP-Book Embedder, we need the following preliminary lemma.
Emilio Di Giacomo et al.
168
8
14 P−NODE
l =left r =right
1
7
(1,2)
Q−NODE
34 15
14 6
12
5
35
15 S−NODE
15
1
13
9
8
(1,2)
14
(5,6)
l
11
(1,8)
33 22
31
(15,8)
r
l 10
4
3
4
9
30
(6,8)
7
13
18
21
25
29
r
10
2 1
(11,15)
l
2
3
5
6
11
12
16
(2,3)
(3,5)
(2,4)
(4,5)
(6,7)
(7,8)
(1,9)
l
r
l
r
l
r
l
(a)
l
32
17
19
20
23
24
(9,11) (1,10) (10,11) (11,12) (12,15)
r
l
r
l
r
26
27
28
(11,13) (13,14) (14,15)
l
l
r
(b)
L 1={1,2}
L 13={6,7,8}
L 25={11,12,15}
L 2={2,3}
L 14={6,7,8}
L 26={11,13}
7
L 3={3,5}
L 15={1,2,4,3,5,6,7,8} L ={13,14} 27
6
L 4={2,3,5} L 16={1,9}
L 28={14,15}
L 5={2,4}
L 17={9,11}
L 29={11,13,14,15}
L 6={4,5}
L 18={1,9,11}
L 30={11,15}
L 7={2,4,5} L 19={1,10}
L 31={11,13,14,12,15}
L 8={2,4,3,5} L 20={10,11}
L 32={15,8}
L 9={5,6}
L 21={1,10,11}
L 33={1,10,9,11,13,14,12,15,8}
L 10={6,8}
L 22={1,10,9,11}
L 34={1,10,9,11,13,14,12,15,2,4,3,5,6,7,8}
L 11={6,7}
L 23={11,12}
L 35={1,10,9,11,13,14,12,15,2,4,3,5,6,7,8}
L 12={7,8}
L 24={12,15}
8
5 3 4 2 15 12 14 13
(c)
11
9 10 1
(d)
Fig. 3. (a) A TTSP-digraph G. The dashed edges are dummy egdes that form an augmented hamiltonian cycle along with the bold edges.(b) The SP QR-tree of G. For each node the number given by the post order visit is shown. For each Q-node the edge associated and the page assigned are also shown. (c) The lists Lµ for each node µ. (d) The final book embedding.
Lemma 1. Let G be a TTSP-digraph, let T be its SP QR-tree, and let µ be an S-node of T . Let Gµ be the pertinent digraph of µ and let u and v be the poles of µ such that u → v. Algorithm SP-Book Embedder assigns the edges of Gµ to the pages in such a way that each edge incident on u is assigned to the left page and each edge incident on v is assigned to the right page. Proof. We prove the statement by induction on the height hµ of the subtree Tµ ⊂ T rooted at µ (note that hµ is always an odd number). If hµ = 1, then all children ν1 , . . . , νk of µ are Q-nodes. Let e1 , . . . , ek be the edges associated with ν1 , . . . , νk , respectively; vertex u is the starting vertex of e1 and v is the end vertex of ek . Algorithm SP-Book Embedder sets dei = lef t for 1 ≤ i ≤ (k − 1)
Book Embeddings and Point-Set Embeddings of Series-Parallel Digraphs
169
(Case 1 of Step 3) and dek = right (Case 2 of Step 3). Hence, the lemma holds when hµ = 1. Let us assume that the lemma is true for hµ = k ≥ 1 and consider the case hµ = k + 2. The children ν1 , . . . , νk of µ are either P -nodes or Q-nodes. In particular, in order to verify that the lemma is true, we only need to verify the assignment on the edges incident on u and v, that is, the edges of the pertinent digraphs of ν1 and νk . – Consider node ν1 : If it is a Q-node representing an edge e, then the algorithm sets de = lef t (Case 1 of Step 3); if ν1 is a P -node then the children of ν1 are all S-nodes except at most one which is a Q-node. For each child which is an S-node, the statement is true by the inductive hypothesis. For the edge e associated with the only child (if present) which is Q-node the algorithm sets de = lef t (Case 1 of Step 3). – Consider node νk : If it is a Q-node representing an edge e, then the algorithm sets de = right, since it is the top child of µ (Case 2 of Step 3); if νk is a P -node then the children of νk are all S-nodes except at most one, which is a Q-node. For each child which is an S-node the statement is true by the inductive hypothesis. For the edge e associated with the only child (if present) which is a Q-node the algorithm sets de = right, since νk is the top child of µ (Case 3 of Step 3). Theorem 2. Let G be a TTSP-digraph with n vertices. There exists an algorithm that computes a two-page upward book embedding of G in O(n) time and space. Proof. Let T be the SP QR-tree of G, and denote by Gµ the pertinent digraph of a node µ of T . We prove by induction that, after the i-th iteration of Step 3 has been executed, a two-page upward book embedding of Gµi is correctly given by list Lµi and by variable de , for each edge e of Gµi . Namely, based on Theorem 1 we prove that Properties UBE1 and UBE2 hold for Gµi . We adopt the same notation used for describing Algorithm SP-Book Embedder. Since Step 3 iterates on the nodes of T in post-order, µ1 is a leaf of T , that is, a Q-node. Hence Gµ1 is a single edge e = (u, v), and Case 1 applies. In this case the proof is trivial. Suppose the statement is true for i ≥ 1; we prove that it is true for i + 1. There are three possible cases: 1. µi+1 is a Q-node. In this case Gµi+1 is a single edge and the proof is trivial. 2. µi+1 is an S-node. Let ν1 . . . νk be the children of µi+1 . For each edge e = (w, z) of Gµi+1 , w and z belong to the same list Lνj for some 1 ≤ j ≤ k. Since Property UBE1 is verified for Lνj and since the merge operation keeps unchanged the ordering of the vertices in Lνj , Property UBE1 holds for Lµi+1 . Let e1 = (w1 , z1 ) and e2 = (w2 , z2 ) be two edges of Gµi+1 such that w1 , z1 , w2 , z2 are all different. If w1 , z1 , w2 , z2 belong to the same list Lνj for some 1 ≤ j ≤ k then Property UBE2 follows from the inductive hypothesis. Otherwise, w1 , z1 ∈ Lνj1 and w2 , z2 ∈ Lνj2 with j1 = j2 . Assume, without
170
Emilio Di Giacomo et al.
loss of generality, that j1 < j2 . Since Lµi+1 = Lν1 ◦ Lν2 ◦ . . . ◦ Lνk , all the vertices in Lνj1 precede all the vertices in Lνj2 . Thus Property UBE2 holds. 3. µi+1 is a P -node. Let ν1 . . . νk be the children of µi+1 , and let u and v be the poles of µi+1 where u → v. We prove first that Property UBE1 is satisfied. Let e = (w, z) be a directed edge of Gµi+1 . There are three cases to consider: – if w = u then w is the first vertex in Lµi+1 and so Property UBE1 holds; – if z = v then z is the last vertex in Lµi+1 and so Property UBE1 holds; – If w = u and z = v then w, z ∈ L− νj for some 1 ≤ j ≤ k. Since the merge operation keeps unchanged the ordering of the vertices in L− νj Property UBE1 follows from the inductive hypothesis. We now show that Property UBE2 is true. Let e1 = (w1 , z1 ) and e2 = (w2 , z2 ) be two directed edges of Gµi+1 such that w1 , z1 , w2 , z2 are all different. Also in this case we have three cases: – wj = u j = 1, 2 and zj = v j = 1, 2. In this case w1 , z1 ∈ L− νj1 for some − 1 ≤ j1 ≤ k and w2 , z2 ∈ Lνj2 for some 1 ≤ j2 ≤ k. • If j1 = j2 = j then the ordering of w1 , z1 , w2 , z2 in Lµi+1 is the same as in L− νj and Property UBE2 follows from the inductive hypothesis. • If j1 = j2 (assume without loss of generality j1 < j2 ). Since Lµi+1 =< − u > ◦L− νk ◦ . . . ◦ Lν1 < v > all the vertices in Lνj2 precedes all the vertices in Lνj1 . Thus the ordering of w1 , z1 , w2 , z2 in Lµi+1 is w2 , z2 , w1 , z1 , and Property UBE2 holds. – One of w1 , z1 , w2 , z2 is equal to u or v (without loss of generality assume that w1 = u, other cases are similar). Let w1 , z1 ∈ Lνj1 and w2 , z2 ∈ Lνj2 . • If j1 = j2 = j then the ordering of w1 , z1 , w2 , z2 in Lµi+1 is the same as in L− νj since the merge operation keeps unchanged the ordering of the vertices z1 , w2 , z2 ∈ L− νj and the vertex w1 = u which precedes all z1 , w2 , z2 in Lνj also precedes all z1 , w2 , z2 in Lµi+1 . Thus Property UBE2 follows from the inductive hypothesis. − • If j1 < j2 then all the vertices in L− νj2 precede all the vertices in Lνj1 , and w1 = u precedes all other vertices in Lµi+1 . Thus the ordering of w1 , z1 , w2 , z2 in Lµi+1 is w1 = u, w2 , z2 , z1 , and Property UBE2 holds. − • If j1 > j2 then all the vertices in L− νj1 precede all the vertices in Lνj2 , and w1 = u precedes all other vertices in Lµi+1 . Thus the ordering of w1 , z1 , w2 , z2 in Lµi+1 is w1 = u, z1 , w2 , z2 , and Property UBE2 holds. – Two of w1 , z1 , w2 , z2 are equal to u or v. • If w1 = u and z1 = v (or symmetrically w2 = u and z2 = v) w1 = u (w2 = u) is the first vertex in Lµi+1 , and z1 = v (z2 = v) is the last vertex in Lµi+1 . Thus the ordering of w1 , z1 , w2 , z2 in Lµi+1 is w1 = u, w2 , z2 , z1 = v (symmetrically w2 = u, w1 , z1 , z2 = v), and Property UBE2 holds. • If w1 = u and z2 = v (or symmetrically w2 = u and z1 = v) then one among e1 and e2 is incident on u and the other is incident on v. By Lemma 1 they are on different pages and Property UBE2 holds. Proofs about time and space complexity are omitted for reasons of space.
Book Embeddings and Point-Set Embeddings of Series-Parallel Digraphs
4
171
Hamiltonicity, Book and Point-Set Embeddability
In their investigation of book-embeddings, Bernhart and Kainen [2] show that an undirected planar graph admits a book embedding on two pages if and only if it is sub-hamiltonian, i.e. it can be augmented with edges to create a hamiltonian cycle while still remaining planar. In a subsequent paper, Chung, Leighton, and Rosenberg [5] show that a family of planar graphs that they call series-parallel graphs have a book embedding on two pages and therefore are sub-hamiltonian. However, it must be noted that the definition of Chung, Leighton, and Rosenberg appears somewhat restrictive if compared to the one commonly used for seriesparallel graphs by the vast majority of researchers (see e.g. [6,16]). In particular, in [5] the series composition is the usual one, but the parallel composition is defined as follows: Let G1 , . . . , Gn be series-parallel graphs with source vertices s1 , . . . sn and sink vertices t1 , . . . tn ; the parallel composition of G1 , . . . , Gn is obtained by taking a new source s and a new sink t and by adding edges between each si and s and between each ti and t. Clearly the family of series-parallel graphs defined by Chung, Leighton, and Rosenberg is a proper subset of the class of TTSP-graphs. For example, a threecycle is a TTSP-graph, but is not a series-parallel graph as defined by Chung et al. Furthermore, it is not obvious how to extend the proof of sub-hamiltonicity given in [5] to all TTSP-graphs. On the other hand, we observe that, since each TTSP undirected graph can be st-oriented in linear time with s and t on the external face [8], Algorithm SP-Book Embedder can also be used for computing a two-page book embedding of a two terminal series-parallel graph. This observation, together with the result by Bernhart and Kainen [2] leads to the following. We recall that he problem of determining if a graph is subhamiltonian is NP-Complete [5] Theorem 3. Let G be a TTSP-graph with n vertices. Then G admits a twopage book embedding and therefore it is sub-hamiltonian. Also there exists an O(n)-time algorithm that computes an augmented hamiltonian cycle of G. In a recent paper, Ganley and Heath [9] conjecture that every k-tree has a book-embedding on exactly k pages. Since every 2-tree is a TTSP-graph, a consequence of Theorem 3 is to prove their conjecture for k = 2. Corollary 1. Every 2-tree has a book embedding on two pages. As a second application of the results in Section 3, we consider the upward point-set embeddability problem, that is the problem of computing a point-set embedding of an upward planar digraph on a given set of points by minimizing the number of bends along the edges and by drawing all edges monotonically increasing in a common direction. We remark that the upward point-set embeddability problem is, in general, different from the non-upward problem. For example, let G be the upward planar graph of Figure 4. Graph G does not admit an upward point set embedding if the points of P are collinear as in Figure 4(b). Conversely, Figure 4(c) shows a non upward point-set embedding of G on P with at most one bend per edge.
172
Emilio Di Giacomo et al.
e
e
e
d c
d c d
b
c a
(a)
b
b
a
a
(b)
(c)
Fig. 4. (a) An upward planar graph G. (b) There is no upward point-set embeddings of G on P . (c) A (non-upward) point-set embedding of G on a set of points P on the same line.
Theorem 4. An upward planar digraph G with n vertices has an upward pointset embedding with at most one bend per edge on every set of n points if and only if G has a two-page upward book embedding. Also, from a two-page upward book embedding of G it is possible to construct in O(n log n) time an upward point-set embedding of G with at most one bend per edge on every set of n points. Proof. If G has an upward point-set embedding with at most one bend per edge on every set of n points then it has an upward point-set embedding on consecutive points of a straight line l. In this upward point-set embedding the edges of G are drawn either on the half-plane to the left of l (assuming l to be a vertical line), or on the half-plane to the right of l. The ordering of the vertices of G along l and the assignment of the edges of G to the left or right half-plane define the two-page upward book embedding of G. Consider now a two-page upward book embedding of G and let vi , i = 1, . . . , n be the vertices of G in the order they appear along the spine. Since G has a two-page upward book embedding, G is sub-hamiltonian, and so we can add a certain number of edges in order to create a hamiltonian cycle C. Let C = (v1 , v2 )(v2 , v3 ) . . . (vn−1 , vn )(vn , v1 ), i.e., the ordering of the vertices in C is set to be the ordering of the vertices along the spine. In order to compute an upward point-set embedding of G on P with at most one bend per edge, we apply the algorithm described by Kaufmann and Wiese [14]. Namely, given a planar graph G′ with a hamiltonian cycle (v1 , v2 , . . . , vn , v1 ), the algorithm in [14] computes a point-set embedding of G′ on P with at most one bend per edge such that vi is mapped to pi (i = 1, . . . , n). About time complexity, we just observe that the algorithm in [14] takes O(n log n) time and that the operations of ordering the points of P according to their y-coordinates and possibly rotating the plane can be performed in O(n log n) time. The equivalence shown above is also valid for the non-upward case. Thus combining Theorem 4, Theorem 3 and, Theorem 2, we have the following. Corollary 2. Let G be a TTSP-(di)graph with n vertices. There exists an O(n log n)-time algorithm that computes an (upward) point-set embedding of G with at most one bend per edge on every set of n distinct points on the plane.
Book Embeddings and Point-Set Embeddings of Series-Parallel Digraphs
173
References 1. M. Alzohairi and I. Rival. Series-parallel ordered sets have pagenumber two. In S. North, editor, Graph Drawing (Proc. GD ’96), volume 1190 of Lecture Notes Comput. Sci., pages 11–24. Springer-Verlag, 1996. 2. F. Bernhart and P. C. Kainen. The book thickness of a graph. J. Combin. Theory, Ser. B 27:320–331, 1979. 3. P. Bose. On embedding an outer-planar graph on a point set. In G. Di Battista, editor, Graph Drawing (Proc. GD ’97), volume 1353 of Lecture Notes Comput. Sci., pages 25–36. Springer-Verlag, 1997. 4. P. Bose, M. McAllister, and J. Snoeyink. Optimal algorithms to embed trees in a point set. Journal of Graph Algorithms and Applications, 2(1):1–15, 1997. 5. F. R. K. Chung, F. T. Leighton, and A. Rosenberg. Embedding graphs in books: A layout problem with applications to VLSI design. SIAM Journal on Algebraic and Discrete Methods, 8:33–58, 1987. 6. G. Di Battista, P. Eades, R. Tamassia, and I. G. Tollis. Graph Drawing. Prentice Hall, Upper Saddle River, NJ, 1999. 7. G. Di Battista and R. Tamassia. On-line planarity testing. SIAM Journal on Computing, 25(5):956–997, October 1996. 8. S. Even and R. E. Tarjan. Computing an st-numbering. Theoret. Comput. Sci., 2:339–344, 1976. 9. J. Ganley and L. Heath. The pagenumber of k-trees is O(k). Discrete Applied Mathematics, 109:215–221, 2001. 10. P. Gritzmann, B. Mohar, J. Pach, and R. Pollack. Embedding a planar triangulation with vertices at specified poi nts. Amer. Math. Monthly, 98(2):165–166, 1991. 11. L. S. Heath and S. V. Pemmaraju. Stack and queue layouts of posets. SIAM Journal on Discrete Mathematics, 10:599–625, 1997. 12. L. S. Heath and S. V. Pemmaraju. Stack and queue layouts of directed acyclic graphs: Part II. SIAM Journal on Computing, 28:1588–1626, 1999. 13. L. S. Heath, S. V. Pemmaraju, and A. Trenk. Stack and queue layouts of directed acyclic graphs: Part I. SIAM Journal on Computing, 28:1510–1539, 1999. 14. M. Kaufmann and R. Wiese. Embedding vertices at points: Few bends suffice for planar graphs. Journal of Graph Algorithms and Applications, 6(1):115–129, 2002. 15. R. Nowakowski and A. Parker. Ordered sets, pagenumbers and planarity. Order, 6:209–218, 1989. 16. J. Valdes, R. E. Tarjan, and E. Lawler. The recognition of series-parallel digraphs. SIAM J. Comput., 11(2):298–313, 1982. 17. M. Yannakakis. Embedding planar graphs in four pages. Journal of Computer and System Sciences, 38:36–67, 1989.
Compact Encodings of Planar Orthogonal Drawings⋆ Amrita Chanda and Ashim Garg Department of Computer Science and Engineering University at Buffalo Buffalo, NY 14260 {achanda,agarg}@cse.buffalo.edu
Abstract. We present time-efficient algorithms for encoding (and decoding) planar orthogonal drawings of degree-4 and degree-3 biconnected and triconnected planar graphs using small number of bits. We also present time-efficient algorithms for encoding (and decoding) turn-monotone planar orthogonal drawings.
1
Introduction
It is important to compress the representation of planar orthogonal drawings to reduce their storage requirements and transmission times over a network, like Internet. The encoding problem is also interesting from a theoretical viewpoint. A degree-d graph is one, where each vertex has at most d edges incident on it. A planar drawing is one with no edge-crossings. An orthogonal drawing is one, where each edge is drawn as an alternating sequence of horizontal and vertical line-segments. A bend (turn) is defined as the meeting point of two consecutive line-segments of an edge in a drawing. In this paper, we investigate the problem of encoding planar orthogonal drawings of degree-4 and degree-3 biconnected and triconnected planar graphs using small number of bits, and present several results. Let d be a planar orthogonal drawing, with b turns (bends), of a planar graph G with n vertices, m edges, and f internal faces. Suppose each line-segment of d has length at most W . Through out the paper, to avoid triviality, we will assume that n ≥ 3. A simple drawing-description format that stores the underlying graph using adjacency-list representation, and stores the coordinates of the vertices and edge-bends would require Ω(n + m log2 n + n log2 (b + n)W + b log2 (b + n)W ) bits in the worst case. More complex formats may require even more bits. We are not aware of any work focusing explicitly on encoding planar orthogonal drawings. In Sections 2, 3, and 4, respectively, we give our result, previous work, and some definitions. In Sections 5, 6, and 7, respectively, we show how to encode (and decode) degree-3 and degree-4 plane graphs, orthogonal representations, and lengths of the line-segments of a planar orthogonal drawing. In Section 8, we give our overall algorithm for encoding (and decoding) a planar orthogonal drawing. ⋆
Research supported by NSF CAREER Award IIS-9985136 and NSF CISE Research Infrastructure Award No. 0101244.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 174–186, 2002. c Springer-Verlag Berlin Heidelberg 2002
Compact Encodings of Planar Orthogonal Drawings
2
175
Our Result
Our results can be summarized as follows (with G, n, m, f , d, W , and b as defined above): Let p = (2 + b + m − f ) log2 (W + 1). Let q = n + b. – If G is a degree-4 biconnected graph, then we can encode (and decode) d using at most 4.74m+2.42n+1.58b+p+O(log q) bits in O((n+b+p)2 ) time, and using at most 5.01m + 2.33n + 1.67b + p + O(log q) bits in O(n+b+p) time. – If G is a degree-4 triconnected graph, then we can encode (and decode) d using at most 3.58m+2.59n+1.58b+p+O(log q) bits in O((n+b+p)2 ) time, and using at most 3.67m + 2.67n + 1.67b + p + O(log q) bits in O(n+b+p) time. – If G is a degree-3 biconnected graph, then we can encode (and decode) d using at most 4.74m+1.23n+1.58b+p+O(log q) bits in O((n+b+p)2 ) time, and using at most 5.01m + 1.33n + 1.67b + p + O(log q) bits in O(n+b+p) time. – If G is a degree-3 triconnected graph, then we can encode (and decode) d using at most 3.58m + n + 1.58b + p + O(log q) bits in O((n + b + p)2 ) time, and using at most 3.67m + n + 1.67b + p + O(log q) bits in O(n + b + p) time. Several drawing algorithms [7,8], that try to minimize the number of bends, produce turn-monotone planar orthogonal drawings, i.e., where for each edge e = (u, v), if we travel from u to v along e, then we will either make left turns or right turns, but not both (see Figure 1(a)). Turn-monotone planar orthogonal drawings are very common in practice. We show that a turn-monotone planar orthogonal drawing d can be encoded even more succinctly: – If G is a degree-4 biconnected graph, then we can encode (and decode) d using at most 3.16m+4n+1.58b+p+O(log q) bits in O((n+b+p)2 ) time, and using at most 3.34m + 4n + 1.67b + p + O(log q) bits in O(n + b + p) time. – If G is a degree-4 triconnected graph, then we can encode (and decode) d using at most 2m+4.17n+1.58b+p+O(log q) bits in O((n+b+p)2 ) time, and using at most 2m + 4.34n + 1.67b + p + O(log q) bits in O(n + b + p) time. – If G is a degree-3 biconnected graph, then we can encode (and decode) d using at most 3.16m+2.81n+1.58b+p+O(log q) bits in O((n+b+p)2 ) time, and using at most 3.34m + 3n + 1.67b + p + O(log q) bits in O(n + b + p) time. – If G is a degree-3 triconnected graph, then we can encode (and decode) d using at most 2m+2.58n+1.58b+p+O(log q) bits in O((n+b+p)2 ) time,, and using at most 2m + 2.67n + 1.67b + p + O(log q) bits in O(n + b + p) time. As a by-product, our technique also encodes orthogonal representations, which are important intermediate constructs used by several drawing algorithms [7,4].
3
Related Work
As mentioned above, we are not aware of any previous work focusing explicitly on encoding planar orthogonal drawings. However, a lot of work has been done on encoding planar graphs. Let G be a planar graph with n vertices and m edges. If G is biconnected (triconnected, triangulated, respectively), then it can be
176
Amrita Chanda and Ashim Garg
+
encoded using at most 2n 1.58m bits [I] (1.58(n+ m ) bits [I], 1.33m bits [I]). If G is a triangulated graph, then any encoding of G requires at least 1.08m bits [9]. [5] presents a technique for encoding G in asymptotically the minimum number of bits in O(n1ogn) time. For more results on graph encoding, see [I]. Our encoding technique is based on the graph encoding technique of [I], and on the concept of canonical orderings of planar graphs [2,6,1].
4
Preliminaries
We use standard definitions of graph-theoretic terms. A plane graph G is a planar graph equipped with an embedding. Two vertices of G are neighbors if they are connected by an edge. Let u l , u2,. . . , uk be some vertices of G. The plane graph induced by u l , u2, . . . , uk is the maximal subgraph of G that consists of these vertices and their incident edges. Suppose G has n vertices. An ordering vl, v2, . . . , v, of the vertices of G is an assignment of unique integers in the range [I,n] to the vertices, such that the ith vertex vi in the order is assigned number i . Let G be a degree-4 plane graph. Two planar orthogonal drawings TI and r2 of G are shape equivalent if: (1) for each vertex v, consecutive edges incident to v and (2) for each edge (u, v), the sequence form the same angle at v in TI and r2, of left and right turns encountered while walking from u to v along the polygonal An orthogonal representation r chain representing (u, v) is the same in TI and r2. of G defines an equivalence class of shape equivalent planar orthogonal drawings of G. r is a t u r n m o n o t o n e representation if each edge is represented as a polygonal chain consisting of only left or right turns, but not both (see Figure l ( a ) ) . An important concept used by our encoding technique is that of a canonical ordering of a plane graph (see Figure 1(b)).This concept has been defined and used in [2,6,1].Let G = (V, E) be a simple biconnected plane graph with n vertices,
Fig. 1. (a) A turn-monotone planar orthogonal drawing. (b) corresponding plane graph G, a rightmost canonical ordering c of G and the canonical spanning tree T, corresponding to c. Here, each vertex is labeled by its number in c , the edges of T, are shown as dark lines. Each face is also labeled by its number in corresponding ordering of faces.
Compact Encodings of Planar Orthogonal Drawings
177
and m edges. Let v1 , v2 , . . . , vn be an ordering of the vertices of G. Let Gi be the plane graph induced by vertices v1 , v2 , . . . , vi . Let Hi be the external face of Gi . Definition 1 ([1]). Let v1 , v2 , . . . , vn be an ordering of the vertices of a biconnected plane graph G = (V, E), where v1 and v2 are two arbitrary vertices on the external face of G with (v1 , v2 ) ∈ E. The ordering is canonical if there exist ordered partitions I1 , I2 , . . . , IK of the interval [3, n] such that the following properties hold for every 1 ≤ j ≤ K: Suppose Ij = [k, k + q]. Let Cj be the path (vk , vk+1 , . . . , vk+q ) (Note, Cj is a single vertex if q = 0). Suppose we say that a vertex u of Gk−1 is a neighbor of Cj if a vertex of Cj is a neighbor of u. Then: – The graph Gk+q is biconnected. Its external face Hk+q contains the edge (v1 , v2 ), and the path Cj . Cj has no chord in G, i.e., G does not contain any edge (vs , vt ) with |s − t| > 1 and k ≤ s, t ≤ k + q. – Cj has at least two neighbors in Gk−1 , all of which are vertices of Hk−1 . The leftmost neighbor is a neighbor of vk and the rightmost neighbor is a neighbor of vk+q . Moreover, if q > 0, then vl and vr are the only neighbors of Cj in Gk−1 . Here, the leftmost and rightmost neighbors of Cj in Gk−1 are defined as follows: Vertices v1 and v2 divide Hk−1 into two paths: a path consisting only of edge (v1 , v2 ), and another path v1 (= u1 )u2 . . . us (= v2 ) that connect v1 and v2 , and that does not contain the edge (v1 , v2 ). We say that a vertex ui is left (right) of another vertex uz , if i < z (i > z). The leftmost (rightmost) neighbor of Cj in Gk−1 is the vertex ub such that ub is a neighbor of Cj , and there is no other vertex ut such that ut is a neighbor of Cj and ut is left (right) of ub . A canonical ordering for a triconnected plane graph is defined the same as for a biconnected plane graph, except that it has the following additional property: Property 1 ([1]). Every vertex vk , where 1 ≤ k ≤ n − 1 has at least one neighbor vp with k < p. A rightmost canonical (rmc) ordering for a biconnected plane graph G is defined as follows (see Figure 1(b)): Definition 2 ([1]). Let v1 , v2 , . . . , vn be a canonical ordering for G, where I1 , I2 , . . . , IK are its corresponding interval partitions. We say that v1 , v2 , . . . , vn is a rightmost canonical (rmc) ordering for G if the following property holds for every interval Ij , where 1 ≤ j ≤ K: Suppose Ij = [k, k + q]. Let v1 , v2 , . . . , vk−1 , uk , uk+1 , . . . , un be any canonical ordering for G whose first j − 1 interval partitions are exactly I1 , I2 , . . . , Ij−1 (Clearly, the Gk−1 and Hk−1 with respect to both canonical orderings are the same). Let vl be the leftmost neighbor of vk on Hk−1 . Let ul be the leftmost neighbor of uk on Hk−1 . Then, vl is to the right of ul on Hk−1 . Theorem 1. [1] Every biconnected plane graph G with n vertices admits a rightmost canonical (rmc) ordering, which can be constructed in O(n) time.
178
Amrita Chanda and Ashim Garg
Any canonical ordering c = v1 , v2 , . . . , vn of a biconnected plane graph G and its corresponding interval partitions I1 , I2 , . . . , IK defines a canonical spanning tree Tc that consists of the edge (v1 , v2 ) plus the union of the paths vl vk vk+1 ...vk+q over all intervals Ij = [vk , vk+q ], where 1 ≤ j ≤ K and vl is the leftmost neighbor of vk on Hk−1 (see Figure 1(b)). Suppose we root Tc at v1 . A tree edge of a vertex v is one that also belongs to Tc , and a non-tree edge is one that does not. The incoming tree edge of v is the edge that connects v to its parent in Tc , and an outgoing tree edge is one that connects v to a child in Tc . Suppose vertex v belongs to interval Ij = [vk , vk+q ]. The incoming non-tree edges of v are those that connect v to neighbors in Gk−1 , and the outgoing non-tree edges are the remaining non-tree edges. Note that by the definition of canonical ordering, each outgoing non-tree edge of v will be of the form (v, vs ), where s > k + q. Also, note that for each incoming non-tree edge (u, v) of v, u will be on Hk−1 . For example, in Figure 1(b), Vertex 12 has incoming tree edge (10, 12), no outgoing tree edge, incoming non-tree edges (11, 12) and (9, 12), and outgoing non-tree edge (12, 14). Properties 2 and 3 follow easily from the definition of canonical ordering: Property 2. Let v = v1 be a vertex of G. Then, v has exactly one incoming tree edge, and at least one outgoing tree-edge or incoming non-tree edge. Vertex v1 has only outgoing tree edges. Property 3. If G is a triconnected graph, then for every vertex v = v1 , vn of G, v has Property 2. Also, it has either at least one outgoing tree-edge, or at least one outgoing non-tree edge. Vertex v1 has only outgoing tree edges. Vertex vn has exactly one incoming tree edge and all its other edges are incoming non-tree edges. Theorem 2. Let G be a biconnected plane graph with n vertices. Suppose, we are given a rightmost canonical ordering c = v1 , v2 , . . . , vn of the vertices of G, along with the number of outgoing tree edges, incoming non-tree edges, and outgoing non-tree edges of each vertex as defined by c. Then, we can determine in O(n) time, all the edges in G, as well as its embedding. In other words, given this information, we can determine the entire structure of graph G. Sketch of Proof. Starting from the empty graph G0 , we reconstruct G iteratively by constructing a sequence of plane graphs G0 , G1 , G2 , . . . , Gp = G, where in each iterative step i, we obtain Gi from Gi−1 by inserting some vertices and edges into it. This is done as follows: For each vertex vk , where 1 ≤ k ≤ n, maintain two counters, T Count(vk ) and N count(vk ), that initially store the number of outgoing tree edges and outgoing non-tree edges, respectively, of vk . In the first iterative step, insert into G0 , vertices v1 , v2 , . . . , vr , where vr is the lowest numbered vertex in c with an incoming non-tree edge. Also, insert the edges (v1 , v2 ), (v1 , v3 ), (v3 , v4 ), . . . , (vr−1 , vr ), (vr , v2 ). Note that these edges will form a single simple cycle. Reduce N count(v2 ) by 1. For each j, where 1 ≤ j ≤ r − 1 and j = 2, reduce T Count(vj ) by 1. In a general iterative step i, we obtain Gi from Gi−1 as follows: Suppose Gi−1 consists of vertices v1 , v2 , . . . , vk−1 . Let vk , vk+1 , . . . , vk+q be the sequence
Compact Encodings of Planar Orthogonal Drawings
179
of consecutive vertices in c such that vertices vk , vk+1 , . . . , vk+q−1 do not have any incoming non-tree edge, but vk+q does. Let Hk−1 be the external face of Gk−1 . Let u be the rightmost vertex on Hk−1 with T Count(u) > 0. We have 2 cases: – q = 0 : Suppose vk has t incoming non-tree edges. Let u1 , u2 , . . . , ut be the first t vertices to the right of u on Hk−1 , such that, for each ui , N Count(ui ) > 0. Insert vertex vk and the edges (u, vk ), (vk , u1 ), (vk , u2 ), . . . , (vk , ut ) into Gk−1 to obtain Gk . For each i, where 1 ≤ i ≤ t, reduce N Count(ui ) by 1 (Note that except for ut , N Count(ui ) for each ui will become 0 now). Reduce T Count(u) by 1. – q > 0 : In this case, vk+q will have only one neighbor u′ on Hk−1 , where u′ is the first vertex right of u with N Count(u′ ) > 0. Insert vertices vk , vk+1 , . . . , vk+q and edges (u, vk ), (vk , vk+1 ), (vk+1 , vk+2 ), . . . , (vk+q−1 , vk+q ), (vk+q , u′ ), into Gk−1 to obtain Gk . Reduce N Count(u′ ) by 1. Reduce T Count(u) by 1. Also, for each i, where k ≤ i ≤ k + q − 1, reduce T Count(vi ) by 1.
5
Encoding Degree-3 And Degree-4 Plane Graphs
The algorithms of [1] will encode a biconnected (triconnected) degree-4 plane graph using 5.17n bits (4.74n bits), and a degree-3 biconnected (triconnected) plane graph using 4.37n (3.95n) bits. But, these algorithms do not consider the degrees of vertices while encoding a graph. (The algorithm of [5] will construct an asymptotically bit-minimum encoding of these graphs, but it is practical only for very large graphs.) Here, we show that we can get a better encoding for degree-3 and degree-4 plane graphs by considering the degrees of their vertices. The basic idea is simple. Suppose we construct a rightmost canonical ordering c = v1 , v2 , . . . , vn of the vertices of a biconnected plane graph G. Then, to encode G, from Theorem 2, it is sufficient to encode, for each vertex, how many outgoing tree edges, incoming non-tree edges, and outgoing non-tree edges the vertex has. Suppose G is a degree-3 graph. From Property 2, a vertex v = v1 can only be of one of the 7 types, A to G, based on its degree, and the number and types of its edges. v is of one of types A to F , if it has degree 3, and of type F or G if it has degree 2. v is of (a) Type A: if it has two outgoing tree edges, (b) Type B: if it has one outgoing tree edge and one incoming non-tree edge, (c) Type C: if it has one outgoing tree edge and one outgoing non-tree edge, (d) Type D: if it has one incoming and one outgoing non-tree edge, (e) Type E: if it has two incoming non-tree edges, (f) Type F: if it has one incoming non-tree edge, and (g) Type G: if it has one outgoing tree edge. Note that vertex v1 will have either two or three outgoing tree edges. Thus, we encode G by a string S = s1 s2 . . . sn , where – s1 represents the number of outgoing tree edges of v1 , and is equal to 0 if v1 has two outgoing edges, and is equal to 1 if v1 has three outgoing edges. – Each symbol si , 2 ≤ i ≤ n, represents the type of vertex vi , and is equal to A, B, C, D, E, F , or G. Since each si , where 2 ≤ i ≤ n, can have 7 possible values, we can encode the substring S ′ = s2 . . . sn using (n − 1) log2 7 ≈ 2.81(n − 1) bits by converting the
180
Amrita Chanda and Ashim Garg
corresponding Base-7 number into binary representation in O(n2 ) time. Using Huffman encoding, we can encode S ′ using at most 3(n − 1) bits in O(n) time. This, combined with Theorems 1 and 2, gives us the following lemma: Lemma 1. Given a degree-3 biconnected plane graph G with n vertices, we can encode it using less than 2.81n bits in O(n2 ) time and decode the encoding to reconstruct G in O(n2 ) time. We can also encode G using at most 3n − 2 bits and decode the encoding to reconstruct G in O(n) time. If G is a degree-3 triconnected graph, then, using Property 3, we can show that each vertex v = v1 , vn can only be of 4 types. This gives a shorter encoding for G: Lemma 2. Given a degree-3 triconnected plane graph G with n vertices, we can encode it using at most 2n−2 bits in O(n) time (using Huffman Encoding). This encoding can be decoded in O(n) time to reconstruct G. If G is a degree-4 biconnected (triconnected) graph, then each vertex v, where v = v1 (v = v1 , vn ), can be of 16 (12) types. This gives Lemma 3 (Lemma 4): Lemma 3. Given a degree-4 biconnected plane graph G with n vertices, we can encode it using at most 4n − 2 bits in O(n) time (using Huffman Encoding) and decode the encoding to reconstruct G in O(n) time. Lemma 4. Given a degree-4 triconnected plane graph G with n vertices, we can encode it using 2 + (n − 2) log2 12 + 1 < 3.59n bits in O(n2 ) time and decode the encoding to reconstruct G in O(n2 ) time. We can also encode G using at most 2 + 3.67(n − 1) + 1 < 3.67n bits (using Huffman encoding) and decode the encoding to reconstruct G in O(n) time.
6
Encoding an Orthogonal Representation
We will use the following properties of an orthogonal representation: Property 4. The sum of angles around any vertex is equal to 360◦ . Property 5. The sum of interior angles of the polygon p representing any internal face is equal to (k − 2)180◦ , where k is the total number of line-segments in p. We can encode an orthogonal representation Γ of a biconnected plane graph G by: – encoding structure: encoding the structure of graph G, – encoding angles: for each vertex, encoding the angles between consecutive edges incident on it, and – encoding turns: for each edge e = (u, v), encoding the sequence of left and right turns encountered while walking from u to v along e.
Compact Encodings of Planar Orthogonal Drawings
181
To encode angles, suppose G has n vertices and m edges. Each angle of Γ can be either 90◦ , 180◦ , or 270◦ . Suppose we have already constructed a rightmost canonical ordering c = v1 , v2 , . . . , vn of the vertices of G. Let vi be a vertex of G. Let e1 e2 . . . ek , where k ≤ 4 be the counterclockwise order of edges incident on vi , where, if vi = v1 , then e1 is the incoming tree edge of v, and if vi = v1 , then e1 is the edge (v1 , v2 ). Let s∗i be the string a1 a2 . . . ak , where aj represents the counterclockwise angle between edges ej and ej+1 at vertex vi . aj is equal to A, B, or C, respectively, if the magnitude of the corresponding angle is equal to 90◦ , 180◦ , or 270◦ , respectively. Then, we can construct a string S ∗ = s∗1 s∗2 . . . s∗n , that encodes all the angles of G. Total number of symbols in S ∗ is equal to number of angles in Γ , which is equal to 2m. Using Property 4, we can encode S ∗ using even fewer bits. Property 4 implies that, for each vertex vi , it is sufficient to encode angles a1 , a2 , . . . , ak−1 since the value of angle ak can be obtained from them. Thus, for vi , it is sufficient to construct the string s∗i = a1 a2 . . . ak−1 . So, the overall number of symbols in string S ∗ can be reduced to 2m − n. We therefore have the following lemma: Lemma 5. Given an orthogonal representation of a degree-4 biconnected graph G with n vertices, we can encode its angles using (2m−n) log2 3 ≈ 1.58(2m−n) ≤ 4.74n bits in O(n2 ) time and at most 1.67(2m − n) ≤ 5.01n bits in O(n) time (using Huffman Encoding). Moreover, during decoding, if we already knew the degree of each vertex, then we can decode these encodings to obtain the angles in O(n2 ) and O(n) time, respectively. If G is a triconnected graph, then each vertex has at least 3 angles around it, and so each angle can be either 90◦ , or 180◦ . Therefore: Lemma 6. Given an orthogonal representation of a degree-4 triconnected graph G with n vertices, we can encode its angles using 2m − n bits in O(n) time. Moreover, during decoding, if we already knew the degree of each vertex, then we can decode the encoding to obtain the angles in O(n) time. Now consider the problem of encoding the turns of Γ . Given a rightmost canonical ordering c = v1 , v2 , . . . , vn of G, and the associated canonical tree Tc , we first construct an ordering o = e1 , e2 , . . . , em of the edges of G by putting the incoming tree and non-tree edges of the vertices v1 , v2 , . . . , vn into o, such that the edges of vi precede those of vj if i < j, and for each vertex vi , we first put its incoming tree edge, and then its incoming non-tree edges in the same order as their counter-clockwise order around vi . Next, for each edge ei = (vj , vk ) in o, where j < k, we construct a (possibly empty) string s+ i consisting of symbols L and R, where a symbol L (R) denotes a left (right) turn encountered while walking from vj to vk along ei . These symbols are placed in s+ i in the order the corresponding turns are encountered while walking from vj to vk . Finally, we construct a string + + + S + = s+ 1 #s2 # . . . #sn consisting of all the si ’s separated by a symbol #. Lemma 7. Given an orthogonal representation Γ with b turns (bends) of a degree-4 biconnected graph G with n vertices, we can encode its turns using (b + m−1) log2 3 ≈ 1.58(b+m−1) bits in O((b+m)2 ) time, and at most 1.67(b+m−1)
182
Amrita Chanda and Ashim Garg
bits in O(b+m) time (using Huffman Encoding). These encodings can be decoded in O((b + m)2 ) and O(b + m) time, respectively, to obtain the turns of Γ . If Γ is a turn-monotone orthogonal representation, then we can reduce the length of S + by using Property 5 as follows: c induces an ordering f1 , f2 , . . . , fp of the internal faces of G, such that when we reconstruct G using c, as in the proof of Theorem 2, starting from an initially empty graph, the faces will get inserted into it in the same order. Let I1 , I2 , . . . , IK be the corresponding intervals of c. The ordering f1 , f2 , . . . , fp is defined as follows (see Figure 1(b)): Let I1 = [v3 , v3+q′ ], where q ′′ ≥ 0. Face f1 is the face consisting of the vertices v1 , v3 , . . . , v3+q′ , v2 . In general, suppose we have already constructed the partial ordering f1 , f2 , . . . , fs of the faces, using intervals I1 , I2 , . . . , Ik−1 . Let Ik = [vk , vk+q ], where q ≥ 0. Let P = v1 (= u1 )u2 . . . us (= v2 ) be the subpath of Hk−1 that we obtain by removing the edge (v1 , v2 ) from Hk−1 . Let Cj be the path vk vk+1 . . . vk+q . We have 2 cases: – q > 0: Then, Cj has exactly two neighbors vl and vr in Hk−1 . Let x1 = (vl )x2 , . . . , xt (= vr ) be the subpath of P that connects vl and vr . Then, fs+1 is the internal face of G consisting of the vertices vl (= x1 ), vk , . . . , vk+q , vr (= xt ), xt−1 , xt−2 , . . . , x2 . We say that face fs+1 belongs to Interval Ik . – q = 0: Then Cj consists of exactly one vertex vk . Let u′1 (= vl ), u′2 , . . . , u′t (= vr ) be the left-to-right order of the neighbors of vk in Hk−1 . Let Pi′ , where 1 ≤ i ≤ t − 1, be the subpath of P that connects u′i and u′i+1 . Then, each face fs+i , where 1 ≤ i ≤ t − 1, is the internal face that consists of the vertex vk and the vertices of path Pi′ . We say that face fs+i belongs to Interval Ik . (Figure 1(b) also shows the ordering of the faces given by the rightmost canonical ordering shown in Figure 1(b).) Let Tc be the canonical spanning tree associated with c. For each face fi , a tree edge of fi is one that is also an edge of Tc . Fact 1. Except for one non-tree edge e, all the non-tree edges of each face fi are already contained in the faces f1 , f2 , . . . , fi−1 . We will call edge e as the non-tree completion edge of fi . Intuitively, we call the edge non-tree completion edge because, while reconstructing G using c, this is the only non-tree edge that we need to add to the already constructed graph to add face fi to it (of course, we will need to add the tree edges of fi also). For example, in Figure 1, edge (14, 12) is the non-tree completion edge of face f10 . For the face fs , in the case q > 0 given above, the non-tree completion edge is the edge (vk+q , vr ). For each face fs+i , in the case q = 0 given above, the non-tree completion edge is the edge (vk , ui+1 ). Since each edge of a turn-monotone orthogonal representation Γ has same kinds of turns only (left or right, but not both), Property 5 implies that for any face of Γ , it is sufficient to encode the turns of all but one edge, namely its non-tree completion edge e, since the turns of e can be deduced from the turns of the other edges. Infact, Lemma 8 says that it is sufficient to encode turns of tree edges:
Compact Encodings of Planar Orthogonal Drawings
183
Lemma 8. Let Γ be a turn-monotone orthogonal representation of a degree-4 biconnected plane graph G. let c be a rightmost canonical ordering of G. Suppose we construct a string S + encoding the turns of Γ as in Lemma 7 using c, except that S + encodes the turns of only the tree edges of G. Then, by decoding S + we can obtain the turns of all the edges of Γ . Proof. Let f1 , f2 , . . . , fp be the ordering of faces that corresponds to c, as defined above. We can easily prove this lemma can using induction: Base Case: Consider face f1 . Decoding S + will give us the turns of all the tree edges of f1 . f1 has exactly one non-tree edge e (which is its non-tree completion edge). From Property 5, we can determine the turns of e also. Induction: Suppose we have already determined the turns of all the edges of faces f1 , f2 , . . . , fi−1 . Consider face fi . From Fact 1, except for its non-tree completion edge e, all the other non-tree of fi are already contained in the faces f1 , f2 , . . . , fi−1 . Decoding S + will give us the turns of all the tree edges of f1 . Hence, except for e, we would know the turns of all the edges of fi . From Property 5, we can determine the turns of e also. ⊔ ⊓ Since, Tc has exactly n − 1 edges, we have: Lemma 9. Given a turn-monotone orthogonal representation with b turns(bends) of a degree-4 biconnected graph with n vertices, we can encode its turns using at most (b + n − 2) log2 3 ≈ 1.58(b + n − 2) bits in O((b + n)2 ) time, and at most 1.67(b + n − 2) bits in O(b + n) time (using Huffman Encoding). These encodings can be decoded in O((b+n)2 ) and O(b+n) time, respectively, to obtain the turns. To encode an orthogonal representation Γ , we construct a string S1 = A′ L′ A∗ L∗ S ′ S ∗ S + , where S ′ , S ∗ , S + are strings encoding structure, angles, and turns, respectively, of Γ , as given by Lemmas 1 (or 2, 3, or 4), 5 (or 6), and 7 (or 9), respectively, L′ (L∗ ) is length of S ′ (S ∗ ) in binary notation, and A′ (A∗ ) encodes the length of L′ (L∗ ) in unary notation, and consists of |L′ | (|L∗ |) 0’s followed by a 1. Note that lengths of A′ , L′ , A∗ , and L∗ are O(log n) each.
7
Encoding Lengths of Line-Segments
Let d be a planar orthogonal drawing with b turns of a degree-4 biconnected plane graph G with n vertices and m edges. Suppose each line-segment of d has length at most W . Just as we constructed a string S + in Section 6 to encode turns, we can construct a string S ′′ = s′′1 s′′2 . . . s′′m , where each si contains the lengths of all the line-segments of edge ei = (vj , vk ), placed in the order the corresponding linesegments are encountered while traveling along ei from vj to vk , where j < k. We can reduce the length of S ′′ by using the following property of d: Suppose we orient each horizontal line-segment of d as going “East” or “West”, and each vertical line-segment as going “North” or “South”, assuming that the linesegment of the edge (v1 , v2 ) incident on v1 goes East. (We can easily do this in O(n+m+b) = O(n+b) time using the angle and turn information contained in d.)
184
Amrita Chanda and Ashim Garg
Property 6. In d, for each face of G: 1. The sum of the lengths of all the line-segments going East = the sum of the lengths of all the line-segments going West, and 2. The sum of the lengths of all the line-segments going North = the sum of the lengths of all the line-segments going South. Property 6 implies that we can omit encoding the length of one horizontal and one vertical line-segment of fi , and still be able to obtain the lengths of all the line-segments of fi from an encoding of the lengths of its other line-segments. To decide which line-segments to omit, consider the ordering f1 , f2 , . . . , fm of the faces of G that we can obtain from a rightmost ordering c of G, as described in Section 6. Let Ik = [vk , vk+q ] be the interval of c, such that fi belongs to Ik . Let Ei be the set of all the edges of fi that are not in the faces f1 , f2 , . . . , fi−1 . Note that Ei contains at least one edge, namely, the non-tree completion edge e = (u, v) of fi . Moreover, the edges of Ei form a connected path p, which connects u with a vertex u′ , where u is the end-vertex of e that belongs to Hk−1 , and u′ is a vertex common to both fi and fi−1 . The free horizontal (vertical) line-segment of fi is defined as the first horizontal (vertical) line-segment encountered while traveling along p from u to u′ . Note that fi will have at least one free line-segment (which can be horizontal or vertical). While encoding the lengths of the linesegments of d, we can omit from S ′′ all the free line-segments of the faces of G. Having constructed S ′′ , we can construct a string S2 = A′′ T ′′ S ′′ , where T ′′ stores the value of W in binary using exactly log2 (W + 1) bits, and A′′ contains a sequence of |T ′′ | 0’s followed by a 1. String A′′ basically encodes the length of T ′′ in unary notation. We have the following lemma: Lemma 10. We can encode the lengths of the line-segments of d using a string S2 consisting of 1+(2+b+m−fH −fV ) log2 (W +1) ≤ 1+(2+b+m−f ) log2 (W +1) bits in O(|S2 |) time, where fH and fV are the number of horizontal and vertical free line-segments, respectively, of d. Assuming that, while decoding, we already know all the angles and turns of d, we can decode S2 to obtain the lengths of all the line-segments of d in O(|S2 |) time.
8
Encoding a Planar Orthogonal Drawing
Let d be a planar orthogonal drawing of a degree-4 biconnected planar graph G. Let Γ be the orthogonal representation of G that corresponds to d. We can encode d by constructing a string S = BLS1 S2 , where S1 is the string constructed in Section 6 that encodes Γ , S2 is the string constructed using Lemma 10 that encodes the free lengths of the line-segments of d, L is a string, with length log2 (|S1 | + 1), that encodes in binary notation the length of string S1 , and B is a string that contains a sequence of |L| 0’s followed by a 1. B encodes the length of L in unary notation. We can obtain d by decoding S, by first extracting B from it and obtaining the length of L, then extracting L and obtaining the length of S1 , then extracting
Compact Encodings of Planar Orthogonal Drawings
185
S1 and decoding it to obtain Γ , and finally, extracting S2 and decoding it to obtain the lengths of the line-segments of d. This is summarized in Theorem 3: Theorem 3. Let d be a planar orthogonal drawing, with b turns (bends) of a plane graph G with n vertices, m edges, and f internal faces. Suppose each linesegment of d has length at most W . Let p = (2 + b + m − f ) log2 (W + 1). Let q = n + b. – If G is a degree-4 biconnected graph, then we can encode (and decode) d using at most 4.74m+2.42n+1.58b+p+O(log q) bits in O((n+b+p)2 ) time, and using at most 5.01m + 2.33n + 1.67b + p + O(log q) bits in O(n + b + p) time. – If G is a degree-4 triconnected graph, then we can encode (and decode) d using at most 3.58m+2.59n+1.58b+p+O(log q) bits in O((n+b+p)2 ) time, and using at most 3.67m + 2.67n + 1.67b + p + O(log q) bits in O(n + b + p) time. – If G is a degree-3 biconnected graph, then we can encode (and decode) d using at most 4.74m+1.23n+1.58b+p+O(log q) bits in O((n+b+p)2 ) time, and using at most 5.01m + 1.33n + 1.67b + p + O(log q) bits in O(n + b + p) time. – If G is a degree-3 triconnected graph, then we can encode (and decode) d using at most 3.58m + n + 1.58b + p + O(log q) bits in O((n + b + p)2 ) time, and using at most 3.67m + n + 1.67b + p + O(log q) bits in O(n + b + p) time. Moreover, if d is turn-monotone, then we can encode it using fewer bits, as follows: – If G is a degree-4 biconnected graph, then we can encode (and decode) d using at most 3.16m + 4n + 1.58b + p + O(log q) bits in O((n + b + p)2 ) time, and using at most 3.34m + 4n + 1.67b + p + O(log q) bits in O(n + b + p) time. – If G is a degree-4 triconnected graph, then we can encode (and decode) d using at most 2m + 4.17n + 1.58b + p + O(log q) bits in O((n + b + p)2 ) time, and using at most 2m + 4.34n + 1.67b + p + O(log q) bits in O(n + b + p) time. – If G is a degree-3 biconnected graph, then we can encode (and decode) d using at most 3.16m + 2.81n + 1.58b + p + O(log q) bits in O((n + b + p)2 ) time, and using at most 3.34m + 3n + 1.67b + p + O(log q) bits in O(n + b + p) time. – If G is a degree-3 triconnected graph, then we can encode (and decode) d using at most 2m + 2.58n + 1.58b + p + O(log q) bits in O((n + b + p)2 ) time,, and using at most 2m + 2.67n + 1.67b + p + O(log q) bits in O(n + b + p) time.
References 1. R. C. Chuang, A. Garg, X. He, M. Y. Kao, and H. Lu. Compact encoding of planar graphs via canonical ordering and multiple parenthesis. In Proc. International Colloqium on Automata, Languages and Programming (ICALP), pp. 118–129, 1998. 2. H. de Fraysseix, J. Pach, and R. Pollack. How to draw a planar graph on a grid. Combinatorica, 10(1):41–51, 1990. 3. G. Di Battista, G. Liotta, and F. Vargiu. Diagram Server. J. Visual Lang. Comput., 6(3):275–298, 1995.
186
Amrita Chanda and Ashim Garg
4. G. Di Battista, G. Liotta, and F. Vargiu. Spirality and optimal orthogonal drawings. SIAM J. Comput., 27(6):1764–1811, 1998. 5. Xin He, M.-Y. Kao, and H. Lu. A fast general methodology for informationtheoretically optimal encodings of graphs. SIAM J. Comput., 30(3):838–846, 2000. 6. G. Kant. Drawing planar graphs using the lmc-ordering. In Proc. 33th Annu. IEEE Sympos. Found. Comput. Sci., pages 101–110, 1992. 7. R. Tamassia. On embedding a graph in the grid with the minimum number of bends. SIAM J. Comput., 16(3):421–444, 1987. 8. R. Tamassia and I. G. Tollis. Planar grid embedding in linear time. IEEE Trans. Circuits Syst., CAS-36(9):1230–1234, 1989. 9. W. T. Tutte. A census of planar triangulation. Canad. J. Math., 14:21–38, 1962.
Fractional Lengths and Crossing Numbers⋆ Ondrej S´ ykora1 , L´ aszl´o A. Sz´ekely2 , and Imrich Vrt’o3 1 Department of Computer Science, Loughborough University Loughborough, Leicestershire LE11 3TU, The United Kingdom 2 Department of Mathematics, University of South Carolina Columbia, SC 29208, USA 3 Institute of Mathematics, Slovak Academy of Sciences D´ ubravsk´ a 9, 842 35 Bratislava, Slovak Republic
Abstract. Adamec and Neˇsetˇril [1] proposed a new the so called fractional length criterion for measuring the aesthetics of (artistic) drawings. They proposed to apply the criterion to the aesthetic drawing of graphs. In the graph drawing community, it is widely believed and even experimentally confirmed that the number of crossings is one of the most important aesthetic measures for nice drawings of graphs [6]. The aim of this note is to demonstrate on two standard graph drawing models that in provably good drawings, with respect to the crossing number measure, the fractional length criterion is closely related to the crossing number criterion.
1
Introduction
Adamec and Neˇsetˇril [1] proposed a new the so called fractional length criterion for measuring the aesthetics of (artistic) drawings. A drawing D is a finite set of continuous rectifiable curves in the Euclidean plane. The fractional length of the drawing D, is defined as follows. For a line l denote by i(l, D) the number of intersections of the line l and the drawing D. The fractional length fl(D) of the drawing D is the expected value of i(l, D), where the expectation relates to the random selection of l such that l has a nonempty intersection with the convex hull of D. See Fig. 1 and Fig. 2. The fractional length of the second drawing is roughly 4.81. The fractional length is invariant under transposition, rotation and scaling. The criterion is also applicable to aesthetic graph drawings. See Fig. 2. In the graph drawing community, it is widely believed and even experimentally confirmed that the number of crossings is one of the most important aesthetic measures for nice drawing of graphs [3,6]. The aim of this note is to demonstrate on two standard graph drawing models that in provably good drawings, with respect to the crossing number measure, the fractional length criterion is closely related to the crossing number criterion. Under provably good drawing we understand a drawing in which the number of crossings differs from the minimum ⋆
This research was supported in part by the EPSRC grant GR/R37395/01, NSF contract 007 2187 and the VEGA grant 2/7007/20.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 186–192, 2002. c Springer-Verlag Berlin Heidelberg 2002
Fractional Lengths and Crossing Numbers
187
Fig. 1. A prehistoric drawing - the Uffington white horse.
Fig. 2. A drawing of the 2-dimensional ordinary Butterfly graph inspired by the web page http://www.uni-paderborn.de/cs/ag-madh/.
by a polylogarithmic factor. More precisely, in the orthogonal model of drawing the relation between both parameters is almost quadratical while in the 2-layer drawing model is linear.
188
2
Ondrej S´ ykora, L´ aszl´ o A. Sz´ekely, and Imrich Vrt’o
Definitions
Let G = (V, E) be a graph. Let cr(D) denote the number of crossings of edges in a drawing D of G in the plane. The crossing number of the graph G, denoted by cr(G), is the minumum of cr(D) over all drawings of G. Let G be a connected graph of maximum degree of at most 4. Consider an infinite grid of horizontal and vertical lines with unit distances between any two parallel neighbouring lines. The VLSI layout for the graph G is an injective mapping of vertices of G into nodes of the grid and a mapping of the edges of G into paths of the grid such that two paths can cross or touch at the grid nodes but can not overlap. See Fig. 3. The area A of G is the area of the smallest rectangle covering the layout, where the minumum is taken over all VLSI layouts of G in the grid [9]. Note that any VLSI layout of G produces the so called orthogonal layout.
Fig. 3. A VLSI layout of a graph within area 49.
Let G = (V0 , V1 , E) be a bipartite graph. Place the vertices of V0 and V1 into distinct points on horizontal lines y = 0 and y = 1, in the standard coordinate systems, respectively. Draw the edges by straight line segments producing a 2layer drawing D of G. See Fig. 4. Let bcr(D) denote the number of crossings of edges of D. The bipartite crossing number of G is the minimum of bcr(D) over all drawings D of G.
Fractional Lengths and Crossing Numbers
189
For a graph G = (V, E), let f : |V | → {1, 2, ..., |V |} be a bijection. The optimal linear arrangement problem for G is to find |f (u) − f (v)|. Length(G) = min f
uv∈E
Now we introduce the main tool for estimating fractional lengths of drawings. Steinhaus’ paper [8] implies the following lemma: Lemma 1. Consider a finite system of rectifiable curves in the plane of total length L. Let P be the perimeter of the convex hull of the corresponding drawing D. Then 2L fl(D) = . P
Fig. 4. A 2-layer drawing of the 3-dimensional hypercube.
3
VLSI Model
Our first drawing model with provably good crossing numbers is the orthogonal graph drawing based on the VLSI layout of graphs. 3.1
Basic Result
Theorem 1. Let G = (V, E) be an n-vertex graph with the maximum degree of at most 4. Consider a VLSI layout of G with the area A. Then there exists an orthogonal drawing D of G with a provably good number of crossings cr(D) and positive constants c1 and c2 satisfying cr(D) + n ≤ fl(D) ≤ c2 cr(D) + n log n. c1 log n
Proof. As we do not care about the constant factors we may assume that the optimal VLSI layout of G lies in a square. In fact, Leiserson [5] proved that any
190
Ondrej S´ ykora, L´ aszl´ o A. Sz´ekely, and Imrich Vrt’o
layout lying in a rectagle of the area A can be redrawn by “folding” in such a way that it occupies a square of the area A′ ≤ 3A. The optimal VLSI layout of G produces in a natural way an orthogonal drawing D of G. The results of Leighton [4], Leiserson [5] and Valiant [10] implies: cr(G) + n ≤ cr(D) + n ≤ A ≤ c3 (cr(G) + n) log2 n ≤ c3 (cr(D) + n) log2 n, (1) for some constant c3 . This means that the drawing induced by the optimal VLSI layout produces a provably good drawing as it provides a polylogarithmic approximation of the crossing number of G. Let L be the sum of lengths of all edges of G in the layout. Observe that 1 (cr(D) + n) ≤ L ≤ 2A. (2) 2 In fact, horizontal or vertical straightline segments of lenght 1/2 starting at a single vertex or crossing in the drawing contribute to L by at least 1/2. To see the second inequality, take a unit square and move its center along all edges in the drawing. The total area of covered points is no greater then A, but every point is covered at most twice. Now consider our drawing as a union of curves in the plane of total length L with a square convex hall of the area A. According to the Lemma 1 we have L fl(D) = √ . 2 A
(3)
From (1) and (2) we get
Hence
√ √ cr(D) + n L √ ≤ √ ≤ A ≤ c3 cr(D) + n log n. 4 A 2 A
cr(D) + n √ L ≤ √ ≤ c3 cr(D) + n log n. (4) log n 2 A Finally, substituting (3) into (4) we get the result. ✷ Our results roughly say that the fractional length of a provably good drawing, with respect to crossing number measure, is proportional to the square root of the number of crossings plus the number of vertices. It suggests that the fractional length expresses for orthogonal drawings the same “beauty” as the crossing number but measured in different units. √ Note √ that it is impossible to remove the n term in cr(D) + n, because an n ×√ n mesh graph has crossing number zero but the fractional lenght is of order n. This suggests that the aesthetic measure cr(G) + n is more suitable than just a sole cr(G). We compared the fractional length measure with the number of crossings in “good” drawings with small number of crossings. A comparison to any drawing would be more desirable but one can easily see that if we consider a general drawing model in the plane then any drawing of a graph can be redrawn keeping the number of crossings same but increasing the fractional length arbitrarily. So without putting “reasonable” assumption on the drawing the both measures are incoparable. 1 √ c3
Fractional Lengths and Crossing Numbers
4
191
Two-Layer Model
Our second model of provably good graph drawing is the 2-layer model with the bipartite crossing number measure. Consider an n-vertex bipartite graph V = (V0 , V1 , E). As the bipartite crossing number depends on the orderings of vertices on the lines y = 0 and y = 1 only, we may assume that the vertices are placed into points with integer coordinates such that the whole drawing fits into an (n − 1) × 1 rectangle. 4.1
General Graphs
Theorem 2. Let G = (V0 , V1 , E) be an n-vertex bipartite graph of minimum and maximum degree δ and d. Let δ ≥ 2 and d = O(δ). Then there exists a 2-layer drawing D of G with a provably good number of crossings bcr(D) and positive constants c1 , c2 and c3 satisfying c1
1 1 bcr(D ≤ fl(D) ≤ c2 bcr(D) + c3 d. dn dn
Proof. Consider an optimal linear arrangement of G. We may assume that the vertices of G are placed on the line y = 0 into points {1, 2, ..., n}. Projecting orthogonally the vertices of V1 on the line y = 1 and drawing the edges of G as straight line segments we obtain a 2-layer drawing D of G. The results of Shahrokhi et al. [7] implies bcr(G) ≤ bcr(D) ≤ 5dLength(G)
(5)
and
1 1 2 (6) nd ≤ bcr(D) + nd2 , 12 12 for some positive constant c4 . The above inequalities immediately imply that the bipartite crossing number of the drawing D is approximately the same as the optimal value bcr(G). Now consider our drawing D as a union of curves in the plane of total length L with a rectangular convex hall of the perimeter 2n. Clearly √ (7) Length(G) ≤ L ≤ 2Length(G). c4 dLength(G) ≤ bcr(G) +
Finally, combining (5),(6) and (7) and noting that fl(D) = L/n, we get √ √ bcr(D) 2bcr(D) 2 d, ≤ fl(D) ≤ + 5dn c4 dn c4 which implies the claim. 4.2
✷
Trees
A more precise relation between the fractional length and the bipartite crossing number holds in the case of trees.
192
Ondrej S´ ykora, L´ aszl´ o A. Sz´ekely, and Imrich Vrt’o
Theorem 3. Let T be an n-vertex tree and dv denote the degree of any vertex v. Then there exist a 2-layer optimal drawing D of T satisfying dv dv 1 bcr(D) + n − 1 + fl(D) ≥ n 2 2 v∈T
√ dv dv 2 bcr(D) + n − 1 + fl(D) ≤ n 2 2 v∈T
Proof. Shahrokhi et al. [7] proved that an optimal 2-layer drawing D of a tree T can be obtained from an optimal linear arrangemment of T by the above projection and moreover dv dv . bcr(T ) = bcr(D) = Length(T ) + 1 − n − 2 2 v∈T
The rest of the proof is similar as above.
✷
References 1. Adamec, J., Neˇsetˇril, J.: Towards an Aesthetic Invariant for Graph Drawing. In: 9th Intl. Symp. on Graph Drawing. LNCS 2265. Springer. Berlin (2001) 287-296 2. Bhatt, S., Leighton, F.T.: A Framework for Solving VLSI Graph Layout Problems. J. Computer and System Science 28 (1984) 300-334 3. DiBattista, G., Eades, P., Tollis, I., Tamassia, R.: Graph Drawing: Algorithms for the Visualization of Graphs. Prentice Hall (1999) 4. Leighton, F.T.: New Lower Bound Techniques for VLSI. Mathematical Systems Theory 17 (1984) 47-70 5. Leiserson, C.E.: Area Efficient Graph Layouts (for VLSI). In: 21st Annual Symposium on Foundations of Computer Science. IEEE Press (1980) 270-281 6. Purchase, H.: Which aestethic has the greatest effect on Human Understanding? In: 5th Intl. Symp. on Draph Drawing. LNCS 1353. Springer. Berlin (1997) 248-261 7. Shahrokhi, F., S´ ykora, O., Sz´ekely, L.A., Vrt’o, I.: On Bipartite Drawings and the Linear Arrangement Problem. SIAM J. Computing 30 (2000), 1773-1789. 8. Steinhaus, H.: Length, Shape and Area. Colloquium Math. III (1954) 1-13 9. Thompson, C.D.: Area-Time Complexity for VLSI. In: 11th Annual ACM Symposium on Theory of Computing. ACM Press (1979) 81-89 10. Valiant, L.G.: Universality Considerations in VLSI Circuits. IEEE Transactions on Computers 30 (1981) 135-140
Drawing Directed Graphs Using One-Dimensional Optimization ⋆ Liran Carmel, David Harel, and Yehuda Koren Dept. of Computer Science and Applied Mathematics The Weizmann Institute of Science, Rehovot, Israel {liran, harel, yehuda}@wisdom.weizmann.ac.il
Abstract. We present an algorithm for drawing directed graphs, which is based on rapidly solving a unique one-dimensional optimization problem for each of the axes. The algorithm results in a clear description of the hierarchy structure of the graph. Nodes are not restricted to lie on fixed horizontal layers, resulting in layouts that convey the symmetries of the graph very naturally. The algorithm can be applied without change to cyclic or acyclic digraphs, and even to graphs containing both directed and undirected edges. We also derive a hierarchy index from the input digraph, which quantitatively measures its amount of hierarchy.
1
Introduction
Visualizing digraphs is a challenging task, requiring algorithms that faithfully represent the relative similarities of the nodes, and give some sense of the overall directionality. The latter requirement renders algorithms designed for undirected graphs inappropriate for digraphs. Consequently, algorithms for digraph drawing usually adopt different strategies from their undirected counterparts. The dominant strategy, rooted in the work of Sugiyama et. al. [11], is based on separating the axes, where the y-axis represents the directional information, or hierarchy, and the x-axis allows for additional aesthetic considerations, such as shortening edge lengths or minimizing the number of edge crossings. In these algorithms, the y-coordinates are computed by dividing the y-axis into a finite number of layers and associating each node with exactly one layer — a process called layering. Edges are allowed only between consecutive layers, and they all point in the same direction. To make this feasible, dummy nodes are sometimes inserted. When dealing with cyclic digraphs, no layout can place all edges in the same direction, and what is traditionally done in this case is to apply a preliminary stage, in which a minimal number of edges is sought, whose reversal will make the digraph acyclic. This is actually an NP-hard problem. Assigning the x-coordinates is normally done in two stages. The first determines the order of the nodes within each layer, in an iterative process called ordering. In a single iteration, the order of the nodes in all layers but one is fixed, and the order of the mobile nodes is determined, so as to minimize the number of edge crossings. This too is an NP-hard problem. The second stage determines the exact locations of the nodes along the x-axis, taking into account various parameters, such as the finite size of the nodes and the smoothness of the edges. For more details see [2,6]. ⋆
For a full version see [1]
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 193–206, 2002. c Springer-Verlag Berlin Heidelberg 2002
194
Liran Carmel, David Harel, and Yehuda Koren
Such digraph drawing algorithms have evolved to produce nice and useful layouts for many different types of digraphs. Nevertheless, we would like to point out two inherent properties of the standard strategy, which, despite being treated in various ways by the many algorithms, are in many cases still undesirable: – Finding a layering for cyclic digraphs requires transforming them into acyclic ones, thus introducing a certain distortion of the original problem. – The layering is strict, in the sense that the y-axis is quantized into a finite number of layers. This constraint may sometimes be advisable for acyclic digraphs, but we show that allowing for more flexibility turns out to be advantageous to the drawing. In this paper we present a new algorithm for digraph drawing. It embraces the idea of axis separation, but uses novel approaches to the drawing of both axes. These approaches, apart from the fact that they produce nice drawings and have fast implementations, also successfully deal with the two aforementioned points — the distortion and the discrete layering. We associate with the nodes continuous y-coordinates, in a way that suggests a natural unified framework that can be applied to any kind of digraph, whether cyclic or acyclic, and which requires no graph modification or preprocessing. In particular, dummy nodes are not required, and cyclic digraphs do not have to go through the process of edge inversion. For some digraphs, the continuous layering produces the usual quantization of the y-axis. But, for many other digraphs the quantization is broken, in order to better represent the hierarchy. We define the vector of y-coordinates as the unique minimizer of a simple energy function, and show that the minimization problem is equivalent to a system of linear equations. The simple form of the energy function enables rigorous analysis, giving rise to many interesting results, the most important of which appears to be the definition of an index for measuring the amount of hierarchy in a digraph. As to the x-coordinates, they are assigned using the minimizer of another energy function that is suitable for the one-dimensional case. By definition, a force is the inverse gradient of the energy. Thus, the strategy of energy minimization is equivalent to a force directed model. Therefore, had we been asked to categorize our algorithm, we would have said that it is purely energy minimization oriented, as all of its parts use energy minimization procedures, each part with its own specially tailored energy function. Force directed models are much more popular in undirected graph drawing than in digraph drawing. We are aware of only one other occasion where a force directed model was suggested for digraph drawing, [10], forcing directionality by applying a homogeneous magnetic field and favoring edges that are parallel to its field lines. Yet, we are under the impression that the inferred energy function is complicated, rich in local minima, and rather difficult to minimize.
2
The Algorithm
A digraph is usually written G(V, E), where V = {1, . . . , n} is a set of n nodes and E ⊆ V × V is a set of directed edges, (i, j) being the edge pointing from node i to node j. Each edge is associated with two magnitudes: (1) symmetric weights, wij = wji , and
Drawing Directed Graphs Using One-Dimensional Optimization
195
(2) target height differences, which express the relative hierarchy of nodes i and j by the number δij , measuring their desired height difference along the y-axis. Thus, in the drawing we would like to place nodes i and j such that yi − yj = δij = −δji . A digraph with δij = 0 for every (i, j) ∈ E is really an undirected graph. A digraph is called unweighted if for every edge (i, j), δij = wij = 1. Henceforth, we assume wij = 0 for any non-adjacent pair of nodes. By the conventional definition, the Laplacian is the symmetric n × n matrix n k=1 wik i = j i, j = 1, . . . , n. Lij = −wij i = j For later use, we introduce another important magnitude associated with a digraph: Definition 1. Let G(V, E) be a digraph. The balance of node i is def
bi =
n
wij δij .
j=1
The balance of G is the vector b = (b1 , . . . , bn )T . A node whose balance is zero will be called a balanced node. The balance of i measures the difference between how much i pushes away other nodes (those nodes j for which δij > 0), and how much it is pushed away from them. 2.1
Assigning the y-Coordinates
Here is our energy function: Definition 2. Let G(V, E) be a digraph, and let y = (y1 , . . . , yn )T be any vector of coordinates. The hierarchy energy is EH (G, y) =
n 1 wij (yi − yj − δij )2 = wij (yi − yj − δij )2 . 2 i,j=1
(1)
(i,j)∈E
Clearly, EH ≥ 0 for any digraph and any vector of coordinates. We define an optimal arrangement of a digraph, y ⋆ , as a minimizer of the hierarchy energy, y ⋆ = arg miny EH (G, y). An optimal arrangement will try to place the nodes such that the height difference yi − yj for any adjacent pair will be close to δij . The weight wij indicates how ‘important’ it is that (yi − yj − δij )2 be small. The larger this quantity, the smaller (yi − yj − δij )2 should be, in order to keep the contribution to the energy small. Using the previously defined notions of Laplacian and balance, the hierarchy energy in the compact form EH = E0 + y T Ly − 2y T b, where E0 = ncan be written 1 2 i,j=1 wij δij . For a proof see the full version of this paper [1]. Differentiating this 2 simple form, we find an explicit formula for an optimal arrangement. As the next result shows, y ⋆ is the solution of a system of linear equations. Proposition 1. Let G(V, E) be a digraph, with Laplacian L and balance b. An optimal arrangement y ⋆ is a solution of Ly = b.
196
Liran Carmel, David Harel, and Yehuda Koren
The proof appears in [1], where we also show that the system Ly = b is compatible with an infinite number of solutions that differ from each other only by a translation. The uniqueness (up to a translation) suggests that y ⋆ carries some essential information, as we show in Section 3. We are now in a position to define the optimal arrangement in a completely unique fashion. We require that the center of mass of the optimal arrangement is at the origin of coordinates, i.e., i yi⋆ = 0. This choice of y ⋆ enables its fast computation using the Conjugate Gradient method, see [1]. Therefore: Definition 3. Let G(V, E) be a digraph with Laplacian L and balance b. Its optimal arrangement, y ⋆ , is the solution of Ly = b, subject to the constraint i yi = 0. Let us see how this algorithm works by applying it to some very small-scale examples. More examples appear in later sections. Figure 1(a) shows an unweighted acyclic digraph. Its optimal arrangement is the solution of the system
2 −1 −1 −1 1 0 −1 0 1
⋆
y =
2 −1 −1
⋆
=⇒
y =
2/3 −1/3 −1/3
,
under the constraint i yi⋆ = 0. This is just the expected two-layer solution. The height difference between the layers is 1, thus δij = yi − yj , ∀(i, j) ∈ E, giving EH (y ⋆ ) = 0. Figure 1(b) shows another example of an unweighted acyclic digraph. In this case,
2 −1 −1 −1 2 −1 −1 −1 2
⋆
y =
2 0 −2
⋆
=⇒
y =
2/3 0 −2/3
.
Aesthetically, this vector of coordinates nicely captures the structure of the digraph, where, in contrast to the first example, nodes 2 and 3 can no longer have the same y-coordinate since they push each other in opposite directions. The result reflects a compromise of sorts, pushing node 2 upwards and node 3 downwards, thus decreasing the height difference y1 − y2 to 32 and increasing y1 − y3 to 34 . The height differences cannot achieve their targets, resulting in a strictly positive hierarchy energy EH (y ⋆ ) = ( 32 − 1)2 + ( 23 − 1)2 + ( 34 − 1)2 = 13 .
1
1
2
3
(a)
2
3
(b)
Fig. 1. Two very small examples of unweighted acyclic digraphs.
Drawing Directed Graphs Using One-Dimensional Optimization
197
Figure 2(a) shows an example of an unweighted cyclic digraph. In this case, 2 −1 0 −1
0
0
−1 3 −1 −1 ⋆ 1 0 −1 2 −1 y = 0 −1 −1 −1 3
=⇒
−1
1/4 y = , 0 ⋆
−1/4
which is schematically plotted in Fig. 2(b). Here we see the naturalness of the way our algorithm deals with cyclic digraphs. The result is aesthetically convincing, putting node 2, whose balance is the largest, at the top, and node 4, whose balance is the smallest, at the bottom. As is always the case with cyclic digraphs, the height differences cannot all achieve their targets, resulting in strictly positive hierarchy energy. Indeed, EH (y ⋆ ) = 4 · ( 41 − 1)2 + ( 12 − 1)2 = 2.5. y 2
1
2
4
3
(a)
1
1 4
3
4
1 4
(b)
Fig. 2. (a) A small example of an unweighted cyclic digraph; (b) its optimal arrangement.
The idea of using energy minimization to determine a vector of coordinates on one axis was already exploited in undirected graph drawing by Tutte [12] and Hall [5], both n utilizing the same quadratic energy function, ET H = 12 i,j=1 wij (yi − yj )2 = y T Ly. Comparing this energy with the hierarchy energy (1), it is clear that they become identical for a digraph with δij = 0, ∀(i, j) ∈ E, which is really an undirected graph. It is instructive to adopt a different viewpoint in explaining a fundamental difference between the minimizer of ET H , and the optimal arrangement y ⋆ . The former is obtained from the equation ∂ET H /∂yi = 0 which gives n j=1 wij yj . (2) yi = n j=1 wij This equation tells us to put node i in the barycenter of its neighbors. Clearly, the zero vector is a solution of (2), a situation that both Tutte and Hall avoid by using various constraints. In analogy, y ⋆ satisfies the following important property n ⋆ j=1 wij (yj + δij ) ⋆ n , yi = j=1 wij
198
Liran Carmel, David Harel, and Yehuda Koren
which is substantially different from (2). Here we take a ‘balanced’ weighted average instead of the barycenter. The introduction of nonzero δij ’s prevents the collapse of all the nodes to the same location, yielding a meaningful solution. 2.2
Assigning the x-Coordinates
In principle, we would like to use a classical force directed model for the x-axis. Directional information should not be considered any longer, since it is assumed to be exhaustively taken care of by the y-axis. However, when trying to modify the customary two-dimensional gradient descent optimization algorithm, for use in our one-dimensional case, convergence was rarely achieved. The reason for this is what we call the ‘swapping problem’. Recall that the y-coordinates of the nodes are already fixed, and now the nodes are allowed to move only along the x-axis. However, if two nodes have close y-coordinates, swapping places along the x-axis is almost always impossible, even if it is energetically favorable, due to the repulsive forces that form an “energy barrier”; see [1] for a demonstration of this. It would be the best, then, to employ an alternative optimization technique for our one-dimensional case, which skirts the swapping problem We suggest to find a vector x = (x1 , . . . , xn )T representing the x-coordinates of the nodes in a way that minimizes edge (squared) lengths. This enables us to use simple energy functions that can be minimized by powerful global techniques. Besides the aesthetical reasoning, minimizing edge lengths is known to reduce edge crossings. We present two alternative variants of the method: – Minimizing edge-squared lengths: This nmeans minimizing the already familiar Tutte-Hall energy function, ET H = 12 i,j=1 wij (xi − xj )2 = xT Lx. As suggested by Hall [5,7], the non-trivial minimizer of this energy function is the Fiedler vector, which is the eigenvector of the Laplacian associated with the smallest positive eigenvalue. We find the minimizer of ET H using ACE [8] — an extremely fast multiscale algorithm for undirected graph drawing. – Minimizing edge lengths: This is the well known problem of minimum linear arrangement [3]. The solution is obtained by minimizing the energy function ELA = n 1 i,j=1 wij |xi − xj |, where (x1 , . . . , xn ) is a permutation of (1, . . . , n). This is 2 an NP-hard problem, and hence we should work with heuristics. In practice, we find a local minimizer of ELA using another fast multiscale algorithm [9], designed especially for this problem. In some of the cases we have studied (most notably, trees), the Fiedler vector was inferior with respect to the final result. The reason for this is that nothing in the Tutte-Hall energy function prevents two nodes from having the same x-coordinate. Therefore, locally dense regions could very well appear. In contrast, the minimum linear arrangement incorporates some kind of ‘repulsive force’, by not letting two nodes have the same x-coordinate. For example, see Fig. 4(a,b). However the Fiedler vector has advantages that make it very attractive in some cases. First, it is guaranteed to be an optimal global minimizer, and second, it can be computed extremely rapidly; see Table 1. In practice, for many graphs the Fiedler vector yields better results (see Section 4).
Drawing Directed Graphs Using One-Dimensional Optimization
199
Final beautification. So far, we have found the vector x using a very simple energy function and have ignored the information about the y-coordinates. As a result, there are cases where local smoothing can improve the drawing; see for example Fig. 4(c). We do this using a richer one-dimensional force directed model, which incorporates the information about the y-coordinates in order to refine the x-coordinates. Specifically, we have chosen to work with the Fruchterman-Reingold model [4]. In practice we do not use forces, but rather the energy they induce. This results in a modified optimization process, more suitable for the one-dimensional case; see [1].
3
Further Implications of the y-Axis Arrangement
Regular Digraphs A regular graph is one in which all nodes have the same degree. In analogy, a regular digraph is one in which all nodes have the same in-degree and the same out-degree. A regular digraph exhibits a high level of symmetry, so that we do not expect to find much hierarchy in it. It can be proved that in a regular digraph each node is balanced, having equal in-degree and out-degree. The optimal arrangement for a regular digraph is the solution of Ly ⋆ = 0; hence y ⋆ = (0, . . . , 0)T . In other words, a regular digraph is a hierarchy-free digraph. A simple example is a directed cycle. Symmetric Nodes A regular digraph is hierarchy-free. Thus, when the nodes are all symmetric, they are all assigned the same y-coordinate. Interestingly, this observation can be extended. Actually, if two nodes are symmetric, they have the same y-coordinate. In the framework of undirected graphs, it is customary to denote two nodes i and j as symmetric if there exists a permutation π such that π(i) = j and π(j) = i, and the Laplacian is invariant under π, L = Lπ . Here, Lπ is the Laplacian whose rows and columns are permuted according to π. For digraphs, we impose symmetry also on the directionality by adding the requirement that b = bπ . This definition reduces to the standard one for undirected graphs, since in this case b is the zero vector. We expect symmetric nodes to have the same level of hierarchy, which is indeed the case. In [1], using the uniqueness of the optimal arrangement, we prove that if i and j are symmetric, then yi⋆ = yj⋆ . Hierarchy Index The y-axis in our drawings contains the entire available information about the hierarchy. We claim that the spread of the projection of the drawing on this axis is closely related to its inherent hierarchy. Two extreme examples are: (1) A directed cycle, in which no node is different from the other, and we do not expect to see any hierarchy at all. Indeed, it is the case, since the cycle is regular. (2) A (k + 1)-path has a maximal amount of hierarchy, each node having a different y-coordinate in unit increments, y ⋆ = (−k/2, −k/2 + 1, . . . , k/2)T . It would be natural, therefore, to associate the hierarchy of a digraph with the mag⋆ ⋆ nitude ∆y ⋆ = ymax . The larger the ∆y ⋆ , the more hierarchical the digraph. One − ymin can use this magnitude to measure how worthwhile it is to allot the y-axis to exhibit the directional information. In order to do so, ∆y ⋆ should be compared with a measure of the dimension of the graph, had it been drawn using undirected graph drawing algorithms. A plausible candidate for measuring this is the diameter D of the digraph, which is the graph theoretic distance between the two most distant nodes. Therefore:
200
Liran Carmel, David Harel, and Yehuda Koren
Definition 4. The hierarchy index of an unweighted digraph is H=
⋆ ∆y ⋆ y ⋆ − ymin = max , D D
where y ⋆ is its optimal arrangement and D is its diameter. If ∆y ⋆ is comparable to D, the directional information is significant and one should use digraph drawing algorithms. If, on the other hand, ∆y ⋆ is small with respect to D, then it is no longer ‘profitable’ to dedicate an entire axis for the directional information, and undirected graph drawing algorithms should be preferred. Regular digraphs are an extreme case of the latter scenario. Here ∆y ⋆ = 0, and hence H = 0. The dual example is a k-path, where ∆y ⋆ = D = k −1, implying H = 1 independent of k. Another example is that of a complete n-node binary tree. Here, D = 2 log n, while ∆y ⋆ = log n. Hence, H = 12 , independently of n. This 1:2 ratio is well visualized when comparing the height of a hierarchical tree drawing with that of a radial drawing generated by undirected force models; see [1]. Cyclic Digraphs Standard layering algorithms can be applied only to acyclic digraphs. When dealing with cyclic digraphs they are first transformed into acyclic ones by inverting the direction of a minimal number of edges [2,6]. (Although, in cases where a special root node is known in advance, better strategies are possible.) Our algorithm allows to directly draw cyclic digraphs without having to invert edge directions. We believe this to be one of its most significant advantages. To make this claim stronger, we now show why it seems that there is no simple connection between the number of edges whose direction should be reversed and the inherent hierarchy of the digraph. As an example, in a directed cycle it suffices to invert the direction of a single edge in order to make it acyclic. Thus, the graph will be drawn by standard layering algorithms as a full-hierarchy path, having the lowest and the highest nodes connected by a reversed edge; see Figure 3. Obviously, this misrepresents the structure of the hierarchy-free cycle. Applying our algorithm to a directed cycle shows that it contains no directionality, being a regular digraph. In the absence of hierarchy, there is no sense in forcing the edges to be all laid out in the same direction.
1
2
3
4
5
Fig. 3. Schematic layering of 5-points circle.
Drawing Directed Graphs Using One-Dimensional Optimization
201
Another example is shown in Fig. 5(a). Here, the digraph does contain hierarchy, and the figure shows its optimal arrangement as dictated by our algorithm. We believe that we can quite objectively claim that this drawing best represents the structure of the digraph, despite of the fact that only about half of the edges point downward, and the rest point upward. This is because the only explicit hierarchy in this digraph, which is well captured in the figure, is between the highest node and the lowest one. None of the other nodes possess evident hierarchical relations, thus some of the edges connecting them are ‘allowed’ to go upward.
4
Examples
We have tested our algorithm against several unweighted digraphs with diverse structures. Figure 4 shows a complete 5-level binary tree. The y-coordinates were naturally quantized into 6 layers, as dictated by the tree structure. Recall that assigning the xcoordinates can be done in two different ways and that there is also a possibility for an additional final beautification. Figure 4(a) shows the drawing obtained when using the Fiedler vector. The result is really bad, with many nodes being placed in exactly the same location. This phenomenon is explained in Subsection 2.2. Using the minimum linear arrangement we get a much better drawing, shown in Fig. 4(b). In Fig. 4(c) we show a slightly improved result produced by the final beautification.
(a)
(b)
(c)
Fig. 4. A 5-level complete binary tree (a) x-coordinates obtained using the Fiedler vector; (b) x-coordinates obtained using the minimum linear arrangement; (c) applying final beautification to refine x-coordinates of (b)
Figure 5 shows three instructive examples. Figure 5(a) shows a directed cycle with an additional edge. In contrast to a pure cycle, which is regular and thus hierarchy-free, this digraph, thanks to the extra edge, does contain hierarchical information. Figure 5(b) shows an acyclic digraph comprised of a few parallel paths of different lengths. In spite of the diversity of path lengths, all edges are drawn in the same direction. Figure 5(c) is a cyclic version of the former digraph, with the direction of the edges along one of the paths (the middle one) being inverted. Interestingly, the drawing is almost identical to that of the acyclic version, with the principal difference being the direction of the
202
Liran Carmel, David Harel, and Yehuda Koren
(a)
(b)
(c)
Fig. 5. Three examples of digraphs; (a) a distorted cycle. The extra edge is responsible for the observed hierarchy; (b) an acyclic digraph comprised of a few parallel paths with varying lengths; (c) a cyclic version of the former digraph.
“reversed” edges. It seems that restricting the y-coordinates to strict horizontal layers would ruin the natural structure of the graphs of Fig. 5(b,c). In the rest of this section, we present graphs which are based on matrices from the Matrix Market collection (available at: math.nist.gov/MatrixMarket/). Each graph is constructed by taking a matrix and replacing each non-zero entry (i, j) with a directed edge from i to j. In Table 1 we provide the sizes of the graphs and running times, as measured on a Pentium IV 2GHz PC. The largest graph, containing 8192 nodes, was drawn in less than 12 second. Unless otherwise is stated, we computed the x-coordinates using the Fiedler vector (without final beautification). Table 1. Running time (in seconds) of the the algorithm graph
|V|
|E|
Nos6 Nos7 Dwa512 Dw2048 Dw8192
675 729 512 2048 8192
1290 1944 1004 4094 17,404
x-coords y-coords total time time time 0.000 0.015 0.015 0.000 0.016 0.016 0.000 0.016 0.016 0.015 0.11 0.125 0.150 0.250 0.4
Figure 6 shows two different drawings of the Nos6 graph. For both of them the y-coordinates are the same (as is always the case, since there is a unique minimizer of the hierarchy energy). However, the x-coordinates are different. In Fig. 6(a) they were computed using the Fiedler vector, while in Fig. 6(b) they were computed using the minimum linear arrangement. Both drawings exhibit the symmetries of the graph very well. Regarding running times, computation of the minimum linear arrangement took 3.7sec, whereas computation of the Fiedler vector took only 0.015sec.
Drawing Directed Graphs Using One-Dimensional Optimization
(a)
203
(b)
Fig. 6. The Nos6 graph. The x-coordinates are drawn by (a) Fiedler vector; (b) minimum linear arrangement.
Fig. 7. Two different drawings of the Nos7 graph. The y-coordinates are the same, whereas the x-coordinates obtained by two different Fiedler vectors.
Figure 6 shows two different layouts of the Nos7 graph. In both cases the x-coordinates were constructed using the Fiedler vector. Here, the multiplicity of the lowest positive eigenvalue of the Laplacian matrix is greater than 1, so there are two different Fiedler vectors. The left-hand-side drawing draws the graph in a “layering style”, putting the nodes on many horizontal layers. The right-hand-side drawing, has a three-dimensional look. It arranges the nodes in 9 two-dimensional layers. Note that in both drawings the edges point downwards.
204
Liran Carmel, David Harel, and Yehuda Koren
The Dwa512 graph
The Dw2048 graph
The Dw8192 graph Fig. 8. Graphs containing both directed and undirected edges. Directed edges are colored by red, while undirected edges are colored by blue (see electronic version of this paper).
Interestingly, our algorithm can be applied to graphs containing both directed and undirected edges. As was already mentioned, all we have to do to deal with an undirected edge (i, j) is to set δij = δji = 0, meaning that such an edge induces no hierarchical relation. Many graphs based on matrices in the Matrix Market collection contain both directed edges (when entry (i, j) is non-zero and entry (j, i) is zero) and undirected edges (when both entries (i, j) and (j, i) are non-zero). In Fig. 8 we show three such graphs: Dwa512, Dw2048 and Dw8192. Directed edges are colored red and undirected edges are colored blue. In all the drawings the graph structure is shown nicely with excellent
Drawing Directed Graphs Using One-Dimensional Optimization
205
symmetry preservation. Note that all directed edges point downwards, and that they induce hierarchical relations between nodes that are contained in undirected components of the graph. We think that these results demonstrate that sometimes restricting the nodes to strict layers hides the graph’s natural structure.
5
Discussion
We have presented a digraph drawing algorithm that uses several one-dimensional energy minimization problems to find an optimal drawing in two-dimensions. The vector of ycoordinates is found using a rather elegant energy minimization algorithm, which yields a unique global minimizer that nicely captures the hierarchical information. For the vector of x-coordinates, which contains non-directional information, we are using an optimization algorithm especially tailored for the one dimensional problem. The layouts produced by our algorithm are very natural, and are not subject to any predefined restrictions. In a way, they simply “let the graph speak for itself”. The fact that the layout is a global minimizer of the one-dimensional energies enables a rather accurate representation of many properties of the graph, such as its hierarchical structure and its symmetries. In terms of running time, our algorithm is very fast, being able to draw 10,000-node graphs in less than a second on a mid-range PC. Significant virtues of our algorithm include its ability to draw cyclic digraphs without having to invert edge directions, the possibility of applying it to graphs containing both directed and undirected edges and its ability to measure the amount of hierarchy in the digraph via the hierarchy index. The amount of hierarchy can be used to decide whether to use hierarchical drawing tools to represent a given digraph, or to prefer undirected graph drawing algorithms. We believe this last issue to be worthy of further research, and suggest the possibility of combining digraph drawing algorithms and undirected graph drawing algorithms into a unified tool: Given a general digraph, we could use the hierarchy index on portions of it, and draw the different portions either with this algorithm or with the other, depending of their level of hierarchy. More specifically, one can scan the optimal y-coordinates vector to find connected subgraphs, such that the nodes in each subgraph have similar y-coordinates. Such subgraphs are candidates for being hierarchy-free components, and should be processed separately. Our algorithm can be used in two different ways for the benefit of the standard approach for digraph drawing: – It can induce layering: We can think of the optimal arrangement as a kind of a ‘continuous layering’. The usual discrete layering can be easily induced from it if we divide the nodes into maximal subsets, such that within each subset the nodes have successive y-coordinates and no edge resides within a single subset. – It can induce ordering: Standard ordering algorithms are typically very local in nature. In a single iteration only one layer is free to change the order of its nodes. We can replace it with a more global approach, using the vector of x-coordinates obtained by our ‘first stage’ to impose a ‘global ordering’.
206
Liran Carmel, David Harel, and Yehuda Koren
References 1. L. Carmel, D. Harel and Y. Koren, “Drawing Directed Graphs Using One-Dimensional Optimization”, Technical Report MCS02-14, The Weizmann Institute of Science, 2001. Available on the web. 2. G. Di Battista, P. Eades, R. Tamassia, and I. G. Tollis, Graph Drawing: Algorithms for the Visualization of Graphs, Prentice-Hall, 1999. 3. J. Diaz, J. Petit and M. Serna, “A Survey on Graph Layout Problems”, to appear in ACM Computing Surveys. 4. T. M. G. Fruchterman and E. Reingold, “Graph Drawing by Force-Directed Placement”, Software-Practice and Experience 21 (1991), 1129-1164. 5. K. M. Hall, “An r-dimensional Quadratic Placement Algorithm”, Management Science 17 (1970), 219-229. 6. M. Kaufmann and D. Wagner (Eds.), Drawing Graphs: Methods and Models, Lecture Notes in Computer Science, Vol. 2025, Springer Verlag, 2001. 7. Y. Koren, “On Spectral Graph Drawing”, manuscript, 2002. 8. Y. Koren, L. Carmel and D. Harel, “ACE: A Fast Multiscale Eigenvectors Computation for Drawing Huge Graphs”, Proc. IEEE Symp. on Information Visualization 2002 (InfoVis 2002), IEEE computer society press, to appear. 9. Y. Koren and D. Harel “A Multi-Scale Algorithm for the Linear Arrangement Problem”, Proc. Graph Theoretical Concepts in Computer Science 2002 (WG 2002), Springer-Verlag, to appear. 10. K. Sugiyama and K. Misue, “A Simple and Unified Method for Drawing Graphs: MagneticSpring Algorithm”, Proc. Graph Drawing 1994, Lecture Notes in Computer Science, Vol. 894, pp. 364–375, Springer Verlag, 1995. 11. K. Sugiyama, S. Tagawa and M. Toda, “Methods for Visual Understanding of Hierarchical Systems”, IEEE Transactions on Systems, Man, and Cybernetics 11(2) (1981), 109–125. 12. W. T. Tutte, “How to draw a graph”, Proc. London Math. Society 13 (1963), 743-768.
Graph Drawing by High-Dimensional Embedding David Harel and Yehuda Koren Dept. of Computer Science and Applied Mathematics The Weizmann Institute of Science, Rehovot, Israel {harel,yehuda}@wisdom.weizmann.ac.il
Abstract. We present a novel approach to the aesthetic drawing of undirected graphs. The method has two phases: first embed the graph in a very high dimension and then project it into the 2-D plane using principal components analysis. Running time is linear in the graph size, and experiments we have carried out show the ability of the method to draw graphs of 105 nodes in few seconds. The new method appears to have several advantages over classical methods, including a significantly better running time, a useful inherent capability to exhibit the graph in various dimensions, and an effective means for interactive exploration of large graphs.
1
Introduction
A graph G(V = {1, . . . , n}, E) is an abstract structure that is used to model a relation E over a set V of entities. Graph drawing is a standard means for the visualization of relational information, and its ultimate usefulness depends on the readability of the resulting layout; that is, the drawing algorithm’s capability of conveying the meaning of the diagram quickly and clearly. Consequently, many approaches to graph drawing have been developed [3,9]. We concentrate on the problem of drawing undirected graphs with straight-line edges, and the most popular approaches to this appear to be those that define a cost function (or a force model), whose minimization determines the optimal drawing. The resulting algorithms are known as force-directed methods. We suggest a new approach to the problem of graph drawing, relying on the observation that laying out a graph in a high dimension is significantly easier than drawing it in a low dimension. Hence, the first step of our algorithm is to quickly draw the graph in a very high dimensional space (e.g., in 50 dimensions). Since standard visualization techniques allow using only 2 or 3 dimensions, the next step of our algorithm is to algorithmically project the high-dimensional drawing into a low dimension. For this, we have adopt a method called principal components analysis (PCA), which is well known in multivariate analysis. The resulting algorithm is extremely fast, yet very simple. Its time complexity is O(m · |E| + m2 · n), where m is the dimension in which the graph is embedded during the first stage of the algorithm. In fact, the running time is linear in the graph’s size, since m is independent of it. Typical computation times are of less than 3 seconds for 105 -node graphs, and are thus significantly faster than force-directed approaches. As to the quality of the drawings, Section 4 shows several very encouraging results. M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 207–219, 2002. c Springer-Verlag Berlin Heidelberg 2002
208
2
David Harel and Yehuda Koren
Drawing Graphs in High Dimension
Frequently, drawing a graph so as to achieve a certain aesthetic criterion cannot be optimally achieved in a low dimension, due to the fact that several aesthetic goals have to compete on a shared limited space. Thus, being able to carry out the initial drawing work in many dimensions leaves more space for richer expression of the desired properties, and thus makes the entire task easier. In order to draw a graph in m dimensions, we choose m pivot nodes that are almost uniformly distributed on the graph and associate each of the m axes with a unique node. Axis i, which is associated with pivot node pi , represents the graph from the “viewpoint” of node pi . This is done by defining the i-th coordinate of each of the other nodes as its graph-theoretic distance from pi . Hence pi is located at place 0 on axis i, its immediate neighbors are located at place 1 on this axis, and so on. More formally, denote by duv the graph-theoretic distance between node v and node u. Let P ivots be some set {p1 , p2 , . . . , pm } ⊂ V . Each node v ∈ V is associated with m coordinates X 1 (v), X 2 (v), . . . , X m (v), such that X i (v) = dpi v . The resulting algorithm for drawing the graph in m dimensions is given in Fig. 1. The graph theoretic distances are computed using breadth-first-search (BFS). (When edges are positively weighted, BFS should be replaced by Dijkstra’s algorithm; see e.g., [2].) The set P ivots is chosen as follows. The first member, p1 , is chosen at random. For j = 2, . . . , m, node pj is a node that maximizes the shortest distance from {p1 , p2 , . . . , pj−1 }. This method is mentioned in [8] as a 2-approximation to the 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. However, different approaches to selecting the pivots may also be suitable.
Function HighDimDraw (G(V = {1, . . . , n}, E), m) % This function finds an m-dimensional layout of G:
Choose node p1 randomly from V d[1, . . . , n] ← ∞ for i = 1 to m do % Compute the i − th coordinate using BFS
dpi ∗ ← BFS(G(V, E), pi ) for every j ∈ V X i (j) ← dpi j d[j] ← min{d[j], X i (j)} end for % Choose next pivot
pi+1 ← arg max{j∈V } {d[j]} end for return X 1 , X 2 , . . . , X m Fig. 1. Drawing a graph in m dimensions
Graph Drawing by High-Dimensional Embedding
209
The time complexity of this algorithm is O(m · (|E| + |V |)), since we perform BFS in each of the m iterations. A typical value of m is 50. Here now are two observations regarding the properties of the resulting drawing. First, for every two nodes v and u and axis 1 i m, we have: duv |X i (v) − X i (u)| This follows directly from the triangle inequality, since: dpi u dpi v + duv and dpi v dpi u + duv =⇒ |X i (v) − X i (u)| = |dpi v − dpi u | duv Thus, nodes that are closely related in the graph will be drawn close together. The second observation goes in the opposite direction, and shows a kind of separation between nodes that are distant in the graph. For an axis i and nodes u and v, denote def
i δv,u = min{dpi v , dpi u }. Then, for every v, u ∈ V and axis 1 i m, we have: i duv − 2δv,u |X i (v) − X i (u)| i For the proof, assume w.l.o.g. that δv,u = dpi v . Again, using the triangle inequality: i duv dpi v + dpi u = dpi v + dpi v + (dpi u − dpi v ) = 2δv,u + |X i (v) − X i (u)| i =⇒ duv − 2δv,u |X i (v) − X i (u)|
Thus if we denote the minimal distance between {v, u} and P ivots by: def
ǫv,u =
min
i∈{1,...,m},j∈{v,u}
dpi j ,
then there exists an axis i such that |X i (v) − X i (u)| duv − 2ǫv,u . We note that according to the way we have chosen the pivots, we expect ǫv,u to be fairly small.
3
Projecting into a Low Dimension
At this stage we have an m-dimensional drawing of the graph. In order to visually realize the drawing we have to project it into 2 or 3 dimensions. Picking a good projection is not straightforward, since the axes are correlated and contain redundant information. Moreover, several axes may scatter nodes better than others, thus being more informative. For example, consider a square grid. If we use two axes that correspond to two opposite corners, the resulting drawing will be essentially 1-dimensional, as the two axes convey basically the same information and are anti-correlated. (That is, being “near” one corner is exactly like being “far” from the opposite corner.) Also, taking an axis associated with a boundary node is very often more informative than taking an axis associated with a central node; the first case causes the nodes to be scattered in a much better way, since the maximal distance from a boundary node is about twice as large as the maximal distance from a central node.
210
David Harel and Yehuda Koren
To address these issues we use a tool that is well known and in standard use in multivariate analysis — principal component analysis (PCA). PCA transforms a number of (possibly) correlated variables into a (smaller) number of uncorrelated variables called principal components (PCs). The first principal component accounts for as much of the variability in the data as possible, and each succeeding component accounts for as much of the remaining variability as possible. By using only the first few principal components, PCA makes it possible to reduce the number of significant dimensions of the data, while maintaining the maximum possible variance thereof. See [4] for a comprehensive discussion of PCA. In our case, we have m n-dimensional variables X 1 , . . . , X m , describing the n nodes in m dimensions. We want to represent the n nodes using only k dimensions (typically k = 2), using k n-dimensional uncorrelated vectors Y 1 , . . . , Y k , which are the principal components. Hence, the coordinates of node i are (Y 1 (i), . . . , Y k (i)). Each of the PCs among Y 1 , . . . , Y k is a linear combination of the original variables X 1 , . . . , X m . def n X i (j) Here are the details. Denote the mean of i-th axis by mi = j=1 n . The first stage of the PCA is to center the data around 0 which is just a harmless translation of ˆ 1, . . . , X ˆ m , defined as: the drawing. We denote the vectors of centered data by X ˆ i (j) = X i (j) − mi , X
i = 1, . . . , m, j = 1, . . . , n
We now construct an m × n matrix, X, whose rows are the (centered) coordinates: 1 ˆ 1 (n) ˆ (1) . . . X X . ... . X= . ... . m m ˆ ˆ X (1) . . . X (n) The covariance matrix S, of dimension m × m, is defined as 1 XX T n We now have to compute the first k eigenvectors of S (those that correspond to the largest eigenvalues). We denote these eigenvectors by u1 , . . . , uk . The vector lengths should be normalized to 1, so that these k vectors are orthonormal. A simple method for computing the eigenvectors is described below. Now to the projection itself. The first new axis, Y 1 , is the projection of the data in the direction of u1 , the next axis, Y 2 , is the projection in the direction of u2 , and so on. Hence the new coordinates are defined by: S=
Y i = X T ui ,
i = 1, . . . , k
For the interested reader, we now briefly discuss the theoretical reasoning behind the PCA process. The projection of the data in a certain direction can be formulated by y = X T u, where u is a unit vector ( u 2 = 1) in the desired direction. Since the original data is centered, the projection, y, is also centered. Thus, the variance of y can be written simply as y T y/n. Note that, 1 1 1 T y y = (X T u)T X T u = uT XX T u = uT Su . n n n
Graph Drawing by High-Dimensional Embedding
211
Consequently, to find the projection that retains the maximum variance, we have to solve the following constrained maximization problem: max uT Su u
(1)
subject to: u 2 = 1 Standard linear algebra shows that the maximizer of problem 1 is u1 , the first eigenvector of S. Hence, Y 1 is the 1-dimensional projection of the data that has the maximal variance (i.e., in which the data is most scattered). Using similar techniques it can be shown that Y 1 , . . . , Y k constitute the k-dimensional projection of the data that yields the maximal variance. Moreover, the orthonogonality of u1 , . . . , uk implies yiT yj = 0 for i = j. Hence, these k axes are uncorrelated In general, as we shall see in Section 4, it suffices to draw a graph on the plane using Y 1 and Y 2 only, thus scattering the nodes in a maximal fashion.1 However, sometimes using Y 3 or Y 4 may be useful too. Regarding time complexity, the most costly step is computing the covariance matrix S = n1 XX T . (In practice we do not divide by n, since multiplication by a constant does not change the eigenvectors.) This matrix multiplication is carried out in a straightforward way using exactly m2 n multiplications and additions, so the time complexity is O(m2 n), with a very small hidden constant (although matrix multiplication can be done faster in theory; see e.g., [2]). As to computing the first eigenvectors of the m × m covariance matrix S (i.e., those that correspond to the largest eigenvalues), we use the simple power-iteration method; see e.g., [15]. Since m λ2 > · · · > λm 0. Let x ∈ Rn . If x is not orthogonal to u1 (i.e., x · u1 = 0) then the series Ax, A2 x, A3 x, . . . converges in the direction of u1 . More generally, in the case where x · u1 = 0, x · u2 = 0, . . . , x · uj−1 = 0, x · uj = 0, the series Ax, A2 x, A3 x, . . . converges in the direction of uj . The full algorithm is depicted in Fig. 2.
4
Examples
Our algorithm was implemented in C, and runs on a dual processor Intel Xeon 1.7Ghz PC. Since the implementation is non-parallel, only one of the processors is used. For all the results given here we have set m = 50, meaning that the graphs are embedded in 50 dimensions. Our experience is that the results are not sensitive to the exact value of m. In fact, increasing m does not degrade the quality of the results, but doing so seems not to be needed. On the other hand, picking an overly small value for m may harm the smoothness of the drawing. We speculate that as the graphs are to be drawn in only two or three dimensions, a vast increase of m cannot be helpful. 1
Thus, using PCA is, in a sense, incorporating a global “repulsive force”, in the terms used in force-directed methods.
212
David Harel and Yehuda Koren
Function PowerIteration (S – m × m matrix ) % This function computes u1 , u2 , . . . , uk , the first k eigenvectors of S .
const ǫ ← 0.001 for i = 1 to k do u ˆi ← random u ˆi ← ˆuuˆii do ui ← u ˆi % orthogonalize against previous eigenvectors
for j = 1 to i − 1 do ui ← ui − (ui · uj )uj end for u ˆi ← Sui u ˆi ← ˆuuˆii % normalization while u ˆi · ui < 1 − ǫ % halt when direction change is negligible ui ← u ˆi end for return u1 , u2 , . . . , uk Fig. 2. The power iteration algorithm
Table 1 gives the actual running times of the algorithm on graphs of different sizes. In addition to the total computation time, we show the times of the two most costly parts of the algorithm — computing the m-dimensional embedding (Fig. 1) and computing the covariance matrix S. We want to stress the fact that since the algorithm does not incorporate an optimization process, the running time is determined completely by the size of the graph (i.e., |V | and |E|), and is independent of the structure of the graph. This is unlike force-directed methods. Graphs of around 105 nodes take only a few seconds to draw, and 106 -node graphs take less than a minute. Thus, the algorithm exhibits a truly significant improvement in computation time for drawing large graphs over previously known ones. 2 Following is a collection of several drawings produced by the algorithm. The layouts shown in Fig. 3 are typical results of our algorithm, produced by taking the first two principal components as the axes. In Fig. 3(a) we show a square grid with 31 of the edges omitted at random. Figure 3(b) shows a folded grid, obtained by taking a square grid and connecting opposing corners. This graph has high level of symmetry, which is nicely reflected in the drawing. Figures 3(c,d) show two finite element graphs, whose drawings give a feeling of a 3-D landscape. Sometimes it is aesthetically better to take different principal components. For example, in Fig. 4(a) the 516 graph is depicted using the first and second PCs, while in Fig. 4(b) the first and third PCs are used. Note that the second PC scatters the nodes better than the third PC, as must be the case. However, here, using the third PC instead of the 2
Our recent ACE algorithm, [10], exhibits similar advantages using totally different methods.
Graph Drawing by High-Dimensional Embedding
213
Table 1. Running time (in seconds) of the various components of the algorithm graph
|V|
|E|
total high dim. covariance time embedding matrix 0.00 0.00 0.00 0.03 0.02 0.01 0.08 0.03 0.05 0.09 0.05 0.05 0.30 0.14 0.08 0.25 0.16 0.09 0.81 0.47 0.16 0.75 0.59 0.13 1.77 0.89 0.77 2.59 1.59 0.89 7.16 5.74 1.25 13.09 10.66 2.19 50.52 41.03 8.48 57.81 47.83 8.84
516 [14] 516 729 Fidap006§ 1651 23,914 4970 [14] 4970 7400 3elt† 4720 13,722 Crack‡ 10,240 30,380 4elt2† 11,143 32,818 Sphere† 16,386 49,152 Fidap011§ 16,614 537,374 Sierpinski (depth 10) 88,575 177,147 grid 317 × 317 100,489 200,344 Ocean† 143,437 409,593 mrngA† 257,000 505,048 grid 1000 × 1000 1,000,000 1,998,000 mrngB† 1,017,253 2,015,714 § Taken from the Matrix Market, at: http:/math.nist.gov/MatrixMarket † Taken from the University of Greenwich Graph Partitioning Archive, at: http://www.gre.ac.uk/˜c.walshaw/partition ‡ Taken from Jordi Petit’s collection, at: http://www.lsi.upc.es/˜jpetit/MinLA/Experiments
second one results in an aesthetically superior drawing. A similar example is given in Fig. 4(c,d) with the Fidap006 graph. In fact, this is the typical case with many graphs whose nice drawing has an unbalanced aspect ratio. The first two axes provide a well balanced drawing, while using different axes (the third or the forth PCs) yields a prettier result. In fact, the algorithm also produces more information than others, by drawing the graph in a high dimension. Thus, we can view the graph from different viewpoints that may reveal interesting aspects of the graph. This is demonstrated in the drawing of the Sphere graph. Fig. 5(a) shows a drawing using the first and second PCs. The six “smooth” corners appearing in Fig. 5(a) become really salient in Fig. 5(b), using the forth and fifth PCs, where a flower shape emerges. 4.1
Zooming in on Regions of Interest
Drawings in two dimensions reveal only part of the richness of the original high dimensional drawing. Indeed, the 2-D drawing must forgo showing some properties of small portions of the graph, in order to get a well balanced picture of the entire graph. This facilitates a novel kind of interactive exploration of the graph structure: The user can choose a region of interest in the drawing and ask the program to zoom in on it. We then utilize the fact that we have a high dimensional drawing of the graph, which possibly contains a better explanation for the chosen subgraph than what shows up in 2-D. First we take the coordinates of the subgraph from the already computed m-dimensional drawing. We then use PCA to project these coordinates into 2-D. In this way we may
214
David Harel and Yehuda Koren
Fig. 3. Layouts of: (a) A 50 × 50 grid with 13 of the edges omitted at random; (b) A 100 × 100 grid with opposite corners connected; (c) The Crack graph (d) The 3elt graph
Fig. 4. (a,b) Drawing the 516 graph using: (a) 1st and 2nd PCs; (b) 1st and 3rd PCs. (c,d) Drawing the Fidap006 graph using: (c) 1st and 2nd PCs; (d) 1st and 3rd PCs
Graph Drawing by High-Dimensional Embedding
215
Fig. 5. (a,b) Two viewpoints of the Sphere graph: (a) using the first and second PCs; (b) using the forth and fifth PCs; (c) zooming in on one of the corners
reveal properties appearing in the high-dimensional drawing, which are not shown in the low-dimensional drawing of the full graph. For example, we wanted to investigate the “corners” of the Sphere graph. We zoomed in on one of the corners, and the result is shown in Fig. 5(c). It can be seen that the corner is a meeting point of four faces. Another example is the dense graph, Fidap011, depicted in Fig. 6. Due to file size limitation, we cannot print this huge graph with adequate visual quality. Hence, it is very instructive to see parts of its micro-structure, as shown in the bottom of Fig. 6(b).
Fig. 6. Top: The Fidap011 graph; Bottom: zooming in on the micro-structure
216
David Harel and Yehuda Koren
Additional related examples are given in Fig. 7. The Sierpinski fractal of depth 7, is shown in Fig. 7(a). Note that the left and top parts of it are distorted (in fact, they are explained by the third PC). In Fig. 7(b) we depict the result of zooming-in on the left part of the graph, revealing its nice structure. The layout of the 4elt2 graph, depicted in Fig. 7(c), resembles the one obtained by [10]. For a better understanding of its structure we may zoom-in on parts of the drawing. Fig. 7(d) shows the results of zooming-in on the bottom strip. In Fig. 7(e) we provide a drawing of the Ocean graph, containing over 143000 nodes. To understand its micro-structure we zoom-in on it, providing a sample result in Fig. 7(f). The last example is the 4970 graph, nicely depicted in Fig. 7(g). We zoom-in on its top-center portion, as shown in Fig. 7(h). Before ending this section, we should mention that our algorithm is not suitable for drawing trees. In fact, for tree-like graphs, it may very hard to pick a suitable viewpoint for projection, probably due to the fact that the high dimensional drawing of these graphs spans a “wild” subspace of quite a high dimension.
5
Discussion
We have presented an extremely fast approach to graph drawing. It seems that our two key contributions are the simple technique for embedding the graph in a very high dimension and the use of principal components analysis for finding good projections into lower dimensions. In terms of performance and simplicity, the algorithm has some significant advantages when compared to force-directed methods. To appreciate these advantages, let us make a short divergence for surveying the state of the art in force-directed drawing of large graphs. A naive implementation of a force-directed method encounters real difficulties when dealing with graphs of more than a few hundred nodes. These difficulties stem from two reasons. First, in a typical force model there is a quadratic number of forces, making a single iteration of the optimization process v ery slow. Second, for large graphs the optimization process needs too many iterations for turning the initial random placement into a nice layout. Some researchers [13,12] have improved these methods to some extent, by accelerating force calculation using quad-trees that reduce the complexity of the force model. This way, [13] reports drawing 1000-node graphs in around 5 minutes (in [12], only running time per a single iteration is mentioned). Whereas using quad-trees addr esses the first issue by accelerating each single iteration, there is still the second issue of getting out of the initial random placement. Both these issues receive adequate treatment by incorporating the multi-scale paradigm as suggested by several authors; see [6,7,5,14]. These methods considerably improve running times by rapidly constructing a simplified initial globally nice layout and then refining it locally. The fastest of them all, [14], draws a 105 -node graph in a typical time of ten minutes. Coming back to our algorithm, we do not have an optimization process, so we do not encounter the aforementio ned difficulties of the force-directed approach. Our algorithm is considerably faster than all of these, however, being able to draw a 105 -node graph in less than three seconds. Moreover, the implementation of our algorithm is much simpler and is almost parameter-free.
Graph Drawing by High-Dimensional Embedding
217
Fig. 7. (a) A depth 7 Sierpinski graph; (b) zooming-in on the squeezed left side of (a); (c) the 4elt2 graph; (d) zooming-in on the bottom of (c); (e) the Ocean graph; (f) zooming-in on the micro structure of (e); (g) the 4970 graph; (h) zooming-in on the top-center portion of (g)
218
David Harel and Yehuda Koren
Recently, we have designed another algorithm for drawing huge graphs, which we call ACE [10]. ACE draws a graph by quickly calculating eigenvectors of the Laplacian matrix associated with it, using a special algebraic multigrid technique (for spectral graph drawing see also [11]). ACE can draw 105 -node graphs in about 2 seconds. However, the running-time of ACE (like that of force-directed methods) depends on the graph’s structure, unlike our algorithm, where it depends only on the graph’s size. A detailed comparison between the results of the two algorithms has yet to be done. The output of our algorithm is multi-dimensional, allowing multiple views of the graph. This also facilitates a novel technique for interactive exploration of the graph, by focusing on selected portions thereof, showing them in a way that is not possible in a 2-D drawing of the entire graph. Several force-directed graph drawing algorithms draw the graph in three or even four dimensions and then project it into a lower dimension, see, e.g., [1,13,5]. These algorithms could possibly benefit from incorporating principal components analysis to project the drawings into the plane. In terms of drawing quality, the results of the new algorithm resemble those of forcedirected graph drawing algorithms. However, being limited by the linear projection, frequently, the static 2-D results are inferior to those of the force-directed approach. For example, in many of the drawings that were given here, it may be observed that the boundaries are somewhat distorted, as they lie inside an absent third dimension. Nevertheless, we should stress the fact that the full power of our algorithm is not expressed well in static 2-D drawings. In order to really utilize its capabilities, one should explore the graph using the novel technique for interactive visualization, which is unique to this algorithm. Applications to information visualization Our algorithm can deal directly with edgeweighted graphs, making it suitable for information visualization tasks. In this case it has an important performance-related advantage over other algorithms, including ACE: In a typical case, one is given n objects and a distance function measuring the dissimilarity between two objects. Note that the time needed for computing the distance between two objects depends solely on the complexity of these two objects, and is independent of n. (This is unlike the computation of the graph theoretic distance, which is not needed in this case.) Frequently, computing the distance between two objects is a costly operation; e.g., when the objects are DNA sequences of length k, a common distance measure is the “edit-distance”, whose computation may take time O(k 2 ). A nice drawing puts similar objects close together, while non-similar objects are distantly located. Hence, forcedirected drawing algorithms that can draw weighted graphs are suitable. However, n is typically large in such applications, so one has to consider multi-scale enhancements, and these would require the computation of the close neighbors of each of the objects. This, in turn, would require the computation of the distances between all pairs, resulting in n · (n − 1)/2 distance computations, which is often too costly. In contrast, our method needs only m · n distance computations, which is a very significant improvement.
Graph Drawing by High-Dimensional Embedding
219
References 1. I. Bruss and A. Frick, “Fast Interactive 3-D Graph Visualization”, Proceedings of Graph Drawing 95, LNCS 1027, pp. 99–110, Springer Verlag, 1996. 2. T. H. Cormen, C. E. Leiserson and R. L. Rivest, Introduction to Algorithms, MIT Press, 1990. 3. G. Di Battista, P. Eades, R. Tamassia and I.G. Tollis, Graph Drawing: Algorithms for the Visualization of Graphs, Prentice-Hall, 1999. 4. B. S. Everitt and G. Dunn, Applied Multivariate Data Analysis, Arnold, 1991. 5. P. Gajer, M. T. Goodrich, and S. G. Kobourov, “A Multi-dimensional Approach to ForceDirected Layouts of Large Graphs”, Proceedings of Graph Drawing 2000, LNCS 1984, pp. 211–221, Springer Verlag, 2000. 6. R. Hadany and D. Harel, “A Multi-Scale Method for Drawing Graphs Nicely”, Discrete Applied Mathematics, 113 (2001), 3–21. 7. D. Harel and Y. Koren, “A Fast Multi-Scale Method for Drawing Large Graphs”, Proceedings of Graph Drawing’00 , LNCS 1984, Springer Verlag, pp. 183–196, 2000. 8. D. S. Hochbaum (ed.), Approximation Algorithms for NP-Hard Problems, PWS Publishing Company, 1996. 9. M. Kaufmann and D. Wagner (Eds.), Drawing Graphs: Methods and Models, LNCS 2025, Springer Verlag, 2001. 10. Y. Koren, L. Carmel and D. Harel “ACE: A Fast Multiscale Eigenvectors Computation for Drawing Huge Graphs”, to appear in Proceedings of IEEE Symposium on Information Visualization (InfoVis) 2002. 11. Y. Koren, “On Spectral Graph Drawing”, manuscript, 2002. 12. A. Quigley and P. Eades, “FADE: Graph Drawing, Clustering, and Visual Abstraction”, Proceedings of Graph Drawing 2000, LNCS 1984, pp. 183–196, Springer Verlag, 2000. 13. D. Tunkelang, A Numerical Optimization Approach to General Graph Drawing, Ph.D. Thesis, Carnegie Mellon University, 1999. 14. C. Walshaw, “A Multilevel Algorithm for Force-Directed Graph Drawing”, Proceedings of Graph Drawing 2000, LNCS 1984, pp. 171–182, Springer Verlag, 2000. 15. D. S. Watkins, Fundamentals of Matrix Computations, John Wiley, 1991.
Advances in C-Planarity Testing of Clustered Graphs (Extended Abstract) Carsten Gutwenger2 , Michael J¨ unger1 , Sebastian Leipert2 , Petra Mutzel3 , Merijam Percan1 , and Ren´e Weiskircher3 1
3
Universit¨ at zu K¨ oln, Institut f¨ ur Informatik, Pohligstraße 1, 50969 K¨ oln, Germany† {mjuenger,percan}@informatik.uni-koeln.de 2 caesar research center, Friedensplatz 16, 53111 Bonn, Germany {gutwenger,leipert}@caesar.de Technische Universit¨ at Wien E186, Favoritenstraße 9–11, 1040 Wien, Austria, {mutzel,weiskircher}@ads.tuwien.ac.at
Abstract. A clustered graph C = (G, T ) consists of an undirected graph G and a rooted tree T in which the leaves of T correspond to the vertices of G = (V, E). Each vertex µ in T corresponds to a subset of the vertices of the graph called “cluster”. c-planarity is a natural extension of graph planarity for clustered graphs, and plays an important role in automatic graph drawing. The complexity status of c-planarity testing is unknown. It has been shown in [FCE95,Dah98] that c-planarity can be tested in linear time for c-connected graphs, i.e., graphs in which the cluster induced subgraphs are connected. In this paper, we provide a polynomial time algorithm for c-planarity testing of “almost” c-connected clustered graphs, i.e., graphs for which all nodes corresponding to the non-c-connected clusters lie on the same path in T starting at the root of T , or graphs in which for each nonconnected cluster its super-cluster and all its siblings in T are connected. The algorithm is based on the concepts for the subgraph induced planar connectivity augmentation problem presented in [GJL+ 02]. We regard it as a first step towards general c-planarity testing.
1
Introduction
A clustered graph consists of a graph G and a recursive partitioning of the vertices of G. Each partition is a cluster of a subset of the vertices of G. Clustered graphs are getting increasing attention in graph drawing [BDM02,EFN00,FCE95], [Dah98]. Formally, a clustered graph C = (G, T ) is defined as an undirected graph G and a rooted tree T in which the leaves of T correspond to the vertices of G = (V, E). †
Partially supported by the Future and Emerging Technologies programme of the EU under contract number IST-1999-14186 (ALCOM-FT).
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 220–236, 2002. c Springer-Verlag Berlin Heidelberg 2002
Advances in C-Planarity Testing of Clustered Graphs
221
In a cluster drawing of a clustered graph, vertices and edges are drawn as usual, and clusters are drawn as simple closed curves defining closed regions of the plane. The region of each cluster C contains the vertices W corresponding to C and the edges of the graph induced by W . The borders of the regions for the clusters are pairwise disjoint. If a cluster drawing does not contain crossings between edge pairs or edge/region pairs, we call it a c-planar drawing. Graphs that admit such a drawing are called c-planar. While the complexity status of c-planarity testing is unknown, the problem can be solved in linear time if the graph is c-connected, i.e., all cluster induced subgraphs are connected [Dah98,FCE95]. In approaching the general case, it appears natural to augment the clustered graph by additional edges in order to achieve c-connectivity without loosing c-planarity. The results presented in this paper are the basis for a first step towards this goal. Namely, we present a polynomial time algorithm that tests c-planarity for “almost” c-connected clustered graphs, i.e., graphs for which all c-vertices corresponding to the non-connected clusters lie on the same path in T starting at the root of T , or graphs in which for each non-connected cluster its super-cluster and all its siblings are connected. The algorithm uses ideas from the linear time algorithm for subgraph induced planar connectivity augmentation presented in [GJL+ 02]. For an undirected graph G = (V, E), W ⊆ V , and EW = {(v1 , v2 ) ∈ E : {v1 , v2 } ⊆ W } let GW = (W, EW ) be the subgraph of G induced by W . If G is planar, a subgraph induced planar connectivity augmentation for W is a set F of additional edges with end vertices in W such that the graph G′ = (V, E ∪ F ) is planar and the graph G′W is connected. The paper is organized as follows: After an introduction into the SPQR data structure and clustered graphs in Sect. 2, we describe in Sect. 3 a linear time algorithm for c-planarity testing of a clustered graph with exactly one cluster in addition to the root cluster. This algorithm can be extended to a quadratic time algorithm for c-planarity testing in clustered graphs with one level beyond the root level in which at most one cluster is non-connected (see Sect. 4). In Sect. 5 we present a technique to extend the previous results to graphs with arbitrarily many non-connected clusters with the restriction that for each non-connected cluster, all its siblings and its super-cluster are connected. The same technique can be applied for graphs in which all the non-connected clusters lie on the same path in T .
2 2.1
Preliminaries SPQR-Trees
The data structure we use is called SPQR-tree and has been introduced by Di Battista and Tamassia [BT96]. It represents a decomposition of a planar biconnected graph according to its split pairs (pairs of vertices whose removal splits the graph or vertices connected by an edge). The construction of the SPQR-tree works recursively. At every node ℘ of the tree, we split the graph
222
Carsten Gutwenger et al.
into the split components of the split pair associated with that node. The first split pair of the decomposition is an edge of the graph and is called the reference edge of the SPQR-tree. We add an edge to every split pair to make sure that they are biconnected and continue by computing the SPQR-tree for every split pair and making the resulting trees the subtrees of the node used for splitting. Every node of the SPQR-tree has two associated graphs: – The skeleton of the node associated with a split pair p is a simplified version of the whole graph where some split-components are replaced by single edges. – The pertinent graph of a node v is the subgraph of the original graph that is represented by the subtree rooted at v. The two vertices of the split pair that are associated with a node ℘ are called the poles of ℘. There are four different node types in an SPQR-tree (S-,P -,Qand R-nodes) that differ in the number and structure of the split components of the split pair associated with the node. The Q-nodes are the leaves of the tree, and there is one Q-node for every edge in the graph. The skeleton of a Q-node consists of the poles connected by two edges. The skeletons of S-nodes are cycles, while the skeletons of R-nodes are triconnected graphs. P -node skeletons consist of the poles connected by at least three edges. Fig. 1 shows examples for skeletons of S-, P - and R-nodes. Skeletons of adjacent nodes in the SPQR-tree share a pair of vertices. In each of the two skeletons, one edge connecting the two vertices is associated with a corresponding edge in the other skeleton. These two edges are called twin edges. The edge in a skeleton that has a twin edge in the parent node is called the virtual edge of the skeleton. Each edge e in a skeleton represents a subgraph of the original graph. This graph together with e is the expansion graph of e. All leaves of the SPQR-tree are Q-nodes and all inner nodes S-, P - or R-nodes. When we see the SPQR-tree as an unrooted tree, then it is unique for every biconnected planar graph. Another important property of these trees is that their size (including the skeletons) is linear in the size of the original graph and that they can be constructed in linear time [BT96,GM01]. As described in [BT96,GM01], SPQR-trees can be used to represent the set of all combinatorial embeddings of a biconnected planar graph. Every combinatorial embedding of the original graph defines a unique combinatorial embedding for each skeleton of a node in the SPQR-tree. Conversely, when we define an embedding for each skeleton of a node in the SPQR-tree, we define a unique embedding for the original graph. The skeleton of S- and Q-nodes are simple cycles, so they have only one embedding. But the skeletons of R-and P -nodes have at least two different embeddings. Therefore, the embeddings of the Rand P -nodes determine the embedding of the graph and we call these nodes the decision nodes of the SPQR-tree. The BC-tree of a connected graph has two types of nodes: The c-nodes correspond to cut-vertices of G and the b-nodes to biconnected components (blocks). There is an edge connecting a c-node and a b-node, if the cut-vertex is contained in the block.
Advances in C-Planarity Testing of Clustered Graphs s B1 v1 B2 v2
e2 v2
B3
e3 t
t
s
s
s e1 v1 C1
223
C2
e1 e2
C3
e3
e4
t
t
(a) Case S-node
(b) Case P -node s
s
U1 U2
e2
e1
U3 U4
e3 U5
e5
e4
t
t (c) Case R-node
Fig. 1. The structure of biconnected graphs and the skeleton of the root of the corresponding SPQR-tree 1
Q-node
1 4
5 1
2
P-node
3
4
1
6 4
1 5
2
3
4
6 4
R-node
S-node
Fig. 2. A graph G and its SPQR-tree (the Q-nodes of the R- and S-node are omitted)
2.2
Clustered Graphs
The following definitions are based on the work of Cohen, Eades and Feng [FCE95]. A clustered graph C = (G, T ) consists of an undirected graph G and a rooted tree T where the leaves of T are the vertices of G. Each node ν of T represents a cluster V (ν) of the vertices of G that are leaves of the subtree rooted at ν. Therefore, the tree T describes an inclusion relation between clusters. T is
224
Carsten Gutwenger et al.
called the inclusion tree of C, and G is the underlying graph of C. The root of T is called root cluster. We let T (ν) denote the subtree of T rooted at node ν and G(ν) denote the subgraph of G induced by the cluster associated with node ν. We define C(ν) = (G(ν), T (ν)) to be the sub-clustered graph associated with node ν. We define pa(ν) the parent cluster of ν in T and chl(ν) the set of child clusters of ν in T . A drawing of a clustered graph C = (G, T ) is a representation of the clustered graph in the plane. Each vertex of G is represented by a point. Each edge of G is represented by a simple curve between the drawings of its endpoints. For each node ν of T , the cluster V (ν) is drawn as a simple closed region R that contains the drawing of G(ν), such that: – the regions for all sub-clusters of R are completely in the interior of R; – the regions for all other clusters are completely contained in the exterior of R; – if there is an edge e between two vertices of V (ν) then the drawing of e is completely contained in R. We say that there is an edge-region crossing in the drawing if the drawing of edge e crosses the drawing of region R more than once. A drawing of a clustered graph is c-planar if there are no edge crossings or edge-region crossings. If a clustered graph C has a c-planar drawing then we say that it is c-planar (see Figure 3). Therefore, a c-planar drawing contains a planar drawing of the underlying graph.
Fig. 3. A planar clustered graph that is not c-planar [FCE95] (the three disjoint clusters are represented by different types of vertices)
An edge is said to be incident to a cluster V (ν) if one end of the edge is a vertex of the cluster but the other endpoint is not in V (ν). An embedding of C includes an embedding of G plus the circular ordering of edges crossing the boundary of the region of each non-trivial cluster (a cluster which is not a single vertex). A clustered graph C = (G, T ) is connected if G is connected. A clustered graph C = (G, T ) is c-connected if each cluster induces a connected subgraph of G. Suppose that C1 = (G1 , T1 ) and C2 = (G2 , T2 ) are two clustered graphs such that T1 is a subtree of T2 , and for each node ν of T1 , G1 (ν) is a subgraph of G2 (ν). Then we say C1 is a sub-clustered graph of C2 , and C2 is a super-clustered graph of C1 . The following results from [FCE95] characterize c-planarity:
Advances in C-Planarity Testing of Clustered Graphs
225
Theorem 1. [FCE95] A c-connected clustered graph C = (G, T ) is c-planar if and only if graph G is planar and there exists a planar drawing D of G, such that for each node ν of T , all the vertices and edges of G − G(ν) are in the outer face of the drawing of G(ν). Theorem 2. [FCE95] A clustered graph C = (G, T ) is c-planar if and only if it is a sub-clustered graph of a connected and c-planar clustered graph. A further result from [FCE95] is a c-planarity testing algorithm for c-connected clustered graphs based on Theorem 1 with running time O(n2 ), where n is the number of vertices of the underlying graph and each non-trivial cluster has at least two children. An improvement in time complexity is given by Dahlhaus who constructed a linear time algorithm [Dah98].
3
Clustered Graphs with Two Clusters
Let C = (G, T ) be a clustered graph with a root cluster and a cluster ν. Let the graph G be connected and the subgraph induced by the vertices of the cluster ν non-connected. The problem of connecting the subgraph induced by one cluster is similar to the problem of planar connectivity augmentation of an induced subgraph [GJL+ 02]. In the following, we name the vertices of G(ν) blue vertices. After constructing an SPQR-tree T for every biconnected component of G we mark for every SPQRtree each edge in every skeleton either blue or black. An edge of a skeleton is marked blue, if its expansion graph contains blue vertices. Otherwise it is marked black. Additionally, we assign an attribute called permeable to certain blue edges. Intuitively, an edge is permeable if it is possible to construct a path connecting only blue vertices through its expansion graph. Let G(e) be the expansion graph of edge e in skeleton S. Since G(e) is biconnected we have that in any planar embedding G(e) there are exactly two faces that have e on their boundary. The edge e in S is permeable with respect to W , if there is an embedding Π of G(e) and a list of at least two faces L = (f1 , . . . , fk ) in Π that satisfies the following properties: 1. The two faces f1 and fk are the two faces with e on their boundary. 2. For any two faces fi , fi+1 with 1 ≤ i < k, there is a blue vertex on the boundary between fi and fi+1 . We call a skeleton S of a node ℘ of T permeable if the pertinent graph of ℘ and the virtual edge of S have the two properties stated above. Thus S is permeable if the twin edge of its virtual edge is permeable. Theorem 3. Let C = (G, T ) be a clustered graph such that the following conditions hold: – G is series-parallel
226
Carsten Gutwenger et al.
– C contains only one non-trivial non-root cluster ν and W is its corresponding vertex set. Let T be set of the SPQR-trees of every biconnected component of G. Let C := {V ∈ 2W |V is a circle in the expansion graph of a P-node and contains both pole vertices} be the set of the vertex sets of all circles in the expansion graphs of P-nodes that contain both pole vertices. Let the subgraph GW induced by W in G allow a planar connectivity augmentation for W . If for every P-node the following property (∗) holds, then C is c-planar: (∗) In every P-node, there is at the most one circle V of C such that 1. the union of the expansion graphs of two children ℘1 and ℘2 contains V and 2. for i ∈ {1, 2} the cut of G − GW with the expansion graph of child ℘i is nonempty. Proof. We calculate the BC-tree of G and for every block B the SP QR-tree of its biconnected component. The SP QR-tree of a series-parallel graph does not contain R-nodes. Hence GW has a planar connectivity augmentation, we assume that GW is connected. As we introduce a minimum cardinality edge set applying the planar connectivity augmentation, we do not loose c-planarity. According to Theorem 1 we need to show that a planar embedding exists such that the subgraph G − GW is embedded into the outside of GW . It follows that we need to show that G−GW is not embedded partially inside of GW (if it is embedded completely in an inner face we choose a face f that has an edge e = (v, w) with v ∈ W and w ∈ / W as outer face). Consider now the P -, S- and Q-nodes. For P -nodes we have the following cases – the P -node is black, that is it contains only black edges, – the P-node is blue and there exists exactly one blue edge in a P -node. The expansion graph of this blue edge contains the subgraph GW or – the P-node is blue and permeable. A blue P-node that is not permeable such that case 2 does not hold cannot exist for the following reasoning. If there is at least one blue edge in the P -node and another blue vertex or blue edge in another node, at least one pole vertex has to be blue due to the connectivity of GW . If there are at least two blue edges in the P -node, the pole vertex must be blue. Similar reasoning holds for S- and Q-nodes of the SPQR-trees and for the cut vertices of graph G. The latter are blue if at least two blocks which they belong to are blue. We have to show that there does not exist a planar embedding such that the subgraph G − GW is embedded in the outside of GW if and only if there exists a P-node P with more than one circle of vertices of W in the corresponding expansion graph fulfilling conditions 1. and 2. Note, that G(ν) is equal to GW and that P is in this case permeable as both pole vertices belong to G(ν).
Advances in C-Planarity Testing of Clustered Graphs
227
If there exists a P-node P with more than one circle of vertices of W in the corresponding expansion graph fulfilling conditions 1. and 2., then we order the edges that correspond to the union of expansion graphs fulfilling conditions 1. and 2. consecutively in P. We want to find an embedding according to Theorem 1. As we have only two clusters (a root cluster and cluster ν) this is equal to the fact, that G(ν) can be embedded into the outside of G − G(ν). As G(ν) is connected (there exists a planar connectivity augmentation) there has to be an embedding Π of G with a sequence of faces f1 , . . . , fk such that there is at least one vertex of G − G(ν) in the boundary between two consecutive faces fi and fi+1 and the boundaries of all those faces contain all vertices of G − G(ν). This is equal to the fact that G − GW has a planar connectivity augmentation for V − W in G as described in [GJL+ 02]. The faces containing vertices of G − G(ν) in their boundaries in P are contained in the sequence of faces f1 , . . . , fk . As the pole vertices are contained in G(ν) and there exists at least two circles of vertices of G(ν) that are contained in at least three expansions graphs, the sequence of faces f1 , . . . , fk cannot be consecutive and therefore there cannot exist a planar connectivity augmentation of G − GW for V − W in G. Therefore, we cannot find an embedding according to Theorem 1 and therefore C is not c-planar. If C is not c-planar, then there is an embedding Π in which the vertices of G − G(ν) cannot be embedded into the outside of G(ν) according to Theorem 1. As G(ν) is connected (there exists a planar connectivity augmentation) there does not exist a sequence of consecutive faces f1 , . . . , fk which are consecutive so that there is at least one vertex of V − W on the boundary between two faces and all vertices of V − W are included in the union of the boundaries of f1 , . . . , fk . Therefore there exists a sequence of faces f1 , . . . , fk in which their boundaries contain all vertices of G − G(ν) and there is a minimum number of consecutive faces fi and fi+1 so that on the boundary between fi and fi+1 is no vertex of G − G(ν). This is equal to the fact, that on the boundary between fi and fi+1 are vertices of G(ν). Let F be the set of all the faces fi and fi+1 . As the S- and Q-nodes have skeletons with only one embedding and a skeleton represents the whole corresponding biconnected component in G, we have to consider the P-nodes. As the pole vertices are contained in G(ν) and F is a minimum cardinality face set, there has to be l paths of vertices of G(ν) from one pole vertex to the other with l = |F2 | + 2 and l ≥ 3. Combining the paths to circles (the first and the last vertex of the paths are the pole vertices), we get more than one circle fulfilling condition 1. and 2. ⊓ ⊔ Note, that (∗) in the previous theorem can be replaced by: There exists a planar connectivity augmentation for V − W in G, if the subgraph GW is connected using the planar connectivity augmentation. Figure 4 gives an example for a clustered graph with underlying series-parallel graph which is not c-planar. The previous theorem can be easily extended to c-connected clustered graph C = (G, T ) with series-parallel underlying graph G. Theorem 4. Let C = (G, T ) be a clustered graph where G is a connected planar graph and W is the vertex set corresponding to the only non-trivial non-root cluster in T . We further assume that the subgraph GW induced by W is connected.
228
Carsten Gutwenger et al.
Fig. 4. Isolations in the expansion graph of P-nodes: The vertices with a circle around are vertices of the connected cluster, the others belong to the root cluster
The clustered graph C is c-planar if and only if there is an embedding of G that contains no cycle of blue vertices that separates the black vertices. Therefore c-planarity can be destroyed in the expansion graphs of R-nodes and in the expansion graphs of P -nodes if the clustered graph is c-connected. Theorem 5. A connected clustered graph C = (G, T ) where G is planar with one non-connected cluster ν is c-planar if and only if 1. there exists a planar connectivity augmentation of the subgraph induced by the non-connected cluster ν and 2. there is an embedding of G that contains no circle of vertices of G(ν) that separates vertices of G − G(ν). Proof. The proof follows from the previous theorems.
⊓ ⊔
Note, that item 2. in the previous theorem can be replaced by: There exists a planar connectivity augmentation for the vertices of G − G(ν) in G. As a result, we are able to deal with c-planarity of a special subclass of clustered graphs using planar connectivity augmentation and SPQR-trees. According to Theorem 5, we know how to test planar connectivity augmentation of a subgraph of a planar graph. We now show how to test whether there exists an embedding of G that contains no circle in G(ν) that separates G−G(ν). Consider a clustered graph C = (G, T ) that has only one non-root cluster ν that is non-connected. Therefore the subgraph G(ν) has more than one connected component. As we choose a minimum cardinality planar augmenting edge set M and take the pole vertices belonging to G(ν) into account to augment C to a c-connected clustered graph and if such an augmentation exists, c-planarity of C is maintained if C is c-planar. Therefore to test whether C is c-planar is equal to the following: Let Ci , i = 1, . . . , l, l ≥ 2 be the connected components of G(ν). I. There exists a drawing such that the drawing of G−Ci can be drawn outside of the drawing Ci for all i = 1, . . . , l and II. there exists a planar connectivity augmentation between all Ci , i ∈ N and therefore for G(ν).
Advances in C-Planarity Testing of Clustered Graphs
229
Fig. 5. A clustered graph C with a non-connected cluster. By splitting the nonconnected cluster, C is extended to a c-connected clustered graph.
We test I. on an auxiliary modified clustered graph C˜ of C as follows. Cluster ν is split into l dummy clusters so that each connected component Ci i = 1, . . . , l corresponds to a dummy cluster. By construction C˜ is a c-connected clustered graph and can be tested according Feng, Eades and Cohen and according Dahlhaus for c-planarity. Definition 1. Let C be a clustered graph with a connected root cluster and a non-connected cluster ν. Let Csub be the clustered graph created by splitting ν into one dummy cluster for each connected component of the subgraph induced by ν that contain at least two vertices (see Fig. 5). A connected component that contains only one vertex is treated as a trivial cluster. We call Csub the c-split clustered graph of C. Note, that Csub is a c-connected clustered graph. Theorem 6. Let C be a clustered graph with a connected root cluster and a non-connected cluster ν. Let Csub be its c-split clustered graph. If Csub is not c-planar then C is not c-planar. Proof. If Csub is not c-planar, there exists an edge-crossing or a cluster-crossing in at least one cluster µ. The subgraphs induced by the dummy clusters of Csub are connected components of the corresponding non-connected cluster ν of C. Thus there exists an edge-crossing or a cluster-crossing in ν and C is not cplanar. ⊓ ⊔ Note that C must not be c-planar if its c-split clustered graph Csub is c-planar (see Fig. 6). In the case that Csub is c-planar and C is not there will not exist a planar connectivity augmentation in C for the non-connected cluster ν. Thus after a positive result after the application of the c-planarity test by Dahlhaus we apply the planar connectivity augmentation algorithm on G and the vertices of ν as subset W (if we have pole vertices that belong to G(ν), we use them for connectivity). Together with Theorem 5 we get the following theorem. Theorem 7. Let C = (G, T ) be a connected clustered graph and ν its only nontrivial non-root cluster that is non-connected. C can be tested for c-planarity in linear time with respect to the number of vertices of C and in the positive case embedded in linear time.
230
Carsten Gutwenger et al. Input: A clustered graph C = (G, T ) that contains a connected root cluster and a non-connected cluster ν. Result : true if and only if there is a c-planar connectivity augmentation for ν; in the positive case an embedding Π and the minimum cardinality augmenting edge set. Compute Csub by splitting the non-connected cluster for each connected component of the subgraph G(ν); Apply the linear time c-planarity test on Csub ; if the test return false then return false; Apply the subgraph induced planarity augmentation algorithm for C and ν; if a planar connectivity augmentation exists then Compute Π; return true; else return false; Algorithm 1. The algorithm for clustered graphs C = (G, T ) that contain a connected root cluster and a non-connected cluster ν. It computes an embedding Π and the minimum cardinality augmenting edge set.
Next we consider the case that G is non-connected and there is only one cluster ν that is not the root cluster and is non-connected. For all connected components of G we apply our algorithm for clustered graphs with one nonconnected cluster. Then we choose for each connected component a face as outer face that contains at least one blue vertex v1 and one non-blue vertex v2 . We connect the blue vertices in the outer face so that the edges of a minimum cardinality augmenting edge set is inserted (as described in [GJL+ 02]). In the positive case a c-planar embedding with a minimum cardinality augmenting edge set will be computed. Thus we have that the clustered graph has a c-planar connectivity augmentation for the non-connected cluster ν which leads us to the following theorem.
Fig. 6. An example where C is not c-planar but its c-split clustered graph Csub is c-planar
Advances in C-Planarity Testing of Clustered Graphs
231
Theorem 8. Let C = (G, T ) be a not necessarily connected clustered graph and ν its only non-trivial non-root cluster that is non-connected. C can be tested for c-planarity in linear time concerning the number of vertices of C and in the positive case embedded in O(n).
4
One-Level Clustered Graphs
As shown in the last section it is possible to test c-planarity of a clustered graph with one non-connected cluster and a root cluster in O(n) time, where n is the number of vertices of G. Next, we consider a clustered graph C = (G, T ) with a cluster tree T with only one level below the root cluster. So now we allow more than one non-root cluster. Further let only one child cluster of the root cluster be non-connected. We assume, that every non-trivial cluster has at least two vertices. We construct a c-split clustered graph Csub of C as described in Sect. 3. If G is not connected, we apply this technique to every connected component of G. First, we test if the c-split clustered graph Csub of C is c-planar. We call Gmod by the c-planarity test of Feng, Eades and Cohen modified graph G. Then we apply the planar connectivity augmentation algorithm described in [GJL+ 02] for the vertices belonging to ν in Gmod . If one exists, then an embedding Π and a minimum cardinality augmenting edge set is computed and true is returned. Otherwise, C is not c-planar. If we get Π, we can apply the techniques used in the c-planarity embedding algorithm of Feng, Eades for the connected clusters using Π to obtain a c-planar embedding of C. For the case that the root cluster is non-connected, we apply further the planar connectivity augmentation algorithm for the root cluster. Theorem 9. Let C = (G, T ) be a connected clustered graph with a cluster tree T with only one level below the root cluster and ν its only non-root nonconnected cluster. Let Csub be the c-split clustered graph of C. Let Gmod be the modified graph G obtained by the c-planarity test by Feng, Eades and Cohen of Csub = (G, Tsub ). C is c-planar if and only if Csub is c-planar and there exists a planar connectivity augmentation of the vertices belonging to the subgraph G(ν) in Gmod . Proof. – “⇐” We have that Csub is c-planar and there exists a planar connectivity augmentation of G(ν) in Gmod . Thus G is planar and there exists a planar drawing of G, such that for every node µ of Tsub , all the vertices and edges of G − G(µ) are in the external face of the drawing of G(µ). Note that this holds for the connected clusters of C and for the dummy clusters in Csub constructed of ν. Therefore, Gmod allows only those c-planar embeddings that respect the connected clusters of C and takes the connected components of G(ν) into account. Hence the planar connectivity augmentation within Gmod has introduced a minimum cardinality augmenting edge set, connecting G(ν) such that the boundary of its external face in any planar drawing
232
Carsten Gutwenger et al.
of G(ν) consists of a connected not simple cycle. Furthermore, the minimum cardinality augmenting edge set connects the connected components of the original G(ν), so that there exists at the most one edge between two connected components. Therefore Gmod − G(ν) is embedded in the outer face of G(ν) after planar connectivity augmentation. Hence, C is c-planar. – “⇒” We have that C is c-planar. Thus Csub is c-planar. Hence the vertices of G(ν) can be embedded so that there is a sequence of faces f1 , . . . , fk with the following property: for all 1 ≤ i < k, there is at least one vertex of W on the boundary between fi and fi+1 and the boundaries of the faces fi (1 ≤ i ≤ k) contain all vertices of W . Therefore G has a planar connectivity augmentation in respect to the vertices of G(ν). ⊓ ⊔ Theorem 10. Let C = (G, T ) be a connected clustered graph with a cluster tree T with only one level below the root cluster and ν its only non-root non-connected cluster. C can be tested for c-planarity in O(n2 ) time in respect to the number n of vertices of C. Proof. We can create the c-split clustered graph Csub in O(n) time where n is the number of vertices of G. The c-planarity testing can be done in O(n2 ) time and the planar connectivity augmentation of the subgraph induced by the non-connected clustered graph in O(n) time. As a result the algorithm can be implemented in O(n2 ) time where n is the number of vertices of G. ⊓ ⊔
5
Multi-level Clustered Graphs
We extend the algorithm of the previous section to clustered graphs with more than one level in the tree T . Consider a clustered graph C = (G, T ) with at least two non-connected clusters where G is connected. Then if for every nonconnected cluster ν in the cluster tree T the parent cluster and all siblings of ν are connected, we show that it is possible to connect the non-connected clusters using the planar connectivity augmentation [GJL+ 02]. To do so, we compute the c-split clustered graph Csub of C. Then, we traverse T towards the root starting at the leaves in order to do the followings: For every non-connected cluster ν of C that has connected siblings µ and a connected parent pa(ν), we test whether the subgraph G(pa(ν)) is planar, test whether the edges that are incident to pa(ν) can be drawn into the outside of the drawing of G(pa(ν)) (see Figure 7) and test whether there exists a planar connectivity augmentation of the vertices of ν. If a planar connectivity augmentation exists, then an embedding Π and a minimum cardinality augmenting edge set is computed and true is returned. Otherwise, C is not c-planar. If we get Π, we can apply the techniques used in the c-planarity embedding algorithm of Feng and Eades for the connected clusters using Π to obtain a c-planar embedding of C.
Advances in C-Planarity Testing of Clustered Graphs
233
Input: A clustered graph C = (G, T ) that contains a connected root cluster, a non-connected child cluster ν and an arbitrarily number of connected child clusters. Result : true if and only if there is a c-planar connectivity augmentation for ν; in the positive case an embedding Π and the minimum cardinality augmenting edge set will be computed. Compute Csub by splitting the non-connected cluster for each connected component of the subgraph G(ν); Apply the c-planarity test by Cohen, Eades and Feng on Csub ; if the test return false then return false; Apply on Gmod (see Theorem 9) in respect to the vertices of G(ν) the planar connectivity augmentation algorithm; if a planar connectivity augmentation exists then Compute Π; return true; else return false; Algorithm 2. The algorithm for clustered graphs C = (G, T ) that contain a connected root cluster, a non-connected child cluster ν and an arbitrarily number of connected child clusters. It computes an embedding Π and the minimum cardinality augmenting edge set if C is c-planar.
G(ν)
t
Fig. 7. Constructing an auxiliary graph Gmod from the connected subgraph G(ν) where the incident edges of ν are connected with a dummy vertex t [FCE95]
Theorem 11. Let C = (G, T ) be a connected clustered graph where its nonconnected clusters ν have a connected parent cluster and only connected sibling clusters. Let Csub = (G, Tsub ) be its c-split clustered graph. Let Gmod be the graph constructed by the c-planarity test of Feng, Eades and Cohen applied to pa(ν) of Csub and where the subgraphs G(chl(pa(ν))) are replaced with their wheel graphs. If Csub is c-planar and there exists for every non-connected cluster ν a planar connectivity augmentation for the vertices of the subgraph G(ν) in Gmod then C is c-planar.
234
Carsten Gutwenger et al.
Proof. The proof is by construction. We extend the c-planarity test by Cohen, Eades and Feng as follows: For every connected parent cluster pa(ν) with a non-connected child cluster ν, we construct the graph Gmod as stated in the theorem (see Fig. 7). Then we apply the linear time planarity test based on PQtrees [BL76,CEL67] to Gmod and in the positive case the planar connectivity augmentation for the subgraph induced by the non-connected cluster [GJL+ 02]. As we do this recursively for every connected parent node that has a nonconnected cluster by taking the wheel graphs as constructed in the c-planarity test into account, we can test c-planarity in O(n2 ) time where n is the number of vertices of G. ⊓ ⊔ Theorem 12. Let C = (G, T ) be a connected clustered graph where its nonconnected clusters ν have a connected parent cluster and only connected sibling clusters. C can be tested for c-planarity and in the positive case embedded in O(n2 ) time with respect to the number n of vertices of C. Input: A clustered graph C = (G, T ) that contains a connected root cluster and non-connected clusters with connected parent cluster and sibling clusters. Result : true if and only if there is a c-planar connectivity augmentation for ν; in the positive case an embedding Π and the minimum cardinality augmenting edge set will be computed. Compute Csub by splitting the non-connected cluster for each connected component of the subgraph G(ν); Change the c-planarity test of Cohen, Eades and Feng as follows and apply it to Csub ; for for every connected parent cluster of a non-connected cluster do Construct Gmod as described in Theorem 11; Test planarity of Gmod ; if the planarity test returns false then return false; Apply the subgraph induced planar connectivity augmentation algorithm for the vertices of G(ν) in Gmod ; if a planar connectivity augmentation exists then Compute Π; return true; else return false; Algorithm 3. The algorithm for clustered graphs that contain a connected root cluster and non-connected clusters with a connected parent cluster and sibling clusters. It computes an embedding Π and the minimum cardinality augmenting edge set if C is c-planar.
We note that this technique can be applied to connected clustered graphs C = (G, T ) where the non-connected clusters lie on the same path from the root
Advances in C-Planarity Testing of Clustered Graphs
235
to the leaves. This is done again by computing the c-split clustered graph Csub for every connected component Ci of C, testing it for c-planarity. In this step, every connected component is modified with wheel graphs. Then we get graph Gmod . We now traverse the path of non-connected clusters in the original cluster tree T from the leaves to the root and apply to the vertices of these clusters the planar connectivity augmentation algorithm [GJL+ 02] in Gmod . This can be done in O(n2 ) time where n is the number of vertices in the underlying graph G. In the positive case, an embedding can be computed in O(n2 ) time. Finally, we consider two non-connected clusters that are siblings in an arbitrary clustered graph where all other clusters are connected and G is planar. If the two clusters are contained in two different connected components (if additionally the root is non-connected) or if they are contained in two different biconnected components or in two different subtrees of a BC-tree, we can apply the one-cluster-method for each connected or biconnected component independently. This can be extended to an arbitrarily number of non-connected clusters that are siblings under the condition that they are in different connected or biconnected components. Combining the techniques used in this paper, there is a large class of clustered graphs that can now be tested for c-planarity.
References BDM02. G. Di Battista, W. Didimo, and A. Marcandalli. Planarization of clustered graphs (extended abstract). In P. Mutzel, Michael J¨ unger, and Sebastian Leipert, editors, Graph Drawing, volume 2265 of Lecture Notes in Computer Science, pages 60–74. Springer-Verlag, 2002. BL76. K. Booth and G. Lueker. Testing for the consecutive ones property, interval graphs, and graph planarity using pq-tree algorithms. Journal of Computer and System Sciences, 13(1):335–379, 1976. BT96. G. Di Battista and R. Tamassia. On-line planarity testing. SIAM Journal on Computing, 25(5):956–997, 1996. CEL67. I. Cederbaum, S. Even, and A. Lempel. An algorithm for planarity testing of graphs. In Theory of Graphs, International Symposium, Rome, pages 215– 232, 1967. Dah98. E. Dahlhaus. Linear time algorithm to recognize clustered planar graphs and its parallelization (extended abstract). In C. L. Lucchesi, editor, LATIN ’98, 3rd Latin American symposium on theoretical informatics, Campinas, Brazil, April 20–24, 1998., volume 1380 of Lecture Notes in Computer Science, pages 239–248, 1998. EFN00. P. Eades, Q.-W. Feng, and H. Nagamochi. Drawing clustered graphs on an orthogonal grid. Journal of Graph Algorithms and Applications, 3:3–29, 2000. FCE95. Q.-W. Feng, R.-F. Cohen, and P. Eades. Planarity for clustered graphs. In P. Spirakis, editor, Algorithms – ESA ’95, Third Annual European Symposium, volume 979 of Lecture Notes in Computer Science, pages 213–226. Springer-Verlag, 1995.
236
Carsten Gutwenger et al.
GJL+ 02. C. Gutwenger, M. J¨ unger, S. Leipert, P. Mutzel, M. Percan, and R. Weiskircher. Subgraph induced planar connectivity augmentation. Technical report, Institut f¨ ur Informatik, Universit¨ at zu K¨ oln, 2002. zaik2002-435. GM01. C. Gutwenger and P. Mutzel. A linear time implementation of SPQR-trees. In J. Marks, editor, Graph Drawing (Proc. 2000), volume 1984 of Lecture Notes in Computer Science, pages 77–90. Springer-Verlag, 2001.
HGV: A Library for Hierarchies, Graphs, and Views Marcus Raitner University of Passau, D-94032 Passau, Germany, [email protected]
Abstract. We introduce the base architecture of a software library which combines graphs, hierarchies, and views and describes the interactions between them. Each graph may have arbitrarily many hierarchies and each hierarchy may have arbitrarily many views. Both the hierarchies and the views can be added and removed dynamically from the corresponding graph and hierarchy, respectively. The software library shall serve as a platform for algorithms and data structures on hierarchically structured graphs. Such graphs become increasingly important and occur in special applications, e. g., call graphs in software engineering or biochemical pathways, with a particular need to manipulate and draw graphs.
1
Introduction
Graphs are often used to model structured data, e. g., road maps with locations connected by roads, the web-graph with web-pages connected by links or biochemical pathways with substances connected by reactions [3]. Particularly for large graphs it is important to view, manipulate, and automatically draw them using some software tools. Clearly, all these tools rely on an appropriate data structure for graphs. There already exist various libraries implementing data structures for graphs, e. g., Leda [15], Gtl [9], or Boost Graph Library [2]. There are many applications with very large graphs. Such graphs must be manipulated efficiently by powerful operations acting on subgraphs. Repeated use of subgraphs induces a hierarchical structure. This is a particular means also for the visualization of large graphs, because certain subgraphs may be collapsed and represented by a meta-node. There are various concepts for extending graphs with such a hierarchical structure [7,10,12,18]. Moreover there are layout algorithms [7, 18] and interactive systems [17, 13] working with these concepts. The inclusion hierarchy on top of a graph can be used to define abstract representations of the graph, so called views [5,6,7] or abridgements [13]. Instead of displaying every single node of the graph, in a view a subset of the nodes is represented as one (abstract) node. These nodes are connected by an (abstract) edge if there is an edge between nodes in the corresponding subsets. In a graph editor views are very convenient since they simultaneously provide an overview of the whole graph and some details from a special portion. In some respects a view can be compared to the well known tree views of file systems where M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 236–243, 2002. c Springer-Verlag Berlin Heidelberg 2002
HGV: A Library for Hierarchies, Graphs, and Views
237
initially only the topmost layer of folders is shown and the folders of interest can be expanded within the view. Up to now there is no thorough description of the software architecture for a library providing graphs with hierarchies and views. This contribution and the prototype implementation [11] are a first step. 1.1
Related Work
There are several notions of hierarchically structured graphs in the literature. Depending on their purpose these definitions come in different flavors ranging from succinct representations of large graphs [16] to graph drawing [7, 18]. The latter is surveyed in [4]. Structuring a graph hierarchically was first employed on statecharts [10]. There the term higraph is defined as an ordinary graph with an acyclic inclusion relation on its nodes. A higraph can be seen as a directed acyclic graph (DAG) describing an inclusion hierarchy with additional graph edges connecting arbitrary nodes. The compound graphs [18] consist of a set of nodes together with inclusion edges and adjacency edges such that the inclusion edges induce a directed graph (mostly a tree) and the adjacency edges induce a directed graph. Like a higraph a compound graph can be seen as a directed graph describing the hierarchy with additional (adjacency) edges connecting arbitrary nodes. Closely related to compound graphs and higraphs are the cigraphs [14]. A cigraph is a root node together with a possibly empty set of sub-cigraphs and a set of edges between nodes in different sub-cigraphs. This means that an edge is always stored at the least common ancestor of the cigraphs it connects. Neither higraphs nor compound graphs nor cigraphs distinguish properly between the nodes of the underlying graph and the nodes of the hierarchy. On the other hand the clustered graphs [7] consist of an ordinary graph and a tree with the leaves of the tree being exactly the nodes of the graph. This can be seen as a tree describing an inclusion hierarchy with additional graph edges between its leaves only. Each node in the tree represents a cluster of nodes of the graph that are leaves of the subtree rooted at the node. With the additional restriction that there are no long tree edges, i. e., tree edges connecting nodes whose heights in the tree differ by more than one, a view at level i of a clustered graph is a graph consisting of all nodes of height i in the tree. Two nodes in the view are connected by an edge if there is at least one graph edge connecting the respective clusters. In [6,5] the notion of a view of a clustered graph is generalized. There a view is a subset of the nodes of the tree such that the corresponding clusters partition the set of nodes of the graph. Hence the view can be detailed and coarsened as needed. In [6] it is shown how to maintain a view on a clustered graph efficiently while navigating up and down the hierarchy using the methods collapse and expand. Some interactive systems [13, 17] actually use these two operations to explore clustered graphs. However, they do not describe thoroughly the coherence
238
Marcus Raitner
of graph, hierarchies and views from a software-engineering perspective. Other systems [1] model clustered graphs as an extension of ordinary graphs and do not provide views at all. 1.2
Our Results
We propose a software architecture for the interaction of graphs, hierarchies, and views. Employing the Observer design pattern [8] twice, our model features an arbitrary number of hierarchies for each graph as well as an arbitrary number of views for each hierarchy. Our model prepares the ground for a graph library with hierarchies and views. Such a library, integrated in a graph editor or a graph layout tool, provides an additional dimension for the structuring of graphs and makes working with large graphs more convenient. A first implementation of our model is available [11]. Since we allow more than one hierarchy per graph we need a rigid distinction between graph and hierarchy. Therefore we extend the clustered graphs by cross edges between tree nodes. Cross edges can be seen as edges on a higher level of abstraction, They describe a relation between clusters of nodes while edges in the graph describe a relation between the nodes of the graph. For our model we generalize the views in [6, 5], which are defined only on clustered graphs. Moreover, our views need not cover the whole graph and can therefore be used to model subgraphs and views of subgraphs.
2
Basic Notions
Definition 1. Let G be a graph with nodes V (G) and edges E(G). A hierarchy ˙ i (H), cross edges Ec (H) and a H over G consists of nodes V (H) = V (G)∪V grouping function cH : V (H) → P(V (G)) such that (i) (ii) (iii) (iv)
∀ v ∈ V (G) : cH (v) = {v} ∃ v ∈ Vi (H) : cH (v) = V (G) ∀ u, v ∈ V (H) : cH (u) ∩ cH (v) = ∅ ⇒ (cH (v) ⊆ cH (u) ∨ cH (u) ⊆ cH (v)) ∀ e = (u, v) ∈ Ec (H) : cH (u) ∩ cH (v) = ∅
The nodes Vi (H) are the called inner nodes and cH (v) is called the cluster of v. A hierarchy over a graph can be seen as a rooted tree with its leaves corresponding exactly to the nodes of the underlying graph and with cross edges connecting tree nodes which are not predecessors of one another. In Fig. 1 the hierarchy over a graph is depicted as an inclusion diagram. The solid lines are edges of the graph and the dashed ones are cross edges. The boxes represent the clusters cH (v) for v ∈ V (H). Figure 2 shows the same graph and the same hierarchy as a tree with graph edges and cross edges. Because of the cross edges this notion of a hierarchy is more general than the clustered graphs of [7]. Our definition differs from compound graphs of [18] and the higraphs of [10] since the hierarchy may not be a DAG and only cross
HGV: A Library for Hierarchies, Graphs, and Views
239
f
e
Fig. 1. Inclusion Diagram
Fig. 2. Tree
Fig. 3. View
edges are allowed. The cigraphs of [14] are equivalent to our model, but do not provide a rigid distinction between graph and hierarchy which is necessary for more than one hierarchy per graph. Definition 2. A view S of a hierarchy H over a graph G is a graph with nodes V (S) ⊂ V (H) such that ∀ u, v ∈ V (S) : u = v ⇒ cH (u) ∩ cH (v) = ∅. Two nodes u, v ∈ V (S) are connected by an edge if and only if (i) ∃ u′ , v ′ ∈ V (H) : cH (u′ ) ⊆ cH (u) ∧ cH (v ′ ) ⊆ cH (v) ∧ u′ is connected to v ′ by a cross edge or (ii) ∃ u′ ∈ cH (u), v ′ ∈ cH (v) : u′ and v ′ are connected by an edge in G. Figure 3 shows a view of the hierarchy of Fig. 1. The edges e and f are examples for (i) and (ii), respectively. There are many other views. Our definition generalizes the one given in [6, 5] in various respects. The clusters of nodes in the view need not cover the whole graph. Therefore we can model subgraphs and views of subgraphs. Using cross edges, our views can have edges connecting clusters which are not connected in the underlying graph.
3
Core Architecture
The three main classes in the class diagram in Fig. 4 are graph, hierarchy, and view. The other two classes, observable_graph and observer, are primarily abstract interfaces modeling the observer design pattern [8]. 3.1
Assumptions
The following assumptions guided the design of our library. 1. Fully dynamic graph, hierarchy and view: Nodes and edges can be added or removed from the underlying graph. The inner nodes of the hierarchy can be inserted or deleted and nodes in the view can be expanded or collapsed.
240
Marcus Raitner g r a p h + + + + +
g r a p h () new_node() : node new_edge(node, node) : edge delete_node(node) delete_edge(edge)
observer observable_graph + observable_graph() + add(observer&) + remove(observer&)
1 observed
1..* observers
+ + + + +
observer(observable_graph&) new_node_handler(node) new_edge_handler(edge) delete_node_handler(node) delete_edge_handler(edge)
hierarchy + + + + + + + + + +
view
hierarchy(observable_graph&) new_node(InputIterator, InputIterator) : node get_root() : node son_edges_begin() : son_edge_iterator son_edges_end() : son_edge_iterator get_father_edge(node) : edge induced_edge(node, node) : int is_predecessor_of(node, node) : bool is_inner_node(node) : bool is_cross_edge(edge) : bool
+ view(hierarchy&, InputIterator, InputIterator) + expand(node) + collapse(node)
Fig. 4. Core Architecture
2. Arbitrarily many hierarchies per graph: A hierarchy always describes one dimension of abstraction, e. g., grouping locations in a road map by their geographical proximity. Sometimes it may be necessary or convenient to use more than one dimension of abstraction for the same graph, i. e., more than one hierarchy. Consider for instance the web-graph, which can be grouped either by domain or by topic. 3. Arbitrarily many views per hierarchy: A view defines an abstract version of a graph in terms of an associated abstraction hierarchy (cf. Definition 2). Clearly, it is very convenient to have more than one view, especially in a viewer or editor, where the user can see one abstract overview and work in another more detailed view. 4. Minimize redundant information: By Definition 1 the graph is part of each associated hierarchy and each view is part of a hierarchy (cf. Definition 2). Since all objects are subject to change it is very important to minimize redundancy. 5. Reusable algorithms: Hierarchies and views can be seen as graphs and thus many graph algorithms are applicable to them. Clearly, these algorithms should be implemented only once. 3.2
Graphs, Nodes and Edges
The class graph is the common base class for hierarchy and view. It consists of nodes and edges and the basic methods for adding and removing these objects. It also provides methods for traversing and accessing nodes and edges. This includes methods for traversing the adjacency of a node in particular. In other words, the graph has full control and the nodes and edges are only handles without state or
HGV: A Library for Hierarchies, Graphs, and Views
241
functionality of their own. Examples for this model are the graphs in Leda [15] and in Boost Graph Library [2]. This is more appropriate here than the alternative, where nodes and edges are objects of their own controlling their adjacency lists themselves as in Gtl [9], because then there can be at most one adjacency list for each node. On the other hand there can be at most one adjacency list per graph and node if the graph manages the lists. In other words nodes can be shared by several graphs, which is important to avoid redundancy. 3.3
The Observer Pattern
The partly abstract classes observer and observable_graph form the observer design pattern [8]. observable_graph extends graph with methods for adding and removing observers dynamically. Any object used as such an observer has to be derived from observer and thus has to implement the callback methods like new_node_handler. All the methods that modify the graph are redefined in observable_graph in order to trigger the appropriate callback method in all its observers with the modified object as argument. Notification of a new node or edge occurs after the change whereas deleting a node or edge is announced in advance. 3.4
Hierarchies
As shown in Fig. 4 a hierarchy is both observer and observable_graph. The observer part keeps track of modifications of the underlying graph whereas the observable_graph part informs the attached views about changes of either the graph or the hierarchy. By definition a hierarchy cannot exist without an underlying graph. Therefore its constructor takes an observable_graph as argument. Initially a hierarchy consists of one root with all the nodes of the associated graph as sons and no cross edges. A hierarchy is a graph and thus it can be modified using the methods already defined in graph. On the other hand, a hierarchy is a special graph, namely a tree with some cross-edges, and imprudent use of such a method could violate this invariant. Therefore these methods are redefined as follows: – new_node(): Creates a new leaf, i. e., a new node in the underlying graph, and attaches it to the root. – new_edge(s,t): If both s and t are leaves then a new edge in the underlying graph is created. If at least one is an inner node and neither is a predecessor of the other a new cross-edge is inserted. – delete_node(n): If n is a leaf it is deleted in the underlying graph. If it is an inner node and is not the root all its sons are attached directly to its father before it is deleted. – delete_edge(e): Depending on whether e is a cross-edge or an edge between leaves it is deleted in the hierarchy or in the underlying graph, respectively.
242
Marcus Raitner
For inserting a new inner node the method new_node(it,end) is provided. Its arguments specify a set of nodes as the range [it,end), where it and end are iterators over some collection of nodes. It is required that all the nodes in this range have the same father in the hierarchy. The new inner node is inserted between these nodes and their father, i. e., the new node becomes the new father of these nodes and is inserted as son of the old father. Apart from these explicit changes a hierarchy must be adapted whenever the underlying graph is modified. This is achieved by implementing the callback methods of the observer interface accordingly. A new node in the underlying graph becomes a leaf attached to the root node and deleting a node in the graph results in removing the corresponding leaf from the hierarchy. Adding or removing an edge from the graph does not result in a change in the hierarchy. However, all attached views are notified about changes of either the graph or the hierarchy. The other new methods in hierarchy as shown in Fig. 4 are either for navigation in the hierarchy, e. g., son_edges_begin or get_father_edge, or provide information used by the views, e. g., induced_edge or is_predecessor_of. 3.5
Views
A view is both a graph and an observer. The graph part is the abstract version of the underlying graph in terms of the associated hierarchy. The observer part listens to changes of this hierarchy and updates the view accordingly. At any time a view consists of a subset of the nodes of its hierarchy and thus the constructor of view takes two arguments: the hierarchy and the initial subset for this view. The subset is given as a range [it,end) in a collection of nodes, where it and end are iterators. Since a view is a graph it can be modified through the standard methods defined in graph. On the other hand a view consists of nodes of the associated hierarchy and induced edges and thus all modifications must be forwarded to the hierarchy. Hence those methods are redefined in view in order to call the respective methods in hierarchy. Whenever a view is notified of a change of the hierarchy (or the graph) it has to check whether it is affected. For instance, if a node in the hierarchy is deleted the view must be adapted if and only if this node was part of the view. In order to perform these updates efficiently the view makes use of the query methods provided in hierarchy, e. g., induced_edge or is_predecessor_of. The method view::expand replaces a node in the view by its sons, and conversely view::collapse replaces all the sons of a node with the node itself. For both methods the view removes some nodes with all their incident edges and inserts one or more others. After inserting the new nodes the view uses query methods like hierarchy::induced_edge to determine their adjacency. Thus a view can not only be used to represent an abstract version of a graph but also to navigate through the hierarchy in either direction.
HGV: A Library for Hierarchies, Graphs, and Views
4
243
Conclusion
We have presented an architecture model for a library featuring graphs with an arbitrary number of hierarchies and views. Such a library shall help in handling large graphs in a convenient manner. It can be used in graph editors for drawing and exploring large graphs interactively. Our model prepares the ground for data structures for the efficient implementation of hierarchies and views and algorithms taking advantage of the additional hierarchical structure.
References 1. Agd. http://www.ads.tuwien.ac.at/AGD/index.html. 2. Boost Graph Library. http://www.boost.org/libs/graph/doc/. 3. F. J. Brandenburg, M. Forster, A. Pick, M. Raitner, and F. Schreiber. Biopath. In Proc. GD 2001, LNCS 2265, pp. 451–456, 2001. 4. R. Brockenauer and S. Cornelsen. Drawing clusters and hierarchies. In Drawing Graphs – Methods and Models, LNCS 2025, pp. 193–227, 2001. 5. A. L. Buchsbaum, M. T. Goodrich, and J. R. Westbrook. Range searching over tree cross products. In 8th ESA, 2000. 6. A. L. Buchsbaum and J. R. Westbrook. Maintaining hierarchical graph views. In 11th ACM-SIAM Symposium on Discrete Algorithms, 2000. 7. P. Eades and Q.-W. Feng. Multilevel visualization of clustered graphs. In Proc. GD 1996, LNCS 1190, pp. 101–112, 1996. 8. E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements od Reusable Object-Oriented Software. AW Professional Computing Series, 1995. 9. Gtl. http://www.infosun.fmi.uni-passau.de/GTL. 10. D. Harel. On visual formalisms. Comm. of the ACM, 31(5):588–600, 1988. 11. Hgv. http://www.infosun.fmi.uni-passau.de/˜raitner/HGV/. 12. M. Himsolt. Konzeption und Implementierung von Grapheneditoren. PhD thesis, Fakult¨ at f¨ ur Mathematik und Informatik, Universit¨ at Passau, 1993. 13. M. L. Huang and P. Eades. A fully animated interactive system for clustering and navigating huge graphs. In Proc. GD 1998, LNCS 1547, pp. 374–383, 1998. 14. W. Lai and P. Eades. A graph model which supports flexible layout functions. Technical Report 96–15, 1996. 15. Leda. http://www.algorithmic-solutions.com/. 16. T. Lengauer and E. Wanke. Efficient solution of connectivity problems on hierarchically defined graphs. SIAM Journal on Computing, 17(6):1063–1080, 1988. 17. I. A. Lisitsyn and V. N. Kasyanov. Higres - visualization system for clustered graphs and graph algorithms. In Proc. GD 1999, LNCS 1731, pp. 82–89, 1999. 18. K. Sugiyama and K. Misue. Visualization of structural information: Automatic drawing of compound digraphs. IEEE Trans. Systems, Man and Cybernetics, 21(4):876–892, 1991.
Rectangular Drawings of Planar Graphs⋆ (Extended Abstract) Md. Saidur Rahman1 , Takao Nishizeki2 , and Shubhashis Ghosh3 1
Graduate School of Information Sciences, Tohoku University, Aoba-yama 05, Sendai 980-8579, Japan. On leave from Bangladesh University of Engineering and Technology (BUET). [email protected] 2 Graduate School of Information Sciences, Tohoku University, Aoba-yama 05, Sendai 980-8579, Japan. [email protected] 3 Department of Computing Science, University of Alberta, Edmonton, Alberta T6G 2E8, Canada. On leave from Bangladesh University of Engineering and Technology (BUET). [email protected]
Abstract. A plane graph is a planar graph with a fixed embedding. In a rectangular drawing of a plane graph, each vertex is drawn as a point, each edge is drawn as a horizontal or vertical line segment, and each face is drawn as a rectangle. A planar graph is said to have a rectangular drawing if at least one of its plane embeddings has a rectangular drawing. In this paper we give a linear-time algorithm to examine whether a planar graph G of the maximum degree three has a rectangular drawing or not, and to find a rectangular drawing of G if it exists.
1
Introduction
The necessity of automatic graph drawing in various areas of science and technology has accelerated the development of many graph drawing styles, and different algorithms have been developed for producing these graph drawing styles [DETT99]. Among different drawing styles a “rectangular drawing” has attracted much attention due to its applications in VLSI floorplanning [KK84, L90, RNN98, RNN02, RNN02, TTSS91] and architectural floorplanning [MKI00]. A plane graph is a planar graph with a fixed embedding. A rectangular drawing of a plane graph G is a drawing of G in which each vertex is drawn as a point, each edge is drawn as a horizontal or vertical line segment without edge-crossings, and each face is drawn as a rectangle. (See Figure 1(a).) Not every plane graph has a rectangular drawing. We denote by ∆ the maximum degree of G. If a plane graph G has a rectangular drawing, then ∆ ≤ 4 and G must be biconnected and have four or more vertices of degree 2 on the outer face. Thomassen [T84] obtained a necessary and sufficient condition for a plane graph of ∆ ≤ 3 to have a rectangular drawing when four vertices of degree two on the outer face are designated as convex corners of a rectangular drawing of the outer face. Linear-time algorithms are given in [BS88, H93, KH97, RNN98] to obtain a rectangular drawing of such ⋆
This work is supported by JSPS grants.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 244–255, 2002. c Springer-Verlag Berlin Heidelberg 2002
Rectangular Drawings of Planar Graphs
245
a plane graph. The plane graph in Figure 1(b) has a rectangular drawing for the four designated corners a, f , i, and l as illustrated in Figure 1(a). Rahman et al. [RNN02] gave a necessary and sufficient condition for a plane graph of ∆ ≤ 3 to have a rectangular drawing when no vertex is designated as a corner, and developed a linear-time algorithm to find a rectangular drawing of a plane graph if it exits. c b a m m
a
p
o n
u
d e
k
q
s
u t
g k
i
t
u
c
o r
(d)
j
n o p q r
d l
f e
k j g i h
s
P 3
h (b)
u
t (c)
m n
k
n p
c u
s j
q
s
a
b e d
f
k
i g
l
P 2
r
m
h
n
f
i
h (a)
g
d
l o p
e
j
r
t
f
P a 1 b c
l
b c
m
s
e
r
j
q p
g
h (e)
Fig. 1. A rectangular drawing (a) and three different embeddings (b), (c) and (d) of the same graph which is subdivision of the graph in (e).
A planar graph G is said to have a rectangular drawing if at least one of the plane embeddings of G has a rectangular drawing. Figures 1(b), (c) and (d) depict three different plane embedings of the same planar graph. Among them only the embedding in Figure 1(b) has a rectangular drawing as illustrated in Figure 1(a). Thus the planar graph has a rectangular drawing. A rectangular drawing of a planar graph with ∆ ≤ 3 has practical application in VLSI floorplanning [KK84, L90, RNN98, RNN02] and architectural floorplanning [MKI00]. Examining whether a planar graph G of ∆ ≤ 3 has a rectangular drawing is not a trivial problem, since G may have an exponential number of plane embeddings in general. A straightforward algorithm checking each of all the embeddings by the linear algorithm above in [RNN02] does not run in polynomial time. It has thus been desired to obtain an efficient algorithm. In this paper we give a lineartime algorithm to examine whether a planar graph G of ∆ ≤ 3 has a rectangular drawing and find a rectangular drawing of G if it exists. We first consider the case where G is a “subdivision” of a planar 3-connected cubic graph, and then consider the case where G is not a “subdivision” of a planar 3-connected cubic graph. The plane graph in Figure 1(b) is a subdivision of the planar 3-connected cubic graph in Figure 1(e). A subdivision G of a planar 3-connected cubic graph has exactly one embedding for each face embedded as
246
Md. Saidur Rahman, Takao Nishizeki, and Shubhashis Ghosh
the outer face [NC88]. Hence G has an O(n) number of embeddings, one for each chosen outer face. Thus, the straightforward algorithm takes time O(n2 ) to examine whether the planar graph G has a rectangular drawing. We however obtain a necessary and sufficient condition for a subdivision G of a planar 3connected cubic graph to have a rectangular drawing, which leads to a linear-time algorithm to examine whether the planar graph G has a rectangular drawing. If G is not a subdivision of a planar 3-connected cubic graph, then G may have an exponential number of embeddings, and hence a straightforward algorithm does not run in polynomial time. We however give a linear-time algorithm to examine whether G has a rectangular drawing or not; we indeed show that it suffices to examine whether only four embeddings of G have rectangular drawings or not. The rest of the paper is organized as follows. Section 2 describes some definitions and presents preliminary results. Section 3 presents the necessary and sufficient conditions for a planar graph of ∆ ≤ 3 to have a rectangular drawing. Section 4 presents a linear-time algorithm to find a rectangular drawing of a planar graph G of ∆ ≤ 3 if it exists. Finally, Section 5 concludes with discussions.
2
Preliminaries
In this section we give some definitions and present preliminary results. Let G = (V, E) be a connected simple graph with vertex set V and edge set E. We denote by d(v) the degree of v. A graph G is called cubic if d(v) = 3 for every vertex v. For V ′ ⊆ V, G − V ′ denotes a graph obtained from G by deleting all vertices in V ′ together with all edges incident to them. For a subgraph G′ of G, we denote by G − G′ the graph obtained from G by deleting all vertices in G′ . The connectivity κ(G) of a graph G is the minimum number of vertices whose removal results in a disconnected graph or a single-vertex graph K1 . We say that G is k-connected if κ(G) ≥ k. A separation pair of a 2-connected graph G is a pair of vertices whose deletion disconnects G. A 3-connected graph has no separation pair. Let P = w0 , w1 , w2 , ..., wk+1 , k ≥ 1, be a path of G such that d(w0 ) ≥ 3, d(w1 ) = d(w2 ) = · · · = d(wk ) = 2, and d(wk+1 ) ≥ 3. Then we call the subpath P ′ = w1 , w2 , ..., wk of P a chain of G, and we call vertices w0 and wk+1 the supports of the chain P ′ . If G is a subdivision of a 3-connected graph, then any vertex of degree 2 in G is contained in exactly one of the chains of G. Two chains on a cycle are consecutive if they have a common support. Chains P1 = a, b and P2 = l on the outer face of the plane graph in Figure 1(b) are consecutive, while P1 and P3 = i are not. Subdividing an edge (u, v) of a graph G is the operation of deleting the edge (u, v) and adding a path u(= w0 ), w1 , w2 , ..., wk , v(= wk+1 ) through new vertices w1 , w2 , ..., wk , k ≥ 1, of degree 2. A graph G is said to be a subdivision of a graph G′ if G is obtained from G′ by subdividing some of the edges of G′ . A graph G is called cyclically 4-edge-connected if the removal of any three or fewer edges leaves a graph such that exactly one of the connected components has a cycle [T92].
Rectangular Drawings of Planar Graphs
247
Let G be a planar biconnected graph, and let Γ be a plane embedding of G. The contour of a face is a cycle of G, and is simply called a face or a facial cycle. We denote by Fo (Γ ) the outer face of Γ . For a cycle C of Γ , we call the plane subgraph of Γ inside C (including C) the inner subgraph ΓI (C) for C, and call the plane subgraph of Γ outside C (including C) the outer subgraph ΓO (C) for C. An edge of G which is incident to exactly one vertex of a cycle C and located outside C is called a leg of C. The vertex of C to which a leg is incident is called a leg-vertex of C. A cycle C in Γ is called a k-legged cycle of Γ if C has exactly k legs in Γ and there is no edge which joins two vertices on C and is located outside C. The set of k legs of a k-legged cycle in Γ corresponds to a “cutset” of k edges for k = 2 or 3. We call a face F of Γ a peripheral face for a 3-legged cycle C in Γ if F is in ΓO (C) and the contour of F contains some edges on C. Clearly there are exactly three peripheral faces for any 3-legged cycle in Γ . A k-legged cycle C is called a minimal k-legged cycle if GI (C) does not contain any other k-legged cycle of G. We say that cycles C and C ′ in Γ are independent if ΓI (C) and ΓI (C ′ ) have no common vertex. A set S of cycles is independent if any pair of cycles in S are independent. A plane biconnected graph G may have a separation pair, and the pair of leg-vertices of any 2-legged cycle in G is a separation pair. A cycle C in a plane embedding Γ of G is called regular if the plane graph Γ − ΓI (C) has a cycle. Clearly a 2-legged cycle C in Γ is not regular if and only if Γ − ΓI (C) is a chain of G, while a 3-legged cycle C is not regular if and only if Γ − ΓI (C) contains exactly one vertex that has degree 3 in G. Let G be a subdivision of a planar 3-connected cubic graph, then Γ has no regular 2-legged cycle, but may have a regular 3-legged cycle, and Γ has no regular 3-legged cycle if and only if G is cyclically 4-edge-connected. Ungar [U53] showed that any plane embedding Γ of a cyclically 4-edgeconnected planar cubic graph G has a rectangular drawing if four vertices of degree 2 are inserted on some edges on the outer face Fo (Γ ). Generalizing the results of Ungar, Thomassen [T84] obtained a necessary and sufficient condition for a plane embedding of a planar graph G with ∆ ≤ 3 to have a rectangular drawing when four vertices of degree 2 on Fo (Γ ) are designated as corners for a rectangular drawing. Generalizing the result of Thomassen, Rahman et al. [RNN02] gave a necessary and sufficient condition for a plane embedding of a planar graph G with ∆ ≤ 3 to have a rectangular drawing when no vertex is designated as a corner, and developed a linear-time algorithm to find a rectangular drawing of G if it exits, as in the following Lemma 1. Lemma 1. [RNN02] A plane embedding Γ of a planar biconnected graph G of ∆ ≤ 3 has a rectangular drawing if and only if Γ satisfies the following four conditions: (a) there are four or more vertices of degree 2 on Fo (Γ ); (b) every 2-legged cycle in Γ contains at least two vertices of degree 2 on Fo (Γ ); (c) every 3-legged cycle in Γ contains at least one vertex of degree 2 on Fo (Γ ); and (d) if an independent set S of cycles in Γ consists of c2 2-legged cycles and c3 3-legged cycles, then 2c2 + c3 ≤4 .
248
Md. Saidur Rahman, Takao Nishizeki, and Shubhashis Ghosh
Furthermore one can examine in linear time whether Γ satisfies the condition above, and if Γ does then one can find a rectangular drawing of Γ in linear time. Although the results above for plane embeddings are known, it is difficult to examine whether a planar graph has a rectangular drawing or not, since a planar graph may have an exponential number of plane embeddings in general. The following fact is known for subdivisions of planar 3-connected cubic graphs. Fact 2 [NC88] Let G be a subdivision of a 3-connected planar graph. Then there is exactly one embedding of G for each face embedded as the outer face. Furthermore, for any two plane embeddings Γ and Γ ′ of G, any facial cycle in Γ is a facial cycle in Γ ′ .
3
Rectangular Drawings of Planar Graphs
In this section we give necessary and sufficient conditions for a planar graph of ∆ ≤ 3 to have a rectangular drawing. In Section 3.1 we consider the case where G is a subdivision of a planar 3-connected cubic graph, and in Section 3.2 the other case. 3.1
Case for a Subdivision of a Planar 3-Connected Cubic Graph
Let G be a subdivision of a planar 3-connected cubic graph. Then by Fact 2 G has an O(n) number of embeddings, one for each chosen outer face. Examining by the linear algorithm in Lemma 1 whether the four conditions hold for each of the O(n) embeddings, one can examine in time O(n2 ) whether G has a rectangular drawing. However, we obtain the following necessary and sufficient condition for G to have a rectangular drawing, which leads to a linear-time algorithm. Theorem 1. Let G be a subdivision of a planar 3-connected cubic graph, and let Γ be an arbitrary plane embedding of G. (a) Suppose first that G is cyclically 4-edge-connected, that is, Γ has no regular 3-legged cycle. Then the planar graph G has a rectangular drawing if and only if Γ has a face F such that (i) F contains at least four vertices of degree 2; (ii) there are at least two chains on F ; and (iii) if there are exactly two chains on F , then they are not consecutive and each of them contains at least two vertices. (b) Suppose next that G is not cyclically 4-edge connected, that is, Γ has a regular 3-legged cycle C. Let F1 , F2 and F3 be the three peripheral faces for C, and let Γ1 , Γ2 and Γ3 be the plane embeddings of G taking F1 , F2 and F3 , respectively, as the outer face. Then the planar graph G has a rectangular drawing if and only if at least one of the three embeddings Γ1 , Γ2 and Γ3 has a rectangular drawing.
Rectangular Drawings of Planar Graphs
249
Before giving a proof of Theorem 1, we observe the following lemma on subdivisions of planar 3-connected cubic graphs. Lemma 3. Let G be a subdivision of a planar 3-connected cubic graph G′ , and let Γ be an arbitrary plane embedding of G. Then the following (a) – (c) hold. (a) If C is a 2-legged cycle in Γ , then the legs e1 and e2 and the leg-vertices v1 and v2 of C are on the outer face Fo (Γ ), and the set of all vertices not in ΓI (C) induces a chain of G on Fo (Γ ) with supports v1 and v2 . (b) For any chain P on Fo (Γ ), the outer face of the plane graph Γ − P is a 2-legged cycle in Γ . (c) Any pair of 2-legged cycles in Γ are not independent. We are now ready to give a proof of Theorem 1. Proof of Theorem 1(a): Necessity: Assume that G is cyclically 4-edge-connected and has a rectangular drawing. Then a plane embedding Γ ′ of G has a rectangular drawing. The four corner vertices of a rectangular drawing of Fo (Γ ′ ) have degree 2, and hence Fo (Γ ′ ) has at least four vertices of degree 2. If all the four corner vertices are contained in the same chain on Fo (Γ ′ ), then G would not have a rectangular drawing. Therefore, there are two or more chains on Fo (Γ ′ ). Suppose that there are exactly two chains on Fo (Γ ′ ). Then clearly each of them contains exactly two of the four corner vertices of degree 2; otherwise, Γ ′ would not have a rectangular drawing. Furthermore, the two chains must be non-consecutive; otherwise, Γ ′ would have a 3-legged cycle C containing no vertex of degree 2 on Fo (Γ ′ ), contrary to Lemma 1(c). Thus the outer face Fo (Γ ′ ) satisfies Conditions (i) – (iii) of Theorem 1(a). By Fact 2, the outer face Fo (Γ ′ ) corresponds to a face F of the arbitrary plane embedding Γ of G. Therefore, the face F in Γ satisfies Conditions (i), (ii) and (iii) of Theorem 1. Sufficiency: We give a constructive proof for the sufficiency of Theorem 1(a). Assume that Γ has a face F satisfying Conditions (i) – (iii) of Theorem 1(a). Let Γ ′ be an embedding of G such that F = Fo (Γ ′ ). It is sufficient to prove that Γ ′ satisfies Conditions (a) – (d) in Lemma 1. (a) By Condition (i) in Theorem 1(a) Fo (Γ ′ ) = F contains at least four vertices of degree 2, and hence Γ ′ satisfies Condition (a) in Lemma 1. (b) We now show that Γ ′ satisfies Condititon (b) in Lemma 1, that is, every 2-legged cycle C in Γ ′ contains at least two vertices of degree 2 on Fo (Γ ′ ). By Condition (ii) in Theorem 1(a) there are at least two chains on Fo (Γ ′ ), and hence we have the following two cases to consider. Case 1: there are exactly two chains P1 and P2 on Fo (Γ ′ ). By Lemmas 3(a) – (c) Γ ′ has exactly two 2-legged cycles C1 and C2 . Clearly each of the 2-legged cycles C1 and C2 contains exactly one chain. By Condition (iii) of Theorem 1(a) each of the two chains P1 and P2 contains at least two vertices of degree 2. Therefore, each 2-legged cycle contains at least two vertices of degree 2 on Fo (Γ ′ ). Thus Γ ′ satisfies Condition (b) of Lemma 1.
250
Md. Saidur Rahman, Takao Nishizeki, and Shubhashis Ghosh
Case 2: there are more than two chains on Fo (Γ ′ ). Assume that there are exactly r chains on Fo (Γ ′ ) and r ≥ 3. Then each 2-legged cycle contains r − 1 (≥ 2) chains on Fo (Γ ′ ), and hence contains at least two vertices of degree 2 on Fo (Γ ′ ). Thus Γ ′ satisfies Condition (b) of Lemma 1. (c) We next show that Γ ′ satisfies Condition (c) in Lemma 1, that is, every 3-legged cycle C in Γ ′ contains at least one vertex of degree 2 on Fo (Γ ′ ). Since G is cyclically 4-edge connected, C is not regular and hence Γ ′ − ΓI′ (C) has no cycle. Therefore, C contains edges on Fo (Γ ′ ), two of the three leg-vertices of C, say u and v, are on Fo (Γ ′ ), and Γ ′ − ΓI′ (C) contains exactly one vertex w that has degree three in G. Clearly w is on Fo (Γ ′ ). The three vertices u, w and v divide Fo (Γ ′ ) to three paths P1 , P2 and P3 ; P1 goes from u to w on Fo (Γ ′ ), P2 from w to v, and P3 from v to u. By Condition (ii) in Theorem 1(a) there are at least two chains on F = Fo (Γ ′ ). We now have the following two cases. Case 1: at most one of P1 and P2 contains a chain. In this case there are at least one chain on P3 since there are at least two chains on Fo (Γ ′ ). Therefore, C contains at least one vertex of degree 2 on Fo (Γ ′ ). Thus Γ ′ satisfies Condition (c) in Lemma 1. Case 2: each of P1 and P2 contains a chain. In this case the two chains on P1 and P2 are consecutive. Therefore by Condition (iii) in Theorem 1(a) Fo (Γ ′ ) contains three or more chains, and hence there is at least one chain on P3 . Thus C contains at least one vertex of degree 2 on Fo (Γ ′ ), and hence Γ ′ satisfies Condition (c) in Lemma 1. (d) We finally show that Γ ′ satisfies Condition (d) in Lemma 1. Let S be any independent set of cycles in Γ ′ . Then c2 ≤ 1 by Lemma 3(c). We now claim that c3 ≤ 1. Otherwise, there are two different 3-legged cycles C and C ′ in S. By (c) above each of C and C ′ contains at least one vertex of Fo (Γ ′ ). Since G is cyclically 4-edge connected, C and C ′ are not regular and hence each of the plane graphs Γ ′ − ΓI′ (C) and Γ ′ − ΓI′ (C ′ ) contains exactly one vertex that has degree 3 in G. Then clearly ΓI′ (C) and ΓI′ (C ′ ) have common vertices, contrary to the assumption that S is an independent set of cycles. Since c2 ≤ 1 and c3 ≤ 1, we have 2c2 + c3 ≤ 3. Thus Γ ′ satisfies Condition (d) of Lemma 1. Q.E.D. Proof of Theorem 1(b): Since the proof for the sufficiency is obvious, we give a proof for the necessity. Suppose that Γ has a regular 3-legged cycle C and that the planar graph G has a rectangular drawing. Then there is a plane embedding Γ ′ of G which has a rectangular drawing. Let F be the face of Γ corresponding to Fo (Γ ′ ). It suffices to show that F is one of the three peripheral faces F1 , F2 and F3 for C in Γ . We first consider the case where C contains an edge on Fo (Γ ). Let C ′ be the cycle in Γ − ΓI (C) such that ΓI (C ′ ) has the maximum number of edges. One can observe that C ′ is a 3-legged cycle in Γ , and any face of Γ other than F1 , F2 and F3 is in ΓI (C) or ΓI (C ′ ). Therefore it is sufficient to prove that F is neither in ΓI (C) nor in ΓI (C ′ ). If F is in ΓI (C), then a 3-legged cycle C ′ in Γ ′ contains no vertex on Fo (Γ ′ ) = F , a contradiction to Lemma 1(c). Similarly, if
Rectangular Drawings of Planar Graphs
251
F is in ΓI (C ′ ), then a 3-legged cycle C in Γ ′ contains no vertex on Fo (Γ ′ ) = F , a contradiction to Lemma 1(c). We next consider the case where C does not contain any edge on Fo (Γ ). Let C ′ be the cycle in Γ − ΓI (C) such that ΓI (C ′ ) includes ΓI (C) and has the minimum number of edges. Any face of Γ other than F1 , F2 and F3 is in ΓI (C) or ΓO (C ′ ). Therefore it is sufficient to prove that F is neither in ΓI (C) nor in ΓO (C ′ ). If F is in ΓI (C), then a 3-legged cycle C ′ in Γ ′ contains no vertex on Fo (Γ ′ ) = F , a contradiction to Lemma 1(c). If F is in ΓO (C ′ ), then a 3-legged cycle C in Γ ′ contains no vertex on Fo (Γ ′ ) = F , a contradiction to Lemma 1(c). Q.E.D. Theorem 1 immediately yields the following algorithm to examine whether a subdivision G of a planar 3-connected cubic graph has a rectangular drawing and to find a rectangular drawing of G if it exists.
1 2 3 4 5 6 7 8 9
10 11 12
Algorithm Subdivision-Draw(G) begin Let Γ be any plane emebedding of G; Examine whether Γ has a regular 3-legged cycle C; if Γ has no regular 3-legged cycle then begin{ G is cyclically 4-edge-connected.} Find a face F in Γ which satisfies Conditions (i)–(iii) in Theorem 1(a); if Γ has such a face F then begin Let Γ ′ be the plane embedding of G whose outer face is F ; Find a rectangular drawing of Γ ′ by the algorithm in [RNN02] end else G has no rectangular drawing; end else { Γ has a regular 3-legged cycle, and G is not cyclically 4-edge-connected.} begin let C be a regular 3-legged cycle; Let F1 , F2 and F3 be the three peripheral faces of C; Let Γ1 , Γ2 and Γ3 be three plane embeddings of G taking F1 , F2 , and F3 as the outer face, respectively; Examine whether Γ1 , Γ2 and Γ3 have rectangular drawings by the algorithm in [RNN02]; if Γ1 , Γ2 or Γ3 , say Γ1 , has a rectangular drawing then Find a rectangular drawing of Γ1 by the algorithm in [RNN02] else G has no rectangular drawing; end end.
252
Md. Saidur Rahman, Takao Nishizeki, and Shubhashis Ghosh
Theorem 2. Algorithm Subdivision-Draw examines in linear time whether a subdivision G of a planar 3-connected cubic graph has a rectangular drawing, and finds a rectangular drawing of G in linear time if it exists.
3.2
The Other Case
In this section we assume that G is a planar biconnected graph of ∆ ≤ 3 but is not a subdivision of a 3-connected cubic graph, and give a linear-time algorithm to examine whether G has a rectangular drawing and to find a rectangular drawing of G if it exists. Let Γ be an arbitrary plane embedding of G. It is trivial to examine whether G has a rectangular drawing if Γ has at most two inner faces. We may thus assume that Γ has three or more inner faces. Since G is not a subdivision of a planar 3-connected cubic graph, Γ has a regular 2-legged cycle. Let C1 , C2 , · · · , Cl be the regular 2-legged cycles in Γ , and let xi , yi , 1 ≤ i ≤ l, be the two leg-vertices of Ci . One can easily observe that l = O(n) if G has n vertices [HT73]. If the planar graph G has a rectangular drawing, then a plane embedding Γ ′ of G has a rectangular drawing. The outer face Fo (Γ ′ ) must contain all vertices x1 , y1 , x2 , y2 , · · · , xl , yl ; otherwise, Γ ′ would not have a rectangular drawing as known from Lemma 1(b). Construct a graph G+ from G by adding a dummy vertex z and dummy edges (xi , z) and (yi , z) for all indices i, 1 ≤ i ≤ l. If G+ is not planar, then G has no rectangular drawing. We thus assume that G+ is planar and has an embedding Γ + such that z is embedded on the outer face. We delete from Γ + the dummy vertex z and all dummy edges incident to z, and let Γ ∗ be the resulting plane embedding of G, in which Fo (Γ ∗ ) contains all vertices x1 , y1 , x2 , y2 , · · · , xl , yl . If Γ ∗ has three or more independent 2-legged cycles, then any plane embedding Γ ′′ of G whose outer face contains all vertices x1 , y1 , x2 , y2 , · · · , xl , yl has three or more independent 2-legged cycles, and hence by Lemma 1(d) Γ ′′ has no rectangular drawing, and consequently the planar graph G has no rectangular drawing. We may thus assume that Γ ∗ has two or less independent 2-legged cycle. Since Γ has a regular 2-legged cycle, Γ ∗ has two or more independent 2legged cycles. Thus Γ ∗ has exactly two independent 2-legged cycles C1 and C2 . We may assume without loss of generality that C1 and C2 are minimal 2-legged cycles, as illustrated in Figure 2(a). If we flip ΓI∗ (C) for any 2-legged cycle C other than C1 and C2 , then the outer face of the resulting embedding does not contain the leg-vertices of C1 or C2 . By flipping ΓI∗ (C1 ) or ΓI∗ (C2 ) around the leg-vertices of C1 or C2 , we have four different embeddings Γ1 (= Γ ∗ ), Γ2 , Γ3 and Γ4 such that each Fo (Γi ), 1 ≤ i ≤ 4, contains all vertices x1 , y1 , x2 , y2 , · · · , xl , yl . Γ1 and Γ2 are illustrated in Figure 2. Clearly, only these four embeddings Γ1 , Γ2 , Γ3 and Γ4 have all vertices x1 , y1 , x2 , y2 , · · · , xl , yl on the outer face. Thus G has a rectangular drawing if and only if any of Γ1 , Γ2 , Γ3 and Γ4 has a rectangular drawing. We thus have the following theorem.
Rectangular Drawings of Planar Graphs x2
x1
x2
x1
C1
C1
C2
C2
y1
Γ1
y2
y1
253
Γ2
y2
Fig. 2. (a) Γ1 = Γ ∗ , and (b) Γ2 is obtained by flipping ΓI∗ (C1 ) only.
Theorem 3. Let G be a planar biconnected graph of ∆ ≤ 3 which is not a subdivision of a planar 3-connected cubic graph. Let Γ be a planar embedding of G such that every 2-legged cycle in Γ has leg-vertices on Fo (Γ ), and let C1 and C2 be the two minimal 2-legged cycles in Γ . Let Γ1 (= Γ ), Γ2 , Γ3 , and Γ4 be the four embeddings of G obtained from Γ by flipping ΓI (C1 ) or ΓI (C2 ) around the leg-vertices of C1 and C2 . Then G has a rectangular drawing if and only if at least one of the four embeddings Γ1 , Γ2 , Γ3 , and Γ4 has a rectangular drawing.
Algorithm
4
In this section we formally describe our algorithm Planar-Rectangular-Draw to examine whether a planar graph G of ∆ ≤ 3 has a rectangular drawing and to find a rectangular drawing of G if it exists.
1 2 3 4 5 6 7 8 9
10 11
Algorithm Planar-Rectangular-Draw(G) begin Let Γ be any plane emebedding of G; Examine whether Γ has a regular 2-legged cycle; if Γ has no regular 2-legged cycle then { G is a subdivision of a planar 3-connected cubic graph.} Examine by Algorithm Subdivision-Draw whether G has a rectangular drawing and find a rectangular drawing of G if it exists; else {G is not a subdivision of a planar 3-connected cubic graph.} begin let x1 , y1 , x2 , y2 , · · · , xl , yl be the leg-vertices of regular 2-legged cycles C1 , C2 , · · · , Cl in Γ ; Construct a graph G+ from G by adding a dummy vertex z and dummy edges (xi , z) and (yi , z) for all indices i, 1 ≤ i ≤ l; Examine whether G+ is planar; if G+ is not planar then G has no rectangular drawing else begin Find a planar embedding Γ + of G+ such that z is embedded on the outer face; Delete from Γ + the dummy vertex z and all dummy edges incident to z,
Md. Saidur Rahman, Takao Nishizeki, and Shubhashis Ghosh
254
and let Γ ∗ be the resulting plane graph; Let C1 and C2 be the two minimal regular 2-legged cycles in Γ ∗ ; Let Γ1 , Γ2 Γ3 and Γ4 be the four plane embeddings of G obtained from Γ ∗ by flipping ΓI∗ (C1 ) or ΓI∗ (C2 ) around the leg-vertices of C1 or C2 ; Examine whether Γ1 , Γ2 Γ3 and Γ4 have rectangular drawings by the algorithm in [RNN02]; if Γ1 , Γ2 , Γ3 or Γ4 , say Γ1 , has a rectangular drawing then Find a rectangular drawing of Γ1 by the algorithm in [RNN02] else G has no rectangular drawing; end
12 13
14 15 16 17
end. We now have the following theorem on Algorithm Planar-RectangularDraw. Theorem 4. Let G be a planar biconnected graph of ∆ ≤ 3. Then Algorithm Planar-Rectangular-Draw examines in linear time whether G has a rectangular drawing and finds a rectangular drawing of G if it exists.
5
Conclusions
In this paper we give a linear-time algorithm to examine whether a planar graph G of ∆ ≤ 3 has a rectangular drawing and to find a rectangular drawing of G if it exists. A box-rectangular drawing of a plane graph G is a drawing of G such that each vertex is drawn as a (possibly degenerated) rectangle, called a box, each edge is drawn as a horizontal or a vertical line segment and the contour of each face is drawn as a rectangle. Linear-time algorithms are known to determine whether a plane graph has a box-rectangular drawing and find a box-rectangular drawing if it exists [RNN00, H01]. A planar graph is said to have a box-rectangular drawing if one of its plane embeddings has a box-rectangular drawing. A straightforward algorithm checking each of all embeddings by a linear algorithm in [RNN00, H01] does not run in polynomial time. Extending the algorithm in this paper, one can obtain a linear algorithm to examine whether a planar graph has a box-rectangular drawing and find a box-rectangular drawing if it exists.
References BS88.
J. Bhasker and S. Sahni, A linear algorithm to find a rectangular dual of a planar triangulated graph, Algorithmica, 3, pp. 247-278, 1988. DETT99. G. Di Battista, P. Eades, R. Tamassia and I. G. Tollis. Graph Drawing, Prentice Hall, Upper Saddle River, NJ, 1999.
Rectangular Drawings of Planar Graphs H93. H01. HT73. KH97.
KK84.
L90. MKI00.
NC88. RNN98. RNN99.
RNN00. RNN02.
TTSS91.
T84.
T92. U53.
255
X. He, On finding the rectangular duals of planar triangulated graphs, SIAM J. Comput., 22(6), pp. 1218-1226, 1993. X. He, A simple linear time algorithm for proper box rectangular drawings of plane graphs, Journal of Algorithms, 40(1), pp. 82-101, 2001. J. E. Hopcroft and R. E. Tarjan, Dividing a graph into triconnected components, SIAM J. Comput., 2(3), pp. 135-158, 1973. G. Kant and X. He, Regular edge labeling of 4-connected plane graphs and its applications in graph drawing problems, Theoretical Computer Science, 172, pp. 175-193, 1997. K. Kozminski and E. Kinnen, An algorithm for finding a rectangular dual of a planar graph for use in area planning for VLSI integrated circuits, Proc. 21st DAC, Albuquerque, pp. 655-656, 1984. T. Lengauer, Combinatirial Algorithms for Integrated Circuit Layout, John Wiley & Sons, Chichester, 1990. S. Munemoto, N. Katoh and G. Imamura, Finding an optimal floor layout based on an orthogonal graph drawing algorithm, J. Archit. Plann. Enviroment Eng. AIJ, No. 524, pp. 279-286, 2000. T. Nishizeki and N. Chiba, Planar Graphs: Theory and Algorithms, NorthHolland, Amsterdam, 1988. M. S. Rahman, S. Nakano and T. Nishizeki, Rectangular grid drawings of plane graphs, Comp. Geom. Theo. Appl., 10(3), pp. 203-220, 1998. M. S. Rahman, S. Nakano and T. Nishizeki, A linear algorithm for bendoptimal orthogonal drawings of triconnected cubic plane graphs, Journal of Graph Alg. Appl., 3, No.4, pp. 31-62, 1999. M. S. Rahman, S. Nakano and T. Nishizeki, Box-rectangular drawings of plane graphs, Journal of Algorithms, 37(2), pp. 363-398, 2000. M. S. Rahman, S. Nakano and T. Nishizeki, Rectangular drawings of plane graphs without designated corners, Comp. Geom. Theo. Appl., 21(3), pp. 121-138, 2002. K. Tani, S. Tsukiyama, S. Shinoda and I. Shirakawa, On area-efficient drawings of rectangular duals for VLSI floor-plan, Mathematical Programming, 52, pp. 29-43, 1991. C. Thomassen, Plane representations of graphs, (Eds.) J. A. Bondy and U. S. R. Murty, Progress in Graph Theory, Academic Press Canada, pp. 43-69, 1984. C. Thomassen, Plane cubic graphs with prescribed face areas, Combinatorics, Probability and Computing, 1, pp. 371-381, 1992. P. Ungar, On diagrams representing maps, J. London Math. Soc., 28, pp. 336-342, 1953.
Extended Rectangular Drawings of Plane Graphs with Designated Corners (Extended Abstract) Kazuyuki Miura, Ayako Miyazawa, and Takao Nishizeki Graduate School of Information Sciences Tohoku University, Sendai 980-8579, Japan {miura,miyazawa}@nishizeki.ecei.tohoku.ac.jp [email protected]
Abstract. In a rectangular drawing of a plane graph, each edge is drawn as a horizontal or vertical line segment, and all faces including the outer face are drawn as rectangles. In this paper, we introduce an “extended rectangular drawing” in which all inner faces are drawn as rectangles but the outer face is drawn as a rectilinear polygon with designated corners, and give a necessary and sufficient condition for a plane graph to have an extended rectangular drawing.
1
Introduction
Automatic drawing of graphs has recently created intense interest due to their broad applications in VLSI floorplanning, computer network, software design etc. [BETT99,BS88,GT97,L90,RNN02,RNN98]. In this paper, we introduce an “extended rectangular drawing” of a plane graph, which is a generalization of a “rectangluar drawing,” and obtain a characterization of plane graphs having extended rectangular drawings. In a rectangular drawing of a plane graph G, each edge is drawn as a horizontal or vertical line segment, and all faces including the outer face are drawn as rectangles, as illustrated in Fig. 1(a). Rectangular drawings have applications in VLSI floorplanning. The outer boundary of a VLSI chip is not always a rectangle but is often a rectilinear polygon of L-, T-, and X-shape, and hence it is desired to find a floorplan of a VLSI chip where each “module” is assigned a rectangular space inside a rectilinear polygon [KK84,L90]. VLSI floorplans with outer boundary of L-, T-, and X-shape are illustrated in Fig. 1. Each vertex which we wish to draw as a “convex corner” of the outer face is drawn by a white circle in Fig. 1, each vertex which we wish to draw as a “concave corner” is drawn by a white circle with ×, each of the other vertices on the outer face is drawn by a black circle, and all vertices not on the outer face are drawn by gray circles. We call a drawing an extended rectangular drawing (with designated corners) if all inner faces are drawn as rectangles and the outer face is drawn as such a rectilinear polygon with designated corners. The maximum degree of a graph G is denoted by ∆. Thomassen obtained a necessary and sufficient condition for M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 256–267, 2002. c Springer-Verlag Berlin Heidelberg 2002
Extended Rectangular Drawings of Plane Graphs with Designated Corners
(a) Rectangular outer face
(c) T-type outer face
257
(b) L-type outer face
(d) X-type outer face R (convex corner) S (non-corner) L (concave corner) inner vertex
Fig. 1. Extended rectangular drawings.
the existence of a rectangular drawing of a plane graph G with ∆ ≤ 3 [T84], and linear-time algorithms were obtained for finding a rectangular drawing of G [BS88,H93,KH97,KK84,RNN98,RNN02]. However, for a general plane graph G which does not necessarily satisfy ∆ ≤ 3, a necessary and sufficient condition has not been known for the existence of a rectangular drawing or an extended rectangular drawing. Of course, ∆ ≤ 4 if G has a rectangular drawing or an extended rectangular drawing. As a main theorem of the paper, we give a necessary and sufficient condition for a plane graph to have an extended rectangular drawing. It immediately yields a necessary and sufficient condition for a plane graph of ∆ ≤ 4 to have an ordinary rectangular drawing. Thomassen’s condition [T84] can be immediately obtained from our main theorem as a corollary. The necessity of our condition is trivial, while the sufficiency is not. Our constructive proof of the sufficiency is outlined as follows. Let G be a plane graph satisfying our condition. We choose an appropriate inner face F of G called a “corner face,” and draw F as a rectangle as illustrated in Figs. 2(a) and (b). Let G∗ = G − F be a graph obtained from G by “trimming off” the face F , then G∗ satisfies our condition. We now choose a corner face of G∗ , and draw the face as a rectangle. Repeating the operation, we eventually obtain an extended rectangular drawing of the whole graph G.
258
Kazuyuki Miura, Ayako Miyazawa, and Takao Nishizeki
-
G*= G F
G
fc F
F (a)
(b)
F F
(c)
(d)
. . .
G
F (f)
(e)
R
S
L
Fig. 2. The outline for a proof of the sufficiency of our main Theorem.
The remainder of the paper is organized as follows. In Section 2, we give some definitions and lemmas. In Section 3, we give a necessary and sufficient condition for a plane graph to have an extended rectangular drawing. Finally we conclude in Section 4.
2
Preliminaries
In this section we give some definitions and lemmas. Let G be a simple connected undirected graph having no multiple edge or loop. The degree of a vertex v in G is the number of neighbors of v in G, and is denoted by d(v). We call a vertex of G a cut vertex if its removal results in a disconnected graph. A graph G is biconnected if G has no cut vertex. A plane graph G is a graph embedded in the plane so that no two edges intersect geometrically except at a vertex to which they are both incident. In this paper, we assume that a plane embedding of G is fixed. If a plane graph G has a rectangular drawing or an extended rectangular drawing, then clearly G is biconnected and ∆ ≤ 4. We thus assume that G is a plane biconnected graph with ∆ ≤ 4. G divides the plane into connected regions called faces. The contour of a face is a cycle of G, and is often called simply a face. We denote the outer face of G by Fo . A vertex and an edge of Fo is called an outer vertex and an outer edge, respectively. A vertex and an edge not on Fo is called an inner vertex and an inner edge, respectively.
Extended Rectangular Drawings of Plane Graphs with Designated Corners
259
A drawing D(G) of G is called an extended rectangular drawing of a plane graph G if (a) each vertex of G is drawn as a point in D(G); (b) each edge of G is drawn as a horizontal or vertical line segment in D(G); (c) each inner face of G is drawn as a rectangle in D(G); and (d) the outer face of G is drawn as a rectilinear polygon in D(G). In an extended rectangular drawing D(G), each cycle C of G is drawn as a rectilinear polygon, which is denoted by D(C). A vertex of polygon D(C) is a vertex of graph G, and is called a corner of a cycle C. The inner angle of a corner is either π/2 or 3π/2. A corner of inner angle π/2 is called a convex corner of a cycle C, while a corner of inner angle 3π/2 is called a concave corner of C. A vertex v of C is called a non-corner of C if v is not a vertex of polygon D(C). In this paper, we assume that a rectilinear polygonal drawing D(Fo ) of the outer face Fo is roughly given: each outer vertex is designated as a convex corner, a concave corner, or a non-corner of Fo . A vertex designated as a convex corner of Fo is called an R-vertex of Fo , a vertex designated as a concave corner is called an L-vertex of Fo , and a vertex designated as a non-corner is called an S-vertex of Fo . (See Fig. 3(a).) If we turn around Fo clockwise, then we turn right at an R-vertex, turn left at an L-vertex, and go straight through an S-vertex. An extended rectangular drawing D(G) is called an extended rectangular drawing with designated corners if all R-vertices of Fo are drawn as convex corners of Fo , all L-vertices as concave corners, and all S-vertices as non-corners, as illustrated in Fig. 3(b). In this paper, we give a necessary and sufficient condition for a plane graph G to have an extended rectangular drawing with designated corners. Thomassen gave a necessary and sufficient condition for a plane graph of ∆ ≤ 3 to have a rectangular drawing [T84]. His condition corresponds to our condition for the special case where exactly four of the outer vertices are designated as R-vertices and all the other outer vertices are designated as S-vertices as illustrated in Fig. 1(a). Therefore his condition can be immediately derived from our condition. The drawings in Figs. 1(a) and (b) are an rectangular drawing and an extended rectangular drawing of the same graph. Thus the same graph may have various extended rectangular drawings. On the other hand, the plane graph in Fig. 3(a) has an extended rectangular drawing in Fig. 3(b), but has no rectangular drawing because there is an outer vertex of degree four. An extended rectangular drawing D(G) satisfies the following four Conditions (i)–(iii) for any outer vertex v of Fo : (i) if d(v) = 2, then v is a convex corner or a non-corner of Fo ; (ii) if d(v) = 3, then v is a concave corner or a non-corner of Fo ; and (iii) if d(v) = 4, then v is a concave corner of Fo . We may thus assume without loss of generality that each outer vertex v of G is designated as follows:
260
Kazuyuki Miura, Ayako Miyazawa, and Takao Nishizeki
R
S L
(a) A plane graph with designated outer corners
(b) An extended rectangular drawing
Fig. 3. An extended rectangular drawing.
(O-1) if d(v) = 2, then v is either an R-vertex or an S-vertex of Fo ; (O-2) if d(v) = 3, then v is either an L-vertex or an S-vertex of Fo ; and (O-3) if d(v) = 4, then v is an L-vertex of Fo . According to the designation of outer vertices, a labeling λ of graph G is defined as follows. [Definition 1] A labeling λ of G assigns R, S, L, R′ or L′ as a label λ(C, v) to each pair of a cycle C of G and a vertex v of C, as follows. Case 1: both of the two edges e1 and e2 of C incident to v are outer edges. (See Fig. 4.) Let λ(C, v) be the same as the designation of v for Fo : R if v is designated as an R-vertex of Fo ; λ(C, v) = S if v is designated as an S-vertex of Fo ; L if v is designated as an L-vertex of Fo .
In Fig. 4 a label λ(C, v) is written in cycle C; v is designated as an R-vertex of Fo in Fig. 4(a), as an S-vertex in Fig. 4(b), and as an L-vertex in Fig. 4(c). Case 2: both e1 and e2 are inner edges, and d(v) = 2. (See Fig. 5.) In this case, v is an inner vertex. Let λ(C, v) = S. (That is, e1 and e2 must be drawn on the same straight line.) Case 3: both e1 and e2 are inner edges, and d(v) = 3. (See Fig. 6.) In this case, v is an inner vertex. Let e3 be the edge incident to v other than e1 and e2 , then λ(C, v) is defined as follows: ′ R if e3 is outside C; λ(C, v) = L′ if e3 is inside C. Label R′ means that v must be either a convex corner or a non-corner of C as illustrated in Figs. 6(a) and (b). Label L′ means that v must be either a concave corner or a non-corner of C as illustrated in Figs. 6(c) and (d).
Extended Rectangular Drawings of Plane Graphs with Designated Corners
261
e2 e1
e1 v
v
R e2
(a) A convex corner v of C and Fo
e1
S
C
Fo
v
e2
C
L
e3
C
Fo
Fo (b) A non-corner v of C and Fo
(c) A concave corner v of C and Fo
Fig. 4. Illustration for Case 1.
e1 v
e2 S
C
Fo
Fig. 5. Illustration for Case 2.
Case 4: exactly one of e1 and e2 is an outer edge, and d(v) = 3. (See Fig. 7.) In this case, v is an outer vertex, and the edge e3 incident to v other than e1 and e2 is an outer edge. By Condition (O-2), v is either an S-vertex or an L-vertex of Fo . Label λ(C, v) is defined as follows: R if v is an S-vertex of Fo ; λ(C, v) = R′ if v is an L-vertex of Fo . Case 5: d(v) = 4. (See Fig. 8.) Let e3 and e4 be the edges incident to v other than e1 and e2 , then λ(C, v) is defined as follows: R if both e3 and e4 are outside C; λ(C, v) = S if exactly one of e3 and e4 is outside C; L if both e3 and e4 are inside C. ✷
Clearly the following lemma holds. Lemma 1. If G has an extended rectangular drawing with designated corners, then the following (a)–(e) holds for any cycle C of G and any vertex v of C:
262
Kazuyuki Miura, Ayako Miyazawa, and Takao Nishizeki
e1 v e3 R' e2
v
v
e3
L' e3
C
C
Fo (a)A convex corner v of C
v e 2
e1
e1 L' e3
e1 R' e2
C
e2
C Fo (c) A concave corner v of C
Fo (b) A non-corner v of C
Fo (d) A non-corner v of C
Fig. 6. Illustration for Case 3. e3 e1
e1 v e3 R e 2
R'
e3 v
v
e1
e2
C
C
Fo (a) A convex corner v of C
Fo (b) A convex corner v of C
R' e2
C
Fo (c) A non-corner v of C
Fig. 7. Illustration for Case 4.
(a) (b) (c) (d) (e)
if λ(C, v) = R, then v is a convex corner of C. if λ(C, v) = S, then v is a non-corner of C. if λ(C, v) = L, then v is a concave corner of C. if λ(C, v) = R′ , then v is either a convex corner or a non-corner of C. if λ(C, v) = L′ , then v is either a concave corner or a non-corner of C.
According to λ(C, v) = R, S, L, R′ and L′ , we call v an R-, S-, L-, R′ - and L -vertex of cycle C, respectively. Let nR (C) be the number of R-vertices of cycle C. Define nL (C), nR′ (C) and nL′ (C) similarly. One can easily know from Definition 1 that the following lemma hold. ′
Lemma 2. (a) nR′ (Fo ) = nL′ (Fo ) = 0 for the outer face Fo of G. (b) nL (F ) = nL′ (F ) = 0 for any inner face F of G. (c) If v is an inner vertex and λ(C, v) = R or L for a cycle C, then d(v) = 4.
3
Extended Rectangular Drawing
In this section, we prove the following main theorem. Theorem 1. A plane biconnected graph G has an extended rectangular drawing with designated corners if and only if each cycle C of G satisfies nR (C) − (nL (C) + nL′ (C)) ≤ 4
(1)
Extended Rectangular Drawings of Plane Graphs with Designated Corners
e4 v e1 e3 R e2
e4
e1
S
C
e2 e1 v e3 L e4
v e2
e3
C
C
Fo (a) A convex corner v of C
Fo (b) A non-corner v of C
263
Fo (c) A concave corner v of C
Fig. 8. Illustration for Case 5.
and (nR (C) + nR′ (C)) − nL (C) ≥ 4.
(2)
One can derive Thomassen’s condition as a corollary of Theorem 1. Although Corollary 1 below is slightly different from the presentation of Thomassen’s condition [T84, Theorem 7.1], they are effectively equivalent with each other. Corollary 1. Let G be a plane biconnected graph of ∆ ≤ 3. Assume that exactly four of the outer vertices of degree two are designated as R-vertices of Fo , and all the other outer vertices are designated as S-vertices of Fo , as illustrated in Fig. 1(a). Then G has an extended rectangular drawing with designated corners, that is, a rectangular drawing if and only if each cycle C of G satisfies nR (C) + nR′ (C) ≥ 4. Proof. Omitted in this extended abstract due to the page limitation.
(3) ✷
Before giving a proof of Theorem 1, we present some definitions and lemmas. A labeling ψC of a cycle C assigns a label R, S, or L to each vertex v of C. We say that ψC is consistent with the labeling λ of G if R if λ(C, v) = R; if λ(C, v) = S; S if λ(C, v) = L; ψC (v) = L R or S if λ(C, v) = R′ ; L or S if λ(C, v) = L′ .
We call a labeling of C consistent with λ simply a consistent labeling of C. We denote by nR (ψC ) the number of vertices v of C such that ψC (v) = R, and denote by nL (ψC ) the number of vertices v of C such that ψC (v) = L. If ψC is a consistent labeling of C, then nR (C) ≤ nR (ψC ) ≤ nR (C) + nR′ (C)
(4)
nL (C) ≤ nL (ψC ) ≤ nL (C) + nL′ (C).
(5)
and We then immediately have the following lemma.
264
Kazuyuki Miura, Ayako Miyazawa, and Takao Nishizeki
Lemma 3. If a plane graph G has an extended rectangular drawing D(G) with designated corners, then each cycle C of G has a consistent labeling ψC such that nR (ψC ) − nL (ψC ) = 4. (6) We are now ready to give a proof of the necessity of Theorem 1, which is rather trivial. Proof of the necessity of Theorem 1 Assume that G has an extended rectangular drawing D(G) with designated corners. By Lemma 3, each cycle C of G has a consistent labeling ψC such that nR (ψC ) − nL (ψC ) = 4. Since ψC is a consistent labeling, by Eqs. (4) and (5) we have that nR (C) ≤ nR (ψC ) and nL (ψC ) ≤ nL (C) + nL′ (C). We thus have nR (C) − (nL (C) + nL′ (C)) ≤ nR (ψC ) − nL (ψC ) = 4, and hence C satisfies Eq. (1). Similarly one can show that C satisfies Eq. (2). ✷ In the remainder of this section, we give a proof for the sufficiency of Theorem 1. The proof of the sufficiency is outlined as follows. First, we choose an appropriate inner face F called a “corner face,” as illustrated in Fig. 2(a). Next, we draw F as a rectangle, and let G∗ = G − F be a graph obtained from G by “trimming off” the face F from G as illustrated in Fig. 2(b). As shown in Lemma 5 later, every cycle of G∗ satisfies Eqs. (1) and (2). Repeating this operation, we can eventually obtain an extended rectangular drawing of G with designated corners. Before giving a proof of the sufficiency, we present some definitions and lemmas. Let F be an inner face of G containing an outer edge. Delete from G all the outer edges on F , and then delete all resulting isolated vertices. The resulting graph is denoted by G∗ = G − F . We call an inner face F of G a corner face if F satisfies the following four Conditions (a)–(d): (a) at least one vertex of F is designated as an R-vertex of Fo . (Hence, the vertex is an outer vertex, and has degree two.) (b) 2 ≤ nR (F ) ≤ 4. (Hence, F has two, three, or four R-vertices.) (c) at least two of the R-vertices of F are outer vertices. (Two of the R-vertices of F are outer vertices in Fig. 9(a), three are outer vertices in Fig. 9(b), and four are outer vertices in Fig. 9(c).) (d) G∗ = G − F is biconnected. We have the following lemma. Lemma 4. If each cycle C of a plane biconnected graph G satisfies Eqs. (1) and (2), then G has a corner face. Proof. Omitted in this extended abstract due to the page limitation.
✷
Extended Rectangular Drawings of Plane Graphs with Designated Corners
265
G* G*
R
G*
F
R
R F
R R Puv u' v u (a) Two outer R-vertices of F
F
R R Puv u v u' (b) Three outer R-vertices of F
R R u v=u' Puv (c) Four outer R-vertices of F
Fig. 9. Illustration for a corner face F .
If G has an extended rectangular drawing with designated corners, then by Lemma 3 each cycle C has a consistent labeling ψC such that nR (ψC )−nL (ψC ) = 4. We say that such a labeling ψC is rectangular if nR (ψC ) = 4 and nL (ψC ) = 0. We then have the following lemma. Lemma 5. If each cycle of G satisfies Eqs. (1) and (2), then any inner face F has a consistent rectangular labeling ψF . Proof. Omitted in this extended abstract due to the page limitation.
✷
Let F be a corner face of F . Then, by Condition (d) of a corner face, G∗ = G − F is biconnected and hence the intersection of G∗ and F is a single path P ∗ of G, which is called the partitioning path of F . In Fig. 10, P ∗ is drawn by thick lines. Clearly, the ends of P ∗ are outer vertices and have degree three or four. All vertices of P ∗ other than the ends are inner vertices of G. Since F is an inner face of G, by Lemma 5 F has a consistent rectangular labeling ψF . We then decide the rough shape of the outer face Fo∗ of G∗ according to ψF : we designate each outer vertex v of G∗ as a convex corner, a concave corner, or a non-corner, as follows. (See Fig. 10.)
L R v R
S
L P*
F
G* S
S
R S v
P*
G* S
S
G*
P* F R
R (b)
L
S
v R
S
F
R (a)
L
(c)
Fig. 10. Illustration for the designation of outer vertices of G∗ .
[Definition 2] (Designation of outer vertices of G∗ ) Case 1: v is not on P ∗ . In this case, v is an outer vertex of G. We designate v as an R-, S-, and L-vertex of Fo∗ if v was designated as an R-, S- and L-vertex of Fo , respectively. Case 2: v is a vertex of P ∗ other than its ends.
266
Kazuyuki Miura, Ayako Miyazawa, and Takao Nishizeki
Since ψF is rectangular, ψF (v) is either S or R. If ψF (v) = S then we designate v as an S-vertex of Fo∗ , while if ψF (v) = R then we designate v as an L-vertex of Fo∗ . Case 3: v is an end of P ∗ . In this case, v has degree three or four, and hence by Condition (O-2) v is either an S-vertex of Fo or an L-vertex of Fo . Consider first the case where v is an S-vertex of Fo as illustrated in Fig. 10(a). In this case, v has degree three, and hence by Case 4 of Definition 1, we have λ(F, v) = R. Since ψF is consistent with λ, ψF (v) = λ(F, v) = R. Thus the vertex v of polygon D(Fo∗ ) must have an inner angle π − π/2, and hence we designate v as an R-vertex of Fo∗ . Consider next the case where v is an L-vertex of Fo as illustrated in Figs. 10(b) and (c). Since ψF is rectangular, either ψF (v) = S or ψF (v) = R. If ψF (v) = S as illustrated in Fig. 10(b), then we designate v as an R-vertex of Fo∗ . If ψF (v) = R as illustrated in Fig. 10(c), then we designate v as an S-vertex of Fo∗ . ✷ One can easily observe that the designation of the outer vertices of G∗ above satisfies Conditions (O-1)–(O-3). We have the following lemma. Lemma 6. If every cycle of G satisfies Eqs. (1) and (2), then any corner face F of G has a consistent rectangular labeling such that each cycle of G∗ = G − F satisfies Eqs. (1) and (2). Proof. Omitted in this extended abstract due to the page limitation.
✷
We are now ready to give a proof of the sufficiency of Theorem 1. Proof of the sufficiency of Theorem 1 We prove, by induction of the number i of inner faces of G, the proposition that if every cycle of G satisfies Eqs. (1) and (2) then G has an extended rectangular drawing with designated corners. If i = 1, then G = Fo and by Lemma 2 and Eqs. (1) and (2), nR (Fo ) = 4 and nL (Fo ) = 0, and hence G can be drawn as a rectangle having the four Rvertices of Fo as the convex corners. The drawing of G is an extended rectangular drawing with designated corners. The proposition thus holds for i = 1. Assume inductively that i ≥ 2 and the proposition holds for any plane graph of less than i inner faces. We shall prove that the proposition holds for a plane graph G of exactly i inner faces. By Lemma 4 G has a corner face F , and by Lemma 6 F has a consistent rectangular labeling ψF for which each cycle of G∗ = G − F satisfies Eqs. (1) and (2). Since ψF is rectangular, F can be drawn as a rectangle D(F ) having the four R-vertices of ψF as convex corners. Since the number of inner faces of G∗ is equal to i − 1, by the inductive assumption G∗ has an extended rectangular drawing D(G∗ ) with designated corners. The designation of outer vertices of G∗ in Definition 2 implies that one can combine the drawings D(F ) and D(G∗ ) to an extended rectangular drawing of G with designated corners. ✷
Extended Rectangular Drawings of Plane Graphs with Designated Corners
4
267
Conclusion
In this paper, we gave in Theorem 1 a necessary and sufficient condition for a plane graph to have an extended rectangular drawing with designated corners. It immediately yields a necessary and sufficient condition for a plane graph of ∆ ≤ 4 to have an ordinary rectangular drawing. Thomassen’s condition for a plane graph of ∆ ≤ 3 to have a rectangular drawing can be easily derived from our condition as in Corollary 1. It is remaining to obtain an efficient algorithm to find an extended rectangular drawing with designated corners.
References BETT99. BS88. GT97.
H93. H99. KH97.
KK84.
L90. RNN02.
RNN98. T84.
G. Di Battista, P. Eades, R. Tamassia and I. G. Tollis, Graph Drawing, Prentice Hall, NJ (1999). J. Bhasker and S. Sahni, A linear algorithm to find a rectangular dual of a planar triangulated graph, Algorithmica, 3, pp.247-278, 1988. A. Garg and R. Tamassia, A new minimum cost flow algorithm with applications to graph drawing, Proc. of Graph Drawing’96, Lect. Notes in Computer Science, 1190, pp. 201-206, 1997. X. He, On finding the rectangular duals of planar triangulated graphs, SIAM J. Comput., 22, 6, pp. 1218-1226, 1993. X. He, On floor-plan of plane graphs, SIAM J. Comput., 28, 6, pp. 21502167, 1999. G. Kant and X. He, Regular edge-labeling of 4-connected plane graphs and its applications in graph drawing problems, Theoret. Comput. Sci., 172, pp. 175-193, 1997. K. Kozminski and E. Kinnen, An algorithm for finding a rectangular dual of a planar graph for use in area planning for VLSI integrated circuits, Proc. of 21st DAC, Albuquerque, pp. 655-656, 1984. T. Lengauer, Combinatorial Algorithms for Integrated Circuit Layout, Wiley, Chichester, 1990. M. S. Rahman, S. Nakano and T. Nishizeki, Rectangular drawings of plane graphs without designated corners, Computational Geometry, 21, pp. 121138, 2002. M. S. Rahman, S. Nakano and T. Nishizeki, Rectangular grid drawings of plane graphs, Comp. Geom. Theo. Appl., 10(3), pp. 203-220, 1998. C. Thomassen, Plane representations of graphs, J. A. Bondy, U. S. R. Murty (Eds.), Progress in Graph Theory, Academic Press Canada, Don Mills, Ontario, Canada, pp. 43–69, 1984.
RINGS: A Technique for Visualizing Large Hierarchies Soon Tee Teoh and Kwan-Liu Ma Computer Science Department, University of California, Davis {teoh, ma}@cs.ucdavis.edu
Abstract. We present RINGS, a technique for visualizing large trees. We introduce a new ringed circular layout of nodes to make more efficient use of limited display space. RINGS provides the user with the means to specify areas of primary and secondary focus, and is able to show multiple foci without compromising understanding of the graph. The strength of RINGS is its ability to show more area in focus and more contextual information than existing techniques. We demonstrate the effectiveness of RINGS by applying it to the visualization of a Unix file directory.
1
Introduction
Ringed Interactive-Navigation Graph System (RINGS) is a technique for visualizing large hierarchical data, as well as large graphs if a spanning tree of the graph is provided as input. RINGS is based on a new ringed circular tree layout algorithm described in more detail in Section 2. Existing methods such as [3,5,7] tend to leave large regions of space empty. Shneiderman’s Tree-maps [8] method makes efficient use of screen space to show a large number of nodes, but in the Tree-map layout, the structural information of the trees is unclear. Three-dimensional visualization methods such as Munzner’s hyperbolic tree [5] and Kleiberg’s botanical tree [2] can be used to navigate through very large graphs and trees, respectively. However, overlapping of edges due to projecting a three-dimensional graph onto a two-dimensional space can lead to occlusion and ambiguity, limiting their effectiveness. The main advantage of the ringed circular method is its efficient use of limited display size by showing more distinguishable nodes at one time, without any of the other methods’ shortcomings listed above. Another important feature of RINGS is its capability to show more contextual information without compromising the clarity of the area in focus. Besides providing interactive navigation and focus+context solutions common in many existing systems, RINGS can also show areas in secondary focus effectively. We also describe how RINGS handles the problem of edge crossing and occlusion. Graphs are often used to display embedded information. RINGS is conducive for this purpose. In Section 5, we demonstrate how RINGS can be used to visualize file sizes, locate specific files and types of files in a directory, and reveal other aspects of the file directory structure. M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 268–275, 2002. c Springer-Verlag Berlin Heidelberg 2002
RINGS: A Technique for Visualizing Large Hierarchies
2
269
Layout Algorithm
Recent graph-drawing algorithms such as Kreuseler et al.’s tree on a hemisphere [3] and Munzner’s hyperbolic tree [5] provide good navigation and focus+context solutions, but they are often less effective in using the available screen space. With a 512×512 display, typically less than 100 nodes and edges are distinguisable at one time while the rest of the graph appears clumped together. In RINGS, we make better use of the available screen space, showing more distinguishable edges and also more structural information in context. In RINGS, a node and all its children are placed in a circle. In this way, the branch any node belongs to is easily identified. Representing each node by a circle has been described in [1,4,6]; however, they place children only on the circumference of the parent circle, wasting empty space in the interior. In the new ringed layout used by RINGS, equal-sized circles corresponding to children are placed in concentric rings around the center of the parent circle (see Figure 1).
Fig. 1. Ringed circular layout of nodes: The four green circles represent the four largest children of the parent node, represented by the large blue circle. The small yellow inner circle is the area left for the remaining children.
Connecting the centers of n equal circles placed in a ring makes an n-sided regular polygon. In Figure 1, θ = π/n , where n is the number of circles in a ring, and θ is in radians. A simple relationship can be derived between the number of children circles in the outermost ring and the percentage of area taken up by the ring. f(n), the fraction of the area left after n circles have been placed in the ring is given by: f (n) =
(1 − sin( nπ ))2 (R2 )2 (1 − sin(θ))2 . = = 2 2 (R1 ) (1 + sin(θ)) (1 + sin( nπ ))2
(1)
This relationship is used to determine the number of children to be placed in each concentric ring. The algorithm first sorts the children by their number of
270
Soon Tee Teoh and Kwan-Liu Ma
Fig. 2. Each node is placed at the center of its circle, and edges are drawn between each pair of connected nodes. Edges are colored according to their distance from the root. Level 1 edges are those directly connected to the root.
children. Next, the algorithm finds the smallest k for which the sum of the number of children of the first k children expressed as a fraction of the total number of grandchildren is greater or equal to f(k). The first k children are placed in the outermost ring. The rest of the children are placed in the same way in the inner rings. A node is positioned in the center of its circle. Edges are drawn as straight lines connecting nodes, as shown in Figure 2. The child labelled C itself has 35 children, and one of those children has descendents, whose circles are outlined in the figure. By placing the largest children in the outermost ring, the number of children in the outer rings is minimized, thereby minimizing the amount of occlusion due to edges drawn from the parent to the children.
3
Interactive Navigation
Like other graph visualization systems, RINGS allows the user to interactively explore the large data. The primary focus is changed by clicking on the child to focus on. The child will be moved to the center and the parent moved to the side as a smooth animation. Figure 3 demonstrates change of focus performed on a 20,000-node Unix file directory. The child in focus becomes the pictorial root because of its central position, and its true parent becomes a pictorial child, since it is placed in a circle on a ring just as any child is. Secondary foci is set by clicking on a child to focus on and dragging it to another child currently occupying a larger area. The positions of the two children are swapped, again with smooth animation (see Figure 4). In addition, the user can reduce the number of children in the outermost ring so that the secondary focus can be enhanced, also shown in Figure 4. The ability to effectively show secondary foci is generally not found in existing methods.
RINGS: A Technique for Visualizing Large Hierarchies
271
Fig. 3. Primary focus is changed by moving a child to the center. The circled child in the left drawing is expanded to the center in the right drawing, while the rest of the graph is moved to the circle in the right drawing. The edge from the focus to its true parent is colored black to distinguish it from the other edges. RINGS smoothly animates these changes.
Fig. 4. Secondary focus is changed by swapping two children. In this example, the user wants to increase the focus on the circled child in the left picture. It is swapped with the selected child at the bottom, resulting in the center picture. To further increase the secondary focus, the user can reduce the number of children in the outermost ring, giving each child more screen space. The number of children is reduced from eleven in the center to five in the right picture.
4
Other Features
Nodes at larger topological distances from the pictorial root occupy very little screen area, so they may become indistiguisable from neighboring nodes. Many edges far away from the foci map to the same pixels on the screen. Figure 5 shows how RINGS provides the option of expanding those nodes out of the confines of their circle. This additional contextual information gives the user a sense of the depth and topology of particular branches without compromising the clarity of the regions in focus.
272
Soon Tee Teoh and Kwan-Liu Ma
Fig. 5. The drawing on the right shows circles at topological distance 4 from the root expanded 200 times. A better sense of topology is gained without losing focus. The depth of certain sub-directories under “research” and “linux home” is revealed.
Fig. 6. Rotation: Occlusion of particular nodes can be eliminated by rotating adjacent rings in opposite directions.
A simple way to improve topology perception is to use different colors for edges with different topological distances from the root. In the color map (shown in Figure 2) used in our examples, darker, more saturated colors are used for edges closer to the root to highlight them. With the RINGS layout, occluded edges are topologically further away from the focus, so they are relatively unimportant. Nevertheless, to overcome the inevitable occlusion, edges are drawn as semi-transparent lines. In addition, RINGS allows the user to rotate adjacent concentric rings in opposite directions (see figure 6) to reveal a particular occluded branch. When visualizing very large graphs, it becomes computationally very expensive to traverse every node in the graph and render individual edges. To maintain
RINGS: A Technique for Visualizing Large Hierarchies
273
navigation at interactive rate, RINGS first creates texture maps of each branch. During interactive navigation of the graph, branches are rendered as texturemapped polygons whereever possible. In this way, even very large trees can be rendered at interactive rates.
5
Visualizing Information Beyond Topology
Figure 7 shows the application of RINGS to the visualization of a Unix file directory. Edges in the graph are colored according to the size of the file or directory. The two pictures show how varying the color map can be used to explore the data.
Fig. 7. Visualizing a Unix directory: In the left picture, the colormap value 1.0 is clipped at 0.1 of the total size of all files in the directory. In the right picture, it is clipped at 0.01.
Other information in the data can also be visualized. Figure 8 shows the result of searching for a file “texture.tga”. The entire path to the file is highlighted in red. In this picture, the user can see the location of the file in relation to the whole directory. The branch and sub-branches the file belongs to are also revealed. Figure 8 highlights all the files in the directory tree with “.cpp”, “.cc”, “.c” or “.h” extensions. This identifies all the sub-directories containing those C++ source files. Examining individual sub-directories of Figure 8 gives insight into their internal structure. Examples of interpreting the visualization are explained in Figure 9. By visualizing typical ringed circular graphs, we can classify the patterns observed (see Figure 10). Understanding this classification aids the gaining of insights into the visualization.
6
Conclusion
We have presented a new ringed circular layout algorithm to visualize large graphs. The main contribution of RINGS is its efficient use of limited display
274
Soon Tee Teoh and Kwan-Liu Ma
Fig. 8. Left: Visualizing the location of a particular file with respect to its neighbors, the branch it belongs to, and the entire directory tree. Right: Highlighting all C++ source files and the directories containing them.
Fig. 9. Interpretation of sub-directories from Figure 8: Sub-directory “240” has 6 subdirectories, 5 of which have a very similar structure. The arrowed one is the exception. “278” has many more sub-directories than “240” and some of them are similar, for example those labelled “A” and “B”. “code” has children which are leaves (files). “277” has children of different sizes. 5 of the largest children are similar, but the child labelled “C” is slightly different in the composition of C++ source files and the child labelled “D” is topologically different from the rest.
space by showing more distinguishable nodes at one time. Other important features of RINGS include showing more contextual information without compromising the clarity of the area in focus, and showing areas in secondary focus. We have demonstrated the effectiveness of RINGS in visualizing specific information embedded in a Unix file directory. RINGS is able to highlight subdirectories with large files and/or large number of files. RINGS is also able to locate specific files and show where they are in relation to the rest of the directory. RINGS is a general graph visualization technique, not limited to the visualization of directory trees. In the future, we plan to apply the technique to the visualization of a variety of hierarchical data, as well as general graphs with spanning trees.
RINGS: A Technique for Visualizing Large Hierarchies
275
Fig. 10. Classification of basic patterns: A) A Solid circle indicates that this node has numerous children of similar size. B) A pattern of radiating lines indicates that the children are leaves. C) Radial lines with large end-points indicate that children are not leaves. D) Many overlapping circles and lines in the expanded view indicate that this node has many very deep descendents. In practice, most nodes in a graph exhibit mixed patterns. However, this simple classification allows intuitive interpretation.
References 1. E.H. Chi and S.K. Card. Sensemaking of Evolving Web Sites Using Visualization Spreadsheets. Proceedings of the Symposium on Information Visualization (InfoViz’99), pp. 18–25, 142. IEEE Press, 1999. 2. E. Kleiberg, H. van de Wetering and J.J. van Wijk. Botanical Visualization of Huge Hierarchies. Proceedings of the Symposium on Information Visualization (InfoViz’01), pp. 87–94. IEEE Press, 2001. 3. M. Kreuseler, N. Lopez and H. Schumann. A Scalable Framework for Information Visualization. Proceedings of the Symposium on Information Visualization (InfoViz’00), pp. 27–36. IEEE Press, 2000. 4. G. Melancon and I. Herman. Circular Drawing of Rooted Trees. Reports of the Center for Mathematics and Computer Sciences, Report number INS-9817, available at: http://www.cwi.nl/InfoVisu/papers/circular.pdf, 1998. 5. T. Munzner. H3: Laying out Large Directed Graphs in 3D Hyperbolic Space. Proceedings of the IEEE Symposium on Information Visualization (InfoViz’97), IEEE CS Press, pp. 2–10, 1997. 6. G.G. Robertson, J.D. Mackinlay and S.K. Card. Cone Trees: Animated 3D Visualization of Hierarchical Information. Human Factors in Computing Systems, CHI’91 Conference Proceedings, ACM Press, pp. 189–194, 1991. 7. M. Sarkar and M.H. Brown. Graphical Fisheye View of Graphs. Human Factors in Computing Systems (CHI’92) Conference Proceedings, ACM Press, pp. 83–91, 1992. 8. B. Shneiderman. Tree Visualization with Tree-maps: A 2D space-filling approach. ACM Transactions on Graphics, 11(1):92–99, September 1990.
Applying Crossing Reduction Strategies to Layered Compound Graphs Michael Forster University of Passau, 94030 Passau, Germany [email protected]
Abstract. We present a new method for the application of 2-layer crossing reduction algorithms to layered compound graphs. It is based on an algorithm by Sander [9, 7, 8] and improves it with fewer crossings. Our method is optimal in the sense that it does not introduce unnecessary crossings by itself. If used with an optimal 2-layer crossing reduction algorithm, the crossing reduction for 2-layer compound graphs is optimal, too.
1
Introduction
Compound graphs are graphs with two sets of edges, adjacency edges and hierarchy edges. The hierarchy edges are interpreted as an inclusion relationship. They are also called “inclusion edges”. There are different notions of compound graphs. Some only restrict the hierarchy edges to be acyclic, others require them to form a tree. This paper uses the latter concept. There are many areas of application for compound graphs. The motivation for our research on the topic comes from the visualization of biochemical pathways. This is an interesting area of application for graph drawing. Parts of a reaction network take place in different regions of the cell, e. g., in the nucleus or in the cytoplasm. Moreover, there are situations where these regions are nested. This leads to clustered graphs, a special type of compound graphs, where adjacency edges are only allowed between leaves of the hierarchy tree. The usual way to draw compound graphs is as follows: compound nodes, i. e., nodes that contain other nodes are drawn as rectangles. The contained nodes – and only these – are drawn within the rectangle. There are some extensions of layout algorithms for planar graphs and of force directed algorithms to compound graphs. See [1] for an overview. Since we focus on directed compound graphs, we use a drawing style where the nodes are partitioned into layers. All nodes of one layer are drawn on a horizontal line. Edges are routed top down. This is similar to the layout style generated by the well-known algorithm of Sugiyama, Tagawa, and Toda for the layout of directed acyclic graphs, see Fig. 1.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 276–284, 2002. c Springer-Verlag Berlin Heidelberg 2002
Applying Crossing Reduction Strategies to Layered Compound Graphs
277
Fig. 1. A layered compound graph
2
Related Work
There are two variants of layered drawings of compound graphs: If using local layers, each node spans exactly one layer. The interior of compound nodes has its own interior layers that are independent of the exterior layers. The representative algorithm with local layers is an algorithm by Sugiyama and Misue [13]. With global layers, there is only one set of layers for all nodes. Compound nodes are allowed to span multiple layers. This is the drawing style used by Sander [9,7,8]. Drawings with local layers typically can be computed faster, while global layers give more compact drawings. Fig. 2 shows the same compound graph drawn with both variants. See [7, 8] for a more detailed comparison. For this paper, we will focus on a global layering scheme.
(a) Local layers
(b) Global layers
Fig. 2. Local vs. global layers
278
Michael Forster
An obvious approach for drawing directed compound graphs is to draw the interior and exterior of compound nodes independently of each other. First, the interior of the compound nodes at the lowest level of the hierarchy is drawn. Then the internal structure is hidden and the compound node is treated as a single big node. Instead of working the hierarchy bottom up, it is possible to start at the root of the hierarchy, first drawing the outside of the compound nodes and then inserting the contents recursively. For this variant, the layering of the graph must be computed as a preprocessing step, because the size of all compound nodes must be known before the top level layering can be done. No matter whether the hierarchy is traversed top down or bottom up, this strategy leads to unnecessary edge crossings, since parts of the layout are computed without considering the global connectivity of the graph. Fig. 3(a) shows a given compound graph, drawn without any edge crossings. Fig. 3(b) shows the graph after the first step of the algorithm. The top level of the hierarchy has been drawn, the interior of the compound node has been ignored. Up to now, we have no crossings, but the positions of the shown nodes hence are fixed. As a result, any order of the interior nodes will lead to an edge crossing, see Fig. 3(c). The other three images of Fig. 3 show a similar example for an unnecessary edge crossing, when traversing the hierarchy bottom up.
a
b
c
d
e
f
(a)
a
f (b)
b
e
a
b
c
d
f
e
(c)
a
b
a
b
a
b
c
d
d
c
d
c
(d)
(e)
(f)
Fig. 3. Unnecessary edge crossings when considering hierarchy levels separately
It is well known that crossing reduction is NP-hard already for ordinary graphs, even if they only consist of two layers [3]. Therefore we cannot expect an efficient optimal crossing reduction algorithm for compound graphs. But in this case, the crossings do not originate from the used crossing reduction method itself, they arise from the application of the crossing reduction method to the compound graph. This means, that even with an optimal 2-layer crossing reduction strategy for ordinary graphs, these crossings are unavoidable. Sander [9,7,8] uses a different approach. His algorithm works as the algorithm of Sugiyama, Tagawa, and Toda for the layout of directed acyclic graphs [13]. The hierarchical structure is considered only when it is necessary to prevent violations of the drawing conventions. Since Sander’s method is the base of our algorithm, we recall it in section 4, in direct comparison to our method.
Applying Crossing Reduction Strategies to Layered Compound Graphs
3
279
Notation
A (directed) graph G = (V, E) consists of nodes V and edges E ⊆ V × V . The direct predecessors and direct successors of a node v ∈ V are defined as predG (v) = { u ∈ V | (u, v) ∈ E } and succG (v) = { u ∈ V | (v, u) ∈ E }. The successors succ∗G (v) and predecessors pred∗G (v) of v are the respective reflexive transitive closures. A compound graph G = (V, E, H) consists of a graph (V, E) with adjacency edges E and an additional relation H ⊆ V ×V such that the graph T = (V, H) is a directed rooted tree with its edges oriented from the root towards the leaves. T is called the hierarchy tree of G, its edges are called hierarchy edges. The nodes of a compound graph G are partitioned into base nodes B = { v ∈ V | succT (v) = ∅ } and compound nodes C = V \B. G|B is called the base graph of G. A layered compound graph G = (V, E, H, L) is a compound graph (V, E, H) where each base node is assigned to a positive integer L : B → N. B is partitioned into disjoint layers B1 , . . . , Bn , where Bi = { v ∈ B | L(v) = i }. The minimum (maximum) layer Lmin (v) (Lmax (v)) of a node v ∈ V is defined as the minimum (maximum) layer number of the leaves reachable in the hierarchy tree. For a base node b ∈ B this results in Lmin (b) = Lmax (b) = L(b). The layer hierarchy tree Ti = (Vi , Hi ) for the i-th layer of an layered compound graph G = (V, E, H, L) is that part of the hierarchy tree that is relevant for the i-th layer, its nodes are Vi = { v ∈ V | Lmin (v) ≤ i ≤ Lmax (v) }. A (layered) clustered graph is a (layered) compound graph where edges are only allowed between the base nodes. A layered compound (or clustered) graph is said to be proper if every edge (u, v) ∈ E is directed downwards and spans exactly one layer, i. e., Lmin (v) = Lmax (u) + 1. This implies that there are no adjacency edges between a node and a predecessor or successor of it in the hierarchy tree. Any layered compound graph can be converted to a proper layered clustered graph by reversing edges and inserting dummy nodes, see Fig. 4 for an example.
(a) A layered compound graph
(b) Inserted dummy nodes
Fig. 4. Converting a layered compound graph to a proper layered clustered graph
280
4
Michael Forster
Crossing Reduction
Reducing the crossings in the drawing of a compound graph is a crucial step in the layout process. We assume that the given compound graph has already been layered and has been converted to a proper layered clustered graph by reversing some edges and inserting dummy nodes. This can be done as described in [7, 8]. The crossing reduction method for clustered graphs proposed by Sander is based on the crossing reduction step in the conventional Sugiyama algorithm for drawing directed acyclic graphs. It starts with a random order of the topmost layer. It then iteratively considers each layer from top to bottom and reorders the nodes on that layer such that the crossings between incoming edges are reduced. When the algorithm has reordered the last layer, it traverses the graph from bottom to top, reordering the layers so that crossings between outgoing edges are reduced. These two traversals are repeated until some termination criterion is met. Since the problem to minimize the crossings between two layers is NPhard, heuristics are used, e. g. the well-known barycenter heuristic, and there are others with varying quality and running times [2, 4, 5]. The main idea of our algorithm is a scheme, how any standard 2-layer crossing reduction method can be applied to proper layered clustered graphs. The main part of the crossing reduction step stays the same, but only base nodes are considered. The base graph is traversed top down and bottom up in the same way, considering the hierarchy only when doing the 2-layer crossing reduction. There are two new restrictions which must be satisfied when reducing crossings in clustered graphs as opposed to unclustered graphs. R1: The nodes on a layer that belong to the same compound node must be placed next to each other with no other nodes between them. R2: The relative position of two compound nodes must be the same on all layers, i. e., compound nodes must not “cross” each other. If any of these restrictions is violated, it is not possible to draw compound nodes as rectangles that contain exactly the respective subtree of the hierarchy, see Fig. 5 for examples. It is the strict enforcement of these extra restrictions that differentiates our method from that of Sander. In Sander’s method the hierarchy is ignored first,
(a) Violation of R1
(b) Violation of R2
Fig. 5. Violations of the order restrictions
Applying Crossing Reduction Strategies to Layered Compound Graphs
281
which leads to violations of the restrictions. These violations are resolved afterwards by sorting the compound nodes by the barycenter of the contained base nodes. Only the intermediate base node order is considered and the adjacency edges are ignored. It is easy to construct simple examples, where this strategy gives many unnecessary crossings, see Fig. 6. Our strategy is to consider the restrictions right from the start.
(a) before reordering
(b) after reordering
(c) optimal result
Fig. 6. Unnecessary crossings with Sander’s method
4.1
Respecting the Hierarchy on a Single Layer (R1)
Our method works by modifying the 2-layer crossing reduction step used as a subroutine in the global crossing reduction. We assume a layered clustered graph G = (V, E, H, L), with two layers B1 and B2 and compound nodes C, V = B1 ∪ B2 ∪ C, its hierarchy tree T = (V, H), and two layer hierarchy trees T1 , T2 . The order of B1 is fixed, B2 must be reordered. We consider the layer hierarchy tree of the bottom layer T2 and ignore R2 for now. We observe the following lemma: Lemma 1. An order of the base nodes complies with R1 if and only if there exists a child order of the layer hierarchy tree so that the order of the base nodes can be obtained by a preorder (postorder) traversal. Because of this observation we will concentrate on finding child orders for the layer hierarchy tree and from this obtain the order of the base nodes. The following lemma characterizes the relationship between edge crossings and the child order of some node in the layer hierarchy tree: Lemma 2. Let e1 = (s1 , t1 ), e2 = (s2 , t2 ) ∈ E be two adjacency edges in G, and let t be the lowest common ancestor of t1 and t2 in the layer hierarchy tree with two children t′1 and t′2 that are predecessors of t1 and t2 , respectively. The edges e1 and e2 cross if and only if t′1 and t′2 have a different relative order than s1 and s2 . Thus each possible edge crossing can be associated with a unique compound node in the layer hierarchy tree. Also each edge crossing is independent of the child orders of all other hierarchy tree nodes in T2 . The number of crossings in some order of the base nodes is the sum of the crossings associated to each layer hierarchy node. We get the following theorem:
282
Michael Forster
Theorem 1. An order of the base nodes has a minimal number of crossings if and only if the corresponding layer hierarchy tree has a minimal number of crossings at each node. By Theorem 1, it is justified to compute the child order of all compound nodes independently without losing quality. To minimize the number of crossings associated to a compound node h ∈ V2 we construct a new graph G′h called the crossing reduction graph of h. G′h consists of two layers. The upper layer B1 stays the same as in G, the lower layer B2′ consists of the children of h in T2 . The relevant adjacency edges of G are then transferred to G′h in the following manner: – Edges (s, t) ending in a node t that is not a successor of h in T2 are ignored. – For each remaining edge (s, t), an edge (s, c) with weight w(s, c) = 1 is created, where c is the unique child of h which is a predecessor of t. If the edge already exists, its weight is increased by 1. We get the following weight function B1 × B2′ → N0 , w: (s, c) → { t ∈ B2 ∩ succ∗T2 (c) | (s, t) ∈ E }
and a corresponding weighted graph G′h : G′h =(Vh′ , Eh′ , w)
Vh′ =B1 ∪ B2′ , B2′ = succT2 (h) Eh′ ={ (s, c) ∈ B1 × B2′ | w(s, c) > 0 } . See Fig. 7 for an illustration. Please note that all crossing reduction graphs can be precomputed before starting the traversal of the graph, since they do not change during the crossing reduction. A conventional algorithm for weighted 2-layer crossing reduction is then applied to the crossing reduction graph and the given order of the upper layer. The resulting order of the lower layer is used as the order for the children of h. In the same way a child order for all other internal nodes of the layer hierarchy tree is computed, and we get an order for the base nodes by traversing the tree.
2
(a) A clustered graph
(b) The crossing reduction graph of the grey node
Fig. 7. Creating the crossing reduction graph
Applying Crossing Reduction Strategies to Layered Compound Graphs
2
(a) Compound nodes across two layers
(b) Constraint method
∞
283
∞
(c) Heavy edge method
Fig. 8. Respecting the hierarchy across layers (R2)
4.2
Respecting the Hierarchy Across Layers (R2)
To respect R2 right from the start, we present two alternative strategies: the constraint method and the heavy edge method. The constraint method is the more promising alternative. It guarantees the compliance with R2, but it depends on a 2-layer crossing reduction algorithm that supports constraints, i. e., predefined relative orders of some node pairs. Some of the conventional crossing reduction methods have been extended to support constraints with varying success. There is also a crossing reduction method by Schreiber [10], that has been designed specifically for the support of constraints. To comply with R2, the constraint method prohibits the relative position of two compound nodes spanning adjacent layers being different. This is done by inserting a constraint into the crossing reduction graph of one specific node. In Fig. 8(b) the dotted arrow shows how constraints are inserted. Please note that it is sufficient to add constraints between compounds nodes having the same parent in the layer hierarchy tree. An alternative to the constraint method is the heavy edge method. It does not need a crossing minimization algorithm that supports constraints, but models compound nodes as edges with a very high weight instead. These are labeled with ∞ in Fig. 8(c). Unfortunately, this approach does not guarantee compliance with R2 when used with a non-optimal crossing reduction algorithm. Consequently it may be necessary to reorder the nodes in the same way as Sander. Additionally, these edges penalize crossings between adjacency edges and compound nodes. Avoiding these crossings make drawing better understandable, but it also leads to more crossings between adjacency edges.
5
Discussion
We presented a new method for crossing reduction in layered compound graphs. Our method improves Sander’s method with regard to the number of crossings. Depending on structure of the hierarchy we may also gain running time improvements. An implementation of the algorithm is in progress, using Schreiber’s 2-layer crossing minimization with constraints support [10]. We shall have experimental results soon.
284
Michael Forster
References 1. Ralf Brockenauer and Sabine Cornelsen. Drawing clusters and hierarchies. In Kaufmann and Wagner [6], chapter 8, pages 193–227. 2. Giuseppe di Battista, Peter Eades, Roberto Tamassia, and Ioannis G. Tollis. Graph Drawing. Prentice Hall, 1999. 3. Peter Eades and Nicholas C. Wormald. Edge crossings in drawings of bipartite graphs. Algorithmica, 11:379–403, 1994. 4. Michael J¨ unger and Petra Mutzel. Exact and heuristic algorithms for 2-layer straightline crossing minimization. In Proc. Workshop on Graph Drawing ’95, pages 337–348. Springer, 1996. 5. Michael J¨ unger and Petra Mutzel. 2-layer straightline crossing minimization: Performance of exact and heuristic algorithms. Journal of Graph Algorithms and Application, 1(1):1–25, 1997. 6. Michael Kaufmann and Dorothea Wagner, editors. Drawing Graphs, volume 2025 of Lecture Notes in Computer Science. Springer, 2001. 7. Georg Sander. Layout of compound directed graphs. Technical Report A/03/96, Universit¨ at Saarbr¨ ucken, 1996. 8. Georg Sander. Visualisierungstechniken f¨ ur den Compilerbau. PhD thesis, Universit¨ at Saarbr¨ ucken, 1996. 9. Georg Sander. Graph layout for applications in compiler construction. Theoretical Computer Science, 217:175–214, 1999. 10. Falk Schreiber. Visualisierung biochemischer Reaktionsnetze. PhD thesis, Universit¨ at Passau, 2001. 11. Falk Schreiber. High quality visualization of biochemical pathways in biopath. In Silico Biology, 2(0006), 2002. http://www.bioinfo.de/isb/2002/02/0006/. 12. Kozo Sugiyama and Kazuo Misue. Visualization of structural information: Automatic drawing of compound digraphs. IEEE Trans. Systems, Man and Cybernetics, 21(4):876–892, 1991. 13. Kozo Sugiyama, Shojiro Tagawa, and Mitsuhiko Toda. Methods for visual understanding of hierarchical system structures. IEEE Trans. Systems, Man and Cybernetics, SMC-11(2):109–125, 1981.
Crossing Reduction by Windows Optimization Thomas Eschbach1 , Wolfgang G¨ unther2 , Rolf Drechsler3 , and Bernd Becker1 1 Institute for Computer Science Albert-Ludwigs-University, Freiburg, Germany {eschbach,becker}@informatik.uni-freiburg.de 2 Infineon AG CL DAT DF LD V, Munich, Germany [email protected] 3 Institute for Computer Science University of Bremen, Bremen ,Germany [email protected]
Abstract. The number of edge crossings is a commonly accepted measure to judge the “readability” of graph drawings. In this paper we present a new algorithm for high quality multi-layer straight-line crossing minimization. The proposed method uses a local optimization technique where subsets of nodes and edges are processed exactly. The algorithm uses optimization on a window applied in a manner, similar to those used in the area of formal verification of logic circuits. In contrast to most existing heuristics, more than two layers are considered simultaneously. The algorithm tries to reduce the total number of crossings based on an initial placement of the nodes and can thus also be used in a postprocessing step. Experiments are given to demonstrate the efficacy of the proposed technique on benchmarks from the area of circuit design.
1
Introduction
In the last few years the area of automated graph drawing has received a lot of attention from academic and industrial researchers as well. Many relations arising in computer science and in other areas such as chemistry can be modeled by graphs. Concerning computer science visualization of graphs has a growing number of applications e.g. in the areas of data bases, software engineering, graphical interfaces, production scheduling and VLSI CAD (Very Large Scale Integration Computer Aided Design). To allow humans to quickly and efficiently interpret information given as graphs, a good drawing is very useful. In the following, we are especially interested in the drawing of digital circuits occurring in VLSI CAD applications, which can be modeled by graphs. Circuit designers need a fast tool to visualize the given circuit to get a good understanding of the design or diagnose bugs. Furthermore, highest drawing quality is needed for public presentation or documentation in this field. Here, the drawing quality is much more important than the required computation time. Graph drawing - from the initial graph to the final layout - is usually split into several sub-tasks (for an overview of graph drawing see [1]). One very important step in the overall flow of graph drawing is crossing minimization, (see M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 285–294, 2002. c Springer-Verlag Berlin Heidelberg 2002
286
Thomas Eschbach et al.
e.g. [5,20,21]). Unfortunately, even minimizing edge crossings in graphs with only two layers is NP-hard [7] and remains NP-hard even if the positions of the nodes in one layer are fixed. Several heuristic methods have been developed [4,8,12,15,18,20], but exact solutions can be found only for small graphs [10,11]. Almost all heuristic methods are based on the so-called layer-by-layer sweep: – First, an initial order is chosen for all nodes. Then the positions of all nodes in the first layer are fixed and the positions of all nodes in the second layer are computed with respect to all nodes in the first layer. – In the next step the algorithm fixes the positions of the nodes in the second layer and computes the positions of the nodes located in the third layer with respect to the second layer. – The algorithm continues until the positions of the nodes in the last layer are computed followed by a sweep in the reverse order of layers from the last layer to the first layer. Typically the procedure given above is iterated until no reduction in the number of crossings can be achieved in an iteration. By this method the multi-layer crossing minimization problem is reduced to the minimization of the edge crossings in the corresponding two-layer graphs by reordering only the nodes of one layer. Due to the significance of the problem, several heuristics have been proposed, e.g. [4,15,20,21,18]. In particular the barycenter method [20] is known for computing good solutions in a short time. Somewhat surprising is that using it in the same layer-by-layer sweep framework yields slightly better results than using a one-sided exact algorithm [11]. In [12] the crossing reduction is solved with tabu search, which usually computes good solutions at the expense of run time. In [15,8] sifting has been proposed, a heuristic that was originally used for minimizing the number of nodes in Binary Decision Diagrams (BDDs) used frequently in logic synthesis applications and formal verification of logic circuits. In the BDD context, a technique called window optimization [6,9] has been proposed that facilitates smooth tradeoff of run time for quality. In this paper we propose the use of windows optimization for multi-layer crossing minimization. It is designed for post-processing a given solution in the area of circuit visualization, if the corresponding graph is too large for an exact approach. An initial order, e.g. computed by one of the approaches described above is improved in the following way: A series of subsets of nodes with constant size typically spreading over several layers are extracted and optimized exactly with respect to their adjacent nodes. The exact method makes use of lower bound computations to prune the search space. Only if the local solution induces a crossing reduction of the whole graph the order of all nodes is re-adjusted. The designer can smoothly influence the trade-off between run time and solution quality by choosing the size of the window. The implementation of the algorithms is done in AGD [19], a state-of-the-art library of algorithms for graph drawing. Since most of the algorithms discussed above are implemented in AGD, a fair comparison is possible. The AGD uses the efficient LEDA graph package for combinatorial and geometric computing
Crossing Reduction by Windows Optimization
287
[17]. Our experiments show that further reductions of up to 10% compared to the AGD results can be obtained by using the new technique. The paper is organized in the following way. First we introduce the basic definitions in the field of the multi-layer straight-line crossing minimization problem. Then a brief outline of the exact algorithm used is given. In the following section the new approach is presented. Next we give the experimental results showing the crossing reduction obtained by applying the windows optimization procedure on the graphs already optimized with the AGD package.
2
Preliminaries
A directed graph G = (V, E) is a multi-layered graph with d layers if the node set V is partitioned into d subsets V1 , V2 , . . ., Vd , i.e. V1 ∪ V2 ∪ . . . ∪ Vd = V and (∀m = m′ ) Vm ∩ Vm′ = ∅. Vm is called the m-th layer of the graph. All edges in E connect nodes in different layers. A layering of a graph is called proper if the edges only connect nodes of adjacent layers Vm and Vm+1 . If a layering of a graph is not proper one can introduce dummy nodes along edges (u, v) for which l = layer(v) − layer(u) > 1. We replace (u, v) by a path (u = v1 , v2 , . . . , vl = v) of length l. In each layer between u and v, one dummy node has to be placed. Algorithms for layering graphs which represent circuits are discussed e.g. in [3]. It is important to note that only the order of the nodes in a layer Vm , m ∈ {1, . . . , d}, affects the number of crossings with adjacent layers. To solve the exact multi-layer straight-line crossing minimization problem we have to determine for all layers m an order ordm containing all nodes in layer Vm so that the number of crossings is minimized. In the following a set of orders ordm , m ∈ {1, . . . , d}, is called an order for the graph. We define xm ij = 1 if ordm (i) < ordm (j), 0 otherwise. It is easily seen, that for a given order of a graph with d layers the number of crossings can be expressed by: C(order) =
d−1 |V m |−1 |Vm |
m=1
i=1
m+1 m+1 (xm + xm ) ik · xlj ki · xjl
(1)
k=i+1 j∈N (i) l∈N (k)
where N (u) = {v ∈ V | e = (u, v) ∈ E} denotes the set of neighbors of u ∈ V . 2.1
Exact Algorithm
We briefly sketch the algorithm for the multi-layer straight-line crossing minimization problem. The algorithm computes the exact optimum and makes use of a lower bound technique to reduce the search space. The main idea goes back to dynamic programming. – The algorithm computes the minimum number of edge crossings for all nodes by considering the solutions for all subsets of nodes. In the first step we consider all subsets S with one node. For each subset the algorithm creates
288
–
–
–
–
Thomas Eschbach et al.
an entry I and stores it in a table. Each entry I contains the number of edge crossings caused by the edges with both ends in S. Additionally the algorithm stores the permutation of the nodes within S in every entry I. In the first step the first node is also the first node in the permutation of the nodes in S An initial upper bound of edge crossings is obtained by using the barycenter heuristic method to compute an order for all nodes [20]. Let S(I) denote the set of nodes stored in the entry I. In the second step we process every entry I of the table in the following way: For each node ni , with ni ∈ / S(I), we create a new entry Inew for S(I) ∪ ni and store it in the new table if the upper bound is larger than the number of crossings of the new subset S(Inew ). Then the algorithm enlarges the permutation of Inew with ni and updates the number of crossings. If there are two table entries with the same subsets of nodes, the one with the larger number of crossings can be deleted, if the following holds: there exists no more than one edge per layer, that is connected to a node u outside S(I), except that they point to different layers. Otherwise, we cannot compute the number of crossings induced by the permutation of the nodes in the subset S(I). To prune the search space the following lower bound L is used: We count the number |u| of edges which leave I from layer m for nodes in layer m+1 (not in I ) and the number |v| of edges which leave I in layer m+1 for nodes in layer m not in I. Then L can be computed as the number of crossings in I plus the product of |u| and |v|. If L is larger than the upper bound we can also delete the table entry. To speed up the algorithm a dynamic hash table is used to store the current permutation together with the current lower bound. For each entry I the corresponding set of nodes is used as a hash key.
In the following we embed this exact algorithm in our windows optimization scenario. However it should be noted that, in principle, the optimization technique described below also works in combination with other exact approaches, like e.g. [11].
3
Windows Optimization
The basic idea is to extract subsets S of nodes from the graph with constant size and the corresponding subset of edges with at least one end in S. Then the optimal order for S and a somewhat simplified representation of neighborhood N of S is computed. (The notion simplified neighborhood is explained below.) If the exactly optimized order of the nodes in S with regard to N reduces the number of crossings of the graph we adopt the locally optimized solution, otherwise we proceed with a new subset S. More precisely, the algorithm extracts windows of D layers with a maximum of W nodes in each layer1 . First, we extract windows with nodes located in the 1
In the experiments we initialize the values D with two and W to four.
Crossing Reduction by Windows Optimization
289
upper D layers. Starting at the leftmost nodes occurring in the current global permutation the algorithm slides the window one position to the right after each attempt to reduce the number of crossings. We compute a sequence of windows whose horizontal size is adapted layer by layer based on the layers with the largest number of nodes. Then the window processes the following D layers, i.e. layers two to layer D + 1, in the same manner until we have traversed the whole graph. We repeat the procedure described above until no further reduction of the number of crossings can be achieved. Then we may increase the number of layers which are considered by incrementing D and repeat the windows optimization procedure to reduce the number of crossings. This allows to achieve a smooth trade-off between quality and run time. A sketch of the algorithm is given below:
WindowsOptimization(Graph G, Order Ord, int D, int W ) { Cold = #crossings(G, Ord) d = number of layers in G repeat { Cnew = Cold for(i = 1; i ≤ d − D + 1) { k = maxi≤m i, resp.). Accordingly, ai is called a second leftmost (or second rightmost) entry if ak = ai for precisely one index k < i (or precisely one index k > i, resp.). Analogous terms are used for the entries bi in the second row of M . A set of consecutive columns of M is called a block. A block is said to be pure if all elements in the first row of the block are distinct and the same is true for the elements in the second row. Assume the columns of M are partitioned into l pure blocks. Consider now two consecutive pure blocks, B1 and B2 , consisting of the columns i+1, i+2, . . . , j and j + 1, j + 2, . . . , k, resp., for some 0 ≤ i < j < k ≤ n. Suppose that there is an element which appears in the first row of B1 as well as in the first row of B2 . That is, ap = aq for some i < p ≤ j and j < q ≤ k. We claim that either bq is a leftmost, second leftmost or rightmost entry, or bp is a rightmost, second rightmost or leftmost entry. Indeed, otherwise, using the fact that bq is neither a leftmost nor a second leftmost entry, we obtain that there exists an index r ≤ i such that br = bq . Since bq is not a rightmost entry, there is an index s > k such that bs = bq . Similarly, in view of the fact that bp is neither a rightmost nor a second rightmost entry, we can conclude that bs′ = bp for some s′ > k. Since
300
J´ anos Pach et al.
bp is not leftmost, there is a r′ ≤ i such that br′ = bp . Observe that now the columns r, r′ < p < q < s, s′ form a forbidden submatrix of type ∗ ∗uu∗ ∗ , y↔xyxy↔x a contradiction. A symmetric argument shows that if bp = bq for some i < p ≤ j and j < q ≤ k, then either aq is a leftmost, second leftmost or rightmost entry, or ap is a rightmost, second rightmost or leftmost entry. Thus, if we delete from M (and from its block decomposition) every column whose upper or lower element is a leftmost, second leftmost, rightmost, or second rightmost entry, the union of the remainders of any two consecutive blocks becomes pure. There are at most n distinct entries, each may appear in the first row and in the second row, so the number of deleted columns is at most 8n. The resulting matrix M ′ can be decomposed into ⌈l/2⌉ pure blocks. Repeating this process at most ⌈log2 l⌉ times, we end up with a matrix consisting of at least m − 8n⌈log2 l⌉ columns that form a single pure block. Thus, we have m − 8n⌈log2 l⌉ ≤ n. Applying the above procedure to the initial partition of M into l = m pure blocks, each consisting of a single column, the upper bound follows. For many other Davenport-Schinzel type results for matrices, consult [FH92]. As we have pointed out before, the last theorem implies that every geometric or x-monotone topological graph with n vertices and no path of length three whose first and last edges cross each other, has at most constant times n log n edges, provided that all of its edges can be stabbed by a line. Thus, we immediately obtain Corollary 1. The maximum number of edges of an x-monotone topological graph with n vertices, containing no path of length 3 whose first and last edges cross, is O(n log2 n). This result is slightly weaker than the bound in Theorem 1.
3
Proof of Theorem 1
We prove the following more general statement. Theorem 6. Let G be an x-monotone topological graph of n vertices, which has no self-intersecting path of length 3. Then G has at most constant times n log n edges. We assume without loss of generality that no two edges that share an endpoint cross each other. Otherwise, the two non-common endpoints of these edges must be of degree 1 or 2, because G has no self-intersecting path of length 3. So
Geometric Graphs with No Self-intersecting Path of Length Three
301
we can delete these endpoints, and complete the argument by induction on the number of vertices. It will be convenient to use the following terminology. If a vertex v is the left (resp. right) endpoint of an edge e, then e is said to be a right (resp. left) edge at v. It follows from our assumption on adjacent edges that the left and the right edges at a given vertex can be ordered from bottom to top. Let e1 = vu1 and e2 = vu2 be two right edges at a vertex v such that the x-coordinate of u1 is at most as large as the x-coordinate of u2 . We define the right triangle determined by them as the bounded closed region bounded by e1 , a segment of e2 ,, and a segment of the vertical line passing through u1 . The vertex v is called the apex of this triangle. Analogously, we can introduce the notion of left triangle. Construct a sequence of subgraphs G0 , G1 , G2 , . . . of G, as follows. Let G0 = G. If Gi has already been defined for some i, then let Gi+1 be the topological graph obtained from Gi by deleting at each vertex the bottom 2 and the top 2 left and right edges (if they exist). We delete at most 8 edges per vertex. Claim. For any k ≥ 0, every triangle determined by two edges of Gk contains at least 2k pairwise different triangles of G. Proof of Claim. By induction on k. Obviously, for k = 0, the claim is true, because every triangle contains itself. Assume that the claim holds for k − 1 (k > 0). Consider, e.g., a right triangle T in Gk , determined by the edges e1 = vu1 and e2 = vu2 , where the x-coordinate of u1 is at most as large as the x-coordinate of u2 . Suppose without loss of generality that e1 lies below e2 . Using the fact that e1 ∈ E(Gk ), we obtain that at u1 there are at least two left edges f1 , f2 ∈ E(Gk−1 ) which lie above e1 . Both of these edges must be entirely contained in T , otherwise we could find a self-intersecting path of length 3. Suppose that f1 lies below f2 . Let T1 and T2 denote the left triangles with apex u1 , determined by e1 and f1 , and by f1 and f2 , resp. Clearly, T1 and T2 both belong to Gk−1 , and they have disjoint interiors. By the induction hypothesis, both T1 and T2 contain 2k−1 pairwise different triangles. It follows that T contains 2k pairwise different triangles, as required. Now we can easily complete the proof of Theorem 6. Since every triangle is specified by a pair of edges meeting at its apex, the total number of different triangles is at most n3 . Hence, for k > 3 log2 n, the graph Gk cannot determine any triangle, and its number of edges is smaller than n. On the other hand, we have that |E(Gk )| ≥ |E(G0 )| − 8kn. Therefore, |E(G)| = |E(G0 )| ≤ 25n log2 n, completing the proof of Theorem 6. We close this section by showing that, up to the value of the constant c, Theorem 1 (and hence Theorem 6, too) is best possible. Let n = 2k be fixed. We (k) will recursively construct a sequence of bipartite geometric graphs Gi = Gi , i i−2 i = 1, 2, . . . , k, such that Gi has 2 vertices, (i + 1)2 edges, and contains no self-intersecting path of length 3. Furthermore, we will maintain the following properties for every i.
302
J´ anos Pach et al.
1. The vertices of Gi have distinct x-coordinates, which are all integers in the closed intervals [−2k , −2k + 2i − 1] and [0, 2i − 1]. Vertices with x-coordinates in the first (resp. second) interval are called left (resp. right). 2. Every edge of Gi connects a left vertex to a right vertex, and hence it must cross the vertical line (x = − 12 ). 3. The horizontal edges of Gi are of length 2k and form a perfect matching. If two vertices of u, v ∈ V (Gi ), are connected by a horizontal edge, than they are said to form a pair. 4. For any vertex v of Gi , the order of the edges incident to v according to their slopes coincides with the order according to the lengths of their projections to the x-axis. Let G1 consist of two vertices, (−2k , 0) and (0, 0), connected by an edge. Obviously, this meets the requirements. Assuming that we have already constructed Gi for some i, we show how to obtain Gi+1 . Let G′i denote the translate of Gi by a vector (2i−1 , Yi ), where Yi is a very large positive integer to be specified later. Let Gi+1 be the union of Gi and G′i , together with the following 2i−1 “new” edges: connect every left vertex v ∈ V (Gi ) to the right vertex v + (2k + 2i−1 , Yi ) ∈ V (G′i ), that is, to the right vertex forming a pair with the translate of v. See Fig. 2. Choose Yi so large that the slope of the new edges exceeds the slope of any line induced by the points of Gi (or by the points of G′i ). We have to check that Gi+1 has the required properties. We have |V (Gi+1 )| = 2|V (G)| = 2i+1 and |E(Gi+1 )| = 2|E(Gi )| + 2i−1 = (i + 2)2i−1 . Properties 1, 2, 3 and 4 are all inherited from Gi . To see that property 4 is maintained, it is sufficient to recall that both the slope and length of the x-projection of every new edge between Gi and G′i is larger than the corresponding values for the old edges. It remains to verify that Gi+1 does not contain a self-intersecting path of length 3. Assume to the contrary that there is such a path P in Gi+1 , and denote its edges by e1 = uv, e2 = vw, and e3 = wz. Since Gi (and thus G′i ) does not contain a self-intersecting path of length 3, at least one of these edges must run between Gi and G′i . Note that there cannot be two such edges, because all edges of Gi+1 running between Gi and G′i are parallel. It is also clear that e2 is not such an edge. Assume, without loss of generality, that e1 runs between Gi and G′i , and that we have u ∈ V (Gi ) and v ∈ V (G′i ). Thus, e2 and e3 belong to G′i . As v is a right vertex, w must be a left vertex, and both e2 and e3 are to the right of w. Since e3 crosses e1 , the slope of e3 must be smaller than that of e2 . In view of property 4, we conclude that the x-coordinate of z is smaller than the x-coordinate of v. This implies that the slope of the line connecting z and v is larger than the slope of e2 , contradicting our assumption.
Geometric Graphs with No Self-intersecting Path of Length Three
303
Fig. 2. The construction of Gi (i = 3)
4
A Strengthening of Theorem 6
The aim of this section is to establish the following stronger form of Theorem 6. Theorem 7. The maximum number of edges of an x-monotone topological graph with n vertices, containing no path of length 3 whose first and last edges cross, is O(n log n). Proof. Let G be an x-monotone topological graph with n vertices and m edges, containing no path of length 3 whose first and last edges cross. Our goal is to construct another topological graph G′ with n′ = 2n vertices and m′ ≥ m/2 − n edges, with the property that G′ has no path of length 3 whose first and last edges cross, and no two adjacent edges of G′ cross each other. Applying Theorem 6 to G′ , the statement follows. First, we split each vertex of G into into two vertices, one of them just a bit left to the other, so that every original edge e becomes an edge connecting the right copy of the left endpoint of e to the left copy of its right endpoint. The resulting x-monotone topological graph G0 has n′ = 2n vertices and m edges, it has no self-intersecting path of length three, and the right endpoint of any edge of G0 is distinct from the left endpoint of any other edge. In the rest of this section, the length of an edge means the length of its projection to the x-axis, and the terms shorter and longer will be used in the same sense. We write e = uv for an edge of G0 , whose left and right endpoints are u and v, resp. We call an edge e = uv long if it is the longest either among all edges uv ′ or among all edges u′ v ∈ E(G0 ). Clearly, G0 has fewer than n′ long edges. Let e and e′ be two edges of G, where e is shorter than e′ , and we have either e = uv and e′ = uw, or e = vu and e′ = wu. We say that e is above e′ if v is above e′ . Similarly, we say e is below e′ if v is below e′ . Note that if e is above or below e′ then e is shorter, but e and e′ may cross several times. Let e = uv be an edge of G0 which is not long. By definition, there exist two edges, e′ = uw and e′′ = zv ∈ E(G0 ), such that both of them are longer than
304
J´ anos Pach et al.
e. So e is either above or below e′ and e is also above or below e′′ . However, e cannot be above both e′ and e′′ . Indeed, otherwise u is above e′′ while v is above e′ , so e′ and e′′ cross, contradicting our assumption on G. Similarly, e cannot be below both e′ and e′′ . Thus, each edge e = uv ∈ E(G0 ) which is not long either satisfies that e is above every longer edge uw and below every longer edge zv, or it satisfies that e is below every longer edge uw and above every longer edge zv. We can assume, by symmetry, that the former condition (which will be referred to as the monotonicity condition) holds for m′ ≥ (m − n′ )/2 = m/2 − n edges. Let G1 be the subgraph of G0 formed by these edges. We are now in a position to define G′ . As an abstract graph, G′ is identical to G1 . The locations of the vertices will coincide, too. For any edge e ∈ E(G1 ), denote by eˆ the corresponding edge of G′ . We draw the edges of G′ one by one, in decreasing order of length. If e in G1 is neither above nor below another edge, set eˆ = e. If e = uv is above (below) at least one other edge, let e− be the shortest edge such that e is above e− (let e+ be the shortest edge such that e is below e+ , resp.). Draw eˆ in such a way that all of its internal points lie strictly above eˆ− and below eˆ+ (if these edges exist). Notice that, if they exist, e+ and e− are longer than e, so eˆ+ and eˆ− are already defined. We make sure during the construction that, if e+ exists, it passes above u, if e− exists, it passes below v (see property 2 below), and if both of them exist, they are disjoint (see property 4 below). We define eˆ to follow e, except in the intervals where eˆ+ is below e or eˆ− is above e. In these intervals, let eˆ run just below eˆ+ or just above eˆ− , close enough not to intersect any further edges and going on the same side of every vertex. See Fig. 3.
e^+
e^
e
e^Fig. 3. The construction of the edge eˆ in G′
Geometric Graphs with No Self-intersecting Path of Length Three
305
We claim that the resulting graph G′ has the following properties. 1. If e is below (above) e′ in G1 , then every interior point of eˆ is below (above, resp.) eˆ′ . 2. If e′ is below (above) e in G1 , then the endpoint of e′ which is not an endpoint of e is below (above, resp.) eˆ. 3. If e, e′ , and e′′ form a path in G1 and e is longer than e′ , then eˆ and e′′ do not cross. 4. If e, e′ , and e′′ form a path in G1 then eˆ and eˆ′′ do not cross. We verify these properties by showing that if they hold for the partially drawn graph, they do not get violated when we add an extra edge eˆ. (1) By the monotonicity, if there exists at least one edge f such that e is below f , then the shortest among them, e+ , must be below all others. Similarly, e− (if exists) must be above all other edges that e is above. Therefore, as property 1 has held so far, it does not get violated now, provided that eˆ is in between eˆ− and eˆ+ , which is the case. (2) Let e = uv and assume that e′ = uw is above e. By definition, w is above e and, by the monotonicity condition, w is above e− , if the latter exists. As property 2 has held so far, w is above eˆ− , so w must be above eˆ. Similarly, if e′ = zv is below e, then z is below eˆ. (3) Note that e′ is above or below e. By symmetry, we can assume without loss of generality that e′ is below e. By monotonicity, this means that they share their right endpoints. Here e and e′′ do not cross, as they are first and last edges of a path of length 3, and the left endpoint of e′′ is below e. So every point of e′′ must be below e or to the right of the right endpoint of e. If e+ exists, we can apply property 3 to the edges e+ , e′ , e′′ , and find that eˆ+ does not cross e′′ . By the construction, wherever eˆ runs below e, it follows eˆ+ , so eˆ is disjoint from e′′ . (4) We consider two cases. If both e and e′′ are shorter than e′ , then one of them is below and the other is above e′ (monotonicity). Thus, by property 1, eˆ′ (drawn before the other two) separates eˆ from eˆ′′ , so they cannot cross. We may assume that e is shorter than e′′ , so in the remaining case e′′ is longer than e′ . The edge e′ is below or above e′′ , and we can again assume, by symmetry, that e′ is below e′′ . Applying property 3 to the path e′′ , e′ , e, we find that e is disjoint from eˆ′′ . By property 2, the left endpoint of e lies below eˆ′′ . Thus, all points of e must be below eˆ′′ or to the right of its right endpoint. As eˆ follows eˆ− wherever it runs above e, it is enough to show that if e− exists, eˆ− is disjoint from eˆ′′ . If e− = e′ , this follows from property 1, otherwise, from property 4 of the initial configuration (before eˆ has been drawn). Observe that, by property 1, no two adjacent edges of G′ cross each other and, by property 4, the same is true for second neighbors. Hence, we can indeed apply Theorem 6 to G′ , and Theorem 7 follows.
306
5
J´ anos Pach et al.
Forbidden Subgraphs – Proof of Theorem 3
For any k ≥ 2, let Fk denote a graph with vertex set V (Fk ) = {x, y} ∪ {bi : 1 ≤ i ≤ k} ∪ {cij : 1 ≤ i < j ≤ k} and edge set E(Fk ) = {xbi , ybi : 1 ≤ i ≤ k} ∪ {cij bi , cij bj : 1 ≤ i < j ≤ k}. We need the following theorem, which can be obtained by a straightforward generalization of a result of F¨ uredi [F91]. Theorem 8. For any fixed integer k ≥ 2, let ex(n, Fk ) denote the maximum number of edges of an Fk -free graph with n vertices. Then we have ex(n, Fk ) = O(n3/2 ). Let G be a topological graph with n vertices, containing no path of length 3 whose first and last edges cross an odd number of times. To establish Theorem 3, it is sufficient to verify that the abstract graph obtained from G by disregarding how the edges are drawn does not have a subgraph isomorphic to F4 . In fact, it is enough to concentrate to a the subgraph F4′ of F4 induceed by the vertex set {x, y} ∪ {bi : 1 ≤ i ≤ 4} ∪ {cij : 1 ≤ i < j ≤ 3}. Notice that F4′ is a subdivision of K5 : it can be obtained from K5 by replacing four of its edges (a triangle and an edge not incident to the triangle) by paths of length two. This means that a topological graph isomorphic to F4′ can be also considered as a topological graph isomorphic to K5 (simply remove the subdividing points). As K5 is not a planar graph, any topological graph isomorphic to it must have at least one crossing. Furthermore, by Tutte’s theorem [T70], there must exist two non-adjacent edges that cross an odd number of times. Thus, any topological graph isomorphic to F4′ has two edges that cross an odd number of times and they are either nonadjacent edges of the underlying K5 or portions of two such edges. However, any two edges with this property can be extended to a self-intersecting path of length 3. Consequently, F4′ is not isomorphic to a subgraph of G, and Theorem 3 follows.
6
Drawing C4 -Free Graphs – Proof of Theorem 4
Let G be a C4 -free bipartite graph with vertex set V (G) = A ∪ B, where A = {a1 , a2 , . . . , an } and B = {b1 , b2 , . . . , bn }. The edge set of G is denoted by E(G). We now construct a drawing of G. Pick 2n points, a1 , . . . , an , b1 , . . . bn , on the x-axis, from left to right in this order. These points will be identified with the vertices of G. For every edge ai bj ∈ E(G), draw an x-monotone arc eij connecting ai to bj , according to the following rules: (i) for any k > i, the arc eij passes above ak if and only if ak bj ∈ E(G); (ii) for any l < j, the arc eij passes above bl if and only if ai bl ∈ E(G); (iii) no two distinct arcs “touch” each other (internal crossings are proper).
Geometric Graphs with No Self-intersecting Path of Length Three
307
Notice that, unless two arcs share an endpoint, the parity of their number of intersections is determined by these rules. Take two non-adjacent edges ai bj , ak bl ∈ E(G) that belong to a path of length 3. We have to distinguish four different cases: 1. 2. 3. 4.
i < k, i < k, i < k, i < k,
j < l, j < l, l < j, l < j,
and and and and
ak bj ∈ E(G); ai bl ∈ E(G); ai bl ∈ E(G); ak bj ∈ E(G).
Consider the first case. By drawing rule (i), the arc eij passes below ak . By rule (ii), ekl passes above bj . In view of rule (iii), this implies that eij and ekl cross an even number of times, as required. The second case can be treated similarly and is left to the reader. In the third case, applying rule (i), we obtain that ak lies above eij . It is sufficient to show that the same is true for bl . At this point, we use that G is C4 -free: since ai bj , bj ak , ak bl ∈ E(G), we have ai bl ∈ E(G). By rule (ii), this implies that bl is above eij , as required. The last case follows in the same way, by symmetry. So far we have checked that in our drawing any two non-adjacent edges cross an even number of times. It is not hard to extend the same property to all pairs of edges, even if they share endpoints. To this end, we slightly modify the arcs eij in some very small neighborhoods of their endpoints. Clearly, this will not effect the crossing patterns of non-adjacent pairs. Fix a vertex ai . Redraw the arcs eij incident to ai so that the counterclockwise order of their initial pieces in a small neighborhood of ai will be the same as the order of x-coordinates of their right endpoints. Consider now two arcs, eij , eil , (l < j), incident to ai . By rule (ii), bl lies below eij . On the other hand, after performing the local change described above, the initial piece of eil will also lie below eij . This guarantees that eij and eil cross an even number of times. Repeating this procedure for each vertex ai , and its symmetric version for each bj , we obtain a drawing which meets the requirements of Theorem 4.
7
Paths of Length Five
If we exclude self-intersecting paths of length five (rather than three), we can establish a slightly better upper bound on the number of edges of a geometric or x-monotone topological graph. Theorem 9. Let G be an x-monotone topological graph of n vertices with no self-intersecting path of length 5. Then G has at most constant times n log n/ log log n edges. We modify the proof of Theorem 6, and use the same notation. We call an edge a left edge at its right endpoint and a right edge at its left endpoint. Suppose G has nm edges with m ≥ 8. Construct a sequence of subgraphs G, G0 , G′0 , G′′0 , G1 , G′1 , G′′1 , G2 , . . . of G, as follows. Let G0 be the topological
308
J´ anos Pach et al.
graph obtained from G by deleting each vertex of degree at most m 2 . Notice that no two edges of G0 that share an endpoint cross each other. Otherwise, since all degrees are at least 5, those two edges could be extended to a crossing path of length 5. Thus, the left and the right edges at a vertex are naturally ordered from top to bottom. Similarly, no path of length 3 or 4 is self-intersecting. 1. If Gi has already been defined for some i, let G′i denote the topological graph obtained from Gi by deleting the bottom and the top left and right edges at each vertex (if they exist). We delete at most four edges per vertex. 2. If G′i has already been defined for some i, let G′′i denote the topological graph obtained from G′i by deleting the bottom and the top left and right edges at every vertex (if they exist). We delete at most four edges per vertex. 3. If G′′i has already been defined for some i, let Gi+1 be the topological graph obtained from G′′i by deleting recursively each vertex of degree at most m 2, . Clearly, as long as so that all vertices of Gi+1 have degree higher than m 2 the average degree of G′′i is at least m, it cannot decrease in this step. Let ai denote the average degree in Gi . It is easy to see that a0 ≥ 2m and m ai ≥ ai−1 − 16 as long as ai−1 − 16 ≥ m. So, we have a⌊ 16 ⌋ ≥ m. Therefore, m G⌊ 16 ⌋ still determines at least one (actually, many) triangle(s). Recall that a left (right) triangle at a vertex is determined by two left (right, resp.) edges of the vertex, and it is the region bounded by one of the edges, a piece of the other edge, and a vertical interval. It is sufficient to establish the following. m Claim. For any 0 ≤ k ≤ 16 , every triangle determined by two edges of Gk k m contains at least 2 − 2 pairwise different triangles of G.
m Indeed, assuming that the Claim is true, a triangle determined by G⌊ 16 ⌋ m m ⌊ 16 ⌋ 3 triangles, and this number is at most n . It follows contains at least 2 − 2 that m ≤ c log n/ log log n, as required by the theorem. Proof of Claim. By induction on k. Obviously, for k = 0, the assertion is true, because every triangle contains itself. Assume that the claim holds for k − 1 (k > 0). Consider a right triangle T in Gk , determined by the edges e1 = vu1 and e2 = vu2 , where the x-coordinate of u1 is at most as large as the x-coordinate of u2 . Suppose without loss of generality that e1 lies below e2 . Since e1 ∈ E(G′′k−1 ), there is at least one left edge, f1 ∈ E(G′k−1 ), at u1 above e1 . This edge, f1 = w1 u1 , must entirely be contained in T , otherwise we could find a self-intersecting path of length 3. Since f1 ∈ E(G′k−1 ), there is at least one right edge, f2 ∈ E(Gk−1 ), at w1 below f1 . Similarly, this edge, f2 = w1 w, must be entirely contained in the triangle determined by e1 and f1 . Therefore, f2 must also lie in T . See Fig. 4. The degree of w in Gk−1 is at least m 2 . In view of the fact that there is no self-intersecting path of length 5 or shorter, none of these edges can cross e1 , e2 , f1 , and f2 . Therefore, all of them are entirely −2 triangles with pairwise disjoint interiors, inside T . They determine at least m m2 k−1 each of which contains at least 2 − 2 further triangles, and we are done by induction.
Geometric Graphs with No Self-intersecting Path of Length Three
309
u2
v w u1 Fig. 4. The edges at w are all in T
8
Related Problems
A. Theorems 1 and 6 easily imply Corollary 2. For any tree T other than a star, there exists a constant c(T ) such that every geometric (or x-monotone topological) graph G with n vertices and more than c(T )n log n edges contains a self-intersecting copy of T . That is, we have excr (n, T ) ≤ c(T )n log n. Indeed, deleting one-by-one every vertex of G whose degree is smaller than |V (T )|, we end up with a graph G′ having at most n vertices and at least (c(T ) log n − |V (T )|)n edges. If c(T ) is sufficiently large, then G′ has a selfintersecting path of length 3. Using the fact that the degree of every vertex in G′ is at least |V (T )|, this path can be extended to a copy of T in G′ (and hence in G). B. A slight modification of the proof of Theorem 1 gives Corollary 3. For any positive integer k, there exists a constant ck with the property that every geometric graph with n vertices and at least ck n log n edges has two adjacent vertices, u and v, and 2k edges incident to them, uu1 , uu2 , . . . , uuk and vv1 , vv2 , . . . , vvk , such that uui crosses vvj for every pair 1 ≤ i, j ≤ k. C. We conjecture that Theorem 1 can be generalized to all topological graphs with with no self-intersecting path of length 3. Recently, we have proved that if G is an x-monotone topological graph with n vertices, all of whose edges cross the yaxis, and G has no self-intersecting path of length 4, then |E(G)| = O(n log1/2 n). It is interesting to note that one cannot guarantee the existence of any specific crossing pattern of a path of length 4, even if the number of edges is at least
310
J´ anos Pach et al.
Ω(n log n). Indeed, the construction in Section 3 provides such a geometric graph with no self-intersecting path of length 3. On the other hand, a convex, balanced, complete bipartite geometric graph, all of whose edges cross the y-axis, has no path of length 4, whose only self-intersection occurs between its first and last edges. D. Any drawing of K3,3 , a complete bipartite graph with 3 vertices in each of its classes, has two non-adjacent edges that cross each other. Clearly, any two edges belong to a cycle of length 4, so excr (n, C4 ) ≤ ex(n, K3,3 ) = O(n5/3 ). This bound has been recently improved to O(n8/5 ) by Pinchasi and Radoiˇci´c [PR02]. It seems likely that the best possible bound is close to n3/2 . It also follows from Theorem 8 that excr (n, C6 ) = O(n3/2 ), and it generalizes to topological graphs. On the other hand, we have excr (n, C6 ) ≥ ex(n, C6 ) ≥ cn4/3 , for a suitable constant c > 0 (see [BS74]). For C4 -free graphs this bound is almost tight. Theorem 10. Let G be a C4 -free geometric (or x-monotone topological) graph on n vertices. If G has no self-intersecting cycle of length 6, then G has O(n4/3 log2/3 n) edges. Proof. Assume without loss of generality that the left end of an edge is not the right end of another edge in G. This can be achieved by splitting the vertices in two as in the proof of Theorem 7. Let G have n vertices and |E(G)| = m > log n c′ n4/3 log2/3 n edges. For p = 2cn |E(G)| < 1, color randomly and independently with probability p each vertex of G red. Let G′ be the subgraph of G induced by the red vertices. Let i(G′ ) denote the number of self-intersecting paths of length 3 in G′ . Deleting one edge from each such path, we obtain a graph with no self-intersecting path of length 3. Thus, in view of Theorem 1, we have |E(G′ )| − i(G′ ) < c|V (G′ )| log |V (G′ )|, for some positive c. Taking expected values, this yields p2 |E(G)| − p4 i(G) < cpn log n. n 3 ′ We obtain i(G) > 8c|E(G)| 2 n2 log2 n . If c is large enough, then i(G) > 2 , and there must exist two self-intersecting paths of length 3 connecting the same pair of vertices. These paths cannot share an internal vertex as that would lead to a C4 . Therefore, putting them together, we get a C6 which intersects itself at least twice.
Geometric Graphs with No Self-intersecting Path of Length Three
311
References AAPPS97.
AH66. B78. BS74. F91. FH92. H34. K79. P99.
PT97. PR02. T02. T70. V98.
P. K. Agarwal, B. Aronov, J. Pach, R. Pollack, and M. Sharir, Quasiplanar graphs have a linear number of edges, Combinatorica 17 (1997), 1–9. S. Avital and H. Hanani, Graphs (in Hebrew), Gilyonot Lematematika 3 (1966), 2–8. B. Bollob´ as, Extremal Graph Theory, Academic Press, New York, 1978. A. Bondy and M. Simonovits, Cycles of even length in graphs, J. Combinatorial Theory, Ser. B 16 (1974), 97–105. Z. F¨ uredi, On a Tur´ an type problem of Erd˝ os, Combinatorica 11 1 (1991), 75–79. Z. F¨ uredi and P. Hajnal, Davenport-Schinzel theory of matrices, Discrete Mathematics 103 (1992), 233–251. ¨ H. Hanani (C. Chojnacki), Uber wesentlich unpl¨ attbare Kurven in dreidimensionalen Raume, Fundamenta Mathematicae 23 (1934), 135–142. Y. Kupitz, Extremal Problems in Combinatorial Geometry, Aarhus University Lecture Notes Series 53, Aarhus University, Denmark, 1979. J. Pach, Geometric graph theory, in: Surveys in Combinatorics, 1999 (J. D. Lamb and D. A. Preece, eds.), London Mathematical Society Lecture Notes 267, Cambridge University Press, Cambridge, 1999, 167–200. J. Pach and G. T´ oth, Graphs drawn with few crossings per edge, Combinatorica 17 (1997), 427–439. R. Pinchasi and R. Radoiˇci´c, On the number of edges in geometric graphs with no self-intersecting cycle of length 4, to appear. G. Tardos, On the number of edges in a geometric graph with no short self-intersecting paths, to appear. W. T. Tutte, Toward a theory of crossing numbers, J. Combinatorial Theory 8 (1970), 45–53. P. Valtr, On geometric graphs with no k pairwise parallel edges, Discrete and Computational Geometry 19 (1998), 461–469.
Two New Heuristics for Two-Sided Bipartite Graph Drawing⋆ Matthew Newton1 , Ondrej S´ ykora1 , and Imrich Vrt’o2 1
Department of Computer Science, Loughborough University Loughborough, Leicestershire LE11 3TU, The United Kingdom {m.c.newton,o.sykora}@lboro.ac.uk, Fax: +44 (0)1509 211 586 http://parc.lboro.ac.uk/ 2 Institute of Mathematics, Slovak Academy of Sciences D´ ubravsk´ a 9, 842 35 Bratislava, Slovak Republic [email protected], Fax: +421 2 59306522
Abstract. Two new heuristic strategies are studied based on heuristics for the linear arrangement problem and a stochastic hill-climbing method for the two-sided bipartite crossing number problem. These are compared to the standard heuristic for two-sided bipartite drawing based on iteration of the barycentre method. Our experiments show that they can efficiently find good solutions.
1
Introduction
Graph drawing addresses the problem of finding a layout of a graph that satisfies given aesthetic and readability objectives. One standard problem with the drawing of bipartite graphs is that of two layer automatic drawing where the two vertex partitions are put in distinct points on two parallel lines and edges are drawn as straight line segments between the two lines. This type of drawing is the basic building block used for drawing hierarchical graphs [5,14,20] or producing row-based vlsi layouts [17]. The most important objective is probably minimisation of the number of crossings in the drawing, as the aesthetics and readability of graph drawings depend on the number of edge crossings (see [16]). vlsi layouts containing less crossings are more easily realisable and consequently cheaper. There are two basic variants of the problem: one-sided and two-sided crossing minimisation. In the one-sided problem the vertices of one part of the bipartite graph are placed in fixed positions on one line. The vertices of the other part are placed on the other line and their positions are found so that the number of pairwise edge crossings is minimised. The two-sided bipartite crossing number problem (or just the bipartite crossing number problem) is if the vertices on both sides are not restricted. Unfortunately, both problems are np-hard [7,8]. A lot of different methods have been designed to solve the one-sided problem—heuristics ⋆
Research of all the authors was supported by the epsrc grant GR/R37395/01. Research of the last two authors was supported by the Slovak Scientific Grant Agency grant No. 2/7007/20.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 312–319, 2002. c Springer-Verlag Berlin Heidelberg 2002
Two New Heuristics for Two-Sided Bipartite Graph Drawing
313
and approximation algorithms (see e.g. [1,4]). For the two-sided bipartite problem a common technique is to apply a one-sided method iteratively. In [10] the one-sided methods, barycentre, lr-Opt (branch and cut method of [10]), split, median, stochastic, greedy-switch, assign and greedy-insert were applied iteratively until there was no change, i.e. until a local minimum had been achieved. The resulting ranking of the heuristics was as above. The iterated barycentre method was the best among the tested methods both in terms of quality and computation time. An interesting observation by the authors of [10], for graphs of up to about 15 vertices on both sides, was that for the graphs with a density of 10%, the resulting number of crossings were 5 to 33 times larger than the optimal value. In this paper we suggest two new heuristic strategies. The first is based on the result in [18] showing a strong relation between the linear arrangement problem of a bipartite graph and its bipartite crossing number. We used two different methods to find a solution to the linear arrangement problem which implies respective permutations of vertices on both sides (layers). One (linear arrangement based on Fiedler’s vector: laf-method) is based on computing the graph’s second laplacian eigenvalue and its corresponding vector, usually called Fiedler’s vector [9]. The other (linear arrangement based on Koren and Harel’s method: lakh-method) is based on the multiscale method of Koren and Harel [12]. The second strategy, stochastic hill-climbing (sh)-method, is based on hill-climbing, a standard optimisation technique, and randomised swapping of vertices. In comparison with genetic algorithms or simulated annealing, stochastic hill-climbing is simpler and faster. Our method is different from the method of [3], which is also called ‘stochastic’ in [10]. It also differs from the greedy-switch heuristic of [6] and from sifting [13] which are based on the swapping of neighbouring vertices. In our experiments we compared the above three methods with the iterated barycentre (ib)-method. The results show that both la* -methods usually outperform the ib-method, especially lakh-method, which produces good drawings in an acceptable running time. The sh-method often produces the best results (see Table 1, shown instead of a graphical comparison due to lack of space).
2
Notations
Let G = (V, E), V = V0 ∪ V1 be a bipartite graph with vertex partitions V0 and V1 . A bipartite drawing of G is obtained by placing the vertices of V0 and V1 into distinct points on two horizontal lines y0 and y1 , respectively, and drawing each edge with one straight line segment. Any bipartite drawing of G is identified by two permutations π0 and π1 of the vertices on y0 and y1 . The problem of the two-sided bipartite drawing of G is to find permutations π0 and π1 that minimise the number of pairwise edge crossings in the corresponding bipartite drawing. The problem of the one-sided bipartite drawing of G is the same, except the permutation π1 is fixed.
314
Matthew Newton, Ondrej S´ ykora, and Imrich Vrt’o
Let bcr(G, π0 , π1 ) denote the total number of crossings in the bipartite drawing represented by the permutations π0 and π1 . The bipartite crossing number of G, denoted by bcr(G), is the minimum number of crossings over all π0 and π1 . Clearly, bcr(G) = minπ0 ,π1 bcr(G, π0 , π1 ). Given an arbitrary graph G = (V, E), the linear arrangement problem is to determine a bijection f : V → {1, 2, 3, ..., |V |} such that uv∈E |f (u) − f (v)| is minimised. This minimum value, whose computation is np-hard [8], is denoted by L(G). Furthermore, dv denotes the degree of v, δG the minimum degree of G and ∆G , the maximum degree of G.
3
Linear Arrangement Problem Based Methods
The bipartite crossing number problem was studied in [18] and a connection between this problem and the linear arrangement problem was established. Lower and upper bounds for bipartite crossing number bcr(G) were derived, where the main term is the optimal arrangement value: Theorem 1 Let G = (V0 , V1 , E), then 1 1 2 δG L(G) − dv ≤ bcr(G) ≤ 5∆G L(G). 36 12 v∈V
By using this result, a polynomial time approximation algorithm [18] with performance guarantee O(log n) from the optimal was obtained for the bipartite crossing number problem if ∆G = O(δG ). The algorithm is based on an approximation algorithm for the linear arrangement problem, where an approximated solution of the linear arrangement problem is found and then the vertices of the partitions of V0 and V1 are put on the lines y0 and y1 in the same order as produced for the linear arrangement problem. Using this idea, we can use any heuristic that solves the linear arrangement problem to produce the pair of permutations π0 and π1 . In [9] a heuristic is suggested that solves the linear arrangement problem by computing the corresponding (so called Fiedler’s) eigenvector f to the smallest positive Laplacian eigenvalue λG of the graph G. Recall that the Laplacian of a graph G is the matrix I(G) − A(G), where A(G) is the adjacency matrix of the graph G and I(G) is the diagonal matrix with vertex degrees on the diagonal, i.e. ivv = dv , and iuv = 0 if u = v and the Fiedler’s eigenvector f fulfills: (I(G) − A(G))f = λG f . Using this approximation of linear arrangement we get the laf-method shown in Algorithm 1. The other method (lakh-method) is based on the multiscale method of Koren and Harel [12] that computes an approximation of the linear arrangement.
4
Stochastic Hill-Climbing Method
The space of orderings of vertices of both sides for two-sided bipartite drawing problem can be represented by all pairs of permutations of {0, 1, 2, . . . , n0 − 1},
Two New Heuristics for Two-Sided Bipartite Graph Drawing
315
Algorithm 1. “Linear Arrangement based on Fiedler’s vector” (laf-method) find smallest positive Laplacian eigenvalue λG or a good approximation find corresponding eigenvector (Fiedler vector) construct approximation to the solution of the Linear Arrangement Problem construct permutations π0 and π1 evaluate the number of crossings for the pair of permutations
and of {0, 1, 2, . . . , n1 − 1}, where n0 and n1 are the number of vertices in V0 and V1 , respectively. To find a solution of the two-sided bipartite drawing problem means searching this space for a pair of permutations providing the minimum number of crossings. To move across the space we might use some type of steps, evaluate a new visited pair of permutations, accept it if it fulfills a condition (e.g. it has lower or equal number of crossings) and continue to search from the new accepted permutation. If the new permutation was not accepted we continue from the old one. The starting permutations are given by the input. Algorithm 2 shows the specific method we used.
Algorithm 2. “Stochastic Hill-Climbing Method” (sh-method) repeat until (termination-condition) randomly choose one of the sides 0 or 1 randomly choose two different vertices on the chosen side swap their positions evaluate the number of crossings for the new pair of permutations if the number of crossings decreases then keep the new pair of permutations else return to the previous pair of permutations
The termination condition can be defined by the number of iterations, or the number of iterations that have passed since the last swap that gave an improvement to the number of crossings (the number of stagnations). According to our experience, the termination should happen if the number of stagnations exceeds a value α ∗ density/(density + β) where density = |E|/|V |, and α, β are proper constants. For the sizes of our graphs these constants could be: α = 1350, β = 65. In our experiments we ran the sh-method while the number of crossings was higher than that achieved by the ib-method, the laf-method and lahk-method. The sh-method program also had a maximum time limit of five minutes and a few graphs did not complete within this limit. For some graphs sh-method stagnated and did not reach the number of crossings of the ib (this includes e.g. leonardo-90x64 and hyper-9) or la* -methods (this includes e.g. bcspwr01 and
316
Matthew Newton, Ondrej S´ ykora, and Imrich Vrt’o
cycle-100). An asterisk in Table 1 indicates one of the previous two conditions. Some graphs completed in less than 0.00005 second, so due to rounding it looks like they finished immediately (climb-100x100-t10 and ball-100x100). The number of crossings that each algorithm reached, together with the time taken, is shown in Table 1; ib-method in columns two and three, laf-method in columns five and six, lakh-method in columns eight and nine. The running times of shmethod necessary to achieve the number of crossings equal to or below that of the ib–, laf– and lakh-methods are shown in columns four, seven and ten, respectively. The best number of crossings found for each graph is shown in boldface.
5
Experiments
Our algorithms were implemented in c, running on 50 Sun ULTRAsparc 5 workstations running Solaris 7. The algorithms were compiled with the gnu c compiler version 2.95.2. One of the computers ran a job control system, written in Perl, to run experiments continuously on the other machines. The experiments for the ib–, laf– and lakh-methods were run first. These programs output the pair of permutations of the nodes in each graph, π0 followed by π1 , from which the number of crossings was counted. Before each experiment, π0 and π1 were randomised (this did not affect the la* -methods, which do not need an initial permutation). The quality of the results of the la* -methods depends on the quality of the approximation of L(G) for a graph G. To compute the Fiedler’s eigenvector in the laf-method we used the procedure jacobi from Numerical Recipes [15]. Although the jacobi procedure is not too efficient, it gives trustworthy results and is recommended for problems of small-to-moderate order. Typical n × n matrices require 12n3 to 20n3 operations. In the lakh-method we used the multiscale algorithm of Koren and Harel [12] for solving the linear arrangement problem running in linear time in the graph size (|V | + |E|). Apart from meshes, the lakh-method gave better results than the laf-method. It is also much faster, especially for larger graphs. Thanks are due to Yehuda Koren who kindly provided us their procedure so we were able to test this method. All ib–, laf– and lakh-methods were run ten times on each graph and the average number of crossings and running time were recorded. A new set of experiments were then run for the sh-method. The algorithm was run thirty times for each graph. For the first, second and third ten runs the program halted when the number of crossings was equal to or below that of the ib–, laf–, lakh-methods, respectively. As in the first set of experiments, π0 and π1 of each graph were randomised before each test run. Graph Test Sets. For our experiments we used the classes of graphs from [4] that contain ‘synthetic’ bipartite graphs with a known bipartite crossing number, bipartite graphs extracted from digitised images (originally suggested by Knuth in the Stanford Graphbase [11]) and from test data retrieved from US National Institute of Standards and Technology [2]. For our tests we also added
Two New Heuristics for Two-Sided Bipartite Graph Drawing
317
the following graphs for which we either know, or believe we know, the optimum drawings. Among these are cycles (with bipartite crossing number n2 − 1, if there are n vertices in the cycle, n is even), rectangular meshes, square n × n meshes (with supposed bipartite crossing number 34 n(n − 1)(n − 2) + 1) and hypercubes (see [19]). Finally, we also used randomly generated graphs. Random Graphs. The random graphs we used were generated based on edge density. The generator takes two arguments: n, the number of nodes the graph should have, and p ∈ [0..100] that determines the percentage chance that an edge will exist between two nodes. n must be an even number, and the graph is generated with n2 nodes in each part. The general graphs were generated having sizes n ∈ [20, 40, 60, 80, 100, 200, 400, 600, 800, 1000] and densities of 10%, 1% and 0.1%. Acknowledgement The authors wish to thank Yehuda Koren and Irene Finocchi, for making available their software, and Mark Withall for useful discussions during the preparation of this paper. Table 1. Comparisons between ib-method (columns two and three), laf-method (columns five and six), lakh-method (columns eight and nine) and sh-method. In columns four, seven and ten are the running times necessary for sh-method to achieve the number of crossings equal to or below that of the ib–, laf– and lakh-methods, respectively. Time is in seconds. Graph Name
a-100x100 a-87x81 add20 andywarhol-100x65 ball-100x100 barpermute-100x100 bars-100x100 bcspwr01 bcsstk15 brick-100x100 camil-100x78 can61 cbar-100x100 cbar-20x20 cbar-50x50 climb-100x100-t10 climb-100x100-t100 climb-100x100-t110 climb-100x100-t120 climb-100x100-t130 climb-100x100-t140 climb-100x100-t150 climb-100x100-t160 climb-100x100-t20 climb-100x100-t30 climb-100x100-t40 climb-100x100-t50 climb-100x100-t60 climb-100x100-t70 climb-100x100-t80 climb-100x100-t90 climb-100x100 climb-20x20 climb-40x40 climb-60x60 climb-80x80 cycle-100 cycle-1000 cycle-20 cycle-200 cycle-300
IB-method Crossings 2550802 2414484 3621791 1893498 947575 3175608 3517232 2954 889155 501133 1559231 69842 88815 465 3870 19276 544406 672990 760146 989397 1355640 2627049 3796488 83505 136135 169887 217630 239888 271755 268910 341906 997171 1316 24032 131937 415731 467 6639 48 1057 1813
SH to LAF-method IB Time Time Crossings Time 0.0031 0.3989 2716464 19.3547 0.0025 0.8535 1327488 2.5816 0.4223 0.0088 1177229 1296.39 0.0074 * 2856377 2.248 0.004 0 934566 9.413 0.004 2.6106 4161703 5.4557 0.0325 0.0324 2075771 6.7551 0.0019 0.0029 464 0.2698 0.1933 * 727592 923.3729 473653 24.6587 0.0171 0 0.0078 * 2076490 3.7254 0.0026 0.0075 12788 1.1197 0.0027 * 88815 6.4762 0.0004 0.0018 19 0.0314 0.0015 19.2498 3870 0.6231 0.0077 0 10824 10.7103 0.0066 0.0182 536316 29.5412 0.0071 0 604213 6.1009 0.0062 0.0116 655080 5.3363 0.0093 0 923308 6.1088 0.0138 0 1081502 5.6321 0.0155 0 1690572 5.7368 0.0297 0 2697887 5.6074 0.0087 0 39548 11.8175 0.0062 0.0022 75347 14.7937 0.0082 0.0087 100168 15.6475 0.0078 0.038 203147 18.0365 0.0067 0.0406 151225 19.583 0.0066 0.05 178569 20.3396 0.0076 0.1685 298802 21.2215 0.0084 0.0457 224044 24.6957 0.0084 0 914106 5.539 0.0004 0 1084 0.0322 0.0016 0.0001 19797 0.3074 0.004 0 109592 0.9228 0.005 0 335135 2.2201 0.0043 * 49 0.7583 1.1338 * 499 4875.714 0.0001 0.0004 9 0.009 0.0198 * 99 10.3766 0.054 * 149 41.6743
SH to LAKH-method LAF Time Crossings Time 0.0111 1301275 15.888 25.6836 1301275 15.034 51.7084 1021504 37.708 11.4422 2784605 17.056 0.0068 749982 9.038 0.0162 2040676 18.829 * 2153777 21.607 * 422 1.263 * 741208 36.756 0.0011 248575 10.123 1.2589 1708444 15.594 * 12847 3.835 * 88815 8.597 * 19 0.515 21.2854 3870 2.64 0.0212 4764 3.768 0.0359 252671 9.847 0.0876 307040 10.205 0.243 367847 11.468 0.0194 493285 12.783 0.4582 694349 14.181 11.4668 1569210 17.33 8.7222 2597067 19.739 1.0374 35877 5.512 0.8598 70994 6.53 0.7436 96179 6.581 0.0756 124927 7.506 0.782 128702 7.294 1.0076 156352 7.927 0.0607 174073 8.199 0.7863 184132 8.31 0.0136 471565 12.415 0.0004 536 0.659 0.0076 11464 2.31 0.0246 64596 6.069 0.1762 211614 8.251 * 83 1.53 * 778 17.825 * 13 0.168 * 171 3.355 * 250 5.077
SH to LAKH Time * * * 35.1931 22.3192 61.6639 45.9696 * * 3.3267 12.8803 * 91.8295 * 26.1418 * * 10.0924 7.8663 6.3544 11.065 20.2285 20.7422 0.4004 0.8385 0.5109 0.9283 2.0096 1.025 1.1534 2.4242 13.5789 0.0221 0.1219 1.0191 2.6622 * * * * *
318
Matthew Newton, Ondrej Sikora, and Imrich Vrt'o
Graph Name
IB-method
Crossings cycle-40 122 cycle-400 2228 cycle-500 2987 cycle-60 274 cycle-80 253 geom2-100x100 179880 hyper-10 2221867 hyper-4 131 999 hyper-5 4710 hyper-6 22714 hyper-7 108038 hyper-8 494357 hyper-9 886963 irregular-100x100 883543 ladyshoe-67x100 leonardo-90x64 455396 mahindas 1318184 mesh-10-10 1212 mesh-15-15 6286 mesh-20-20 12570 mesh-25-25 30245 mesh-30-10 6246 mesh-30-15 16014 mesh-30-20 27610 mesh-30-25 39139 mesh-30-30 45950 mesh-30-5 1225 mesh-35-35 85203 mesh-40-40 120812 mesh-5-5 252 monnalisa-100x65 1945030 monnalisa-20x13 3588 monnalisa-40x26 50578 monnalisa-60x39 257956 monnalisa-80x52 770234 moonsurface-100x100 2146803 orani678 4941969 psmigrl 2.05e+09 random-100-0.1 0 random-100-1 102 random-100-10 16707 random-1000-0.1 19093 random-1000-1 1683123 1.58e+08 random-1000-10 0 random-20-0.1 0 random-20.1 25 random-20-10 5 random-200-0.1 2257 random-200-1 275147 random-200-10 1 random-40-0.1 3 random-40.1 370 random-40-10 400 random-400-0.1 42140 random-400-1 4210581 random-400-10 0 random-60-0.1 13 random-60.1 1798 random-60-10 2806 random-600-0.1 204855 random-600-1 20385097 random-600-10 0 random-80-0.1 31 random-80.1 5416 random-80-10 6687 random-800-0.1 620494 random-800-1 64476577 random-800-10 1376092 ring-100x100 12979 ring-80x80 scra-100x100 2754221 scra-87x81 2322384 scrball-100x100 928260 texturel-100x100 3894302 texture2-100x100 814985 texture3-100x100 5035435 texture4-100x100 2226143 texture5-100x100 2224888 texture6-100x100 5572581 texture7-100x100 2900151 tie-100x100 3190315 triangle-100x100 6123591 zenios 6845283
SH t o LAF-method SH t o LAKH-method SH t o IB LAF LAKH Time Time Time Time Crossings Time Crossings Time 0.0005 0.0053 19 0.0457 29 0.474 199 152.9575 0.0981 328 7.116 249 282.9466 0.2015 404 8.998 29 0.1782 0.0014 0.0104 45 0.8 39 0.4786 0.0024 0.0684 63 1.185 0 43073 6.538 391832 2.4829 0.0037 0.1256 * 2548526 7116.157 144.4579 0.2571 118 0.0049 0.0001 0.0011 0.0022 124 0.154 0.0011 0.0002 0.0018 776 0.0346 0.0143 786 0.545 0.0093 * 4200 0.1669 0.0006 0.0395 4359 1 . 4 9 4 0.0845 * 0.526 22134 3.957 1.2749 23464 16.9141 0.0026 * * 106400 38.4887 106922 9.756 9.6853 0.013 * 0.0541 535292 1247.529 24.5621 498715 21.38 70.8947 492835 12.699 0.0027 6.6072 0 3690604 5.2365 669064 1 1 . 1 5 1 13.8607 0.0054 0.9114 2.7296 727351 2.0314 * 1341314 1.8802 0.3251 1 0 7 3 7 5 8 1 1 . 9 8 8 4.9457 0.0077 324736 25.755 0.8055 0.0013 1266715 836.6369 299.3661 997 0.7666 1009 1.978 0.0028 * * 3858 5.614 3 8 9 7 23.6179 0.0175 * * 9519 118.2442 9993 8.964 0.0701 * * 19340 551.8628 1 9 7 0 8 14.722 0.2926 * * 3367 6.287 3729 31.9283 0.0445 * * 8119 10.96 8 8 6 6 182.8301 0.1238 * * 14920 13.7 1 6 4 6 5 650.1603 0.2655 * * 23524 1 8 . 8 4 3 25258 1056.526 0.5404 * * 34200 2470.742 34836 23.848 0.654 679 2.946 706 2.3688 0.0066 * 55098 6805.752 1.5665 * 84679 21971.12 3.2542 84 0.0088 90 0.302 0.0124 0.0002 0.0007 * 5179482 2.7837 0.4914 4314354 19.776 93.816 0.0101 * 0.919 0.0003 6332 0.021 0.0336 6156 * 0.0023 106336 3.903 128954 0.153 0.0044 * 0.0035 540595 7.249 11.2691 656433 0.5054 0.0472 * 2072231 1 . 3 0 4 3 0.2279 1 7 3 1 7 7 8 12.19 56.0786 0.0077 1599527 1 6 . 8 4 7 36.2476 0.0175 0.7537 1807232 5.771 3.1508 1955821 36.533 8 8 . 4 4 0 3 0.9359 0.0601 2202672 710.6326 26.2889 * 1.85e+09 423.455 * l . Q l e + O Q 608.8471 0.265 73.6012 0.0005 0 0.1306 0 0 0 0 0 0 1.201 0.0009 0.0001 102 0.0126 0 8304 2.706 1.2585 0.0074 0.0003 9575 0.7139 0.0667 0 0 0.3769 0.0049 18980 3.6272 0.0039 772973 41.513 9.4952 0.0113 1672515 3937.91 0.009 * 6.0268 1 . 4 e + 0 8 3973.301 197.7546 1.36e+08 226.149 1.243 0.0001 0 0.0001 0 0 0 0 0 0.0001 0 0.0001 0 0.075 0 0 0 0 0.126 0.0001 12 0.0007 0.0003 0 0 0 0.0092 0.0016 0.0006 5 0.4618 0.0011 0 0 0.0119 1748 0.1166 0.0017 0 182662 9.832 3.8573 0.0446 0.0011 201022 6.843 0.4308 0 0.286 0.0001 0.0001 1 0.0003 0 0 0 0.375 0.0004 0.0001 1 0.0106 0.0003 0 87 0.498 0.0004 0.0002 268 0.0217 0.0006 0 0 0.0154 0.0006 288 0.6268 0.0032 5032 7.745 0.442 0.0006 21995 234.6991 0.0763 3215659 35.652 41.3217 0.6203 0.0424 3435193 118.4158 5.4909 0.0002 0 0.0261 0 0 0 0 0 0 0.594 0.0021 0.0002 0.0001 8 0.0263 0.0004 376 1.011 0.0015 0.0002 2018 0.164 0 0 0 0.1033 0.0013 2497 0.92 0.0035 0.001 58159 1 5 . 6 3 7 0.8702 0.0043 206670 611.0068 2.5476 0.0854 17455934 715.8014 299.6423 16400000 8 1 . 4 0 8 0.0003 0 0.0721 0 0 0 0 0 0.0005 0.0002 15 0.0151 0.0011 0 0.9 * 0.0041 0.0002 2143 0.3074 2011 1.673 0.1985 0.0032 6851 2.5984 0.0036 0 0 233566 25.781 6.4117 0.0066 555193 2080.685 0.0794 3.8251 0.1718 56162991 2123.121 299.6723 53900000 140.667 344728 1 1 . 2 8 7 0.0053 0.0032 1389508 4.7603 0 338 2.731 0.0025 0.0004 10506 0.1934 0.0035 1301275 16.005 0.0034 2558436 3.6129 0.3933 0 1301275 1 5 . 0 9 8 0.0023 1.0449 1327488 2.4466 28.4834 749982 9.185 23.8414 0.0034 0.0315 934566 9.1585 0.0048 3211303 21.713 21.8718 0.0612 0.0167 3323967 6.5414 5.6343 390889 1 1 . 8 3 13.0504 0.0215 0.0005 432977 5.7274 2.2476 4024066 23.237 32.7983 0.0327 0.0182 4238284 6.0099 7.0197 1073482 5.5928 28.7785 1080003 15.952 40.5893 0.0112 0 1636037 1 7 . 3 1 8 36.0044 1797332 6.7338 0.0284 0.0003 3.0323 3744003 22.265 60.4353 3745269 5 . 7 8 8 31.4037 0.01 0.088 2075480 1 7 . 8 3 3 18.7751 2319081 5.1494 0.018 3.2826 0 2033573 16.586 3184326 5.0847 0.0059 0.2814 0.3251 * 4003275 20.285 4003275 6.5481 0.0029 0.008 * 987540 33.587 1113354 1220.934 0.6242 1.0495
Two New Heuristics for Two-Sided Bipartite Graph Drawing
319
References 1. Bastert, O., Matuszewski, C.: Layered drawings of digraphs. In: Drawing Graphs, Methods and Models (eds. Kaufmann, M., Wagner D.), LNCS 2025, Springer (2001) 87–118 2. Boisvert, R., Pozo, R., Remington, K., Barrett, R., Dongarra, J.: Matrix Market: a web resource for test matrix collections. In: The Quality of Numerical Software: Assessment and Enhancement (ed. Boisvert, R.), Chapman and Hall, London, (1997) 125–137, Matrix Market is available at the url: http://math.nist.gov/MatrixMarket/ 3. Dresbach, S.: A new heuristic layout algorithm for DAGs. In: Operations Research Proceedings 1994 (eds. Derigs, U., Drexl, A.B.A.), Springer (1994) 121–126 4. Demetrescu, C., Finocchi, I.: Removing cycles for minimizing crossings. J. Experimental Algorithmics, to appear 5. Di Battista, G., Eades, P., Tamassia, R., Tollis, I.G.: Graph Drawing: Algorithms for Visualization of Graphs. Prentice Hall (1999) 6. Eades, P., Kelly, D.: Heuristics for reducing crossings in 2-layered networks. Ars Combin. 21 (1986) 89–98 7. Eades, P., Wormald, N.: Edge crossings in drawings of bipartite graphs. Algorithmica 11 (1994) 379–403 8. Garey, M.R., Johnson, D.S.: Crossing number is np-complete. SIAM J. Algebraic Disc. Meth. 4 (1983) 312–316 9. Juvan, M., Mohar, B.: Optimal linear labellings and eigenvalues of graphs. Discrete Appl. Math. 36 (1992) 153–168 10. J¨ unger, M., Mutzel, P.: 2-Layer straight line crossing minimization: Performance of exact and heuristic algorithms. J. Graph Algorithms Appl., 1 (1997) 1–25 11. Knuth, D.E.: The Stanford GraphBase: A platform for combinatorial computing. Addision-Wesley, (1993) 12. Koren, Y., Harel, D.: A multi-scale algorithm for the linear arrangement problem. In: 28th Intl. Workshop on Graph-Theoretic Concepts in Computer Science (WG’2002), LNCS, Springer (2002), to appear 13. Matuszewski, C., Sch¨ onfeld, R., Molitor, P.: Using sifting for k-layer straightline crossing minimization. In: 7th Intl. Symp. on Graph Drawing (GD’99), LNCS 1731, Springer (1999) 217–224 14. Mutzel, P.: Optimization in leveled graphs. In: Pardalos, M., Floudas C.A. (eds.): Encyclopedia of Optimization. Kluwer, Dordrecht (2001) 15. Press, W.H., Teukolsky, S.A., Vetterling, W.T., Flannery, B.P.: Numerical Recipes in C. The Art of Scientific Computing. Second edition, Cambridge University Press (1992) http://www.nr.com/ 16. Purchase, H.: Which aesthetic has the greatest effect on human understanding? In: 5th Intl. Symp. on Graph Drawing (GD’97), LNCS 1353, Springer (1998) 248–261 17. Sarrafzadeh, M., Wong, C.K.: An Introduction to VLSI Physical Design. McGraw Hill, (1996) 18. Shahrokhi, F., S´ ykora, O., Sz´ekely, L.A., Vrˇto, I.: On bipartite drawings and the linear arrangement problem. SIAM J. Computing 30 (2001), 1773–1789 19. Shahrokhi, F., S´ ykora, O., Sz´ekely, L.A., Vrˇto, I.: A new lower bound for the bipartite crossing number with algorithmic applications. Theoretical Computer Science 245 (2000) 281–294 20. Sugiyama, K., Tagawa, S., Toda, M.: Methods for visual understanding of hierarchical system structures. IEEE Transactions on Systems, Man, and Cybernetics SMC-11 (1981) 109–125
Straight-Line Drawings of Binary Trees with Linear Area and Arbitrary Aspect Ratio
⋆
(Extended Abstract) Ashim Garg and Adrian Rusu Department of Computer Science and Engineering University at Buffalo Buffalo, NY 14260 {agarg,adirusu}@cse.buffalo.edu
Abstract. Trees are usually drawn planar, i.e. without any crossings. In this paper, we investigate the area requirement of (non-upward) planar straight-line grid drawings of binary trees. Let T be a binary tree with n nodes. We show that T admits a planar straight-line grid drawing with area O(n) and with any pre-specified aspect ratio in the range [1, nα ], where α is a constant such that 0 ≤ α < 1. We also show that such a drawing can be constructed in O(n log n) time.
1
Introduction
A drawing Γ of a tree T maps each node of T to a distinct point in the plane and each edge (u, v) of T to a simple Jordan curve with endpoints u and v. Γ is a straight-line drawing if each edge is drawn as a single straight-line segment. Γ is a polyline drawing if each edge is drawn as a connected sequence of one or more line-segments, where the meeting point of consecutive line-segments is called a bend. Γ is a grid drawing if all the nodes and edge-bends have integer coordinates. Γ is a planar drawing if edges do not intersect each other in the drawing. Γ is an upward drawing if a parent is always assigned either the same or higher y-coordinate than its children. In this paper, we concentrate on grid drawings. So, we will assume that the plane is covered by a rectangular grid. Let R be a rectangle with sides parallel to the X- and Y -axes. The width (height) of R is equal to the number of grid points with the same y (x) coordinate contained within R. The area of R is equal to the number of grid points contained within R. The aspect ratio of R is the ratio of its longer and shorter sides. R is the enclosing rectangle of Γ , if it is the smallest rectangle that covers the entire drawing. The width, height, area, and aspect ratio of Γ is equal to the width, height, area, and aspect ratio, respectively, of its enclosing rectangle. T is a binary tree if each node has at most two children. We denote by T [v], the subtree of T rooted at a node v of T . T [v] consists of v and all the descendents of v. Γ has the subtree separation property [1] if, for any two node-disjoint subtrees T [u] and T [v] of T , the enclosing rectangles of the drawings of T [u] and T [v] do not overlap with each other. ⋆
Research supported by NSF CAREER Award IIS-9985136 and NSF CISE Research Infrastructure Award No. 0101244.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 320–332, 2002. c Springer-Verlag Berlin Heidelberg 2002
Straight-Line Drawings of Binary Trees
2
321
Our Result
Planar straight-line drawings are more aesthetically pleasing than non-planar polyline drawings. Grid drawings guarantee at least unit distance separation between the nodes of the tree, and the integer coordinates of the nodes and edge-bends allow the drawings to be displayed in a display surface, such as computer screen, without any distortions due to truncation and rounding-off errors. Giving users control over the aspect ratio of a drawing allows them to display the drawing in different kinds of display surfaces with different aspect ratios. The subtree separation property makes it is easier for the user to detect the subtrees in the drawing. Finally, it is important to minimize the area of a drawing, so that the users can display a tree in as small drawing area as possible. We, therefore, investigate the problem of constructing (non-upward) planar straight-line grid drawings of binary trees with small area. Clearly, any planar grid drawing of a binary tree with n nodes requires Ω(n) area. A long-standing fundamental question, therefore, has been that whether this is a tight bound also, i.e., given a binary tree T with n nodes, can we construct a planar straight-line grid drawing of T with area O(n)? In this paper, we answer this question in affirmative, by giving an algorithm that constructs a planar straight-line grid drawing of a binary tree with n nodes with O(n) area in O(n log n) time. Moreover, the drawing can be parameterized for its aspect ratio, i.e., for any constant α, where 0 ≤ α < 1, the algorithm can construct a drawing with any user-specified aspect ratio in the range [1, nα ]. The drawing also exhibits the subtree separation property.
3
Previous Results
Previously, the best-known bound on area of planar straight-line grid drawings of binary trees was O(n log log n), which was shown in [1] and [7]. We now summarize some other known results on planar grid drawings of binary trees (for more results, see [4]). Let T be a binary tree. [5] presents an algorithm for constructing an upward polyline drawing of T in O(n) area. [6] and [9] present algorithms for constructing an orthogonal polyline drawing of T in O(n) area. [2] gives an algorithm for constructing upward straight-line drawing of T in O(n log n) area. If T is a Fibonacci tree, (AVL tree, balanced tree, respectively), then [2,8] ([3],[2], respectively) give algorithms for constructing an upward straight-line drawing of T in O(n) area.
4
Preliminaries
Throughout this paper, by the term drawing, we will mean a planar straight-line grid drawing. We will assume that the plane is covered by an infinite rectangular grid. A horizontal channel (vertical channel) is an infinite line parallel to X- (Y -) axis, passing through the grid-points.
322
Ashim Garg and Adrian Rusu
Let T be a tree, with one distinguished node v, which has at most one child. v is called the link node of T . Let n be the number of nodes in T . T is an ordered tree if the children of each node are assigned a left-to-right order. A partial tree of T is a connected subgraph of T . If T is an ordered tree, then the leftmost path p of T is the maximal path consisting of nodes that are leftmost children, except the first one, which is the root of T . The last node of p is called the leftmost node of T . Two nodes of T are siblings if they have the same parent in T . T is an empty tree, i.e., T = φ, if it has zero nodes in it. Let Γ be a drawing of T . By bottom (top, left, and right, respectively) boundary of Γ , we will mean the bottom (top, left, and right, respectively) boundary of the enclosing rectangle R(Γ ) of Γ . Similarly, by top-left (top-right, bottomleft, and bottom-right, respectively) corner of Γ , we mean the top-left (top-right, bottom-left, and bottom-right, respectively) corner of R(Γ ). Let R be a rectangle, such that Γ is entirely contained within R. R has a good aspect ratio, if its aspect ratio is in the range [1, nα ], where α is a constant, such that 0 ≤ α < 1. Let r be the root of T . Let u∗ be the link node of T . Γ is a feasible drawing of T , if it has the following three properties: – Property 1: The root r is placed at the top-left corner of Γ . – Property 2: If u∗ = r, then u∗ is placed at the bottom boundary of Γ . More over, we can move u∗ downwards in its vertical channel by any distance without causing any edge-crossings in Γ . – Property 3: If u∗ = r, then no other node or edge of T is placed on, or crosses the vertical and horizontal channels occupied by r. Theorem 1 ([9]). Let n0 and α be two constants, where n0 ≥ 1 and 0 < α < 1/2. Let m1 , m2 , . . . , mn0 be a set of positive numbers. Let G(n), and g(n) be two functions such that – ∀n > n0 , and ∀x, where 0 < x ≤ 1 − α, G(xn) ≤ x(G(n) − g(n) G(n)), and – ∀n ≤ n0 , G(n) ≥ mn .
and 0 ≤ β < 1/2, Then, if g(n) ≤ cnβ , where c > 0 and β are constants, √ then G(n) = O(n). More specifically, G(n) = γn − δ ng(n) is a solution, where γ and δ are constants that satisfy the following conditions: √ – ∀n ≤ n0 , γn − δ ncnβ ≥ mn , and √ – δ(µ1/2−β − 1) > γ, where µ = 1/(1 − α).
Theorem 2 (Separator Theorem [9]). Every n-node binary tree T contains an edge e, called a separator edge, such that removing e from T splits T into two trees T1 and T2 , with n1 and n2 nodes, respectively, such that for some x, where 1/3 ≤ x ≤ 2/3, n1 ≤ xn, and n2 ≤ (1 − x)n. More over, e can be found in O(n) time. Let v be a node of tree T located at grid point (i, j) in Γ . Let Γ be a drawing of T . Assume that the root r of T is located at the grid point (0, 0) in Γ . We define the following operations on Γ :
Straight-Line Drawings of Binary Trees
323
– rotate operation: rotate Γ counterclockwise by δ degrees around the z-axis passing through r. After a rotation by δ degrees of Γ , node v will be located at grid point (i cos δ − j sin δ, i sin δ + j cos δ). – flip operation: flip Γ vertically or horizontally. After a horizontal flip of Γ , node v will be located at grid point (−i, j). After a vertical flip of Γ , node v will be located at grid point (i, −j).
5
Algorithm u∗ -HV-Draw
We first describe Algorithm u∗ -HV-Draw, which is used by our main drawing algorithm (described in Section 6). Algorithm u∗ -HV-Draw is based on the well-known HV -Drawing algorithm of [2]. Lemma 1 summarizes the main result on HV -Drawing algorithm: Lemma 1 ([2]). Let T be an n-node binary tree with root r. Let R be a rectangle with width (height) n and height (width) log2 n + 2. We can construct a drawing of T within R in O(n) time, such that r is placed at the top-left corner of R. Unfortunately, given a tree T with a link node u∗ , HV -Drawing algorithm may not construct a feasible drawing of T because it may not place u∗ at the bottom of the drawing. Algorithm u∗ -HV-Draw will, however, construct a feasible drawing. Algorithm u∗ -HV-Draw can be described as follows: Let W and H be the width and height of R, respectively. – Order the children of each node such that u∗ becomes the leftmost node of T . – Let r = r1 , r2 , . . . , rk−1 , rk = u∗ , be the nodes in the leftmost path of T (see Figure 1(a)). Let c = c1 , c2 , . . . , ck be the right children of r1 , r2 , . . . , rk , respectively. Let T1 , T2 , . . . , Tk be the subtrees of T rooted at c1 , c2 , . . . , ck , respectively. For each i, where 1 ≤ i ≤ k, let ni be the number of nodes in Ti . – If W ≤ H (H < W ), for each i, where 1 ≤ i ≤ k, construct a drawing Γi of Ti , using HV -Drawing algorithm, within a rectangle Ri with height (width) ni and width (height) log2 ni + 2 (see Lemma 1). – Based on the value of k, tree T is drawn as follows: • k ≥ 2: If W ≤ H, then as shown in Figure 1(b), stack the drawings of Γ1 , Γ2 , . . . , Γk one above the other such that their left boundaries are aligned. Place each ri , where 1 ≤ i ≤ k − 1, at the same height as ci and at unit horizontal distance from it towards its left. Place u∗ to the left of ck at unit horizontal distance and at unit vertical distance below the bottom boundary of Γk . If H < W , then first flip Γk vertically, and then, as shown in Figure 1(c), place Γ1 , Γ2 , . . . , Γk in a left-to-right order with two units of horizontal separation between them, such that their top boundaries are aligned. Let Γh be the drawing among Γ1 , Γ2 , . . . , Γk with maximum height. Place u∗ one unit below the bottom boundary of Γh , and one unit to the left of ck−1 . Move Γk down until its bottom boundary is either below, or aligned with the bottom boundary of Γk−1 . Place each ri , where 1 ≤ i ≤ k − 1, at one unit above and one unit to the left of ci , and draw edges (ri , ci ), and (ri , ri+1 ). Draw the edge (u∗ , ck ).
324
Ashim Garg and Adrian Rusu
(a)
(b)
(c)
(d)
(e)
(f)
Fig. 1. (a) General form of a binary tree T with link node u∗ and root r, where u∗ is also the leftmost node of T . This figure uses the notation of Section 5. (b,c) Drawing T when k ≥ 2: if (b) W ≤ H, and if (c) H < W . (d) Special case when k = 1. (e,f) Drawing T when k = 1: if (e) W ≤ H, and if (f) H < W . For simplicity, we have shown Γ1 , Γ2 , . . . , Γk as identically sized boxes, but in actuality, they may have different sizes.
• k = 1: For both W ≤ H and H < W , place r one unit above and to the left of the top-left corner of Γ1 (see Figure 1 (d,e,f)). Draw edge (r, c). Lemma 2. Let T be an n-node binary tree with a link vertex u∗ . Algorithm u∗ HV-Draw can be used to construct in O(n) time, a feasible drawing of T within a rectangle with width n and height log2 n + 4, as well as within a rectangle with width log2 n + 4 and height n.
6
Our Overall Tree Drawing Algorithm
Let T be a binary tree with a link node u∗ . Let n be the number of nodes in T . Let A and ǫ be two numbers such that 1/3 < ǫ < 1, and A is in the range [1, nǫ ]. Let R be a large enough rectangle with aspect ratio A, width W and height H (we will determine later on, how large R should be). Notice that because 1 ≤ A < nǫ , R has a good aspect ratio. Our tree drawing algorithm, called DrawTree, uses a simple divide-andconquer strategy to recursively construct a feasible drawing Γ of T within R, by performing the following actions at each recursive step: – Split Tree: Split T into at most five partial trees by removing at most two nodes and their incident edges from it. Each partial tree has at most (2/3)n nodes. Based on the arrangement of these partial trees within T , we get two cases, which are shown in Figures 2 and 3, and described later in Section 6.1. – Assign Rectangles: Correspondingly, split R into at most five smaller rectangles, and assigns each smaller rectangle to a partial tree. The splitting is done by cutting the longer side (height or width) of R. – Draw Partial Trees: Recursively construct a feasible drawing of each partial tree within its assigned rectangle.
Straight-Line Drawings of Binary Trees
(a)
(b)
(c)
(e)
325
(d)
(f)
Fig. 2. Drawing T in all the subcases of Case 1 (when the separator (u, v) is not in the leftmost path of T ): (a) TA = ∅, TC = ∅, d = u∗ , (b) TA = ∅, TC = ∅, (c) TA = ∅, TC = ∅, d = u∗ , (d) TA = ∅, TC = ∅, r = e, (e) TA = ∅, TC = ∅, r = e, (f) TA = ∅, TC = ∅, d = u∗ . For each subcase, we first show the structure of T for that subcase, then its drawing when W ≤ H, and then its drawing when H < W . In Subcases (a) and (c), for simplicity, e is shown to be in the interior of ΓA , but actually, either it is the same as r, or if W ≤ H (H < W ), then it is placed on the bottom (right) boundary of ΓA . For simplicity, we have shown ΓA , ΓB , and ΓC as identically sized boxes, but in actuality, they may have different sizes.
– Compose Drawings: Within R, arrange the drawings of the partial trees, and draw the nodes and edges, that were removed from T to split it, such that the drawing Γ of T thus obtained is a feasible drawing. Note that the arrangement of these drawings is done based on the cases shown in Figures 2 and 3. We now give details of each action performed by Algorithm DrawTree: 6.1
Split Tree
The splitting of tree T into partial trees is done as follows: – Order the children of each node such that u∗ becomes the leftmost node of T . – Using Theorem 2, find a separator edge (u, v) of T , where u is the parent of v. – Based on whether, or not, (u, v) is in the leftmost path of T , we get two cases: • Case 1: The separator edge (u, v) is not in the leftmost path of T . We get six subcases: (a) In the general case, T has the form as shown in Figure 2(a). In this figure: r is the root of T , T2 is the subtree of T rooted at v, c is the sibling of v, T1 is the subtree rooted at c, Tα is the
326
Ashim Garg and Adrian Rusu
(a)
(c)
(b)
(d)
Fig. 3. Drawing T in all the subcases of Case 2 (when the separator (u, v) is in the leftmost path of T ): (a) TA = ∅, TB = ∅. (b) TA = ∅, TB = ∅. (c) TA = ∅, TB = ∅. (d) TA = ∅, TB = ∅. For each subcase, we first show the structure of T for that subcase, then its drawing when W ≤ H, and then its drawing when H < W . In Subcases (a) and (d), for simplicity, e is shown to be in the interior of ΓA , but actually, either it is same as r, or if W ≤ H (H < W ), then it is placed on the bottom (right) boundary of ΓA . For simplicity, we have shown ΓA , ΓB , and ΓC as identically sized boxes, but in actuality, they may have different sizes.
subtree rooted at u, w is the parent of u, a is the last common node of the path r ❀ v and the leftmost path of T , f is the right child of a, Tβ is the maximal tree rooted at f that contains w but not u, TB is the tree consisting of the trees Tα and Tβ , and the edge (w, u), e is the parent of a, and d is the left child of a, TA is the maximal tree rooted at r that contains e but not a, and TC is the tree rooted at d. In addition to this general case, we get five special cases: (b) when TA = ∅ and TC = ∅ (see Figure 2(b)), (c) TA = ∅, TC = ∅, d = u∗ (see Figure 2(c)), (d) TA = ∅, TC = ∅, r = e (see Figure 2(d)), (e) TA = ∅, TC = ∅, r = e (see Figure 2(e)), and (f) TA = ∅, TC = ∅, d = u∗ (see Figure 2(f)). In each case, we remove nodes a and u, and their incident edges, to split T into at most five partial trees TA , TC , Tβ , T1 , and T2 . We also designate e as the link node of TA , w as the link node of Tβ , and u∗ as the link node of TC . We randomly select a leaf of T1 , and a leaf of T2 , and designate them as the link nodes of T1 and T2 , respectively. • Case 2: The separator edge (u, v) is in the leftmost path of T . We get four subcases: (a) In the general case, T has the form as shown in Figure 3(a). In this figure, r is the root of T , c is the right child of u, TB is the subtree of T rooted at c, e is the parent of u, TA is the maximal tree rooted at r that contains e but not u, and TC is the tree rooted at v. In addition to the general case, we get the following three special cases: (b) TA = ∅, TB = ∅ (see Figure 3(b)), (c) TA = ∅, TB = ∅ (see Figure 3(c)), and (d) TA = ∅, TB = ∅ (see Figure 3(d)). In each case, we remove node u, and its incident edges, to split T into at most three partial trees TA , TB , and TC . We also designate e as the link node of TA ,
Straight-Line Drawings of Binary Trees
327
and u∗ as the link node of TC . We randomly select a leaf of TB and designate it as the link node of TB . 6.2
Assign Rectangles
Let Tk be a partial tree of T , where for Case 1, Tk is either TA , TC , Tβ , T1 , or T2 , and for Case 2, Tk is either TA , TB , or TC . Let nk be number of nodes in Tk . Algorithm DrawTree assigns a rectangle Rk , with width Wk and height Hk , to Tk , where Wk and Hk are as follows: Let W and H be the width and height, respectively, of R. Assume that H < W (the case when W ≤ H is handled similarly). 1−ǫ Let H ′ = H − 2, and W ′ = W − 3 max{n 1+ǫ , log2 n + 4} − 2. Let x = nk /n. – If nk < H ′ (i.e., if Tk is a very small tree), then Wk = log2 nk + 4, and Hk = H ′ ; – Otherwise, if xW ′ /H ′ ≤ n−ǫ k (i.e., if Tk is a moderately large tree), then Wk = H ′ /nǫk , and Hk = H ′ ; – Otherwise (i.e., if Tk is a large tree), Wk = xW ′ /H ′ and Hk = H ′ . This assignment strategy ensures that when the drawings of all the partial trees are composed together to obtain a drawing Γ of T in the Compose Drawings step, then Γ will fit inside R. It also ensures that, except when Tk is a very small tree, Rk has a good aspect ratio. 6.3
Draw Partial Trees
In Subcase (d) of Case 1, and if H < W , then in Subcases (a) and (c) of Case 1, and Subcases (a) and (d) of Case 2, we first change the orientation of RA , so that its height becomes its width, and its width becomes its height. Also, in Case 1, if H < W , and Tβ = φ, we change the orientation of Rβ . This is done so because, in these situations, as explained later in Subsection 6.4, we need to rotate RA and Rβ during the Compose Drawings step. In all other situations, we do not change the orientation of the rectangle assigned to a partial tree. Next we draw each partial tree Tk within its assigned rectangle Rk . If Tk is a large tree or a moderately large tree (see their definitions in Subsection 6.2), then Tk is drawn within Rk by calling Algorithm DrawTree recursively for it, and if Tk is a very small tree, then Tk is drawn within Rk by calling Algorithm u∗ -HV-Draw for it. Note that recursion for DrawTree stops when either T is empty, or contains exactly one node, or gets designated as a very small tree (in which case, it is drawn using u∗ -HV-Draw). 6.4
Compose Drawings
Let Γk denote the drawing of a partial tree Tk constructed in Step Draw Partial Trees. We now describe the construction of a feasible drawing Γ of T from the drawings of the partial trees in both Cases 1 and 2.
328
Ashim Garg and Adrian Rusu
In Case 1, we first construct a feasible drawing Γα of the partial tree Tα by composing Γ1 and Γ2 as shown in Figure 4, then construct a feasible drawing ΓB of TB by composing Γα and Γβ as shown in Figure 5, and finally construct Γ by composing ΓA , ΓB and ΓC as shown in Figure 2. Γα is constructed as follows (see Figure 4): – If u does not belong to the leftmost path of T , and T1 = ∅ (see Figure 4(a)), then, if W ≤ H, place Γ1 above Γ2 such that the left boundaries of Γ1 and Γ2 are aligned; otherwise (i.e., if W > H) place Γ1 to the left of Γ2 , such that the top boundaries of Γ1 and Γ2 are aligned. Place u at one unit to the left and one unit above Γ1 . Draw edges (u, c) and (u, v). – If u does not belong to the leftmost path of T , and T1 = ∅ (see Figure 4(b)), then for both W ≤ H and H < W , place u at one unit to the left and one unit above Γ2 . Draw edge (u, v). – Otherwise (i.e., if u ∈ leftmost path of T ), Γα is same as Γ2 (see Figure 4(c)). ΓB is constructed as follows (see Figure 5): Let y be the root of Tα . Note that y = u if u does not belong to the leftmost path of T , and y = v otherwise. – if Tβ = ∅ (see Figure 5(a)) then, if W ≤ H, then place Γβ above Γα such that the left boundaries of Γβ and Γα are aligned; otherwise (i.e., if W > H), first rotate Γβ by 90◦ and then flip it vertically, then place Γβ to the left of Γα such that the top boundaries of Γβ and Γα are aligned. Draw edge (w, y). – Otherwise (i.e., if Tβ = ∅), ΓB is same as Γα (see Figure 5(b)). Γ is constructed from ΓA , ΓB and ΓC as follows (see Figure 2): Let x be the root of TB . Note that x = f if Tβ = ∅, and x = y otherwise. – In Subcase (a), as shown in Figure 2(a), if W ≤ H, stack ΓA , ΓB , and Γc one above the other and place node a between ΓA and ΓB , such that ΓA , a, ΓB , and ΓC are separated by unit vertical distance from each other, left boundaries of ΓB and ΓC are aligned with each other and are placed at unit horizontal distance to the right of the left boundary of ΓA , and a is aligned with the left boundary of ΓA . If H < W , then first rotate ΓA by 90◦ , and then flip it vertically. Then, place ΓA , a, ΓC , and ΓB from left-to-right in that order, separated by unit horizontal distances, such that a is aligned with the top boundary of ΓA , the top boundaries of ΓB and ΓC are aligned, and are at unit vertical distance below the top boundary of ΓA . Then, move ΓC down until u∗ becomes the lowest node of Γ . Draw edges (e, a), (a, x), and (a, d). – In Subcase (b), for both W ≤ H and H < W , place node r one unit above and left of the top boundary of ΓB (see Figure 2(b)). Draw edge (r, x). – The drawing procedure for Subcase (c) is similar to the one in Subcase (a), except that we also flip ΓC vertically (see Figure 2(c)). – In Subcase (d), as shown in Figure 2(d), if W ≤ H, first flip ΓB vertically, and then flip it horizontally, so that its root x gets placed at its lower-right corner. Then, first rotate ΓA by 90◦ , and then flip it vertically. Next, place ΓA above ΓB with unit vertical separation, such that their left boundaries are aligned, next move node e (which is the link node of TA ) to the right until
Straight-Line Drawings of Binary Trees
(a)
(b)
329
(c)
Fig. 4. Drawing Tα , when: (a) u does not belong to the leftmost path of T and T1 = ∅, (b) u does not belong to the leftmost path of T and T1 = ∅, and (c) u ∈ leftmost path of T . For each case, we first show the structure of Tα for that case, then its drawing when W ≤ H, and then its drawing when H < W . For simplicity, we have shown Γ1 and Γ2 as identically sized boxes, but in actuality, their sizes may be different.
it is either to the right of, or aligned with the right boundary of ΓB (since ΓA is a feasible drawing, by Property 2, as given in Section 4, moving e will not create any edge-crossings), and then place u∗ one unit to the right of and below x. If H < W , first rotate ΓA by 90◦ , and then flip it vertically. Then, place ΓA , u∗ , and ΓB left-to-right in that order separated by unit horizontal distances, such that the top boundaries of ΓA and ΓB are aligned, and u∗ is placed one unit below the bottom boundary of the drawing among ΓA and ΓB with greater height. Draw edges (u∗ , e) and (u∗ , x). – In Subcase (e), as shown in Figure 2(e), if W ≤ H, first flip ΓB vertically, then place ΓA , ΓB , and u∗ one above the other with unit vertical separation, such that the left boundary of ΓA is at unit horizontal distance to the left of the left boundary of ΓB , and u∗ is aligned with the left boundary of ΓA . If H < W , then first flip ΓB vertically, place ΓA to the left of ΓB at unit horizontal distance, such that their top boundaries are aligned. Next, move ΓB down until its bottom boundary is either aligned with or below the bottom boundary of ΓA . Then, place u∗ one unit below the bottom boundary of ΓB , such that it is aligned with left boundary of ΓA . Draw edges (u∗ , r) and (u∗ , x). Note that, since ΓA is a feasible drawing, by Property 3 (see Section 4), drawing (u∗ , r) will not create any edge-crossings. – The drawing procedure in Subcase (f) is similar to the one in Subcase (a), except that we do not have ΓA here (see Figure 2(f)). In Case 2, we construct Γ by composing ΓA , ΓB and ΓC , as follows (see Figure 3): – The drawing procedures in Subcases (a), (b), and (c) are similar to those in Subcases (a), (b), and (f), respectively, of Case 1 (see Figures 3(a,b,c)). – In Subcase (d), as shown in Figure 3(d), if W ≤ H, we place ΓA , u, and ΓC one above the other separated by unit vertical distances such that u is aligned with the left boundary of ΓA , and the left boundary of ΓC is one unit to the right of the left boundary of ΓA . If H < W , then first rotate ΓA by 90◦ , and then flip it vertically. Then, place ΓA , u, and ΓC from left to right in that order, separated by unit horizontal distances, such that u is aligned with the top boundary of ΓA , and the top boundary of ΓC is one unit below the top boundary of ΓA . Draw edges (u, v) and (u, e). Lemma 3 (Planarity). Given a binary tree T with a link node u∗ , Algorithm DrawTree will construct a feasible drawing Γ of T .
330
Ashim Garg and Adrian Rusu
(a)
(b)
Fig. 5. Drawing TB when: (a) Tβ = ∅, and (b) Tβ = ∅. Node y shown here is either node u or v. For each case, we first show the structure of TB for that case, then its drawing when W ≤ H, and then its drawing when H < W . In Case (a), for simplicity, w is shown to be in the interior of Γβ , but actually, it is either same as f , or if W ≤ H (H < W ), then is placed on the bottom (right) boundary of Γβ . For simplicity, we have shown Γβ and Γα as identically sized boxes, but in actuality, their sizes may be different.
Lemma 4 (Time). Given an n-node binary tree T with a link node u∗ , Algorithm DrawTree will construct a drawing Γ of T in O(n log n) time. Lemma 5 (Area). Given an n-node binary tree T with a link node u∗ , Algorithm DrawTree can construct a drawing of T within a rectangle with O(n) area. Sketch of Proof. The proof is similar to the proof of Theorem 5 of [9]. Let R be a rectangle assigned to T , with aspect ratio A, such that A is in the range [1, nǫ ], where ǫ is a constant, such that 1/3 < ǫ < 1. Let D(n) be some function such that the area of R should be at least D(n) for the algorithm to succeed in drawing T entirely within R. Let H be the height and W be the width of R. We have two cases: H < W and W ≤ H. Consider the case when H < W (the case W ≤ H is analogous). Let Tk be a partial tree of T into which T is split, as described in Section 6.1. Let Rk , nk , x, Hk , Wk , W ′ , and H ′ be as defined in Section 6.2. 1−ǫ We show that the condition D(xn) ≤ xW ′ H ′ = x(W − 3 max{n 1+ǫ , log2 n + 4} − 2)(H − 2) is a sufficient condition for Algorithm DrawTree to draw T within R. For T to be drawn succesfully within R, each partial tree Tk should be drawn successfully within its assigned rectangle, and their drawings should be succesfully combined to lie entirely within R. If Tk is a very small tree, then it can be drawn within its assigned rectangle Rk using Algorithm u∗ -HV-Draw, as shown in Lemma 2. If Tk is a moderately large partial tree, then Rk has area equal to (H ′ /nǫk )H ′ ≥ xW ′ H ′ , and if it is a large partial tree, then Rk has area exactly equal to xW ′ H ′ . Thus, if D(xn) ≤ xW ′ H ′ , we can draw Tk within its assigned rectangle. In both Case 1 and Case 2, as shown in Figures 2, 3, 4, and 5, Algorithm DrawTree uses at most 2 extra horizontal channels and 2 extra vertical channels to combine the drawings of the partial trees to obtain a drawing of T . The rectangles assigned to all the partial trees have equal height, namely, H ′ = H − 2. At least two of the partial trees contain n/12 nodes each. Hence, at most three partial trees can get designated as very small or moderately large. 1 We can show that if Tk is a moderately large tree, then it has at most n 1+ǫ nodes 1−ǫ in it, and Wk ≤ n 1+ǫ . Hence, the total area of the rectangles assigned to the 1−ǫ very small and moderately large trees is at most 3 max{n 1+ǫ , log2 n + 4}(H − 2).
Straight-Line Drawings of Binary Trees
331
Thus, the total area within R available for drawing all the large partial trees is 1−ǫ at least W ′ H ′ = (W − 3 max{n 1+ǫ , log2 n + 4} − 2)(H − 2). Therefore, if each large partial tree Tk can be drawn within area xW ′ H ′ , i.e., within its assigned rectangle, then the entire drawing of T can fit within R. 1−ǫ Thus, D(xn) ≤ x(W − 3 max{n 1+ǫ , log2 n + 4} − 2)(H − 2) is a sufficient condition for drawing T within R. Since we are interested in finding D(n), suppose the rectangle R assigned to T has area equal to D(n). Then, because H isthe shorter side of R, H ≤ D(n), and since A = W/H ≤ nǫ , W ≤ nǫ/2 D(n). Substituting W and 1−ǫ H by these bounds in D(xn) ≤ x(W − 3 max{n 1+ǫ , log2 n + 4} − 2)(H − 2) and with some mathematical manipulation, we get that D(xn) ≤ x(D(n) − 1−ǫ (3 max{n 1+ǫ , log2 n+4}+2nǫ/2 +2) D(n)) is a sufficient condition for drawing T within R. Since 1/3 < ǫ < 1, (1−ǫ)/(1+ǫ) and ǫ/2 are both less than 1/2. Hence, 1−ǫ 3 max{n 1+ǫ , log2 n + 4} + 2nǫ/2 + 2 ≤ cnβ , for some constants c and β, where c > 0, and 0 ≤ β < 1/2. Hence, from Theorem 1, we get that D(n) = O(n). Theorem 3 (Main Theorem). Let T be a binary tree with n nodes. Given any number A, where 1 ≤ A ≤ nα , for some constant α, where 0 ≤ α < 1, we can construct in O(n log n) time, a planar straight-line grid drawing Γ of T with O(n) area, and aspect ratio A. Proof. Let ǫ be a constant such that 1 ≤ A ≤ nǫ and 1/3 < ǫ < 1. Assign a rectangle R with area D(n) and aspect ratio A to T , where D(n) is the function defined in the proof of Lemma 5. Note that from the proof of Lemma 5, D(n) = O(n). Construct a drawing Γ of T in R by calling Algorithm DrawTree with T , R and ǫ as input. From Lemmas 3, 4, and 5, Γ will be a planar straight-line grid drawing of T contained entirely within R.
References 1. T. Chan, M. Goodrich, S. Rao Kosaraju, and R. Tamassia. Optimizing area and aspect ratio in straight-line orthogonal tree drawings. Comput. Geom. Theory Appl. to appear. Prel. version in Proc. Graph Drawing’96, LNCS, vol. 1190, pp. 63-75. 2. P. Crescenzi, G. Di Battista, and A. Piperno. A note on optimal area algorithms for upward drawings of binary trees. Comput. Geom. Theory Appl., 2:187-200, 1992. 3. P. Crescenzi, P. Penna, and A. Piperno. Linear-area upward drawings of AVL trees. Comput. Geom. Theory Appl., 9:25–42, 1998. 4. G. Di Battista, P. Eades, R. Tamassia, and I. G. Tollis. Graph Drawing. Prentice Hall, Upper Saddle River, NJ, 1999. 5. A. Garg, M. T. Goodrich, and R. Tamassia. Planar upward tree drawings with optimal area. Internat. J. Comput. Geom. Appl., 6:333–356, 1996. 6. C. E. Leiserson. Area-efficient graph layouts (for VLSI). In Proc. 21st Annu. IEEE Sympos. Found. Comput. Sci., pages 270–281, 1980. 7. C.-S. Shin, S.K. Kim, S.-H. Kim, and K.-Y. Chwa. Area-efficient algorithms for straight-line tree drawings. Comput. Geom. Theory Appl., 15:175–2002, 2000.
332
Ashim Garg and Adrian Rusu
8. L. Trevisan. A note on minimum-area upward drawing of complete and Fibonacci trees. Inform. Process. Lett., 57(5):231–236, 1996. 9. L. Valiant. Universality considerations in VLSI circuits. IEEE Trans. Comput., C-30(2):135–140, 1981.
Some Applications of Orderly Spanning Trees in Graph Drawing⋆ Ho-Lin Chen1 , Chien-Chih Liao1 , Hsueh-I Lu2 , and Hsu-Chun Yen1 1
Department of Electrical Engineering, National Taiwan University Taipei 106, Taiwan, Republic of China [email protected], [email protected] [email protected], http://www.ee.ntu.edu.tw/˜yen/ 2 Institute of Information Science, Academia Sinica Taipei 115, Taiwan, Republic of China [email protected], http://www.iis.sinica.edu.tw/˜hil/
Abstract. Orderly spanning trees seem to have the potential of becoming a new and promising technique capable of unifying known results as well as deriving new results in graph drawing. Our exploration in this paper provides new evidence to demonstrate such a potential. Two applications of the orderly spanning trees of plane graphs are investigated. Our first application deals with Podevs drawing, i.e., planar orthogonal drawing with equal vertex size, introduced by F¨ oßmeier and Kaufmann. Based upon orderly spanning trees, we give an algorithm that produces a Podevs drawing with half-perimeter no more than 3n + 1 and at most 2 one bend per edge for any n-node plane graph with maximal degree ∆, a notable improvement over the existing results in the literature in terms of the size of the drawing area. The second application is an alternative proof for the sufficient and necessary condition for a graph to admit a rectangular dual, i.e., a floor-plan using only rectangles.
1
Introduction
Graph drawing has emerged as an exciting and fast growing area of research in the computer science community in recent years [10]. Among various techniques for drawing planar graphs, the canonical orderings of triconnected plane graphs have served as a fundamental step upon which many drawing algorithms are built [6, 9, 12, 15, 16, 18, 19]. The work by de Fraysseix, Pach and Pollack [9] is considered to be the first using the canonical orderings to produce straight-line drawings with polynomial sizes for planar graphs. The technique of canonical orderings has subsequently been applied to drawing graphs with respect to a variety of aesthetic constraints, including straight-line, convexity, orthogonality, 2-visibility, floor-planning, among others. Alternatively, Schnyder [32] introduced the concept of realizers which provides an interesting characterization for vertices and edges in triangulated planar graphs. Applications of realizers to graph drawing can be found in [8, 32], for instance. ⋆
Research supported in part by NSC Grant 90-2213-E-002-100.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 332–343, 2002. c Springer-Verlag Berlin Heidelberg 2002
Some Applications of Orderly Spanning Trees in Graph Drawing
333
Fig. 1. (a) A plane triangulation G, where an orderly spanning tree T of G rooted at node 1 is drawn in dark. The node labels show the counterclockwise preordering of the nodes in T . (b) A Podevs drawing of G. (c) A floor-plan of G.
(a)
(b)
(c)
(d)
Fig. 2. Module types: (a) I-module, (b) L-module, (c) T-module, and (d) Z-module.
Recently, Chiang, Lin, Lu [5] introduced the concept of orderly spanning trees for planar graphs, extending that of canonical ordering for plane graphs not required to be triconnected and that of realizer for plane graphs not required to be triangulated. In fact, for a plane triangulation G, (i) if T is an orderly spanning tree of G, then the counterclockwise preordering of the nodes of T is always a canonical ordering of G, and (ii) if (T1 , T2 , Tn ) is a realizer of G, where Ti is rooted at vi for each i = 1, 2, n, then each Ti plus both external edges of G incident to vi is an orderly spanning tree of G. In addition, orderly spanning trees of planar graphs can be computed in linear time [5]. In light of their recent success in establishing floor-planning [23] and 2-visibility drawing [5], we feel that orderly spanning trees have the potential of becoming a new and promising technique capable of unifying known results as well as deriving new results in graph drawing. Along this line of research, in this article we demonstrate two additional applications of orderly spanning trees in graph drawing, namely, Podevs drawing and rectangular dual. For more about the applications of ordering spanning trees, the interested reader is referred to [5] for succinct graph encoding and [24] for the design of compact routing tables. Our first application of orderly spanning tree is concerned with Podevs drawings of planar graphs, introduced by F¨ oßmeier and Kaufmann [13]. In Podevs drawings, all vertices are given as identical k × k squares, with the size k de-
334
Ho-Lin Chen et al.
termined appropriately. Edges are routed as axis-parallel paths along the grid lines. See Figure 1(b) for an illustration. Let ∆ be the degree of the input n-node m-edge planar graph. F¨ oßmeier and Kaufmann [13] gave a linear-time algorithm for computing a (∆ + 1)n × (∆ + 1)n Podevs drawing with at most 2m bends.1 They also gave an O(n2 log n)-time algorithm, extending from Tamassia’s classic result [35], that computes a Podevs drawing with minimum number of bends.2 Bonichon, Le Sa¨ec and Mosbah [4] gave a linear-time algorithm to obtain a (∆ − 1)(n − 2) × (∆ − 1)(n with at most one bend per edge. ∆ − 1) Podevs ∆drawing They also provided a (n − 2) × (n − 1) Podevs drawing with at most 2 2 3m bends. Based upon orderly spanning trees, we give a linear-time algorithm 2 to produce a Podevs drawing with half-perimeter (i.e., height plus width) no more than ( 3n + 1)∆ and at most one bend per edge, a notable improvement 2 over [4, 13] in terms of the drawing area.3 Our second application has to do with floor-planning planar graphs. Floorplanning [25, 36], a fundamental step in VLSI chip design, refers to the process of, given a graph whose nodes (respectively, edges) representing functional entities (respectively, interconnections), partitioning a rectangular chip area into a set of non-overlapping rectilinear polygonal modules (each of which describes a functional entity) in such a way that the modules of adjacent nodes share a common boundary. For example, Figure 1(c) is a floor-plan of the graph in Figure 1(a). For floor-planning general plane graphs, Yeap and Sarrafzadeh [37] showed that rectilinear modules with at most two concave corners are sufficient and necessary. He [15], measuring the complexity of a module in terms of the number of its constituent rectangles, presented a linear-time algorithm to construct a floor-plan of a plane triangulation using modules, each of which is a union of two disjoint rectangles (called 2-rectangular modules). More recently, Liao, Lu and Yen [23] used orderly spanning trees to demonstrate a linear-time algorithm to layout, given an n-node plane triangulation, a floor-plan in an using three basic modules, namely, I-module, area bounded by (n − 1) × 2n+1 3 L-module, and T-module depicted in Figures 2(a), 2(b), and 2(c), respectively. (He’s algorithm [15] may produce a floor-plan containing Z-modules as shown in Figure 2(d).) A floor-plan using only rectangles to represent nodes is called a rectangular dual. It was shown in [20–22] that an internally triangulated plane G admits a rectangular dual if and only if G has four exterior nodes, and G has no 1
2
3
The area bound mentioned in [13] is 2(∆ + 1)n × (∆ + 1)n, which has to do with the 2n × n straight-line drawing of [7]. Using an n × n straight-line drawing of G (e.g., [32]), the area bound of [13] can be reduced by a factor of two. The optimality for the number of bends has to do with an additional property required by the drawing. That is, each nontrivial face should occupy a nonempty region in the drawing, which is for putting the labels of faces. Such a drawing is called a Podevsnef drawing, standing for planar orthogonal drawing with equal vertex size and none-empty face. Very recently, Mutzel and Weiskircher [28] resorted to integer programming to minimize the number of bends in such a drawing. Under slightly modified conditions, e.g., the nodes need not be of the same size, there are efficient algorithms producing more compact orthogonal drawings [1–3, 11, 12, 30].
Some Applications of Orderly Spanning Trees in Graph Drawing
335
separating triangles.4 In this paper, we are able to provide an alternative proof, based upon orderly spanning trees, for the above sufficient and necessary condition for a graph to admit rectangular dual. Aside from offering a simpler proof in comparison with that of [36, 37], we feel that our exploration might lead to new algorithms and characterization for the so-called slicible floor-plans [29, 34], i.e., those obtainable by means of horizontal or vertical cuts. As we shall see later, our exploration also leads to a simple way of achieving proper box rectangular drawing of [16, 31]. The remainder of this paper is organized as follows. Section 2 gives the preliminaries. Section 3 presents our Podevs drawing algorithm. Section 4 shows the sufficient and necessary condition for a planar graph that admits a rectangular dual. Section 5 concludes the paper with future work and some comments on applying rectangular-dual algorithms to obtaining proper box-rectangular drawing.
2
Preliminaries
A plane graph is a planar graph equipped with a fixed planar embedding. The embedding of a plane graph divides the plane into a number of connected regions, each of which is called a face. The unbounded face of G is called the exterior face, whereas the remaining faces are interior faces. G is a plane triangulation if G has at least three nodes and the boundary of each face, including the exterior face, of G is a triangle. Let T be a rooted spanning tree of a plane graph G. Two nodes are unrelated in T if they are distinct and neither of them is an ancestor of the other in T . An edge of G is unrelated with respect to T if its endpoints are unrelated in T . Let v1 , v2 , . . . , vn be the counterclockwise preordering of the nodes in T . A node vi is orderly in G with respect to T if the neighbors of vi in G form the following four blocks in counterclockwise order around vi : B1 (vi ): B2 (vi ): B3 (vi ): B4 (vi ):
the the the the
parent of vi , unrelated neighbors vj of vi with j < i, children of vi , and unrelated neighbors vj of vi with j > i,
where each block could be empty. T is an orderly spanning tree of G if v1 is on the boundary of G’s exterior face, and each vi , 1 ≤ i ≤ n, is orderly in G with respect to T . It is not difficult to see that if G is a plane triangulation, then B2 (vi ) (respectively, B4 (vi )) is nonempty for each i = 3, 4, . . . , n (respectively, i = 2, 3, . . . , n − 1. For each i = 2, 3, . . . , n, let p(i) be the index of the parent of vi in T . Let w(i) denote the number of leaves in the subtree of T rooted at vi . Let ℓ(i) and r(i) be the functions such that vℓ(i) (respectively, vr(i) ) is the last (respectively, first) neighbor of vi in B2 (vi ) (respectively, B4 (vi )) in counterclockwise order around vi . For example, in the example shown in Figure 1(a), 4
A separating triangle, which is also known as complex triangle [36, 37], is a cycle of three edges enclosing some nodes in its interior. For example, (2, 3, 5) and (8, 10, 12) are two separating triangles of the graph shown in Figure 1(a).
336
Ho-Lin Chen et al.
one can easily verify that node 3 is indeed orderly with respect to T , where B1 (3) = {1}, B2 (3) = {2}, B3 (3) = {4, 5}, B4 (3) = {6, 9}, p(3) = 1, w(3) = 2, ℓ(3) = 2, and r(3) = 9. When G is a plane triangulation, it is known [5] that for each edge (vi , vj ) of G − T with i < j, at least one of i = ℓ(i) and j = r(i) holds. To be more specific, if i = 2 and j = n, then both 3 = ℓ(n) and n = r(3) hold; otherwise, precisely one of i = ℓ(i) and j = r(i) holds. The following lemma is an important property of orderly spanning tree. Lemma 1 (see [5]). Given an n-node span plane triangulation G, an orderly 5 leaves is obtainable in O(n) time. ning tree T of G with at most 2n+1 3 A floor-plan F of G is a partition of a rectangle into n non-overlapping rectangular modules r1 , r2 , . . . , rn such that vi and vj are adjacent in G if and only if the boundaries of ri and rj share at least one non-degenerated line segment. The size of F is the area of the rectangle being partitioned by F with the convention that the corners of all modules are placed on integral grid points. For example, the size of the floor-plan shown in Figure 1(c) is 8 × 7. Based upon Lemma 1, Liao, Lu, and Yen [23] gave a linear-time algorithm for obtaining floor-plans for plane triangulations with the best known worst-case size. Lemma 2 (see [23]). Given an n-node plane triangulation G with n ≥ 3, a floor-plan F of G can be constructed in O(n) time such that F consists of Imodules, L-modules, and T-modules only. The size of F is at most (n − 1) × 2n+1 . 3
3
Podevs Drawings
The following corollary of Lemma 2 shows how to obtain a Podevs drawing from the output floor-plan of [23]. Corollary 1. Let G be an n-node internally triangulated plane graph with at least four vertices on the external boundary of G. Let a and b be two nodes of G ∆ Podevs on the external boundary of G. Then, G admits an (n − 1)∆ × 2n+1 3 drawing with at most one bend per edge. Moreover, nodes a and b on the external cycle have only upward edges except edge (a, b). Proof. (sketch) We first compute a floor-plan as guaranteed by Lemma 2. Now for each module, we place a unit square at a position that is visible to all points in the module. It is not difficult to see that one can connect the squares corresponding to two adjacent nodes in G by a line with one bend such that no two edges intersect each other. The corollary can be obtained by enlarging the above drawing by a factor of ∆. For example, the Podevs drawing in Figure 1(b) is obtained this way. 2n−f +1 5 Recently, Mosbah, Bonichon, and Le Sa¨ec [26] proved a tighter bound on 3 the number of leaves in an orderly spanning tree from the viewpoint of realizers, where f is the number of “cyclic faces” in a realizer of G. In the extreme cases, f could be O(1).
Some Applications of Orderly Spanning Trees in Graph Drawing
337
Let G be a plane triangulation on n nodes v1 , v2 , . . . , vn−1 , r, where r belongs to the external boundary of G, such that (r, vi ) is an edge of G for each i = 1, 2, . . . , n − 1. Let Ga,b denote the subgraph of G induced by r, va , va+1 , . . . , vb . We have the following two lemmas. Let h(Γ ) (respectively, w(Γ ) and hw(Γ )) denote the number x such that x∆ is the required height (respectively, width and half-perimeter) of the drawing Γ . Lemma 3. G has a Podevs drawing Γ with w(Γ ) ≤ (n − 1), h(Γ ) ≤ n2 + 1 that has at most one bend per edge. Moreover, if n is odd, then nodes r, v1 , vn−1 and edge (r, vn−1 ) occupy the four corners of Γ ; otherwise, nodes r, v1 , edge (v1 , vn−1 ), and edge (vn−1 , r) occupy the four corners of Γ . Proof. (sketch) We prove the lemma by induction on n. Clearly, the lemma holds trivially for n = 4 and n = 5. As for the induction step, consider the case that k is odd. We first find the index i such that vi is connected to both v1 and vk−1 . If i = 2 or i = k − 2, then we may assume without loss of generality that i is odd. By the inductive hypothesis, we can obtain drawings of G1,i and Gi,n−1 with total width no more than k − 1 whose maximum height is at most k2 . Now we combine the graphs to get the drawing of G, as shown in Figure 3(a). If i = 2, then we can draw Gi,k−1 and add v −1 nodes properly, each increasing the width by one, to get Γ , as shown in Figure 3(b). The case i = k − 2 is similar. The case that k is even can be proved similarly. Lemma 4. Ga,b has a Podevs drawing Γ with hw(Γ ) ≤ (n − 1) + n2 + 1 that contains at most one bend per edge. The other two nodes a and b on the external cycle has only upward edges except edge (a, b) and are on consecutive corners of the drawing. Proof. (sketch) If i = 2 or i = k − 2, find the node vi such that vi is adjacent to all three nodes on the external boundary. Without loss of generality, we may assume i ≥ (k − 1)/2. By Corollary 1, we can find a drawing D1 of Gi,k−2 with h(D1 ) ≤ k−i and w(D1 ) ≤ k−i such that r and vi are on two consecutive corners. Let j = 1 be the smallest number such that vi and vj are connected.By Lemma 3, + 2 such we have a drawing D2 of Gj,i with w(D2 ) ≤ i − j + 1 and h(D2 ) ≤ i−j 2 that r, vj , vi are three consecutive corners of D2 . Combining the two drawings and adjust the position ofr, vi , and v1 properly, we can get a drawing Dk of G with hw(D) ≤ k − i + i−j + 1 + i − j + 1 + j ≤ k + i−j + 2 ≤ (k − 1) + 2 + 2. 2 2 The second equality holds only when j = 2 and the third equality holds only when i = k − 2. If i = k − 2 or j = 2, then the hw(D) ≤ (k − 1) + k2 + 1. If i = k − 2 and j = 2, then by Lemma 3 we can draw Gj,i in a (k − 3) × k2 area. If k is even, then we can add v1 and vi such that the width and height of the drawing are increased by 2 and 1, respectively. If k is odd, then we can add v1 and vi such that the width and height of the drawing are both increased by 2. In both cases, we have hw(D) ≤ (k − 1) + k2 + 1. Theorem 1. Any n-node plane graph G has a Podevs drawing 2nwith half-peri+1)(∆−1) and width no more than ( meter no more than ( 3n 2 3 +1)(∆−1).
Ho-Lin Chen et al.
338
r
r
r
(a)
r
r
(b)
Fig. 3. (a) The left drawing is for G1,i , the middle drawing is for Gi,n−1 , and the right drawing is the combined one. (b) The left drawing is for G1,n−2 and the right drawing is the resulting drawing of adding one node.
Proof. (sketch) Find an orderly spanning tree T of G. Let the number of leaves of T be m. A cluster of leaves in T is a maximum set of connected leaves of T with the same parent in T . If m ≤ n/2, then the drawing obtained from the original floor-plan satisfies the requirement. Otherwise, by Corollary 1, we can get a drawing Γ of G with w(Γ ) ≤ m and h(Γ ) ≤ n−1. Using Lemma 4, for each cluster of the leaves, we can adjust the drawing Γ such that a cluster of t tleaves +1−4 = t+ 2 +1. in an area with half-perimeter bounded by (t+3−1)+ t+3 2 The half-perimeter of the drawing is at most n − m/2 + m + Ne + No /2, where Ne is the number of clusters with even number of leaves and No is the number of clusters with odd number of leaves. For any two clusters C1 and C2 of leaves, we say that C1 is an ancestor of C2 if an ancestor of C2 is connected to some leaves in C1 . If C1 is an ancestor of C2 and the number of leaves in C2 is more than one, then let the parent of C2 be N2 , we can reduce the width by 1 by shifting the subtree rooted at N2 . If for two clusters Ci and Cj , we cannot find a sequence of clusters Ci , Ci+1 , · · · , Cj such that Ca is an ancestor of Ca+1 , for all a, then the height of the drawing can be reduced by 1 since the two clusters may share the same level of the Podevs drawing. Suppose the sequence of clusters that has the maximum height is S. We know that the half-perimeter of the drawing is at most n−m/2+m+Ne (S)+No (S)/2−Nt (S) ≤ 3n + 1, where Ne (S) is the number of clusters in S that has even number of 2 leaves, No (S) is the number of clusters in S that has odd number of leaves, and Nt (S) is the number of clusters in S that has at least two leaves. Since the width of the drawing in Lemma 3 is at most n−1. The above operations do not increase the width of the drawing. Therefore, the width of the drawing is at most m. By Lemma 2, we can find the desired drawing of the graph. Now we expand each node by the same factor. One problem occurs when there is a straight edge connecting two nodes such that two nodes cannot put in the same level, see Figure 4. We define a new notation: for a node N in the graph, edge-right-bend-up(N ) is the number of edges attach to the right-hand side of the node N and have an upward bend. (Similar for others.) The rest of the proof shows that The graph can be properly rearranged such that the node size is smaller than (∆ − 1) × (∆ − 1). The only problem occurs when there is a straight edge connecting two nodes. According to our algorithm, one node will have more than one downward edges
Some Applications of Orderly Spanning Trees in Graph Drawing
339
A A
B
B
Fig. 4.
if and only if its children are leaves which have already been rearranged. In this case, there is no downward straight edge. Otherwise, the node has only one downward edge and can be attached to any point of the node. So, we can always arrange the downward straight edge to satisfy the constraint that the node size is smaller than (∆ − 1) × (∆ − 1). Consider the case where two nodes A and B are connected by a horizontal straight edge and edge-right-bend-up(A) + 1 + edge-left-bend-down(B) ≥ ∆ − 1. (See Figure 4). Rearrange edge-right-bend-up(A)+edge-left-bend-down(B)−∆+1 of the nodes connecting to A such that the edges are connected to the upward side of the node A and bends toward right. (As shown in Figure 4.) This change may increase the height of the graph at most edge-right-bend-up(A) but can always be compensated since there are edge-right-bend-up(A) nodes connecting to A and edge-left-bend-down(B) nodes connecting to B that can share columns and hence decrease the width of the graph by the minimum of edge-right-bend-up(A) and edge-left-bend-down(B).
4
Rectangular Dual
This section gives an alternative proof for the following theorem. Theorem 2. Every internally triangulated plane graph G without complex triangle has a rectangular dual if and only if G has at least four vertices on the external boundary of G. For a internally triangulated plane graph G and a node r and at least three other nodes on the external cycle, let floor-plan(G, r) be a floor-plan of G consisting of I-modules, L-modules, and T-modules such that r completely occupies one of its four sides. By Lemma 2, such a floor-plan can be obtained in linear time. In such a floor-plan, the level of a node v, denoted ℓ(v), is defined as the distance between the bottom boundaries of r and v. For example, we have ℓ(1) = 0, ℓ(7) = 1, ℓ(8) = 2, and ℓ(5) = 6 in the floor-plan shown in Figure 1(c). Lemma 5. If a plane graph G is internally triangulated and has no complex triangle, then for any three consecutive nodes a, r, b on the external cycle of G, there is a rectangular dual of G with a, r, b completely occupying three sides of the drawing. Proof. (sketch) We prove the theorem by induction on the number of nodes in G. Clearly, the theorem holds trivially if G has at most three nodes. Suppose
340
Ho-Lin Chen et al.
Fig. 5. An illustration for our algorithm for rectangular dual.
for any plane graph G with less than n nodes, the theorem holds. For a graph G with n nodes and nodes a, r, b specified on the external cycle, we can find a rectangular dual by the following process. Step 1. Triangulate G so that (a, r, b) is the external boundary of the triangulated graph. Step 2. By computing floor-plan(G, r), we get a floor-plan F of G consisting of only L-modules and T-modules. We then repeat the following three steps until all nodes are picked and processed in Step 3. Step 3. Choose the node N1 having the lowest level among all L-module and T-module nodes. Without loss of generality, we may assume that N1 bends to the right, the node at the right-hand side of N1 is N2 , and the parents of N1 , N2 are N0 , N3 , respectively, as shown in Figure 5(a). Step 4. If ℓ(N0 ) < ℓ(N3 ), then draw a horizontal line L at the bottom of N3 . Let G1 be the subgraph of G induced by all nodes surrounded by N1 , N2 , N3 and L. By the induction hypothesis, we can find a rectangular dual R1 of G1 such that N1 , N2 , N3 completely occupy the remaining three sides of R1 . Adjust R1 such that the four corners of R1 are N1 , N1 , N2 , and N3 respectively. Expand R1 and F so that all the nodes on the external cycle of R1 have the same size in two graphs. Replace the subgraph G1 in F by expanding R1 . Step 5. If ℓ(N3 ) < ℓ(N0 ), then draw a horizontal line L at the bottom of N0 . Let G2 be the subgraph of G induced by all nodes surrounded by N0 , N1 , N2 and L. By the inductive hypothesis, we can find a rectangular dual R2 of G2 such that N0 , N1 , N2 are three sides of R2 . Adjust R2 such that the four corners of R2 belong to N0 , N1 , N2 , N2 , respectively. Expand R2 and F so that all the nodes on the external cycle of R2 have the same size in two graphs. Replace the subgraph G2 in F by expanding R2 . Since we maintain the property stated in Step 2 and the number of bends is reduced by 1 each time, we can get a rectangular dual of G in O(n) iterations.
Some Applications of Orderly Spanning Trees in Graph Drawing 1
2
1
2
341
1
A
2
A 3
3
4
3
4
4
Fig. 6. An illustration for using rectangular duals to obtain proper box rectangular drawings.
5
Concluding Remarks
In conventional floor-planning, two rectangles are may be adjacent even if the two modules corresponding to them do not have interconnections. Such unwanted adjacencies are not desirable in some other floor-planning problem. In floorplanning of a Multi-chip Module (MCM), two chips generating excessive heat should not be adjacent, or two chips operating on high frequency should not be adjacent to avoid malfunctioning due to their interference [33]. Unwanted adjacencies may cause a dangerous situation in some architectural floor-planning, too [14, 16, 31]. A box-rectangular drawing [31] has the nice property of avoiding unwanted adjacency of modules, but may draw some vertices as points. A proper box rectangular drawing, introduced by He [16], requires every vertex to be drawn as a real box. A rectangular-dual algorithm gives an alternative way for obtaining a proper box rectangular drawing. First of all, we add a new vertex v into each nontriangular internal face F of the given biconnected graph G with at least four nodes on the external boundary. We then triangulate F by adding an edge from v to each node on the boundary of F . G becomes a triangular plane graph G′ . We then obtain a rectangular dual D′ for G′ . A proper box rectangular drawing D of G can be obtained from D′ by turning the module for each newly introduced vertex into a dead space. Clearly, two rectangles are always adjacent if and only if the two modules corresponding to them have interconnections in G and G′ . See Figure 6 for an example. An interesting possibility for future work is to see whether orderly spanning trees play any constructive role in characterizing slicible floor-plans. It would also be interesting to close the gap between the upper and lower bounds for Podevs drawing for planar graphs, and to see whether new results concerning Podevs drawing with two or more bends can be derived.
References 1. P. Bertolazzi, G. Di Battista, and W. Didimo. Computing orthogonal drawings with the minimum number of bends. IEEE Transactions on Computers, 49(8):826– 840, 2000. 2. T. Biedl and M. Kaufmann. Area-efficient static and incremental graph drawings. In Proceedings of the 5th European Symposium on Algorithms, Lecture Notes in Computer Science 1284, pages 37–52. Springer-Verlag, 1997.
342
Ho-Lin Chen et al.
3. T. Biedl, B. Madden, and I. Tollis. The three-phase method: A unified approach to orthogonal graph drawing. International Journal of Computational Geometry and Applications, 10(6):553–580, 2000. 4. N. Bonichon, B. Le Sa¨ec, and M. Mosbah. Orthogonal drawings based on the stratification of planar graphs. In Proceedings of the 6th International Conference on Graph Theory, Electronic Notes in Discrete Math 5, Marseille, France, 2000. Elsevier. A full version can be found at http://citeseer.nj.nec.com/bonichon00orthogonal.html. 5. Y.-T. Chiang, C.-C. Lin, and H.-I. Lu. Orderly spanning trees with applications to graph encoding and graph drawing. In Proceedings of the 12th Annual ACM-SIAM Symposium on Discrete Algorithms, pages 506–515, Washington, D. C., USA, 7–9 Jan. 2001. A revised and extended version can be found at http://xxx.lanl.gov/abs/cs.DS/0102006. 6. M. Chrobak and G. Kant. Convex grid drawings of 3-connected planar graphs. International Journal of Computational Geometry & Applications, 7(3):211–223, 1997. 7. M. Chrobak and T. H. Payne. A linear-time algorithm for drawing a planar graph on a grid. Information Processing Letters, 54(4):241–246, May 1995. 8. H. de Fraysseix, P. Ossona de Mendez, and P. Rosenstiehl. On triangle contact graphs. Combinatorics, Probability and Computing, 3:233–246, 1994. 9. H. de Fraysseix, J. Pach, and R. Pollack. How to draw a planar graph on a grid. Combinatorica, 10:41–51, 1990. 10. G. di Battista, P. Eades, R. Tammassia, and I. Tollis. Graph Drawing: Algorithms for the Visualization of Graphs. Prentice Hall, 1998. 11. M. Eiglsperger and M. Kaufmann. Fast compaction for orthogonal drawings with vertices of prescribed size. In Mutzel et al. [27], pages 124–138. 12. U. F¨ oßmeier, G. Kant, and M. Kaufmann. 2-visibility drawings of planar graphs. In S. North, editor, Proceedings of the 4th International Symposium on Graph Drawing, Lecture Notes in Computer Science 1190, pages 155–168, California, USA, 1996. Springer-Verlag. 13. U. F¨ oßmeier and M. Kaufmann. Drawing high degree graphs with low bend numbers. In S. Whitesides, editor, Proceedings of the 3th International Symposium on Graph Drawing, Lecture Notes in Computer Science 1027, pages 254–266, Passau, Germany, 1995. Springer-Verlag. A full version: Technical Report WSI-95-21, Wilhelm-Schickard-Institut Universit¨ at T¨ ubingen, 1995. 14. R. L. Francis and J. A. White. Facility layout and location. Prentice-Hall, New Jersey, 1974. 15. X. He. On floor-plan of plane graphs. SIAM Journal on Computing, 28(6):2150– 2167, 1999. 16. X. He. A simple linear time algorithm for proper box rectangular drawings of plane graphs. Journal of Algorithms, 40(1):82–101, 2001. 17. O. H. Ibarra and L. Zhang, editors. Proceedings of the 8th International Conference on Computing and Combinatorics, Lecture Notes in Computer Science 2387, Singapore, August 15–17 2002. Springer. 18. G. Kant. Drawing planar graphs using the canonical ordering. Algorithmica, 16(1):4–32, 1996. 19. G. Kant and X. He. Regular edge labeling of 4-connected plane graphs and its applications in graph drawing problems. Theoretical Computer Science, 172(12):175–193, 1997. 20. K. Ko´zmi´ nski and E. Kinnen. Rectangular duals of planar graphs. Networks, 15(2):145–157, 1985.
Some Applications of Orderly Spanning Trees in Graph Drawing
343
21. K. A. K´ ozmi´ nski and E. Kinnen. Rectangular dualization and rectangular dissections. IEEE Transactions on Circuits and Systems, 35(11):1401–1416, 1988. 22. Y. T. Lai and S. M. Leinwand. A theory of rectangular dual graphs. Algorithmica, 5(4):467–483, 1990. 23. C.-C. Liao, H.-I. Lu, and H.-C. Yen. Floor-planning via orderly spanning trees. In Mutzel et al. [27], pages 367–377. 24. H.-I. Lu. Improved compact routing tables for planar networks via orderly spanning trees. In Ibarra and Zhang [17], pages 57–66. 25. K. Mailing, S. H. Mueller, and W. R. Heller. On finding most optimal rectangular package plans. In Proceedings of the 19th Annual IEEE Design Automation Conference, pages 263–270, 1982. 26. M. Mosbah, N. Bonichon, and B. Le Sa¨ec. Wagner’s theorem on realizers. In M. Hennessy and P. Widmayer, editors, Proceedings of the 29th International Colloquium on Automata, Languages, and Programming, Lecture Notes in Computer Science 1443, pages 1043–1063, M´ alaga, Spain, 2002. Springer-Verlag. 27. P. Mutzel, M. J¨ unger, and S. Leipert, editors. Proceedings of the 9th International Symposium on Graph Drawing, Lecture Notes in Computer Science 2265, Vienna, Austria, 2001. Springer. 28. P. Mutzel and R. Weiskircher. Bend minimization in orthogonal drawings using integer programming. In Ibarra and Zhang [17], pages 484–493. 29. R. Otten. Efficient floorplan optimization. In Proceedings of International Conference on Computer Design, pages 499–503, Port Chester, New York, 1983. 30. A. Papakostas and I. G. Tollis. Efficient orthogonal drawings of high degree graphs. Algorithmica, 26(1):100–125, 2000. 31. M. S. Rahman, S. Nakano, and T. Nishizeki. Box-rectangular drawings of plane graph. In Proceedings of the 21st Graph-Theoretic Concepts in Computer Science, Lecture Notes in Computer Science 1272, pages 250–261. Springer-Verlag, 1999. 32. W. Schnyder. Embedding planar graphs on the grid. In Proceedings of the First Annual ACM-SIAM Symposium on Discrete Algorithms, pages 138–148, 1990. 33. N. Sherwani. Algorithms for VLSI physical design automation. Kluwer Academic Publishers, 1995. 34. L. Stockmeyer. Optimal orientation of cells in slicing floorplan designs. Information and Control, 57(2):91–101, 1983. 35. R. Tamassia. On embedding a graph in the grid with the minimum number of bends. SIAM Journal on Computing, 16(3):421–444, 1987. 36. S. Tsukiyama, K. Koike, and I. Shirakawa. An algorithm to eliminate all complex triangles in a maximal planar graph for use in VLSI floorplan. In Proceedings of the IEEE International Symposium on Circuits and Systems, pages 321–324, 1986. 37. K.-H. Yeap and M. Sarrafzadeh. Floor-planning by graph dualization: 2-concave rectilinear modules. SIAM Journal on Computing, 22(3):500–526, 1993.
Improving Walker’s Algorithm to Run in Linear Time Christoph Buchheim1 , Michael J¨ unger1 , and Sebastian Leipert2 1
Universit¨ at zu K¨ oln, Institut f¨ ur Informatik, Pohligstraße 1, 50969 K¨ oln, Germany {buchheim,mjuenger}@informatik.uni-koeln.de 2 caesar research center, Friedensplatz 16, 53111 Bonn, Germany [email protected]
Abstract. The algorithm of Walker [5] is widely used for drawing trees of unbounded degree, and it is widely assumed to run in linear time, as the author claims in his article. But the presented algorithm clearly needs quadratic runtime. We explain the reasons for that and present a revised algorithm that creates the same layouts in linear time.
1
Introduction
Since Walker presented his article [5] on drawing rooted ordered trees of unbounded degree, this topic is considered a solved problem of Automatic Graph Drawing. In 1979, Wetherell and Shannon [6] presented a linear time algorithm for drawing binary trees satisfying the following aesthetic requirements: the y-coordinate of a node corresponds to its level, so that the hierarchical structure of the tree is displayed; the left child of a node is placed to the left of the right child, i.e., the order of the children is displayed; finally, each parent node is centered over its children. Nevertheless, this algorithm showed some deficiencies. In 1981, Reingold and Tilford [2] improved the Wetherell-Shannon algorithm by adding the following feature: each pair of isomorphic subtrees is drawn identically up to translation, i.e., the drawing does not depend on the position of a subtree within the complete tree. They also made the algorithm symmetrical: if all orders of children in a tree are reversed, the computed drawing is the reflected original one. The width of the drawing is not always minimized subject to these conditions, but it is close to the minimum in general. The algorithm of Reingold and Tilford runs in linear time, too. Extending this algorithm to rooted ordered trees of unbounded degree in a straightforward way produces layouts where some subtrees of the tree may get clustered on a small space, even if they could be dispersed much better. This problem was solved in 1990 by the algorithm of Walker [5], which spaces out subtrees whenever possible. Unfortunately, the runtime of the algorithm presented in [5] is quadratic, in contrary to the author’s assertion. In the present article, we close this gap by giving an adjustment of Walker’s algorithm that does not affect the computed layouts but yields linear runtime. M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 344–353, 2002. c Springer-Verlag Berlin Heidelberg 2002
Improving Walker’s Algorithm to Run in Linear Time
345
In the next section, we establish the basic notation about trees and state the aesthetic criteria guiding the algorithms to be dealt with. In Sect. 3, we explain the Reingold-Tilford algorithm. In Sect. 4, we describe the idea of Walker’s algorithm and point out the non-linear parts. We improve these parts in order to get a linear time algorithm in Sect. 5.
2
Preliminaries
We define a (rooted) tree as a directed acyclic graph with a single source, called the root of the tree, such that there is a unique directed path from the root to any other node. The level of a node is the length of this path. For each edge (v, w), we call v the parent of w and w a child of v. If w1 and w2 are two different children of v, we say that w1 and w2 are siblings. Each node w on the path from the root to a node v is called an ancestor of v, while v is called a descendant of w. A leaf of the tree is a sink of the graph, i.e., a node without children. If v− and v+ are two nodes such that v− is not an ancestor of v+ and vice versa, the greatest distinct ancestors of v− and v+ are defined as the unique ancestors w− and w+ of v− and v+ , respectively, such that w− and w+ are siblings. Each node v of a rooted tree T induces a unique subtree of T with root v. In a binary tree, each node has at most two children. In an ordered tree, a certain order of the children of each node is fixed. The first (last) child according to this order is called the leftmost (rightmost) child. The left (right) sibling of a node v is its predecessor (successor) in the list of children of the parent of v. The leftmost (rightmost) descendant of v on level l is the leftmost (rightmost) node on level l belonging to the subtree induced by v. Finally, if v1 is the left sibling of v2 , w1 is the rightmost descendant of v1 on some level l, and w2 is the leftmost descendant of v2 on the same level l, we call w1 the left neighbor of w2 and w2 the right neighbor of w1 . To draw a tree into the plane means to assign x- and y-coordinates to its nodes and to represent each edge (v, w) by a straight line connecting the points corresponding to v and w. When drawing a rooted tree, one usually requires the following aesthetic properties: (A1) The layout displays the hierarchical structure of the tree, i.e., the ycoordinate of a node is given by its level. (A2) The edges do not cross each other and nodes on the same level have a minimal horizontal distance. (A3) The drawing of a subtree does not depend on its position in the tree, i.e., isomorphic subtrees are drawn identically up to translation. If the trees to be drawn are ordered, we additionally require the following: (A4) The order of the children of a node is displayed in the drawing. (A5) The algorithm works symmetrically, i.e., the drawing of the reflection of a tree is the reflected drawing of the original tree. Here, the reflection of an ordered tree is the tree with reversed order of children for each parent node. Usually, one tries to find a layout satisfying (A1) to (A5) with a small width, i.e., with a small range of x-coordinates.
346
3
Christoph Buchheim, Michael J¨ unger, and Sebastian Leipert
Reingold and Tilford’s Algorithm
For ordered binary trees, the first linear time algorithm satisfying (A1) to (A5) was presented by Reingold and Tilford [2]. This algorithm is easy to describe informally: it draws the tree recursively in a bottom-up sweep. Leaves are placed to an arbitrary x-coordinate and to the y-coordinate given by their level. After drawing the subtrees induced by the children of a parent node independently, the right one is shifted so that it is placed as close to the right of the left subtree as possible.1 Next, the parent is placed centrally above the children, this is, at the x-coordinate given by the average x-coordinate of the children, and at the y-coordinate given by its level. Finally, the edges are inserted. The Reingold-Tilford algorithm obviously satisfies (A1) to (A5). The difficult task is how to perform the steps described above in linear time. The crucial part of the algorithm is the shifting of the second subtree; solving the following problems takes quadratic runtime in total, if a straightforward algorithm is used: first, the computation of the new position of this subtree, second, the shifting of the subtree itself. For the first problem, define the left (right) contour of a tree as the sequence of leftmost (rightmost) nodes in each level, traversed from the root to the highest level. For an illustration, see Fig. 1, where nodes belonging to the contours are shaded. To place the right subtree as close to the left one as possible, we have to compare the positions of the right contour of the left subtree with the positions of the left contour of the right subtree, for all levels occuring in both subtrees. Since each node belongs to the traversed part of the left contour of the right subtree at most for one subtree combination, the total number of such comparisons is linear for the complete tree. The runtime problem is how to traverse the contours without traversing (too many) nodes not belonging to the contours. To solve this problem, Reingold and Tilford introduce threads. For each leaf of the tree that has a successor in the same contour, the thread is a pointer to this successor. See Fig. 1 again, where the threads are represented by dotted arrows. For every node of the contour, we now have a pointer to its successor in the contour: either it is the leftmost (rightmost) child, or it is given by the thread. Finally, to keep the threads up to date, one has to add a new thread whenever two subtrees of different height are combined. For the second problem, the straightforward algorithm would shift all nodes of the right subtree by the same value. Since this needs quadratic time in total, Reingold and Tilford attach a new value mod (v) to each node v, which is called its modifier (this technique was presented by Wetherell and Shannon [6]). The position of each node is preliminary in the bottom-up traversal of the tree. When moving a subtree rooted at v, only mod (v) and a preliminary x-coordinate prelim(v) are adjusted by the amount of shifting. The modifier of a node v 1
For simplicity, we assume throughout this paper that all nodes have the same dimensions and that the minimal distance required between neighbors is the same for each pair of neighbors. Both restrictions can be relaxed easily, since we will always compare a single pair of neighbors
Improving Walker’s Algorithm to Run in Linear Time
347
t
Fig. 1. Combining two subtrees and adding a new thread t
is interpreted as a value to be added to all preliminary x-coordinates in the subtree rooted at v, except for v itself. Thus, the real position of a node is its preliminary position plus the aggregated modifier modsum(v) given by the sum of all modifiers on the path from the parent of v to the root. To compute all real positions in linear time, the tree is traversed in a top-down fashion at the end. When comparing contour nodes to compute the new position of the right subtree, we need the real positions of these nodes, too. For runtime reasons, we may not sum up modifiers on the paths to the root. Therefore, modifiers are used in leaves as well. A modifier of a leaf v with a thread to a node w stores the difference between modsum(w) and modsum(v). Since new threads are added after combining two subtrees, these modifier sums can be computed while traversing the contours of the two subtrees. We have to traverse not only the inside contours but also the outside contours for computing the modifier sums, since v is a node of the outside contour. Now the aggregated modifiers can be computed as the sums of modifiers along the contours instead of the paths to the root.
4
Walker’s Algorithm
For drawing trees of unbounded degree, the Reingold-Tilford algorithm could be adjusted easily by traversing the children from left to right, placing and shifting the corresponding subtrees one after another. However, this violates property (A5): the subtrees are placed as close to each other as possible and small subtrees between larger ones are piled to the left; see Fig. 2(a). A simple trick to avoid this effect is to add an analogous second traversal from right to left; see Fig. 2(b), and to take average positions after that. This algorithm satisfies (A1) to (A5), but smaller subtrees are usually clustered then; see Fig. 2(c). To obtain a layout where smaller subtrees are spaced out evenly, as for example in Fig. 2(d), Walker [5] proposed the following proceeding; see Fig. 3: the subtrees of the current root are processed one after another from left to right. First, each child of the current root is placed as close to the right of its left sibling as possible. As in Reingold and Tilford’s algorithm, the left contour of the current subtree is then traversed top down in order to compare the positions of its nodes to those of their left neighbors. Whenever two conflicting neighbors v− and v+ are detected, forcing v+ to be shifted to the right by an amount of
348
Christoph Buchheim, Michael J¨ unger, and Sebastian Leipert
(a)
(b)
(c)
(d)
Fig. 2. Extending the Reingold-Tilford algorithm to trees of unbounded degree
shift, we apply an appropriate shift to all smaller subtrees between the subtrees containing v− and v+ . More precisely, let w− and w+ be the greatest distinct ancestors of v− and v+ . Notice that both w− and w+ are children of the current root. Let subtrees be the number of children of the current root between w− and w+ plus 1. Spacing out the subtrees is shifting the subtree rooted at the i-th child to the right of w− by an amount of i·shift/subtrees, for i = 1, . . . ,subtrees. Observe that subtrees may be shifted several times by this algorithm, even while adding a single subtree. It is easy to see that this algorithm satisfies (A5).
Fig. 3. Spacing out the smaller subtrees
Unfortunately, many parts of the algorithm presented in [5] do not run in linear time. Some of them are easy to improve, for example by using Reingold and Tilford’s ideas, and some require new ideas. All problems concern Walker’s procedure APPORTION; see pages 695–697 in [5]. In the following, we list the critical parts. In the next section, we will explain how to change these in order to obtain linear runtime. Traversing the right contour: A recursive function GETLEFTMOST is used to find the leftmost descendant of a given node v on a given level l. If the level
Improving Walker’s Algorithm to Run in Linear Time
349
of v is l, the algorithm returns v. Otherwise, GETLEFTMOST is applied recursively to all children of v, from left to right. The aggregated runtime of GETLEFTMOST is not linear in general. To prove that, we present a series of trees Tk such that the number of nodes in Tk is n ∈ Θ(k 2 ), but the total number of GETLEFTMOST calls is Θ(k 3 ). Since k ∈ Θ(n1/2 ), this shows that the total runtime of GETLEFTMOST is Ω(k 3 ) = Ω(n3/2 ). The tree Tk is defined as follows (see Fig. 4(a) for k = 3): Beginning at the root, there is a chain of 2k nodes, each of the last 2k − 1 being the right or only child of its predecessor. For i = 1, . . . , k, the i-th node in this chain has another child to the left; this child is the first node of a chain of 2(k − i) + 1 nodes. The number of nodes in Tk is 2k +
k
(2(k − i) + 1) = 2k + k(k − 1) + k ∈ Θ(k 2 ) .
i=1
Now, for each i = 0, . . . , k − 1, we have to combine two subtrees when visiting the node on the right contour of Tk on level i. In this combination, the highest common level of the subtrees is 2k − i − 1, and by construction of Tk we always have to apply GETLEFTMOST to every node of the right subtree up to this level. The number of these nodes is k−i+
k−i−1
(2j) = (k − i) + (k − i)(k − i − 1) = (k − i)2 ,
j=0
hence the total number of GETLEFTMOST calls for all combinations is k−1 i=0
(k − i)2 =
k
i2 = k(k + 1)(2k + 1)/6 ∈ Θ(k 3 ) .
i=1
Finding the ancestors and summing up modifiers: This part of the algorithm is obviously quadratic. When adjusting the current subtree to the left subforest, the greatest distinct ancestors of the possibly conflicting neighbors are computed for each level by traversing the graph up to the current root, at the same time computing the modifier sums. Since the distance of the levels grows linearly, the total number of steps is in Ω(n2 ). Counting and shifting the smaller subtrees: When shifting the current subtree to the right because of a conflict with a subtree to the left, the procedure APPORTION also shifts all smaller subtrees in-between immediately. Furthermore, the number of these subtrees is computed by counting them one by one. Both actions have an aggregated runtime of Ω(n3/2 ), as the following example shows. Let the tree T k be constructed as follows (see Fig. 4(b) for k = 3): add k children to the root. The i-th child, counted i = 1, . . . , k from left to right, is root of a chain of i nodes. Between each pair of these children, add k children as leaves. The leftmost child of the root has 2k + 5 children, and up to level k − 1, every rightmost child of the 2k+5 children has again 2k+5 children. The number
350
Christoph Buchheim, Michael J¨ unger, and Sebastian Leipert
of nodes of T k is 1+
k
i + (k − 1)k + (k − 1)(2k + 5) ∈ Θ(k 2 ) .
i=1
Furthermore, by construction of the left subtree, adding the i-th subtree chain for i = 2, . . . , k results in a conflict with the left subtree on level i. Hence all (i − 1)(k + 1) − 1 smaller subtrees between the two conflicting ones are counted and shifted. Thus, the total number of counting and shifting steps is k
((i − 1)(k + 1) − 1) = (k + 1)k(k − 1)/2 − k + 1 ∈ Θ(k 3 ) .
i=2
As in the last example, we derive that counting and shifting needs Ω(n3/2 ) time in total.
(a) T3
(b) T 3
Fig. 4. Examples proving the non-linear runtime of Walker’s algorithm
5
Improving Walker’s Algorithm
In this section, we explain how to improve the algorithm of Walker to run in linear time without affecting the computed layouts. For a closer look, see [1], where we present the complete revised algorithm in a pseudocode style as well as an experimental runtime comparison of both versions. Traversing the contours and summing up modifiers: This can be done exactly as in the case of binary trees by using threads; see Sect. 3. The fact that the left subforest is no tree in general does not create any additional difficulty. Finding the ancestors: The problem of finding the greatest distinct ancestors w− and w+ of two nodes v− and v+ can be solved by the algorithm of Schieber and Vishkin [3]. For each pair of nodes, this algorithm can determine the greatest distinct ancestors in constant time, after an O(n) preprocessing step. However,
Improving Walker’s Algorithm to Run in Linear Time
351
in our application, a much simpler algorithm can be applied. First observe that we know the right ancestor w+ anyway; it is just the root of the current subtree. Furthermore, as v+ is always the right neighbor of v− in our algorithm, the left one of the greatest distinct ancestors only depends on v− . Thus we may shortly call it the ancestor of v− in the following. We use a node pointer ancestor (x) for each node x to save its ancestor and initialize it to x itself. Observe that this value is not correct for rightmost children, but we do not need the correct value w− of ancestor (v− ) until the right neighbor v+ of v− is added, i.e., until the current root is the parent node of w− . Hence assume that we are placing the subtrees rooted at the children of v from left to right. Since tracing all ancestor (x) consumes too much time, we use another node pointer defaultAncestor . Our aim is to have the following property (*) for all nodes v− on the right contour of the left subforest after each subtree addition: if ancestor (v− ) is up to date, i.e., is a child of v, then it points to the correct ancestor w− of v− ; otherwise, the correct ancestor is defaultAncestor . We start with placing the first subtree, rooted at w, which does not require any ancestor calculations. After that, we set defaultAncestor to w. Since all pointers ancestor (x) of the left subtree either point to w or to a node of a higher level, the desired property (*) holds, see Fig. 5(a). After placing the subtree rooted at another child w′ of v, we distinguish two cases: if the subtree rooted at w′ is smaller than the left subforest, we can actualize ancestor (x) for all nodes x on its right contour by setting it to w′ . By this, we obviously keep (*); see Fig. 5(b). Otherwise, if the new subtree is larger than the left subforest, we may not do the same because of runtime. But now it suffices to set defaultAncestor to w′ , since again all pointers ancestor (x) of the subtree induced by w′ either point to w′ or to a node of a higher level, and all other subtrees in the left subforest are hidden. Hence we have (*) again; see Fig. 5(c).
(a)
(b)
(c)
Fig. 5. Adjusting ancestor pointers when adding new subtrees: the pointer ancestor (x) is represented by a solid arrow if it is up to date and by a dashed arrow if it is expired. In the latter case, the defaultAncestor is used and drawn black. When adding a small subtree, all ancestor pointers ancestor (x) of its right contour are updated. When adding a large subtree, only defaultAncestor is updated
352
Christoph Buchheim, Michael J¨ unger, and Sebastian Leipert
Counting the smaller subtrees: For that, we just have to number the children of each node consecutively; then the number of smaller subtrees between the two greatest distinct ancestors w− and w+ is the number of w+ minus the number of w− minus 1. Hence it can be computed in constant time (after a linear time preprocessing step to compute all child numbers).
0
0
0
0
0
0
1
0
0
0
1 3
0
0
[− 13 ]
0
0
0
0
0
0
1
1 3
0
0
1
0
[− 13 ] 0
[ 13 + 15 ]
0
0
0
[− 31 ] 0
1 [− 15 ]
Fig. 6. Aggregating the shifts: the top number at node x indicates the value of shift(x), and the bottom number indicates the value of change(x)
Shifting the smaller subtrees: In order to get a linear runtime, we will shift each subtree at most once when it is not the currently added subtree. The currently added subtree, however, may be shifted whenever it conflicts with a subtree to the left, using the fact that shifting a single subtree is done in constant time (recall that we only have to adjust prelim(w+ ) and mod (w+ )). Furthermore, shifting the current subtree immediately is necessary to keep the right contour of the left subforest up to date. All shiftings of non-current subtrees are performed in a single traversal after all subtrees of the current root have been placed. To memorize the shiftings at the moment they arise, we use real numbers shift(x) and change(x) for each node x and set both to zero at the beginning. Assume that the subtree rooted at w+ is the subtree currently placed, and that a conflict with the subtree rooted at w− forces the current subtree to move to the right by an amount of shift. Let subtrees be the number of subtrees between w− and w+ , plus 1. According to Walker’s idea, the i-th of these subtrees has to be moved by i·shift/subtrees. We save this by increasing shift(w+ ) by shift, decreasing change(w+ ) by shift/subtrees, and increasing change(w− ) by shift/subtrees. The interpretation of this is the following: to the left of node w+ , the nodes are shifted by an amount initialized to shift, but this amount starts decreasing by shift/subtrees per subtree at node w+ and ends decreasing at w− , where it is zero. The trick is to aggregate the shifts: since the decrease in the amount of
Improving Walker’s Algorithm to Run in Linear Time
353
shifting is linear, we can add all these decreases in one array; see Fig. 6 for an example. Finally, we execute all shifts in a single traversal of the children of the current root as follows, see Fig. 7: we use two real values shift and change to store the shifts and the decreases of shift per subtree, respectively, and set both to zero at the beginning. Then we traverse the children from right to left. When visiting child v, we move v to the right by shift (i.e., we increase prelim(v) and mod (v) by shift), increase change by change(v), and increase shift by shift(v) and by change. Then we go on to the left sibling of v. It is easy to see that this algorithm shifts each subtree by the correct amount.
0
0
0
1
0
1
[ 31 + 15 ]
0
0
[− 13 ]
0
[− 15 ]
0
[ 15 + 31 ]
[ 25 + 23 ]
3 5
4 5
0
0
[− 15 − 31 ] [− 51 − 13 ] [− 51 − 31 ][− 15 ]
[− 15 ]
Fig. 7. Executing the shifts: the new numbers at node x indicate the values of shift and change before shifting x, respectively
References 1. C. Buchheim, M. J¨ unger, and S. Leipert. Improving Walker’s algorithm to run in linear time. Technical Report zaik2002-431, ZAIK, Universit¨ at zu K¨ oln, 2002. 2. E. Reingold and J. Tilford. Tidier drawings of trees. IEEE Transactions on Software Engineering, 7(2):223–228, 1981. 3. B. Schieber and U. Vishkin. On finding lowest common ancestors: Simplification and parallelization. In Proceedings of the Third Aegean Workshop on Computing, volume 319 of Lecture Notes in Computer Science, pages 111–123, 1988. 4. K. Supowit and E. Reingold. The complexity of drawing trees nicely. Acta Informatica, 18(4):377–392, 1983. 5. J. Walker II. A node-positioning algorithm for general trees. Software – Practice and Experience, 20(7):685–705, 1990. 6. C. Wetherell and A. Shannon. Tidy drawings of trees. IEEE Transactions on Software Engineering, 5(5):514–520, 1979.
Semi-dynamic Orthogonal Drawings of Planar Graphs (Extended Abstract) Walter Bachl sd&m AG, Thomas Dehler-Str. 27, 81837 M¨ unchen [email protected]
Abstract. We introduce a new approach to orthogonal drawings of planar graphs. We define invariants that are respected by every drawing of the graph. The invariants are the embedding together with relative positions of adjacent vertices. Insertions imply only minor changes of the invariants. This preserves the users mental map. Our technique is applicable to two-connected planar graphs with vertices of arbitrary size and degree. New vertices and edges can be added to the graph in O(log n) time. The algorithm produces drawings with at most m+f bends, where m and f are the number of edges and faces of the graph.
1
Introduction
Orthogonal drawings of graphs are used in many applications, e.g. entity-relationship diagrams or VLSI design. They occur in interactive programs like CASE tools, where graphs are built step by step in an interactive session. Clearly the user shall be supported in this task. Such a system should not only create nice drawings. The given layout shall be changed such that the users mental map is preserved ([7,10]). A lot of work has been done on incremental orthogonal layout of non planar graphs ([11,3,9,1]). But we know only one activity in the area of incremental orthogonal layout of planar graphs [2] which is based on [8]. Brandes et al. optimize a combination of static and interactive requirements, this means layout quality and the preservation of the mental map. We introduce a different approach with invariants for the representation of the users mental map. We restrict ourselves to two-connected planar graphs and allow changes of the graph by insertions of vertices and edges. These insertions must preserve planarity, the embedding, and the mental map. Our model is based on the concept of the Kandinsky algorithm [8]. There are unit size vertices with sufficiently many pins on each side to connect arbitrary many edges to the node. In the following, we first define the restrictions R and show how updateoperations change R. We examine the number of bends which can be achieved with this restrictions. This leads to the 4-sector model. Then we show how to implement the update-operations O(log n) and how to generate drawings in O(n) time. M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 354–361, 2002. c Springer-Verlag Berlin Heidelberg 2002
Semi-dynamic Orthogonal Drawings of Planar Graphs
2
355
Restrictions
We consider two-connected planar graphs together with an embedding. Additionally we define restrictions as invariants for insertions. Definition 1. Given a planar graph G(V, E). A restriction system R for G consists of 1. An embedding of the graph. 2. Two attributes e. x and e. y for each edge e = {v1 , v2 } ∈ E. A drawing of G is said to respect R, if it is drawn with the embedding and for each edge e = {v1 , v2 }, if e. x , then v1 has to be left of v2 and if e. y , then v1 has to be below v2 . Both relations are proper. Hence, e. x and e. y have an intuitive meaning. Let G(V, E, R) denote a graph G with vertices V , edges E and the restriction system R. For the semi-dynamic changes we consider the following operations: – initialize(): Create a complete graph of three vertices as initial graph. – insertV ertex(edge e): Replace the edge e = {v1 , v2 } by a new vertex v and the two edges {v1 , v} and {v, v2 }. – insertEdge(vertex v1 , v2 , f ace f ): Insert the edge {v1 , v2 } in the common face f of v1 and v2 . This set of operations is sufficient to produce any two-connected planar graph ([5]). The users mental map is preserved by the following requirements. Definition 2. Let G(V, E, R) be a planar embedded graph with a restriction system, which is transformed to G′ (V ′ , E ′ , R′ ) by an update operation from above. insertEdge(v1 , v2 , f ) is called restriction preserving update operation if: 1. ∀ei ∈ E: ei . x and ei . y are not changed. 2. The embeddings of G(V, E, R) and G′ (V ′ , E ′ \ {e}, R′ ) are identical. insertN ode(e) is called restriction preserving update operation if: 1. ∀ei ∈ E \ {e}: ei . x and ei . y are not changed. 2. The embeddings of G(V, E, R) and G′ (V ′ , E ′ , R′ ) are identical, if the vertex v and the edges e1 and e2 are replaced in G′ by a new edge {v1 , v2 }. 3. e1 and e2 inherit the attributes x and y from e, i.e. {v1 , v}. x = {v, v2 }. x = {v1 , v2 }. x ∧ {v1 , v}. y = {v, v2 }. y = {v1 , v2 }. y .
3
Bounds on the Number of Bends
We introduce the 4-sector model, which will serve as an invariant for our algorithm. From now on we use figures as graphical representations for restriction systems. If {v1 , v2 }. x , then v1 is drawn to the left of v2 . Similary for y .
356
Walter Bachl
Definition 3. A graph with the restriction system G(V,E , R ) is in the 4-sector model if the vertices around every face f are arranged such that it is possible to divide t h e m into four groups, where in -
-
-
-
sector 1, the cyclic successor sector 2, the cyclic successor sector 3, the cyclic successor sector 4, the cyclic successor
of of of of
every every every every
vertex vertex vertex vertex
is is is is
to to to to
its its its its
upper lower lower upper
right, right, left, left.
Note, that every sector can be empty or consist of a single vertex only. Figure 1 shows two graphical representations of faces in the 4-sector model. The ordering of the vertices in the 4-sector model is unique. It is a necessary condition for the insertion of a new edge with at most one bend. Is it also sufficient?
Fig. 1. Two drawings of faces in the sector model.
Lemma 1. There are graphs with a restriction systems R in the 4-sector model, where a restriction preserving update operation i n s e r t E d g e inserts a n edge with (at least) two bends in any orthogonal drawing respecting R. Proof. See Figure 2. Suppose, that by the restriction system R the vertices are in relative positions as shown. T h e n in any drawing of the graph a n edge between vl and ug in f has to be drawn with two bends.
Fig. 2. Orthogonal edge between and v g needs two bends.
vl
Fig. 3. Notations for the proof of Theorem 1.
This is no restriction of the 4-sector model, because two bends are unavoidable.
Semi-dynamic Orthogonal Drawings of Planar Graphs
357
Theorem 1. There are graphs, where a sequence of restriction preserving update operations leads to a graph with a restriction system such that in any orthogonal planar drawing that respects R, at least one edge has at least two bends. This is independent of the initial restriction system. Proof. Consider the vertices v1 and v2 in Figure 3, which shows an embedding. For any restriction system, a connecting edge {v1 , v2 } through at least one of the common faces must have at least two bends. In the remaining faces we connect the two other vertices by an edge. Thus, one common face of v1 and v2 remains, where v1 and v2 can be connected only by an edge with at least two bends.
4
Interactive Algorithm
We show how to implement the update operations in O(log n) and then construct a drawing of a graph with a restriction system in the 4-sector model. initialize() creates a triangle with a restriction system in O(1). 4.1
Insert-Operations
Theorem 2. Given a planar graph with a restriction system R in the 4-sector model. Then insertV ertex(edge e) can be made restriction preserving such that the resulting graph and the restriction system are in the 4-sector model. Proof. The proof is similar to a derivation step in [4]. The edge e is replaced and the new edges inherit x and y from e. See Figure 4 for an illustration. v1
v1 v v2
v2
Fig. 4. Insertion of a new vertex where the partial-order in x-direction is represented by a dashed arrow and the partial-order in y-direction by a dotted arrow.
Theorem 3. Given a planar graph with a restriction system in the 4-sector model. Then insertEdge(v1 , v2 , f ) can be made restriction preserving such that the resulting graph and the restriction system are in the 4-sector model. Proof. The operation insertEdge(v1 , v2 , f ) divides f into two new faces f1 and f2 . The embedding is updated by the insertion of e between the two edges adjacent to v1 and the two edges adjacent to v2 in face f . Hence, the embedding is preserved as required by definition 2.
358
Walter Bachl
Next consider the restrictions. The attributes x and y have to be computed for the new edge. We discuss the main cases. All other cases are similar. If v1 and v2 are in the same sector, then v1 and v2 are ordered in both directions and x and y of the new edge are taken from this ordering. If v2 is in the sector following the sector of v1 , then the vertices are ordered only in one direction and unordered in the other. The given direction is taken by the edge, the other is chosen arbitrarily. Finally, if v1 and v2 are in diagonal sectors of the face (e.g. v1 in sector 1 and v2 in sector 3), then v1 and v2 are unordered in both directions. Because of the geometric properties of the 4-sector model we have one forbidden ordering of the vertices (v1 can not be right and below of v2 ). The algorithm chooses one of the three remaining orderings (e.g. v1 above and left of v2 ). In all cases, this leads to two new faces which inherit a part of the sectors of face f and the new edge serves as part of one sector in both faces. The graph and the restriction system respect the 4-sector model. No dependencies are changed. 4.2
Data Structures and Time Complexity
Our data structure is an extension of a DCEL ([12]) that is commonly used for planar embeddings. The data structures consist of the following attributes: – Edge e: 1. The embedding is stored in a DCEL. Thus every edge has pointers to its cyclic successor and predecessor at both end vertices. 2. x and y are stored in the attributes of each edge. – Face f : 1. vertex[1..4]: vertex[i] is the first vertex of sector i of f . 2. edge[1..4]: edge[i] connects vertex[i] to its cyclic predecessor in f . 3. tree[1..4]: tree[i] is a balanced tree for all vertices in sector i. It supports the operations “insert()”, “navigate()” (traversal from a leaf to the root) and “split()” in logarithmic time. At the root we store the number of the face and the number of the sector. – Vertex v: Every vertex v holds pointers to the edges which end at v in a face f , if v is not the first vertex of a sector in f . The pointers to the edges have a connection to the corresponding face. Since every vertex can be in the middle of a sector in only two faces, two pointers are sufficient. 1. edge[1..2]: edge[i] is a pointer to the edge which connects v to its cyclic predecessor in face fi . 2. leaf [1..2]: leaf [i] is a pointer to a leaf in the tree, which is assigned to the sector in face i which contains vertex v. Theorem 4. The operations insertN ode(e) and insertEdge(v1 , v2 , f ) can be implemented in O(log n) time using a data structure of size O(n). Proof. For insertV ertex(e) the embedding is updated by replacing e by the new edges. Edge e is in two faces. From its end vertices we can access the trees and
Semi-dynamic Orthogonal Drawings of Planar Graphs
359
insert the new vertex in O(log n) time. For insertEdge(v1 , v2 , f ), we have to find the edges at v1 and v2 between which the new edge has to be inserted. If vi marks the beginning of a sector in f , we get the edges from the attributes edge[1..4] of f . Otherwise we traverse the trees leaf [1..2] to the root and compare the face number with f . One of them must be f and we take the edge from the attribute edge[1..2]. f is split into two new faces f1 and f2 , and we compute the attributes of f1 and f2 from the attributes of f . The attributes edge[1..4] and vertex[1..4] can be computed in constant time from the same attributes of f and the vertices v1 and v2 . tree[1..4] is either a part of a split tree or a full tree of a face f or is created with only one vertex. Additionally, the number of the face at the root of every tree has to be updated. By using the trees this takes O(log n) time. x and y : For insertV ertex(e) the replaced edge is given. Thus, we can copy x and y in O(1) to the new edges. For insertEdge(v1 , v2 , f ), we have to know the sectors of v1 and v2 in f to find valid dependencies for the new edge. If a vertex is the first vertex of a sector, then we can get this information from the attributes of the face. Otherwise, we search in the two trees which are used to find the edges that are adjacent to the vertex in face f . Since we store the number of the sector at the root we have access to the number of the sector of the vertex. The space requirement for all balanced binary trees is in O(n), because every vertex is represented in at most two trees. All other attributes have constant size. 4.3
Drawing Algorithm
We generate an orthogonal representation, and then can use any algorithm which computes an orthogonal drawing from an orthogonal representation (e.g. [8]). The algorithm has the following properties: 1. 2. 3. 4.
The drawing respects the restriction system. At most |F | edges have two bends. The remaining edges have one bend. The algorithm takes O(n) time. The routing of an edge is fixed as long as the number of its bends is unchanged. In [6] the routing of an edge is claimed to be part of the mental map. 5. The drawings are in the Kandinsky-Model [8].
Since the embedding is given, only the routing of the edges has to be computed. Every edge starts vertically at the right side of its left adjacent vertex followed by a horizontal segment. If the edge has one bend, it ends at the right vertex. In case of an edge with two bends we have an additional vertical segment. Figure 5 shows all possible edge routings. Thus it remains to compute which edges have two bends and which have only one bend. Lemma 2. Given a planar graph and its restriction system in the 4-sector model. An edge e has two bends if there exists a face where
360
Walter Bachl
Fig. 5. Possible routings of an edge.
1. sector 1 and 3 are empty and sector 4 consists only of edge e or 2. sector 2 and 4 are empty and sector 1 consists only of edge e or 3. the cyclic successor of e at the right end vertex v of e has two bends and both edges leave v to the upper left or 4. the cyclic predecessor of e at the right end vertex v of e has two bends and both edges leave v to the lower left. All other edges have one bend. The orthogonal representation which is constructed by this rules leads to a planar drawing of the graph. Proof. Clearly, edges in different sectors do not intersect, since the algorithm of [8] partitions a face into disjoint rectangles. Also edges in the same sector cannot intersect and it remains to show, that edges do not intersect at incident vertices. Consider the right side of a vertex v. Let e1 = {v, v1 } be the first edge in counterclockwise order, which ends at the right side of v. Let e2 = {v, v2 } be its successor in the counterclockwise order around vertex v and e2 ends at the right side of v. e1 and e2 cannot intersect, if edge e1 leaves v to the lower right and e2 to the upper right. If both e1 and e2 leave v to the lower right, then the vertical segment of e1 has to be left of the vertical segment of e2 . This holds as long as v1 and v2 are unordered in x-direction or v1 is to the left of v2 . If there is a path in the x-dependencies from vertex v2 to vertex v1 , then v1 has to be right of v2 . We show, that edge e1 must have two bends and therefore the vertical segment of e1 can be to the left of the vertical segment of e2 . Consider face f , which is bounded by the edges e1 and e2 (Figure 6). Let e3 be the cyclic successor of e1 at vertex v1 and e4 be the last edge in the path in the x-dependencies from v2 to v1 . Since e4 is on a path in the x-dependencies, it must be attached to v1 on the left side. The path cannot be to the left of edge e1 and therefore e4 ends above e1 at vertex v1 . Since e3 must be between e1 and e4 , it also leaves v1 to the upper left and therefore it is in face f in sector 2. Since e1 is in sector 4 and e2 and e3 are in sector 2, all remaining edges are in sector 2 and edge e1 has two bends (rule one). All other cases at other sides of the vertices are similar. Theorem 5. Given a planar embedded graph with a restriction system in the 4-sector model. Then at most f edges have two bends, where f is the number of faces of the graph.
5
Further Extensions
Our approach is easy to extend to additional requirements. For example, for graphs with vertices of arbitrary sizes, the drawing algorithm takes the width of
Semi-dynamic Orthogonal Drawings of Planar Graphs
361
Fig. 6. Notations for the proof of Lemma 2.
the vertices into account, when it evaluates the 5, dependencies and similarily for the height and 5, dependencies.
Acknowledgment
I would like to thank Prof. F.J. Brandenburg for his helpful suggestions. This research was done while the author was with the University of Passau.
References S.S. Bridgeman, J. Fanto, A. Garg, R. Tamassia, and L. Vismara. InteractiveGiotto: An algorithm for interactive orthogonal graph drawing. In Graph Drawing (GD 97), LNCS 1353, pages 303-308. Springer, 1997. 2. U. Brandes, M. Giidemann, and D. Wagner. Fully dynamic orthogonal graph layout for interactive systems. Technical report, Universitat Konstanz, 2000. 3. T.C. Biedl and M. Kaufmann. Area-efficient static and incremental graph drawings. In Proc. European Symposium on Algorithms (ESA '97), Lecture Notes in Computer Science 1284, pages 37-52. Springer, 1997. 4. F. J. Brandenburg. Designing graph drawings by layout graph grammars. In Graph Drawing (GD 94), LNCS 894, pages 416-427. Springer, 1995. 5. G. Di Battista and R. Tamassia. On-line planarity testing. SIAM Journal on Computing, 25(5):956-997, 1996. 6. S.S. Bridgeman and R. Tamassia. Difference metrics for interactive orthogonal graph drawing algorithms. In Graph Drawing (GD 98), LNCS 1547, pages 57-71. Springer, 1998. 7. 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. 8. U. FoBmeier and M. Kaufmann. Drawing high degree graphs with low bend numbers. In Graph Drawing (GD 95), LNCS 1353, pages 254-266. Springer, 1996. 9. U. FoBmeier. Interactive orthogonal graph drawing: Algorithms and bounds. In Graph Drawing (GD 97), LNCS 1353, pages 111-123. Springer, 1997. 10. K. Misue, P.Eades, W. Lai, and K. Sugiyama. Layout adjustment and the mental map. Journal of visual languages and computing, 6:183-210, 1995. 11. A. Papakostas and I.G. Tollis. Issues in interactive orthogonal graph drawing. In Graph Drawing (GD 95), LNCS 1027, pages 419-430. Springer, 1996. 12. F.P. Preparata and M.I. Shamos Computational Geometry: An Introduction Springer. 1985 1.
Graph Layout for Workflow Applications with ILOG JViews Gilles Diguglielmo, Eric Durocher, Philippe Kaplan, Georg Sander, and Adrian Vasiliu ILOG SA, 9, rue de Verdun - BP 85, 94253 Gentilly Cedex, FRANCE {gdigugli|durocher|kaplan|sander|vasiliu}@ilog.fr http://jviews.ilog.com
1
Introduction
Workflow is the flow of information and control in a company’s business processes [1]. Examples of such processes are purchasing procedures, production planning or customer support mechanisms. Managing business processes more efficiently can reduce the costs and improve product and customer services. A workflow modeler is a software that allows to design, document and optimize the business processes. Today’s workflow management systems are graphical tools that allow to manipulate and monitor workflows that are visualized as diagrams. The automatic layout of workflow diagrams is a central part of the GUI of such software systems. The ILOG JViews Component Suite is a set of pure Java components for building sophisticated interactive commercial Web-based user interfaces. Besides ready-to-use components for cartography, charting, resource scheduling (Gantt charts), it includes a component specialized for building the GUI of workflow applications (Fig. 1). This workflow component utilizes the powerful graphic framework and graph layout package of JViews [3]. It provides full customization of the look & feel of all graphical elements via Cascading Style Sheets, and supports XML input and output derived from the Workflow Management Coalition standards.
2
Highlights of the Layout Algorithms
Workflow graphs consist of nodes representing activities, decisions, participants or data, and edges representing transitions and relations. Workflow graphs may contain subprocesses, hence they are nested graphs with intergraph edges, that is, edges between different subgraphs (Fig. 2). A hierarchical layout [4,2] and a tree layout is used. Labels are placed at the edges by a simulated annealing technique [3]. The hierarchical layout algorithm is enhanced by various features to fit into the workflow application domain: – In incremental mode, the relative positions of nodes are preserved when the graph changes. Hence, small editing operations don’t cause a large rearrangement of the diagram. This helps the user to preserve the mental map of the diagram. M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 362–363, 2002. c Springer-Verlag Berlin Heidelberg 2002
Graph Layout for Workflow Applications with ILOG JViews
Fig. 1. Workflow Modeler
363
Fig. 2. Nested Workflow
– A constraint system allows to define relations between the node position, such as “is left of”, “is above”, “it leftmost”, or to cluster nodes. Constraints are used to place the “participant” and “data” nodes relative to the workflow skeleton that is formed by the “activity” and “decision” nodes. – Special ports specify the node side or the fixed pin points where edges start or end at the nodes. This is often required for “decision” nodes of workflow diagrams. – Swim lanes allow to divide the layout area into vertical stripes representing the business units that participate on the workflow. The JViews Graph Layout component also contains many more layout algorithms that are designed for other application domains. An online demonstration of the ILOG Workflow Cockpit is available at http://www.ilog.com/products/ jviews/workflow.
References 1. L. Fischer, editor. New tools for new times: The workflow paradigm. Future Strategies Inc., second edition, 1995. 2. G. Sander. A fast heuristic for hierarchical manhattan layout. In Proc. Symposium on Graph Drawing, GD’95, pages 447–458. Springer, LNCS 1027, 1996. 3. G. Sander and A. Vasiliu. The ILOG JViews graph layout module. In Proc. Symposium on Graph Drawing, GD’2001, pages 438–439. Springer, LNCS 2265, 2002. 4. K. Sugiyama, S. Tagawa, and M. Toda. Methods for visual understanding of hierarchical systems. IEEE Trans. Sys. Man, and Cybernetics, SMC 11(2):109–125, 1981.
InterViewer: Dynamic Visualization of Protein-Protein Interactions⋆ Kyungsook Han1 , Byong-Hyon Ju1 , and Jong H. Park2 1
2
1
Department of Computer Science & Engineering, Inca University Inchon 402-751, South Korea MRC-DUNN, Human Nutrition Unit, Cambridge CB2 2XY, UK http://wilab.inha.ac.kr/protein/
Short Description
From the perspective of graph drawing, a protein interaction network is challenging because it is a complicated, nonplanar graph with a large number of edge crossings and because it is a disconnected graph consisting of many connected components with nodes of a wide range of degrees. InterViewer is a system for drawing and exploring protein-protein interaction networks in three-dimensional space. Unique features of InterViewer include: (1) it is much faster than other recent implementations of drawing algorithms; (2) it can be used not only for drawing protein interaction networks but also for simplifying them into different types of networks; and (3) it provides an integrated framework for querying protein interaction databases and directly visualizing the query results.
2
Areas of Application
InterViewer has been developed to visualize and analyze protein-protein interactions. Uses of InterViewer include: – visualizing large protein interaction networks and exploring them in 3D by rotating or by zooming in or out of them, – finding proteins sharing a function or proteins interacting with a target protein within a specified distance level, – comparing two or more protein interaction networks, – creating a local database of protein-protein interactions, and – producing protein interaction networks for publications or presentations
3
Layout Algorithms and Layout Features
InterViewer’s layout is based on the force-directed layout of Walshaw’s algorithm [2], but different from Walshaw’s algorithm in the following sense: (1) ⋆
This work was supported by the advanced backbone IT technology development program of the Ministry of Information and Communication of Korea under grant number IMT2000-C3-4.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 364–365, 2002. c Springer-Verlag Berlin Heidelberg 2002
InterViewer: Dynamic Visualization of Protein-Protein Interactions
(A)
365
(B)
Fig. 1. (A) Subgraph of PSIMAP [1] obtained by extracting protein families interacting with protein family 7.39.1 within distance level of 2. (B) Simplified graph of Fig. 1A by replacing a complete subgraph with a star-shaped subgraph centered at a dummy node, shown as a circle.
Walshaw’s algorithm groups nodes into clusters, whereas InterViewer does not. (2) Walshaw’s algorithm initially places nodes randomly, whereas InterViewer places nodes on the surface of a sphere for better results. (3) Walshaw’s algorithm iteratively updates layouts until the graph size falls below a certain threshold value, whereas InterViewer iterates 20 times unless specified otherwise by a user. Subgraphs with nodes of high degree often reduce the readability of the graph due to cluttered edges. We simplify this type of graph by replacing a complete subgraph with a star-shaped subgraph. While a complete graph with n nodes contains n(n − 1)/2 edges, a star-shaped graph with n nodes contains exactly n edges. Thus, replacing complete subgraphs with star-shaped subgraphs substantially reduces the number of edges (see Fig. 1).
4
Architecture and Interfaces
The layout algorithm was implemented in Borland Delphi 6.0, and databases of protein-protein interactions were constructed using Microsoft Data Access Components 2.7. InterViewer runs on Windows 2000/XP/Me/98/NT 4.0. InterViewer is not coupled with a specific database. The user can easily make his own interaction databases using our program called DataServer and exploit them with InterViewer. DataServer and InterViewer can run on a same computer or on different computers. Details are at http://wilab.inha.ac.kr/protein/.
References 1. Park, J., Lappe, M., Teichmann, S.A.: Mapping protein family interactions: intramolecular and intermolecular protein family interaction repertoires in the PDB and Yeast. J. Mol. Biol. 307 (2001) 929–938 2. Walshaw, C.: A multilevel Algorithm for Force-Directed Graph Drawing. In Proc. 8th Int. Symp. Graph Drawing, LNCS 1984, (2002) 171–182
Some Modifications of Sugiyama Approach Danil E. Baburin A.P. Ershov Institute of Informatics Systems, Lavrentev pr. 6, Novosibirsk, 630090, Russia [email protected]
Abstract. We present a graph drawing algorithm that was developed as an extension of the hierarchical layout method of Sugiyama [4]. The main features of the algorithm are that the edges are orthogonal and that each edge has at most two bends.
1
Introduction
In a number of works [2,3] Sander presents his methods and heuristics on how to combine hierarchical approach of Sugiyama [4] with methods of orthogonal graph drawing and with Manhattan conventions. In our work we develop and extend these ideas. The main difference is that we have achieved an orthogonal layout with maximum number of edge bends equal to two compared to four bends in Sander’s works. Also we solved the task of minimizing the number of orthogonal edge crossings between any pair of adjacent levels of hierarchy and tried a new heuristic to build an initial position of nodes before starting the crossing reduction step. On the Fig. 1 we present a diagram layout constructed by our algorithm. Note that this is left to right drawing as opposed to conventional hierarchical layout. The algorithm was implemented by means of C++ and provided with an interface that enabled its use in Higres system [1].
2
Our Methods and Heuristics
The crossing reduction step considers the problem of drawing a layered digraph with a small number of edge crossings. We present a heuristic method that could be used to form an initial ordering with relatively small number of edge crossings. Then this ordering could be improved using any known method. During the layer assignment step we are parsing the graph into a spanning tree plus extra edges. Our heuristic changes the order in which subtrees appear in this tree to minimize the number of crossings that are formed by non-spanning edges. Subtrees are ordered greedily according to the number of extra edges connecting them to the left and right. In our algorithm we introduce a concept of edge width. Each edge has assigned width with some minimum value that depends on the size of edge label and a number of multi edges that were combined in the preprocessor step of the algorithm into one edge. Then while assigning vertical coordinates to vertices we operate with vertical ranges. These M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 366–367, 2002. c Springer-Verlag Berlin Heidelberg 2002
Some Modifications of Sugiyama Approach
367
Fig. 1. Sample layout produced by our algorithm. The graph has 40 vertices and 60 edges.
ranges could be bounded by some coordinates or could dynamically depend on neighbor ranges. When we are drawing edges between two adjacent levels of hierarchy we are dividing horizontal space between adjacent layers into vertical levels that would contain vertical segments of the edges. Then we are defining a notion of potentially crossing edges. This crossing could be eliminated if correspondent edges are drawn in different vertical segments and in a particular order. Our task was to eliminate all such crossings and to minimize the number of vertical levels being used. We are solving this problem by constructing a supplementary directed graph G’. Now our goal could be formulated in terms of a coloring problem for G’. Vertices of G’ need to be colored in a minimum number of colors so that any adjusted vertices would have different colors. Also all directed edges should point from vertexes with smaller color indices to vertexes with larger color indices. Then we can draw edges in original graph by assigning vertical levels to colors in increasing order.
References 1. I. A. Lisitsyn, V.N. Kasyanov, “Higres – Visualization system for Clustered Graphs and Graph Algorithms”, Graph Drawing, LNCS 1731, Czech Republic 1999, pp. 82-89 2. G. Sander, “A Fast Heuristic for Hierarchical Manhattan Layout”, Graph Drawing, LNCS 1027, Germany 1995, pp. 447-458 3. G. Sander, “Graph layout through the VCG tool”, DIMACS Intern. Workshop, GD’94. LNCS. 894, 1995, pp. 194–205. 4. K. Sugiyama, S. Tagawa, M. Toda, “Methods for Visual Understanding of Hierarchical systems”, IEEE Trans. Sys., Man, and Cybernetics, SMC 11(2), 1981, pp. 109-125.
A Framework for Complexity Management in Graph Visualization Ugur Dogrusoz and Burkay Genc Computer Eng. Dept., Bilkent Univ., Ankara 06533, Turkey Tom Sawyer Software, Oakland, CA 94612, USA
1
Short Description
We present a comprehensive framework for development of complexity management techniques in graph visualization tools. The presented architecture is capable of managing multiple associated graphs with navigation links and nesting of graphs as well as ghosting, folding and hiding of unwanted graph elements. The theoretical analyses show that the involved data structures and algorithms are quite efficient, and an implementation in a graph drawing tool has proven to be successful. Our architecture is based on dynamic interactive compound graphs. The definition of compound graphs is extended to efficiently handle the graph editing and complexity management operations. A navigation forest is used to keep track of navigational links among nodes and graphs, and a nesting forest is used to keep track of nesting (inclusion) relations.
2
Complexity Management Operations
The framework manages complexity via the following instruments: Expand/Collapse: Most applications require multiple levels of abstraction, where the user would like to visualize the information with varying levels of abstraction for different parts of the drawing. A collapse operation allows us to cancel a nesting relation between a node and a graph, thus avoiding the drawing of the graph inside the node. The expand operation is defined as the reverse operation creating a nesting relation between a node and a graph. Folding/Grouping: A fold operation is applied to a group of graph members, and results in a new (folder) node and its new child graph with these members. At any time, an unfold operation may be applied on a folder node to reverse the effects of the fold operation. Often times, members of a graph need to be put together according to some criteria to emphasize certain grouping. This can be achieved through folding followed by an expand operation, enabling all the group members to be gathered in the newly created graph. M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 368–369, 2002. c Springer-Verlag Berlin Heidelberg 2002
A Framework for Complexity Management in Graph Visualization
369
Invisibility/Hiding/Ghosting: A graph member is said to be invisible when it is not rendered on the display yet it is part of the graph topology. Hiding, on the other hand, is used to avoid any means of user interaction on a set of graph members, and temporarily removes graph contents from the graph topology as well. Any set of graph members may later be unhidden. Ghosting can be used to visually decrease the importance of a graph member by means of changing its color and/or brightness of its skin, and sending it to the background. Unlike hiding, the member is still there, both visually and topologically.
3
Implementation
Our framework has been successfully implemented and integrated into Tom Sawyer Software’s Graph Editor Toolkit for Java, version 5.0.
Fig. 1. Upper Left: Map of a small network drawing in GET for Java. Upper Right: All related network devices are grouped together under a folder. Lower Left: Lab4 has been expanded to reveal details. Additionally, Printer1, PC41, PC43 and PC47 are unavailable, so they are hidden. Lower Right: The varying levels of the details of the server has been input as deeply nested graphs.
A Partitioned Approach to Protein Interaction Mapping⋆ Yanga Byun, Euna Jeong, and Kyungsook Han Department of Computer Science and Engineering Inha University, Inchon 402-751, South Korea [email protected], [email protected], [email protected] http://wilab.inha.ac.kr/protein/ Abstract. This is a brief description of a new program for drawing protein interactions in three-dimensional space. Our program divides nodes into three groups: biconnected subgraph in the center, terminal nodes at the outermost region, and the rest in between them. Experimental results show that the program efficiently generates a clear and aesthetically pleasing drawing of large-scale protein interaction networks and that it is an order of magnitude faster than other force-directed layouts.
Protein interactions, when visualized as an undirected graph, often yield a nonplanar, disconnected graph with nodes of wide range of degrees. This paper presents a new force-directed program that divides nodes into three groups: – Group V1 is a set of terminal nodes, i.e., nodes with degree 1. – Group V2 is a set of nodes in the subgraphs separated by cutvertices, except those in the longest subgraph. – Group V3 consists of nodes which are members of neither V1 nor V2 . While we find groups in the order of V1 , V2 , and V3 , we layout them in reverse order; V3 is first positioned in the center of the sphere, V2 in the outer region of V3 , and V1 in the outer region of V2 and V3 . Our program was implemented in Microsoft’s C♯ and runs on any Windows 2000/XP/Me/98/NT 4.0 system. Table 1 shows the running times on five cases, Brain (http://www.infosun.fmi. uni-passau.de/GD2001/graphC/brain.gml), Gd29 (http://www.infosun.fmi.uni-passau. de/GD2001/graphA/GD29.gml), Y2H (http://depts.washington.edu/sfields/yplm/dat a/), MIPS-G and MIPS-P (http://mips.gsf.de/proj/yeast/tables/interaction/), at each stage of partitioning nodes into three groups, finding shortest paths in three groups, and layout and drawing. The test cases of Brain and Gd29 are different from the other data not only in the size of data sets but also in the relative size of their V3 . Brain has 28 nodes in V3 out of total 33 nodes and Gd29 has 129 nodes in V3 out of total 178 nodes. However, in test cases Y2H, MIPS-G, and MIPS-P the ratio of V3 to the total number of nodes is less than 1/2. Comparison of our algorithm with other forcedirected layout algorithms shows that ours is more effective for bigger graphs and for graphs that do not have excessively high portion of V3 (data not shown). If the portion of V3 is high, the improvement in speed can be marginal. Fig. 1 shows the drawings of the MIPS physical interaction data. ⋆
This work was supported by the advanced backbone IT technology development program of the Ministry of Information and Communication of Korea under grant number IMT2000-C3-4.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 370–371, 2002. c Springer-Verlag Berlin Heidelberg 2002
A Partitioned Approach to Protein Interaction Mapping
371
Table 1. Running times at each stage on five cases. P: partitioning nodes into V1 , V2 and V3 , SP: finding shortest paths in all groups, LD: layout and drawing.
Data
Edges
V1
Brain Gd29 Y2H MIPS-G MIPS-P
135 344 542 805 2372
4 40 255 198 665
Nodes V2 V3 1 10 100 102 289
28 128 118 231 572
P
Running times LD total (= P + SP + LD) 0.02s 0.15s 0.25s 0.90s 2.06s 3.80s 0.87s 3.49s 5.77s 5.16s 8.52s 16.92s 1m 18.82s 56.20s 3m 11.41s SP
0.08s 0.84s 1.41s 3.24s 56.39s
(A)
(B)
(C)
(D)
Fig. 1. Drawings of the largest connected component of the MIPS physical interaction data with 1526 nodes and 2372 edges. (A) Initial layout, (B) After drawing the nodes in V3 shown in the rectangle, (C) After drawing the nodes in V3 and V2 shown in the rectangle, (D) Final drawing.
Camera Position Reconstruction and Tight Direction Networks Ileana Streinu and Elif Tosun
⋆
Computer Science Department Smith College, Northampton, MA 01063 {streinu, etosun}@cs.smith.edu
Abstract. A concrete reconstruction problem arising in Computer Vision motivates our investigation of combinatorial variations on the problem of drawing a graph with given direction vectors associated to its edges. We formulate solutions in dimension 2 and report on experimental results done with simple implementations.
Direction Networks. A (planar)direction network is a graph G = (V, E) with slopes (or direction vectors) associated to its edges. A compatible embedding is given by coordinates for the vertices V inducing edge directions equal to the given ones. A direction network is tight if it has a unique embedding, up to translations and scalings, it is inconsistent if it has no embedding at all, and it is loose or under constrained if it has more than one (non similar) embedding. An inconsistent network is usually over-constrained: some of the edge directions can be inferred algebraically from other edge directions, and thus a small error in the data leads to inconsistency. In the under-constrained case, the space of embeddings is a linear subspace whose dimension measures how loose the network is. See Fig. 1.
Fig. 1. Left: a loose graph and two non-similar parallel redrawings. Right: an overconstrained case, with consistent and inconsistent directions (the rightmost case has no solution for the given direction of the hanging edge.)
The Camera Position Reconstruction Problem. Our motivating problem comes from the MIT City Project [1]. A robot moves around the MIT campus taking pictures of the buildings. It seeks to reconstruct a model of the 3dimensional urban environment from these images. The usage of a hemispherical camera, edge detection and feature matching software produce what amounts to ⋆
Research partially supported by the first author’s NSF RUI grant CCR-0105507. Part of the work was conducted during the Workshop on Rigidity Theory and Scene Analysis, organized by the first author at McGill University Bellairs Institute in Barbados in Jan. 2002, with partial support from NSF grant CCR-0203224.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 372–373, 2002. c Springer-Verlag Berlin Heidelberg 2002
Camera Position Reconstruction and Tight Direction Networks
373
be a 3-dimensional direction network. In [1] standard least-squares techniques are used to infer approximations of the vertex positions. The authors report that the solution is very rarely unique, with the information inferred from the images being too weak to allow correct reconstruction. Our Contribution. It is stated in [1] that the determination of the minimal set of distinct pairs needed for a non-degenerate solution is significantly more complicated and depends entirely on the topology of the adjacency graph. Our contribution is to propose a theoretical solution for what seems to be the bottleneck in the full automation of this system, and perform enough preliminary experimentation to validate the feasibility of taking it to the practical level. We formulate the problem in rigidity theoretical terms. This leads to reasonably efficient and implementable algorithms. We have experimented with algorithms in dimension 2. The real case (dimension 3) is more complicated but still reasonably well understood theoretically. Our implementation was done in Mathematica for quick prototyping. The planar case allows to develop a solid theoretical strategy for accurate testing. These preliminary results indicate that our approach may be practical even in dimension 3. The Combinatorial Rigidity approach. If one could understand which edges must additionally be sampled to ensure that a unique solution is found, then one could send the robot to retake some pictures. This being a costlier process than the off-line processing of images, one would like to do only the work that is absolutely necessary. We are led to the following three problems. 1. Decision: Given a direction network, decide whether it is tight or not. 2. Extension: Given a loose direction network, find a set of edges to be added so that the resulting network becomes tight. 3. Extraction: Given an inconsistent direction network, find a set of edges to be removed to obtain a tight network. These problems fall into the rigidity theory category of parallel redrawings. A good starting point is Whiteley ([4] and [3]). Our implementation relies on an algorithm proposed by Sugihara [2], based on matroidal concepts. In the planar case, the duality between fixed-length and fixed-direction rigidity allowed us to design a test generator using Henneberg constructions for tight graphs. Acknowledgements. We thank Seth Teller for suggesting the problem to us, and to Ruth Haas, Brigitte Servatius, Jack Snoeyink and Walter Whiteley for useful references and enjoyable conversations on these topics.
References 1. Antone, M.E., Teller, S.: Automatic Recovery of Camera Positions in Urban Scenes. Technical Report MIT LCS TR-814. December 2000 2. Sugihara, K.: Detection of Structural Inconsistency in Systems of Equations with degrees of freedom and its applications. Discrete Appl. Math. 10 (1985) 297–312. 3. Whiteley, W.: Some Matroids from Discrete Applied Geometry. Contemporary Mathematics 197 (1996) 4. Whiteley, W.: Rigidity and Scene Analysis. In J.E. Goodman and J. O’Rourke (eds.), Handbook of Discrete and Computational Geometry, pp. 893–916
Demonstration of a Preprocessor for the Spring Embedder Paul Mutton and Peter Rodgers University of Kent at Canterbury {pjm2, P.J.Rodgers}@ukc.ac.uk Abstract. Spring embedding is a widely used method for producing automated layouts of graphs. We present a preprocessor that improves the performance of the classical spring embedder, which can be used in conjunction with other optimization and approximation techniques. It creates an initial graph layout with edge lengths that are approximately equal and with a minimum node separation from which the spring embedder typically needs far fewer iterations to produce a well laid out graph.
Introduction. The spring embedder [1] is a widely used method for drawing general graphs. In its classical form, the layout is randomized before the iterative force process is simulated. We present a preprocessor for the spring embedder, discussed in more detail in [5]. Our preprocessor is a two phase process and is used before the spring embedder is initiated. The first phase attempts to keep connected nodes at a suitably close distance by an iterative method that produces edges lengths close to a user specified ideal. The second phase approximates an even node distribution by placing the nodes on a grid. The spring embedder, or some other optimized force directed variant, is applied after these two phases. In some specialized cases, such as grid or mesh like structures, or some graphs exhibiting strong clusters, the graph can be drawn with just the preprocessor and without requiring any subsequent spring embedding. Previous work in preprocessing includes placing the graph in simple binary trees or meshes [2]. The Wave Front method [6] applies the spring embedder to a subgraph wave that sweeps through the graph. Other work on initial placement includes [4] which adds nodes to the layout incrementally, placing nodes at the barycenter of its three closest graph theoretical distance neighbours. This is followed by a local application of the force directed drawing process on the node, considering just its neigbours. Brief Description of the Method. We use force models based on those of Fruchterman and Reingold, which defines k, the ideal minimum node separation. In this model, the repulsive force between nodes is k 2 /d and the attractive force due to edges is d2 /k, where d is the distance between the two nodes. The first phase of the preprocessor attempts to obtain an initial drawing where all edge lengths are approximately equal to ka, where a ≥ 1, as the spring embedder appears to perform better when reducing the volume of the graph slightly. Preliminary experimentation suggests that a = g 1/3 is a reasonable value, where g is the mean degree of nodes in the graph. Prior to phase one, the nodes are randomly distributed within a cubic volume of side length 103 ka(|N|1/3 ), which is large enough to ensure good results, as the layout will rapidly shrink with the extropic application of the iterative first phase. M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 374–375, 2002. c Springer-Verlag Berlin Heidelberg 2002
Demonstration of a Preprocessor for the Spring Embedder
375
Each iteration of phase one involves visiting every ka node in the graph. For each node n, we examine the m1 set of emanating edges. Each edge connects n to mi p1 and we calculate the position of point pi such that the vector mi pi = ka(ui ), where ui is the unit vector of mi n. Node n is moved to the mean position of all pi of n n. The graph rapidly shrinks into a more stable graph p2 where each edge length is near to ka. Each iteration m2 has linear time complexity, O(|E|). Phase one often leaves dense clusters of nodes Fig. 1. Node placement in the first very close together, so we now apply the second phase phase in order to achieve a minimum node separation. This places the nodes on a threedimensional grid of unit size k. This is much quicker than the first phase, as it is not iterative. Application of both phases results in a new graph layout where edge lengths remain close to the phase one ideal value of ka, whilst ensuring all nodes have the final graph ideal minimum node separation of k. This yields the initial drawing to which we apply the spring embedder. Summary of Results and Further Work. Preliminary results show the method is promising in improving the speed of the spring embedding process. The spring embedder finds an equilibrium for medium sized graphs of about 200 nodes approximately 10 times faster than with a random layout [5]. The time taken for the preprocessing is insignificant compared to the time required for spring embedding. Further experiments with optimized spring embedders also show improvements in performance. In some cases spring embedding was not required, as the preprocessor produced a good layout. Systematic testing with larger graphs and alongside other preprocessing methods is now needed to explore the benefits of the method. The method has been implemented in Java with a focus on encapsulation and reuse; however, a radical performance increase could be gained by concentrating on optimising the code in an effective environment. Also requiring consideration is integration with other optimization and approximation techniques, as the method is amenable to integration with common force approximation methods such as Barnes-Hut tree coding methods, and with multilevel clustering methods.
References 1. P. Eades. A Heuristic for Graph Drawing. Congressus Numerantium 42. pp. 149-60. 1984. 2. A. Frick, A. Ludwig, H. Mehldau. A Fast Adaptive Layout Algorithm for Undirected Graphs. GD’94, LNCS 894. pp. 388-403. 1995. 3. T.M.J. Fruchterman, E.M. Reingold. Graph Drawing by Force-directed Placement. Software – Practice and Experience, Vol. 21(11). pp. 1129-1164. 1991. 4. P. Gajer, M.T. Goodrich, S.G. Kobourov. A Fast Multi-Dimensional Algorithm for Drawing Large Graphs. GD 2000, LNCS 1984. pp. 211-221. 2001 5. P.J. Mutton, P.J. Rodgers. Spring Embedder Preprocessing for WWW Visualization. Proceedings of 6th International Conference on Information Visualization, IV02-WGV. pp. 744-749. 2002. 6. A.J. Quigley, Large Scale Relational Information Visualization, Clustering, and Abstraction, PhD Thesis, University of Newcastle, Australia. August 2001.
Graph-Drawing Contest Report Franz J. Brandenburg Universit¨ at Passau, D-94032 Passau, Germany, [email protected]
Abstract. This report describes the Ninth Annual Graph Drawing Contest, held in conjunction with the 2002 Graph Drawing Symposium in Irvine, California. The purpose of the contest is to monitor and challenge the current state of the graph-drawing technology.
1
Introduction
The contest had two categories, two so-called “challenge graphs” and a new interactive graph analysis, which replaced the former artistic category. The challenge graphs were open to everyone in and outside the graph drawing community. The requirements were drawings in printable from and a description of the drawing procedure. The interactive graph analysis was initiated by Joe Marks and Sue Whitesides, who also designed the two query graphs for this category. It was directed to the participants of the symposium. Text descriptions for the 2002 contest were available via the World Wide Web (WWW) and announced with the Graph Drawing Symposium. The data on the graphs was provided in GML format. However, only four submissions from three teams were received on the challenge graphs, and the participants at the symposium were not well prepared for the interactive test. The entries for graph A, the “Knowledge Nation Graph”, realize similar ideas and introduce some innovative concepts from graph drawing into the representation of the Knowledge Nation Graph. However, the created drawings are not yet capable to visualize this graph in all its aspects. For graph B it has turned out that spring embedders perform quite well on this graph and display it like a crown, although its hidden structure is not displayed by these methods. All four submissions were nominated as winners of the same grade.
2 2.1
Winning Submissions Category A
The graph for Category A is the “Knowledge Nation Graph”. Its original drawing is shown in Fig. 1. For more information on the graph and its story see http://www.cs.usyd.edu.au/˜visual/library/. The Knowledge Nation Graph has been proposed by Carsten Friedrich from the University of Sydney. M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 376–379, 2002. c Springer-Verlag Berlin Heidelberg 2002
Graph-Drawing Contest Report
377
Fig. 1. The “Knowledge Nation Graph”
From a graph theoretic view it has 23 nodes and 59 edges. Two nodes, “Government” and “Knowledge Nation” are dominant, and are connected to almost all other nodes. The entry by Daniel Gmach, Paul Holleis, and Thomas Zimmermann, students at the University of Passau, places the Government node near the center and displays the Knowledge Nation as the outer frame, see Fig. 2. So the dominance of these nodes is reflected. The frame reduces the visual complexity. However, the drawing is hard to read and has too many crossings. The drawing was made using Graphlet. The entry by Nikola S. Nikolov and Patrick Healey from the University of Limerick is a two step approach. First the graph is partitioned into the cue map, which is obtained by selecting the two highest degree nodes Government and Knowledge Nation and adding the then isolated nodes. The remaining nodes are grouped into black, grey and white nodes representing out-, in- and non-
Fig. 2. Entry of Gmach, Holleis, and Zimmermann
378
Franz J. Brandenburg
G
G
Government G
Manufacturing/ Construction
Environment
Agriculture
Law/Public Service
CSIRO/CRCs/B of M
Telstra/AP
Defence
Mining
G
G
Banking/Insurance
TAFE/Training
Third Age/ Lifelong Learning
Welfare
G
ABC/Media
Arts/Leisure/Sport
G
Schools
Knowledge Nation G
Universities
Medicine/Health
G
Infrastructure
Communications/ IT and Print
G
Trade/Commerce
G
(a) Cue Map
Tourism
(b) Main Map
Fig. 3. Entry of Nikolov and Healey
neighbours of the Knowlegde Nation node. The black and the grey clusters are represented by single nodes. The main map is obtained from the remaining nodes and copies of the Government node for each incident edge. The drawings of the graphs are shown in Fig. 3(a) and 3(b) and were made by a customized Sugiyama algorithm. 2.2
Category B
Graph B represents a gadget from an NP-reduction. There are two parallel paths such that the remaining edges connect nodes on either path. Aesthetically pleasing and almost identical drawings are obtained by spring embedders. This has been discovered by Daniel Gmach, Paul Holleis, and Thomas Zimmermann, students of the University of Passau, using the Kamada-Kawai algorithm and the constraint spring embedder from Graphlet (see Fig. 4) and by Christoph Vogt, student of the University of Cologne, using his implementation of the GEM algorithm (see Fig. 5).
Fig. 4. Entry of Gmach, Holleis, and Zimmermann for Category B
Graph-Drawing Contest Report
379
Fig. 5. Entry of Vogt for Category B
2.3
Category C
In the previous graph drawing contests the emphasis has been on the production of graph drawings that could be used to support a variety of unspecified visualization or analysis tasks. In this part of the contest the analysis part was made explicit, requiring contestants to conduct interactive graph analysis in real time and hoping that this contest task would inspire new research into graph drawing and graph analysis methods. Since the competitors were not prepared for the contest it will be repeated at the 11th Graph Drawing Symposium 2003. 2.4
Conclusion
The response on the Graph Grawing Contest has declined over the past years. To encourage submissions for the 10th Graph Drawing Contest in 2003 it is anticipated to increase the prize money to $ 1000 for the winner of the challenge graph category, and to $ 500 in the interactive category. Acknowledgement I wish to thank Carsten Friedrich, University of Sydney for providing the “Knowledge Nation Graph” and Joe Marks, MERL, Cambridge and Sue Whitesides, Mc Gill University, Montreal, for introducing and preparing Category C. The Graph Drawing Contest 2002 has been sponsered by MERL Mitsubishi Electric Research Laboratries, Cambridge, sd&m AG M¨ unchen, and Tom Sawyer Software, Oakland.
Techniques for Interactive Graph Drawing James Arvo University of California, Irvine [email protected]
Abstract. There are two complementary approaches to graph drawing: algorithmic and interactive. By algorithmic graph drawing we mean the automatic placement of vertices and routing of edges using heuristics to improve understandability. Interactive graph drawing, on the other hand, implies that a user directly influences at least some low-level aspects of graph layout, either by direct placement of vertices and edges, or by providing some form of feedback to the system. Interactively engaging the user is in some instances unavoidable. When a user desires a difficult-to-quantify aesthetic quality of the graph, or is incrementally constructing a graph (such as a state diagram for an automaton) as part of a problem-solving task or pedagogical exercise, it is difficult or impossible to employ algorithmic graph drawing. In these instances it is more natural to employ a sketching metaphor in which a user draws the graph in a traditional sense. A common strategy for making interactive drawing of diagrams immediately understandable is to incorporate physical analogies; that is, to mimic some familiar real-world appearance or process. For example, the hand-drawn appearance of a diagram can be retained by preserving its unevenness and through the use of textures that impart the appearance of physical writing implements, such as pencil, ink, or chalk. It can be advantageous to retain this type of appearance in situations where userdrawn and computer-drawn diagrams coexist. The behavior of a graph that is interactively altered can also incorporate useful physical metaphors. For example, the edges adjacent to a vertex that is interactively re-positioned by a user can mimic physical linkages that stretch when pulled, and bend or contract when pushed. Such behaviors are natural in that they are almost immediately plausible and predictable to a user. However, not all interactive techniques can benefit from physical metaphors, for some transcend the capabilities of physical media. For example, recognition of hand-drawn elements, such as those representing vertices and edges, are often combined with gradual morphing that can improve the appearance of the diagram. Since physical writing surfaces exhibit no analogous behavior, a spectrum of possibilities has been explored. One approach that has been successfully applied in the context of graph drawing is the approach known as fluid sketching in which drawing and morphing occur nearly simultaneously. There are many potential combinations of algorithmic and interactive graph drawing to explore, such as the graceful re-routing of edges as a user interactively re-positions a vertex, or systems in which a user modifies automatically generated graphs, or in which local improvements are automatically applied to user-drawn graphs. M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, p. 380, 2002. c Springer-Verlag Berlin Heidelberg 2002
Drawing Venn Diagrams Frank Ruskey University of Victoria, Victoria, B.C. V8W 3P6, Canada, [email protected]
Abstract. Venn diagrams have long been used as an aid in understanding set containment relationships and in certain logical arguments. They also have interesting combinatorial properties. This talk is a survey some of what is known about Venn diagrams, particularly the aesthetic and extremal properties of the drawings, including recent results about symmetric Venn diagrams. Connections with graph drawing, of which there are many, will be emphasized. For more about Venn diagrams see http://www.theory.cs.uvic.ca/˜cos/venn.
M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, p. 381, 2002. c Springer-Verlag Berlin Heidelberg 2002
Author Index
Abelson, David 86 Arvo, James 380 Baburin, Danil E. 366 Bachl, Sabine 74 Bachl, Walter 354 Barth, Wilhelm 130 Becker, Bernd 285 Biedl, Therese 54 Binucci, Carla 66 Brandenburg, Franz-Josef 74, 376 Brandes, Ulrik 1 Buchheim, Christoph 344 Byun, Yanga 370 Carmel, Liran 193 Chanda, Amrita 174 Chen, Ho-Lin 332 Cornelsen, Sabine 31 Didimo, Walter 66, 162 Diehl, Stephan 23 Diguglielmo, Gilles 362 Dogrusoz, Ugur 368 Drechsler, Rolf 285 Dujmovi´c, Vida 42, 118 Durocher, Eric 362 Eiglsperger, Markus 1 Eppstein, David 150 Eschbach, Thomas 285 Fiala, Jiˇr´ı 110 Forster, Michael
276
Garg, Ashim 174, 320 Genc, Burkay 368 Ghosh, Shubhashis 244 Giacomo, Emilio Di 142, 162 G¨ org, Carsten 23 G¨ unther, Wolfgang 285 Gutwenger, Carsten 220 Han, Kyungsook 364, 370 Harel, David 193, 207 Healy, Patrick 98
Hong, Seok-Hee
86
Jeong, Euna 370 Ju, Byong-Hyon 364 J¨ unger, Michael 130, 220, 344 Kaplan, Philippe 362 Kaufmann, Michael 1, 12 Koren, Yehuda 193, 207 Kratochv´ıl, Jan 110 Leipert, Sebastian 220, 344 Liao, Chien-Chih 332 Liotta, Giuseppe 66, 142, 162 Lu, Hsueh-I 332 Ma, Kwan-Liu 268 Miura, Kazuyuki 256 Miyazawa, Ayako 256 Morin, Pat 42 Mutton, Paul 374 Mutzel, Petra 130, 220 Newton, Matthew 312 Nikolov, Nikola S. 98 Nishizeki, Takao 244, 256 Nonato, Maddalena 66 Pach, J´ anos 295 Park, Jong H. 364 Patrignani, Maurizio 142 Percan, Merijam 220 Pinchasi, Rom 295 Proskurowski, Andrzej 110 Rahman, Md. Saidur 244 Raitner, Marcus 236 Rodgers, Peter 374 Ruskey, Frank 381 Rusu, Adrian 320 Sander, Georg 362 Schank, Thomas 31 Streinu, Ileana 372 S´ ykora, Ondrej 186, 312 Sz´ekely, L´ aszl´ o A. 186
384
Author Index
Tardos, G´ abor 295 Taylor, Donald E. 86 Teoh, Soon Tee 268 Tosun, Elif 372 T´ oth, G´eza 295 Vasiliu, Adrian 362 Vrt’o, Imrich 186, 312
Wagner, Dorothea 1, 31 Weiskircher, Ren´e 220 Whitesides, Sue 118 Wiese, Roland 12 Wismath, Stephen K. 162 Wood, David R. 42 Yen, Hsu-Chun
332