Sie sind auf Seite 1von 401

Lecture Notes in Computer Science 2528

Edited by G. Goos, J. Hartmanis, and J. van Leeuwen


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: goodrich@ics.uci.edu
Stephen G. Kobourov
University of Arizona
Department of Computer Science
Tucson, AZ 85721-0077, USA
E-mail: kobourov@cs.arizona.edu

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 <http://dnb.ddb.de>.

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äber 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 partici-
pants 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 demonstra-
tions (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 University of Konstanz
Franz Brandenburg University of Passau
Giuseppe di Battista University of Rome
Christian Duncan University of Miami
Michael T. Goodrich (Co-chair) University of California, Irvine
Xin He SUNY Buffalo
Seok-Hee Hong University of Sydney
Michael Kaufmann University of Tübingen
Stephen G. Kobourov (Co-chair) University of Arizona
Giuseppe Liotta University of Perugia
Anna Lubiw University of Waterloo
Petra Mutzel Vienna University of Technology
Stephen North AT&T Research
Roberto Tamassia Brown University
Ioannis Tollis University of Texas, Dallas
Sue Whitesides McGill University

Steering Committee
Franz Brandenburg University of Passau
Giuseppe di Battista University of Rome
Peter Eades University of Sydney
Michael T. Goodrich University of California, Irvine
Michael Jünger University of Cologne
Stephen G. Kobourov University of Arizona
Giuseppe Liotta University of Perugia
Petra Mutzel Vienna University of Technology
Takao Nishizeki Tohoku University
Pierre Rosenstiehl Ecole des Hautes Etudes
en Sciences Sociales
Roberto Tamassia Brown University
Ioannis Tollis University of Texas, Dallas

External Referees
Christian Bachmaier Sabine Cornelsen
Vladimir Batagelj Emilio Di Giacomo
Carla Binucci Walter Didimo
Organization VII

Tim Dwyer Andreas Pick


Hugo do Nascimento Maurizio Pizzonia
Markus Eiglsperger Marcus Raitner
Cesim Erten Thomas Schank
Michael Forster Martin Schönhacker
Carsten Friedrich Falk Schreiber
Marco Gaertler Frank Schulz
Emden Gansner Don E. Taylor
Jan-Willem Goossens Luca Vismara
Gunnar Klau Dorothea Wagner
Gabriele Kodydek Roland Wiese
Maria Flavia Mammana René Weiskircher
Alessandro Marcandalli Thomas Willhalm
Maurizio Patrignani
Leon Peeters

Sponsoring Institutions
In Memoriam: Ivan Rival

The Graph Drawing community is saddened by the loss of Ivan Rival in Jan-
uary, 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 Ot-
tawa 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 Process-
ing 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 visualiza-
tion. 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örg

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ć, 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řı́ Fiala, Jan Kratochvı́l, Andrzej Proskurowski

An Efficient Fixed Parameter Tractable Algorithm


for 1-Sided Crossing Minimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Vida Dujmović, Sue Whitesides

Simple and Efficient Bilayer Cross Counting . . . . . . . . . . . . . . . . . . . . . . . . . . . 130


Wilhelm Barth, Michael Jünger, 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ýkora, László A. Székely, 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ünger, Sebastian Leipert, Petra Mutzel,
Merijam Percan, René 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ünther, Rolf Drechsler, Bernd Becker

Geometric Graphs with No Self-intersecting Path of Length Three . . . . . . . 295


János Pach, Rom Pinchasi, Gábor Tardos, Géza Tóth

Two New Heuristics for Two-Sided Bipartite Graph Drawing . . . . . . . . . . . . 312


Matthew Newton, Ondrej Sýkora, 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ünger, 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
Department of Computer & Information Science, University of Konstanz.
{Ulrik.Brandes|Dorothea.Wagner}@uni-konstanz.de
2
Wilhelm Schickard Institute for Computer Science, University of Tübingen.
{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], quasi-
visibility [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 sys-
tem 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 ver-
tical 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 corre-


sponding 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-shape-
metrics framework [?, Ch. 2.3] by planarizing the graph (topology step), com-
puting 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 ex-
tends 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 op-
timization of an objective function, the Bayesian framework [2,1] suggests to
incorporate a difference metric [6] as a penalty in the objective function. Opti-
mization 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 frame-
work 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 quasi-
orthogonal 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 algo-
rithms. 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

1 
B(Q) = |b| .
2
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 |
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 7

(1,w) (2,0) (1,w) (2,0)


f g f g
(1,0)

(2,0) (2,0)
s (1,2C) s

(a) around a vertex (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 re-
mains 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, be-
cause 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 ver-
tices 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
RelName Schema RelName

ATTRIBUTE REL_ATTRS SCH_RELS Relation


Relation DataType

REL_ATTRS
KEY_ATTRS

d AttrName ATTRIBUTE KEY_ATTRS


Query
KeyNo

KEY INDEX_ATTRS KeyNo


KEYS BASE_RELATION
INDEX_ATTRS VIEW_RELATION

DEFINES KEY KEYS BASE_RELATION d

RefRel

FKEY RefRel VIEW_RELATION Query


FKEY VIEW_ATTRS
DEFINES Indexes

VIEW_ATTRS

AttrName
VIEW_ATTRIBUTE
AttrName VIEW_ATTRIBUTE
AttrNum
INDEX

IndexName INDEX Indexes AttrNum

IndexName IndexType 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 draw-
ings. 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 sce-
nario. 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. Interactive-
Giotto: 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 3-
dimensional orthogonal graph drawing. Journal of Graph Algorithms and Ap-
plications, 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ößmeier and M. Kaufmann. Drawing high degree graphs with low bend num-
bers. Proc. Graph Drawing ’95. Springer LNCS 1027:254–266, 1996.
14. J. Ignatowicz. Drawing force-directed graphs using Optigraph. Proc. Graph Draw-
ing ’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-1-
013, Max-Planck-Institut für Informatik, Saarbrücken, 1998.
17. U. Lauther and A. Stübinger. Generating schematic cable plans using springem-
bedder 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ça and P. Eades. Learning aesthetics for visualization. Anais do XX
Seminário 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ür Informatik, Universität Tübingen, 72076 Tübingen
mk@informatik.uni-tuebingen.de
2
yWorks GmbH, Sand 13, 72076 Tübingen
Roland.Wiese@yworks.de

Abstract. In this paper we present new ideas to extend the frame-


work 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 circu-
lar 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 cir-
cles 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 lay-
out, 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 embed-
ding 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 pro-
posed to handle clusters. Compound graphs and also clustered graphs have two
different representations, an adjacency representation and also an inclusion rep-
resentation. 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 con-
cept. 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 Michael Kaufmann and Roland Wiese

2 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 espe-
cially 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 in-
troduce 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 main-
taining the mental map. The layout of the different parts will either stay un-
changed, 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 38
10
16 5
3 24 39

29
28
21 29
7 31

25 26 34
4 7 18
9
13
20
37
25

28
Root Root 4 16 23
11
2 6
22
8 26 19
34
3
14 5 12
8 11

13
37 17
22 15 14
27
2 9 21
40
36 24
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 in-
dependent 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 un-
derlying 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.

C N N N N N N

C C C C

N N N N N N N N N N N N N N N N

C C C C

N N S N N N S N N S N N N N N 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 hicir-
cular 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 oper-
ations 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

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 bicon-
nected 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.

C S

N N S N C S

N N N S N N C C

N N N N S N 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 ad-
ditional 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, ob-
viously, 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 SPQR-
trees. 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 tree-
like 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 Kauf-
mann/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öz 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 Pre-
sentation Services, IEEE Network, 11, pp. 29-36, 1988.
12. Krebs V., Visualizing Human Networks, Release 1.0: Esther Dyson’s Monthly Re-
port, pp. 1-25, 1996.
13. Lengauer T., Combinatorial Algorithms for Integrated Circuit Layout, Wiley-
Teubner, 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 Hier-
archical 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örg

University of Saarland, FR 6.2 Informatik,


PO Box 15 11 50, D-66041 Saarbrücken, Germany
diehl@acm.org, goerg@cs.uni-sb.de

Abstract. In this paper we present a generic algorithm for drawing se-


quences 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 com-
puting 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
of research. – Jürgen Branke [3]

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örg

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 dis-
v∈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<n 1≤i≤n
Unfortunately, the two optimization goals can not be achieved at the same
time in general. For the online dynamic graph drawing problem l1 , . . . , ln−1 and
gn are given and ln has to be computed.

3.1 Foresighted Layout without Tolerance


In a previous paper we introduced a dynamic graph drawing algorithm which
we called Foresighted Layout [7].
Given a sequence of n graphs we compute a global layout which induces a
layout for each of the n graphs. In the simplest case this global layout is just the
layout of the supergraph of all graphs in the sequence. By forming temporal
equivalence classes of nodes and edges Foresighted Layout can also produce
more compact global layouts. In a GAP (graph animation partition) nodes with
disjoint live times are grouped together. In an RGAP (reduced GAP) also edges
with disjoint live times are represented by a single edge. We have proven the N P-
completeness of computing a minimal GAP respectively RGAP by reduction on
the minimal graph coloring problem [6,10].
A unique feature of the above approach is that once they are drawn on the
screen neither nodes nor the bends of edges change their positions in graphs
subsequently drawn. This algorithm preserves the mental map in a trivial way
by using the global layout, but does so at the cost of other aesthetic criteria.
Foresighted Layout does not work for all classes of graphs equally well, as it
requires that the supergraph, GAP or RGAP of the graphs belongs to the same
class as the individual graphs. For example, in general the supergraph of trees
is not a tree, and the supergraph of planar graphs is not a planar graph.

3.2 Foresighted Layout with Tolerance


In this paper we extend the above method, such that it can trade aesthetic
quality for dynamic stability and vice versa. To this end we use a tolerance
value δ and allow such layouts for individual graphs in the sequence for which
the mental distance to certain other graphs1 is smaller than δ. As a result we
can formulate a weaker problem.
1
The strategies that we are going to present differ particularly with regard to what
other graphs are chosen for comparison.
26 Stephan Diehl and Carsten Görg

Definition 5 (The Tolerant Offline Dynamic Graph Drawing Prob-


lem). Given a sequence of n graphs g1 , . . . , gn and a tolerance value δ. Compute
layouts l1 , . . . , ln for these graphs such that 
1. Δ(li , li+1 ) < δ for all 1 ≤ i < n 2. Γ = Γ (li ) is maximal
1≤i≤n

As a simple corollary we get that 0 ≤ Δ < n ∗ δ. In general we can expect


that Γ increases for larger values of δ. In other words a small δ enforces dynamic
stability, while larger values increase local quality.
For efficiency reasons we do not try to compute an optimal solution, but we
compute approximations. Algorithm 1 is generic in the sense that it works with
different static layout algorithms and related metrics and adjustment strategies.
We use the notation l|g to denote the layout which results from restricting l to
the nodes and edges in g. In other words l|g is the layout for g induced by the
layout l. We use uppercase letters for the global layout L and layouts Li for
graphs gi induced by the global layout. For all other layout we use lowercase.

Algorithm 1. Foresighted Layout with tolerance δ


Compute global layout L for supergraph (resp. GAP or RGAP) of g1 , . . . , gn
for i := 1 to n do
Li := L|gi
// Compute li by adjusting Li
li := adjust(. . .)
// using one of the strategies discussed in Section 3.3
if i==1 then
Draw graph g1 using l1
else
Draw graph gi by morphing from li−1 to li
end if
end for

3.3 Layout Adjustment Strategies


Classical layout adjustment methods adjust(gi , li−1 ) draw a graph gi by adapting
the layout li−1 of the preceding graph. Our adjustment strategies also take the
global layout into account. We use the supergraph (resp. GAP or RGAP) as
a rough abstraction of the whole sequence of graphs. In a sense it contains
information about the whole future. In addition the strategies might consider
the previous, next or all graphs in the sequence. Instead of the graph gi these
strategies get the layout Li for the graph induced by the global layout and try
to adjust it while regarding constraints on the mental distance to other layouts.
If they can not fulfill the constraints these strategies yield the induced layout.

Strategy 1 (Independent Adjustment). li = adjust(Li , δ)


This strategy tries to preserve the mental map by ensuring that Δ(Li , li ) < δ.
As a result all graphs in the animation stay close to the global layout.
Graphs, They Are Changing 27

Strategy 2 (Predecessor Dependent Adjustment). li = adjust(Li , li−1 , δ)


This strategy differs from the above by requiring that the layout stays close to
that of the preceding one, i.e. Δ(li−1 , li ) < δ. Note, that there is no constraint
for adjusting L1 . As a result l1 can be very far from the induced layout and this
can have undesirable effects. The value of Δ(l1 , L2 ) might get greater than δ and
all adjustments to L2 might not sufficiently reduce the mental distance. In this
case the adjustment will fail and return the induced layout.

Strategy 3 (Context Dependent Adjustment). li = adjust(Li , li−1 , Li+1 , δ)


This strategy extends the previous one by enforcing that the layout stays close
to both the preceding layout as well as the induced layout for the subsequent
graph, i.e. Δ(li−1 , li ) < δ and Δ(li , Li+1 ) < δ. In particular, this strategy makes
sure that l1 stays close to L2 and thus we do not run into the problem discussed
above when adjusting L2 .

The above strategies try to adjust a layout as much as possible, before pro-
ceeding to the next one. The previous layout can thus impose too much restric-
tions on the next one and render adjustments impossible. The following strategy
strives to evenly adjust all layouts in the sequence.

Strategy 4 (Simultaneous Adjustment). (l1 , . . . , ln ) = adjust(L1 , . . . , Ln , δ)


This strategy simultaneously adjusts the induced layouts L1 , . . . , Ln such that
Δ(li , li+1 ) < δ for all 1 ≤ i < n. An variant of the simultaneous adjustment
strategy could also try to preserve the inertia of movements.

3.4 Layout Adjustment for Force-Directed Layout

We show how a simple spring embedder [8,2] can be modified to perform layout
adjustment according to the above strategies. Unfortunately once this embed-
ders have computed a layout that does not preserve the mental map further
iterations do not resolve the problem. As a result we extended these embedders
by simulated annealing. We assume a global temperature T which cools off after
each iteration.

Algorithm 2. adjust(Li , li−1 , Li+1 , δ) context dependent


l := Li
for j := 1 to #Iterations do
Compute forces for each node in l with global temperature T
Compute new layout l by applying forces to nodes in l
if Δ(li−1 , l ) < δ and Δ(l , Li+1 ) < δ then
l := l
end if
T := anneal(T, j)
end for
return l
28 Stephan Diehl and Carsten Görg

Algorithm 2 follows immediately from the above general description of the


strategies. In Algorithm 3 the iterations of the embedder are performed simulta-
neously on all layouts. After each step we check whether the mental distances of
a layout and the layouts of its previous and next graphs are below the tolerance
value. If not the layout is discarded and the layout of the previous iteration is
used for the next iteration.

Algorithm 3. adjust(L1 , . . . , Ln , δ) simultaneous


(l1 , . . . , ln ) := (L1 , . . . , Ln )
for j := 1 to #Iterations do
for i := 1 to n do
Compute forces for each node in li with global temperature T
Compute new layout l by applying forces to nodes in li
if Δ(li−1 , l ) < δ and Δ(l , li+1 ) < δ then
li := l
end if
T := anneal(T, j)
end for
end for
return (l1 , . . . , ln )

4 Examples

In Figure 1 navigation through word collocation graphs is shown, more precisely


the sequence consists of the three graphs for the words Lecture, Corbate, Award
and Turing. In the first column the supergraph layouts of the graphs are shown.
The nodes for the mentioned words have always the same relative position (the
three layouts have small mental distances), but the layouts are of poor quality.
In the second column context dependent adjustment with orthogonal mental
distance and δ = 2 is shown. The layout quality is better, but the mental distance
is larger, because the nodes Lecture and Corbate have changed their horizontal
order. In the third column simultaneous adjustment with orthogonal mental
distance and δ = 2 is shown. The layout of the first graph is even more compact
(because more iterations could be performed) and the mental distance is equal
to that of context dependent adjustment.
We have done experiments with several animations including navigation in
the genealogy of the Hohenzollerns (family of German emperors), navigation in
word collocation graphs based on data from www.wortschatz.uni-leipzig.de,
computation of a full lattice for a given set of pairs of integers, as well as several
random animations of graphs and trees. Obviously, these animations are difficult
to show in a paper. Therefore a Java applet with examples is available online at
http://www.cs.uni-sb.de/˜diehl/ganimation/.
Graphs, They Are Changing 29

Fig. 1. Different adjustment strategies.

5 Implementation

In our first prototype implementation we implemented a spring embedder with


polar and parallel magnetic fields, gravity, and simulated annealing similar to
the algorithm used in VCG [16] (except that we do not use local temperatures).
The prototype implements all strategies discussed in this paper and provides
orthogonality and Euclidean distance as mental distances. Smooth transition
between two graphs are animated in the following phases. First all deleted edges
shrink and disappear. Then all deleted nodes disappear. Next all remaining nodes
and edges are moved to their new positions using linear interpolation. Finally
all new nodes appear and all new edges expand. We are currently working on
adjustment strategies for hierarchical layout and these will be integrated into our
original Foresighted Layout implementation that used hierarchical layout [7].

6 Related Work

So far, we have not found any published work on offline dynamic graph draw-
ing. An overview of online dynamic graph drawing has e.g. been given in [3].
The general framework of Brandes and Wagner [1] characterizes the tradeoff be-
tween local quality and dynamic stability using conditional probabilities. In their
formulation the conditional probability for a layout depends on those of the pre-
30 Stephan Diehl and Carsten Görg

ceding ones, i.e. no look-ahead in the sequence is available, but the formulation
could be easily adapted to the offline case.
Finally there are several papers that suggest layout adjustment algorithms
for certain classes of graphs. All these algorithms have in common that they are
based on a certain mental map distance built into the algorithm [13,5,12,14].

7 Conclusion and Future Work


We presented a generic algorithm to compute graph animations. We discussed
several strategies for layout adjustment. The effectiveness of the resulting ani-
mations needs to be studied and evaluations similar to those of Purchase [15]
for aesthetic rules must be performed for dynamic stability. For this we plan to
implement additional layout algorithms and metrics.
The generic nature of our approach allows us to easily combine different
layout algorithms, metrics and adjustment strategies. This comes at the cost of
performance. One solution is to manually or automatically specialize the generic
algorithm with respect to a given layout algorithm, adjustment strategy and
metric before computing the layout. In a specialized algorithm the phases could
be interleaved and allow more clever adjustment, e.g. only new coordinates are
computed for those nodes which violate orthogonality.

References
1. U. Brandes and D. Wagner. A Bayesian paradigm for dynamic graph layout. In
Graph Drawing (Proc. GD ’97), volume 1353 of Lecture Notes Computer Science.
Springer-Verlag, 1997.
2. Ulrik Brandes. Drawing on physical analogies. In Drawing Graphs [11]. 2001.
3. Jürgen Branke. Dynamic graph drawing. In Drawing Graphs [11]. 2001.
4. S. Bridgeman and R. Tamassia. Difference metrics for interactive orthogonal graph
drawing algorithms. In Proceedings of 6th International Symposium on Graph
Drawing GD’98. Springer LNCS 1457, 1998.
5. R.F. Cohen, G. Di Battista, R. Tamassia, and I.G. Tollis. Dynamic graph draw-
ings: Trees, series-parallel digraphs, and st-digraphs. SIAM Journal on Computing,
24(5), 1995.
6. S. Diehl, C. Görg, and A. Kerren. Foresighted Graphlayout. Technical Re-
port A/02/2000, FR 6.2 - Informatik, University of Saarland, December 2000.
http://www.cs.uni-sb.de/tr/FB14.
7. Stephan Diehl, Carsten Görg, and Andreas Kerren. Preserving the Mental Map
using Foresighted Layout. In Proceedings of Joint Eurographics – IEEE TCVG
Symposium on Visualization VisSym’01. Springer Verlag, 2001.
8. P. Eades. A heuristic for graph drawing. Congressus Numerantium, 42, 1984.
9. C. Friedrich and M. E. Houle. Graph Drawing in Motion II. In Proceedings of
Graph Drawing 2001. Springer LNCS (to appear), 2001.
10. M. R. Garey and D. S. Johnson. Computers and Intractability. A Guide to the
Theory of N P-Completeness. Freeman and Company, 1979.
11. M. Kaufmann and D. Wagner, editors. Drawing Graphs – Methods and Models,
volume 2025 of Lecture Notes in Computer Science. Springer-Verlag, 2001.
Graphs, They Are Changing 31

12. K.A. Lyons, H. Meijer, and D. Rappaport. Cluster busting in anchored graph
drawing. Journal of Graph Algorithms and Applications, 2(1), 1998.
13. K. Misue, P. Eades, W. Lai, and K. Sugiyama. Layout Adjustment and the Mental
Map. Journal of Visual Languages and Computing, 6(2):183–210, 1995.
14. A. Papakostas and I.G. Tollis. Interactive orthogonal graph drawing. IEEE Trans-
actions on Computers, 47(11), 1998.
15. H.C. Purchase, R.F. Cohen, and M. James. Validating graph drawing aesthetics. In
F. J. Brandenburg, editor, Graph Drawing (Proc. GD ’95), volume 1027 of Lecture
Notes Computer Science. Springer-Verlag, 1996.
16. G. Sander. Visualization Techniques for Compiler Construction. Dissertation (in
german), University of Saarland, Saarbrücken (Germany), 1996.
Drawing Graphs on Two and Three Lines

Sabine Cornelsen, Thomas Schank, and Dorothea Wagner

University of Konstanz, Department of Computer & Information Science


{Sabine.Cornelsen, Thomas.Schank, Dorothea.Wagner}@uni-konstanz.de

Abstract. We give a linear-time algorithm to decide whether a graph


has a planar LL-drawing, i.e. a planar drawing on two parallel lines. This
has previously been known only for trees. We utilize this result to obtain
planar drawings on three lines for a generalization of bipartite graphs,
also in linear time.

1 Introduction

Let G = (A ∪ B, E) be a partitioned graph, i.e. a graph with a partition of its


vertex set into two disjoint sets A and B. We will refer to the vertices of A as
A-vertices and to the vertices of B as B-vertices, respectively. The question of
drawing partitioned graphs on parallel lines arises from drawing bipartite graphs,
i.e. partitioned graphs such that A and B are independent sets. A natural way
to draw such graphs is to draw all vertices of A on one – say horizontal – line, all
vertices of B on a parallel line, and all edges as straight-line segments between
their end-vertices. Such a drawing will be denoted by BA-drawing.
If G is planar, a drawing without edge crossings would be desirable. Harary
and Schwenk [6] and Eades et al. [3] showed that a bipartite graph G has a
planar BA-drawing if and only of G is a caterpillar, i.e. a tree such that the set
of all vertices of degree larger than one induces a path.
To obtain planar drawings of a larger class of bipartite graphs, Fößmeier
and Kaufmann [5] proposed BAB-drawings. Again, every edge is a straight-
line segment between its end-vertices and all vertices of A are drawn on one
horizontal line, but the vertices of B may be drawn on two parallel lines – one
above the A-vertices and one below. Fößmeier and Kaufmann [5] gave a linear-
time algorithm to test whether a bipartite graph has a planar BAB-drawing.
Another generalization of planar BA-drawings of bipartite graphs are planar
drawings of leveled graphs which are considered by Jünger et al. [7].
Planar drawings for non-bipartite partitioned graphs are considered by Biedl
et al. [1,2]. A complete characterization of graphs that have a planar BA-drawing
is given in [1]. Felsner et al. [4] considered line-drawings of unpartitioned graphs.
They gave a linear time algorithm that decides whether a tree has a planar
straight line drawing on a fixed number of lines.
We will show how to decide in linear time whether an arbitrary graph has
a planar LL-drawing, i.e. a straight line drawing on two parallel lines without

This work was partially supported by the DFG under grant BR 2158/1-1.

M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 31–41, 2002.

c Springer-Verlag Berlin Heidelberg 2002
32 Sabine Cornelsen, Thomas Schank, and Dorothea Wagner

edge crossings. Our algorithm works even if the end-vertices of some edges are
constrained to be on different lines. For planar BAB-drawings, we relax the
condition of bipartiteness to partitioned graphs with the only constraint that
the neighbor of each vertex of B with degree one is in A. Actually, even this
restriction is only necessary in very special cases, which are discussed in Sec-
tion 2.2. Note that LL-drawings of unpartitioned graphs are the special case of
BAB-drawings with A = ∅.
This paper is organized as follows. In Section 2, we consider planar BAB-
drawings. First, we decompose the input graph such that the A-vertices of each
component induce a path. We then show that we can substitute each of these
components by a graph that contains only B-vertices, but simulates the possible
planar BAB-drawings of the component. Finally, in Section 3, we show how to
decide whether an unpartitioned graph has a planar drawing on two parallel
lines.

2 BAB-Drawings
Let G = (A ∪ B, E) be a partitioned graph such that every B-vertex of degree
one is adjacent to an A-vertex. Since we want to test planarity, we can reject
every graph with more than 3n − 6 edges. So we can assume that the number of
edges is linear in the number n := |A ∪ B| of vertices. For a subset S ⊂ A ∪ B
we denote by G(S) the graph that is induced by S.

2.1 Decomposition
If G has a planar BAB-drawing, the connected components of G(A) have to be
paths. Therefore, the vertex set of a connected component of G(A) will be called
an A-path of G. By P(A), we denote the set of A-paths. P(A) can be determined
in linear time. Next, we want to decompose G into components. A subdivision
B-path between two vertices b1 and bk is a set {b2 , . . . , bk−1 } ⊂ B such that
– {bi , bi+1 } ∈ E for i = 1 . . . k − 1 and
– degree bi = 2 for i = 2 . . . k − 1.
For an A-path P ∈ P(A), the A-path component GP is the graph induced by
the union of the following sets of vertices
– set P ,
– set BP of all B-vertices that are incident to P ,
– all subdivision B-paths between two vertices of BP that are not subdivision
B-paths between two vertices of BP  for any P  ∈ P(A) \ {P }.
Similar to the subdivision paths, we also omit edges that would be contained
in several A-path components in any of these components. Figure 1 shows a
graph with three A-path components. A vertex of an A-path component GP
that is adjacent to a vertex of G − GP is called a connection vertex of GP . Given
a BAB-drawing of G, we call the first and last vertex of GP on each of the
Drawing Graphs on Two and Three Lines 33

Fig. 1. Decomposition of a graph into three A-path components. White vertices are A-
vertices, all other vertices are B-vertices. Rectangularly shaped vertices are connection
vertices. Dashed edges are not contained in any of the three A-path components.

three lines a terminal of GP . By the restriction on B-vertices of degree one, the


following lemma is immediate.
Lemma 1. Let P be an A-path of G.
1. All connection vertices of GP are in BP .
2. In any planar BAB-drawing of G, every connection vertex of GP is a ter-
minal of GP .
3. If G has a planar BAB-drawing, GP has at most four connection vertices.
Let P, P  ∈ P(A) be distinct and b1 , b2 ∈ BP ∩ BP  be two connection vertices
of both GP and GP  . Then b1 and b2 are drawn on different lines in any planar
BAB-drawing. In this case, we add edge {b1 , b2 } to G. We will refer to such an
edge as a reminder edge.
Lemma 2. 1. The sum of the sizes of all A-path components is in O(n).
2. There is a linear-time algorithm that either computes all A-path components
and reminder edges or returns an A-path component that has more than four
connection vertices.
Proof. 1. By definition, each edge is contained in at most one A-path compo-
nent. The number of A-path components is at most |A| and each A-path
component is connected. Thus the sum of the number of vertices in all A-
path components is at most |E| + |A| ∈ O(n).
2. First, each subdivision B-path is substituted by a single edge between its two
end-vertices and all sets BP are computed. This can be done in linear time,
e.g. by depth first search. Then for each P ∈ P(A), we examine the incident
edges e of all b ∈ BP . If both end vertices of e are contained in BP ∪ P ,
we add e to GP , if not, we classify b as a connection vertex and stop the
examination of this vertex b. This guarantees that for each vertex, at most
one edge that is not in GP is touched. If the number of connection vertices
of GP is greater than 4, we can return GP , else we add a ‘pre-reminder’ edge
labeled GP between all six pairs of connection vertices of GP to G.
In a final walk through the adjacency list of each connection vertex, we
can use the pre-reminder edges to determine the reminder edges and those
edges of G between connection vertices that have to be added to an A-path
component. Finally, subdivision vertices are reinserted into the replacement
edges. 

34 Sabine Cornelsen, Thomas Schank, and Dorothea Wagner

2.2 Substitution

In this section, we show how to substitute an A-path component GP by a graph


that contains only B-vertices, but simulates all possible planar BAB-drawings
of GP in which the connection vertices are terminals. We say that two terminals
of GP are on the same side of GP in a BAB-drawing if they are both first or
both last vertices on their lines. They are on different sides if one is a first and
the other one a last vertex. Essentially, there are six questions of interest:

#: How many connection vertices are contained in GP ?


η: Does the number of connection-vertices equal the number of B-vertices of GP ?
τ : Does GP have a planar BA-drawing?
τv : For each connection vertex v of GP , is there a planar BAB-drawing of GP
that induces a BA-drawing of GP − v?
σvw : For each pair v, w of connection-vertices of GP , is there a planar BAB-
drawing of GP , such that v and w are on the same side of GP ?
δvw : For each pair v, w of connection-vertices of GP , is there a planar BAB-
drawing of GP , such that v and w are on different sides of GP ?

Note that τ implies τv and τv implies σvw and δvw for any pair v, w of connection
vertices of GP . Thus, provided that there exists some planar BAB-drawing of
GP , these six questions lead to the cases listed in Table 1. Note that the listed
substitutes contain different kind of edges. There is one case with a parallel edge
and one case with a dotted edge. Let G be the graph constructed from G by
substituting each A-path component in the way described above. We say that an
edge in an LL-drawing is vertical if the end vertices of e are drawn on different
lines.

Lemma 3. 1. The size of G is linear in the size of G.


2. G has a planar LL-drawing with every multiple edge and every reminder
edge drawn vertically and no dotted edge having a parallel edge if and only
if G has a planar BAB-drawing.

We discuss only, where the precondition on degree one vertices is needed and
omit the rest of the proof. If we have a planar BAB-drawing and we want to
construct a planar LL-drawing of G by replacing each A-path component GP by
its substitute, we have to make sure, that for any two vertices v and w of GP all
vertices that are drawn between v and w do also belong to GP . But there might
be also subdivision paths S between vertices of degree one and vertices b ∈ BP .
If b is not a connection vertex, we can add S to GP , but if b is a connection
vertex, there need not exist a suitable substitute any more. There is no problem,
if there are at least three subdivision paths between b and vertices of degree one,
since then at least one of them has to be drawn on the other line then b and
then any of them can be drawn there, thus neither has to be added to GP .

Lemma 4. For each component, the six questions that determine the substitute,
can be answered in time linear in the size of the component.
Drawing Graphs on Two and Three Lines 35

Table 1. Substitutes for the A-path components. Cases that correspond up to the
names of the connection vertices are omitted. A + means that the corresponding ques-
tion is answered by yes. A ⊕ means that the answer to this property is implied. No
entry means that the according property is not fulfilled.

1 connection vertex 4 connection vertices


η τ τv σvx σvy σvz
+ ⊕ ⊕ v + + + v • ? • y
? 
+ ⊕ v • w • • • x
+ v @
@ + + v • • x
• • y • • z
v •
~~
+ v • x
• •
y • z

2 connection vertices 3 connection vertices


η τ τv τw σvw δvw τv τw τx σvw σvx σwx
+ + ⊕ ⊕ ⊕ ⊕ v w + + + ⊕ ⊕ ⊕ v w
+ ⊕ ⊕ ⊕ ⊕ {{
v x
w + + ⊕ ⊕ ⊕ v • x
+ ⊕ ⊕ ⊕ ⊕ ||
v • w w
+ + ⊕ ⊕ v w ⊕ ⊕
+ + v • • w
|| }}
• x
+ ⊕ ⊕ v B • + ⊕ ⊕
B x B v
B
w • w •
+ + v • • + + + v • @ • •
@ ~~
w • • w • • • x
+ v • • + + v •
w • • x w
+ v • • + v • •
• • w w • x

Proof. It is obvious how to decide Properties # and η. To decide properties


σvw and δvw , suppose, we have an A-path component GP with an A-path P :
a1 , . . . , ak . For technical reasons, we add vertices a0 and ak+1 , one at each end,
to P .
Let W be the set of vertices of a connected component of GP (B). Suppose
first that we wouldn’t allow edges between B-vertices on different lines. In this
case G(W ) has to be a path and the vertices in W have to occur in the same
order as their adjacent vertices in P . Furthermore, let a (ar ) be the A-vertex
36 Sabine Cornelsen, Thomas Schank, and Dorothea Wagner

with lowest (highest) index that is adjacent to W . Then we say that the edges
{ai , ai+1 }, i = , . . . , r − 1 are occupied by G(W ). Finally, if a vertex b in G(W )
is a connection vertex of GP then b has to be a terminal. Thus, if a is an
A-vertex with the lowest (highest) index that is adjacent to b, then the edges
{ai , ai+1 }, i = 0, . . . , (or i = , . . . , k + 1) are also occupied by G(W ).
In general, if GP has a planar BAB-drawing, G(W ) might be a path with at
most two chords and the A-vertices adjacent to this path may change at most
twice between increasing and decreasing order. Thus, there are three reasons for
changing the line in W : a chord, a change in the order of the adjacent A-vertices,
or a connection vertex. Note also that such a change of lines might occur in at
most two connected components of GP (B). If there is a line change between b1
and b2 in W , then similar to the case of connection vertices above, G(W ) also
occupies the edges between the adjacent A-vertices of b1 and b2 and one end of
the A-path P . Note that in case of a line change some edges in G(P ) might be
occupied twice.

2 1 2 2
0 1 1 2 0 0 1 1 0 0 0
2 1 1 0 1

(a) (b) (c) (d)

Fig. 2. Three reasons for changing a line: a) a chord, b) a change in the order of
adjacent A-vertices, and c) a connection vertex. d) A connection vertex occupies a
part of the A-path. The numbers indicate how many times an edge or a vertex in the
A-path is occupied.

We label every edge and every vertex in G(P ) with the number of times it
is occupied as indicated in Fig. 2, where the number of times a vertex v ∈ P is
occupied by G(W ) is defined as follows. v is occupied k times by G(W ), if both
adjacent edges in the A-path are occupied k-times by W and v is not adjacent
to an end vertex of W and k − 1 times if it is adjacent to such an end vertex. It is
also occupied k − 1-times if one adjacent edge is occupied k-times and the other
one k − 1 times. There exists a planar BAB-drawing with the corresponding
choice of the direction of the connection vertices, if and only if

1. in total, every edge in G(P ) is occupied at most twice and


2. each vertex v ∈ P that is adjacent to an end vertex of a connected component
of GP (B) is occupied at most once.

This test works in linear time, since we can reject the graph, as soon as an edge
gets a label higher than 2 and because there are at most four connection vertices
and at most two components that change lines for which different orientations
have to be checked. A similar approach can be used to answer questions τ and τv .


Drawing Graphs on Two and Three Lines 37

The results in the next section show how to test the conditions of Lemma 3,2,
which completes the algorithm for deciding whether a planar BAB-drawing ex-
ists.

3 LL-Drawings

Given a graph G = (V, E) and a set of edges U ⊂ E, we show how to decide in


linear time whether there exists a planar LL-drawing of G with the property that
each edge in U is drawn vertically. A long version of the planar LL-drawability
test can be found in [8]. We will first discuss trees and then the general case.

3.1 LL-Drawings of Trees

Felsner et al. [4] characterized trees that have a planar LL-drawing and called
them strip-drawable. We give a slightly different characterization.

Lemma 5. A tree T has a planar LL-drawing, if and only if it contains a spine,


i.e. a path S such that T − S is a collection of paths.

Proof. ⇒ The unique path between a leftmost and a rightmost vertex of T in a


planar LL-drawing is a spine of T .
⇐ An LL-drawing can be achieved by placing the spine on one of the lines
and the path components in the order of their adjacency to the spine on the
other line. 


As indicated in [4], the inclusion minimal spine Smin can be computed in linear
time. If a vertex v is required to be an end vertex of a spine, we only have to
check if there is a path between v and an end vertex of Smin in T − Smin . We
will use this fact when we examine the general case. Finally, the following lemma
characterizes whether the edges in a set U ⊂ E can be drawn vertically.
Lemma 6. An edge e can be drawn vertically if and only if there exists a spine
S that contains at least one end vertex of e.

3.2 LL-Drawings of General Graphs

For general graphs, the existence of a spine is still necessary for the existence
of a planar LL-drawing, but it is not necessarily sufficient. For example, see the

Fig. 3. LL-drawings of a tree. The spine is drawn black.


38 Sabine Cornelsen, Thomas Schank, and Dorothea Wagner

graph on the right. To test whether a general graph has a


planar LL-drawing, we first split the graph into components
like paths, trees and two connected components. We give nec-
essary conditions for these components and show how to test
them in linear time. Finally, by constructing a drawing, we
show that these necessary conditions are also sufficient. First
we make the following observation.

Lemma 7. Every graph that has a planar LL-drawing is outer planar.

Proof. Since all vertices are placed on two horizontal lines, every vertex is either
a top most or bottom most vertex and is thus incident to the outer face. 


Suppose now without loss of generality that G is a connected graph. A vertex


v is called a connection vertex, if it is contained in a cycle and its removal
disconnects G. We denote the set of all connection vertices by Vc . The connection
vertices can be determined with depth first search in linear time.

Fig. 4. A graph with a planar LL-drawing. Connection vertices are solid.

A subgraph L of G is called a single line component, if it is maximal with the


property that L is an induced graph and there exists a vertex v ∈ Vc such that
L is a connected component of G − v. By L̄, we denote a single line component
L including its incident connection vertex. If L̄ forms a path we call it a strict
single line component, otherwise we call it a fan.

Fig. 5. Fans and a strict single line component, connection vertices are solid.

Simply testing for all v ∈ Vc , whether the connected components of G(V \


{v}) are paths leads to a quadratic time algorithm for finding the single line
components. But we can use outer-planarity to do it in linear time. Note that
any single line component contains at most two connection vertices (see Fig. 5 for
illustration). Thus, we can find them, by storing the three last visited connection
vertices on a walk around the outer face and testing, whether the vertices between
the first and second occurrence of the same connection vertex induce a path.
Drawing Graphs on Two and Three Lines 39

Let G be the subgraph that results from G by deleting all single line com-
ponents. The two-lined components of G are the components that we get by
splitting G at the connection vertices of G. Two-lined components that do not
contain a cycle will be called tree components. All other two-lined components
will be denoted by two-lined biconnected components. Figure 6 illustrates the
different components of the graph in Fig. 4.

Fig. 6. Components of the graph in Fig. 4. There are two trees, two two-lined bicon-
nected components, two fans, and three strictly single lined components.

We have now defined all components that we need to characterize those


graphs that have a planar LL-drawing. Note that a graph that contains no two-
lined biconnected components has a planar LL-drawing if and only if it contains
a spine. Before we formulate the characterization for the general case, consider
the set L of all two-lined components. Let P be the graph with vertex set L
in which two two-lined components are adjacent if and only if they share a
connection vertex. Suppose a planar LL-drawing for G is given. Then all two-
lined biconnected components require at least two lines. All tree components
also require at least two lines or are connected to two components that require
two lines. Thus P has to be a path. We will refer to this property by saying that
the two-lined components induce a path.

Theorem 1. A graph G has a planar LL-drawing if and only if

1. G is outer planar,
2. the two-lined components induce a path,
3. each tree component T has a spine S such that the connection vertices of T
are end vertices of S, and
4. for each two-lined biconnected component B there is a drawing with the fol-
lowing properties.
(a) Connection vertices are leftmost or rightmost vertices of B on their line.
(b) At most one two-sided component is connected to each vertex of B.
(c) If a two-sided component or a fan is connected to a vertex of B, then a
vertex on the same side is at most connected to a path.

The necessity of these conditions follows from Section 3.1, Lemma 7, and the
observations mentioned above. To show that these conditions are also sufficient,
we sketch how to find a drawing of G in linear time.
40 Sabine Cornelsen, Thomas Schank, and Dorothea Wagner

Drawing and Sufficient Conditions. In this subsection we sketch how to


construct in linear time a planar LL-drawing if the conditions in Theorem 1 are
fulfilled. We also mention which edges can be drawn vertically. Since a linear
order on the two-lined components is given, we only have to show how to draw
each component separately.
It was already shown in Section 3.1 how to find a spine and that a tree with a
spine has a planar LL-drawing. For drawing two-lined biconnected components,
first note that a biconnected graph has a unique outer planar embedding. Start-
ing with a connection vertex on any line, we add the others in the order of their
appearance around the outer face and switch lines only if necessary, i.e. at a con-
nection vertex or a chord. We do this procedure for each direction around the
outer face. Those cases in which lines are switched at most twice, are the pos-
sible outer planar drawings of a two-lined biconnected component, with respect
to Theorem 1,4. Hence, if a drawing exists, it can be found in linear time.
Vertical edges in two-lined biconnected components only yield another condi-
tion for switching lines. Let L be a fan on a single e1
line component L and a connection vertex v. If L is
connected to two two-lined components, only edges e2
between v and L can be vertical edges. Else, also
edges indicated by dotted lines in the Figure on
the right hand side can be drawn upright, but only
one of the edges e1 and e2 simultaneously.

4 Conclusion
We showed how to decide in linear time, whether an arbitrary graph has a
planar drawing on two parallel lines, even if the input contains edges that have
to be drawn vertically. We applied this result to decide in linear time whether a
partitioned graph G = (A∪B, E) with the property that every B-vertex of degree
one is adjacent to an A-vertex has a planar BAB-drawing. The algorithm worked
in three steps. First, the graph was decomposed into A-path components. Then,
each of these components was substituted by a graph that contained only B-
vertices, but simulates the possible positions of the connection vertices. Finally,
we test whether the resulting graph has a planar LL-drawing. We discussed that
the restriction on the vertices of degree one is only needed in the following sense:
If b is a connection vertex of an A-path component, the number of subdivision
B-paths between b and vertices of degree one may not be one or two.
For further research, it would be interesting to examine whether our approach
could be extended to BAAB-drawings, that is drawings for which there are two
parallel middle lines for the A-vertices.

References
1. T. C. Biedl. Drawing planar partitions I: LL-drawings and LH-drawings. In Proceed-
ings of the 14th Annual ACM Symposium on Computational Geometry (SCG ’98),
pages 287–296, 1998.
Drawing Graphs on Two and Three Lines 41

2. T. C. Biedl, M. Kaufmann, and P. Mutzel. Drawing planar partitions II: HH-


drawings. In J. Hromkovic, editor, Graph Theoretic Cocepts in Computer Science,
24th International Workshop, (WG ’98), volume 1517 of Lecture Notes in Computer
Science, pages 124–136. Springer, 1998.
3. P. Eades, B. D. McKay, and N. C. Wormald. On an edge crossing problem. In
Proceedings of the 9th Australian Computer Science Conference (ACSC 9), pages
327–334, 1986.
4. S. Felsner, G. Liotta, and S. K. Wismath. Straight-line drawings on restricted integer
grids in two and three dimensions. In M. Jünger and P. Mutzel, editors, Proceedings
of the 9th International Symposium on Graph Drawing (GD 2001), volume 2265 of
Lecture Notes in Computer Science, pages 328–342. Springer, 2002.
5. U. Fößmeier and M. Kaufmann. Nice drawings for planar bipartite graphs. In
G. Bongiovanni, D. P. Bovet, and G. Di Battista, editors, Proceedings of the 3rd
Italian Conference on Algorithms and Complexity (CIAC ’97), volume 1203 of Lec-
ture Notes in Computer Science, pages 122–134. Springer, 1997.
6. F. Harary and A. Schwenk. A new crossing number for bipartite graphs. Utilitas
Mathematica, 1:203–209, 1972.
7. M. Jünger, S. Leipert, and P. Mutzel. Level planarity testing in linear time. In
S. H. Whitesides, editor, Proceedings of the 6th International Symposium on Graph
Drawing (GD ’98), volume 1547 of Lecture Notes in Computer Science, pages 224–
237. Springer, 1998.
8. T. Schank. Algorithmen zur Visualisierung planarer partition-
ierter Graphen. Master’s thesis, Universität Konstanz, 2001.
http://www.inf.uni-konstanz.de/algo/lehre/theses/.
Path-Width and Three-Dimensional
Straight-Line Grid Drawings of Graphs 

Vida Dujmović1 , Pat Morin2 , and David R. Wood2


1
School of Computer Science, McGill University, Montréal, Canada.
vida@cs.mcgill.ca
2
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) vol-
ume. 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 pre-
viously known for drawings of series-parallel graphs. For planar graphs

we obtain three-dimensional drawings with O(n2 ) volume and O( n)
2
aspect ratio, whereas all previous constructions with O(n ) 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 soft-
ware 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 ver-
tices 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 axis-
aligned 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 three-
dimensional 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 two-


dimensional technique due to Erdös [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 three-
dimensional 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 series-
parallel 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 coordi-
nates 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ć, 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 (tree-
decomposition) 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 path-
decomposition (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ć et al. [13], Hlinĕný [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 three-
dimensional 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) vol-
ume. 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 lan-
guages 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ć, 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 so-
called 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 <i x and y <j w for some layers i and j. Thus β(v) < α(x) and
β(y) < α(w). Since vw is an edge, v and w appear in some bag together; that is,
α(w) ≤ β(v), which implies that β(y) < α(x). This is the desired contradiction
since x and y appear in some bag together. 


The second step of our algorithm is based on the algorithm of Pach et al. [30]
for balancing the size of the colour classes in a vertex-colouring. Note that while
Lemma 2 produces an ordered layering with no intra-layer edges, the remaining
steps of our algorithm are valid in the more general situation that the given
ordered layering possibly has intra-layer edges.

Lemma 3. If a graph G has an ordered k-layering with no X-crossing, then for


every l > 0, G has an ordered l + k -layering with no X-crossing and at most
 nl  vertices in each layer.

Proof. For each layer with q >  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 sub-
layers of the same original layer as there is at most one edge between such sub-
layers. 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 mo-
ment 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 three-
dimensional 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) three-
dimensional 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 two-


dimensional layered graph drawing. An ordered k-layering of a graph G con-
sists of a partition V1 , V2 , . . . , Vk of V (G) into layers, and a total ordering <i
of each Vi , such that for every edge vw, if v <i w then there is no vertex x
with v <i x <i w. The span of an edge vw is |i − j| if v ∈ Vi and w ∈ Vj . An
intra-layer edge is an edge with zero span. An X-crossing consists of two edges
vw and xy such that for distinct layers i and j, v <i x and y <j w. The next
lemma highlights the intrinsic relationship between three-dimensional drawings
and ordered layerings.

Lemma 1. Let G be an n-vertex graph with an A × B × C three-dimensional


drawing. Then G has an ordered AB-layering with no X-crossing, and G has an
ordered 2AB-layering with no X-crossing and no intra-layer edges.

Proof. Let Vx,y be the set of vertices of G with an X-coordinate of x and a


Y -coordinate of y, where without loss of generality 1 ≤ x ≤ A and 1 ≤ y ≤ Y .
Consider each set Vx,y to be ordered Vx,y = (vx,y,1 , . . . , vx,y,nx,y ) by the Z-
coordinates of its elements. Then the ordered layering {Vx,y : 1 ≤ x ≤ A, 1 ≤
y ≤ Y } has no X-crossing as otherwise there would be a crossing in the original
 
drawing. Now, define Vx,y = {vx,y,j : j odd} and Vx,y = {vx,y,j : j even}, and
consider these sets to be ordered as in Vx,y . Then, as in the above, the ordered
 
layering {Vx,y , Vx,y : 1 ≤ x ≤ A, 1 ≤ y ≤ B} has no X-crossing. Moreover there

is no intra-layer edges, as otherwise an edge between two vertices in Vx,y would

have passed through a vertex in Vx,y (or vice versa) in the original drawing.  
48 Vida Dujmović, Pat Morin, and David R. Wood

Cohen et al. [8] allow three ‘free’ dimensions, whereas Pach et al. [30] use the as-
signment of vertices to colour classes to ‘fix’ one dimension with two dimensions
free. We use an assignment of vertices to layers in an ordered layering without
X-crossings to fix two dimensions with one dimension free.

Lemma 4. If a graph G has an ordered k-layering {(Vi , <i ) : 1 ≤ i ≤ k} with


no X-crossing then G has a k × 2k × 2k · n three-dimensional drawing, where n
is the maximum number of vertices in a layer.

Proof. Let p be the smallest prime such that p > k. Then p ≤ 2k by Bertrand’s
postulate. For each i, 1 ≤ i ≤ k, represent the vertices in Vi by the grid-points

{(i, i2 mod p, t) : 1 ≤ t ≤ p · |Vi |, t ≡ i3 (mod p)} ,

such that the Z-coordinates respect the given linear ordering <i . Draw each edge
as a line-segment between its end-vertices. Suppose two edges e and e cross such
that their end-vertices are at distinct points (iα , i2α mod p, tα ), 1 ≤ α ≤ 4. Then
these points are coplanar, and if M is the matrix
⎛ ⎞
1 i1 i21 mod p t1
⎜1 i2 i22 mod p t2 ⎟
M =⎜ ⎝1 i3 i23 mod p t3 ⎠

1 i4 i24 mod p t4

then the determinant det(M ) = 0. We proceed by considering the number of


distinct layers N = |{i1 , i2 , i3 , i4 }|.
• N = 1: By the definition of an ordered layering e and e do not cross.
• N = 2: If either edge is intra-layer then e and e do not cross. Otherwise
neither edge is intra-layer, and since there are no X-crossings in the ordered
layering, e and e do not cross.
• N = 3: Without loss of generality i1 = i2 . It follows that det(M ) =
(t2 − t1 ) · det(M  ), where
⎛ ⎞
1 i2 i22 mod p
M  = ⎝1 i3 i23 mod p⎠ .
1 i4 i24 mod p

Since t1 = t2 , det(M  ) = 0. However, M  is a Vandermonde matrix modulo p,


and thus
det(M  ) ≡ (i2 − i3 )(i2 − i4 )(i3 − i4 ) (mod p),
which is non-zero since i2 , i3 and i4 are distinct and p is a prime, a contradiction.
• N = 4: Let M  be the matrix obtained from M by taking each entry modulo
p. Then det(M  ) = 0. Since tα ≡ i3α (mod p), 1 ≤ α ≤ 4,
⎛ ⎞
1 i1 i21 i31
⎜1 i2 i22 i32 ⎟
M ≡ ⎜ ⎟
⎝1 i3 i23 i33 ⎠ (mod p) .
1 i4 i24 i34
Path-Width and Three-Dimensional Straight-Line Grid Drawings of Graphs 49

Since each iα < p, M  is a Vandermonde matrix modulo p, and thus

det(M  ) ≡ (i1 − i2 )(i1 − i3 )(i1 − i4 )(i2 − i3 )(i2 − i4 )(i3 − i4 ) (mod p),

which is non-zero since iα = iβ and p is a prime. This contradiction proves there


are no edge crossings. The produced drawing is at most k × 2k × 2k · n . 


We now prove the theorems.


Proof of Theorem 1. By Lemma 2, G has an ordered k-layering with no X-
crossing, where k = pw(G) + 1. By Lemma 3 with l = k, G has an ordered
(2k)-layering with no X-crossing and at most  nk  vertices on each layer. By
Lemma 4, G has a 2k × 4k × 4k ·  nk  three-dimensional drawing, which is at
most 2(pw(G) + 1) × 4(pw(G) + 1) × 4(n + pw(G) + 1). The result follows since
1 ≤ pw(G) < n. 

Proof of Theorem 2. By Lemma 2, G has an ordered k-layering with no X-
crossing, where k = pw(G) + 1. By Lemma 3 with l = nr , G has an ordered
 nr + k-layering with no X-crossing and at most r vertices in each layer. By
assumption r ≤ n/(pw(G) + 1). Thus k ≤ nr and the number of layers is at most
r . By Lemma 4, G has a r × r × 4n three-dimensional drawing, which has
2n 2n 4n
3 2
volume 32n /r and aspect ratio 2r. 


3 Commentary
Consider the following open problems concerning straight-line grid drawings.

1. A graph with degree bounded by some constant k is (k + 1)-colourable, and


thus by the theorem of Pach et al. [30], has a three-dimensional drawing
with O(n2 ) volume. Pach et al. [30] ask whether every graph with bounded
degree has a three-dimensional drawing with o(n2 ) volume?
2. As discussed in Section 1 every planar graph has a three-dimensional drawing
with O(n2 ) volume. Felsner et al. [17] ask whether every planar graph has
a three-dimensional drawing with O(n) volume? Even a volume bound of
o(n2 ) would be interesting.

As a final observation, we show that a generalisation of the ‘wrapping’ al-


gorithm of Felsner et al. [17] can be applied in conjunction with our algorithm,
which may be helpful in solving the above open. Note that Felsner et al. [17]
prove the case s = 1 (with improved constants in the volume).

Lemma 5. Let a graph G have an ordered k-layering {(Vi , <i ) : 1 ≤ i ≤ k} with


no X-crossing. If the maximum edge span is s, then G has an O(s)×O(s)×O(n)
three-dimensional drawing.

Proof. Let t = 2s + 1. Construct an ordered t-layering of G by merging the


layers {Vi : i ≡ j (mod t)} for each j, 0 ≤ j ≤ t − 1, with vertices in Vα
appearing before vertices in Vβ in the new layer j, for all α, β ≡ j (mod t) with
50 Vida Dujmović, Pat Morin, and David R. Wood

α < β. The given ordering of each Vi is preserved in the new layers. It remains
to prove that there is no X-crossing. Consider two edges vw and xy. Let i1 and
i2 , 1 ≤ i1 < i2 ≤ k, be the minimum and maximum layers containing v, w, x or
y in the ordered k-layering.
Firstly consider the case that i2 − i1 > 2s. Then without loss of generality v
is on layer i2 and y is on layer i1 . Thus w is on a greater layer than x, and even
if x (or y) appear on the same layer as v (or w) in the new t-layering, x (or y)
will be to the left of v (or w). Thus these edges do not form an X-crossing in
the ordered t-layering. Otherwise i2 − i1 ≤ 2s. Thus any two of v, w, x or y will
appear on the same layer in the t-layering if and only if they are on the same
layer in the given ordered k-layering (since t > 2s). Hence the only way for these
four vertices to appear on exactly two layers in the ordered t-layering is if they
were on exactly two layers in the given k-layering, in which case, by assumption
vw and xy do not form an X-crossing.
Therefore there are no X-crossings. By Lemma 3 with l = t, G has an ordered
2t-layering with no X-crossing and at most  nt  vertices in each layer. Since
t = 2s + 1, by Lemma 4, G has a 2(2s + 1) × 4(2s + 1) × 4(2s + 1) 2s+1 n
 three-
dimensional drawing, which is 2(2s + 1) × 4(2s + 1) × 4(n + 2s). The result follows
since s ≤ n. 


Lemma 5 also shows that small path-width is not necessary √ for√a graph
to have a three-dimensional drawing
√ with small volume. The n × n plane
grid graph has path-width Θ( n), but has an ordered layering with maximum
edge span 1. Therefore it has a three-dimensional drawing with O(n) volume by
Lemma 5.

Note Added in Proof


The results in this paper have recently been extended. In particular, Wood [38]
has proved that every graph G from a proper minor-closed family has a O(1) ×
O(1) × O(n) three-dimensional drawing if and only if G has O(1) queue-number,
and Dujmović and Wood [14] have proved that graphs of bounded tree-width
have three-dimensional drawings with O(n) volume.

Acknowledgements
The authors are grateful for stimulating discussions with Prosenjit Bose, Hu-
bert de Fraysseix, Stefan Langerman, Giuseppe Liotta, and Patrice Ossona de
Mendez.

References
[1] H. L. Bodlaender, A linear-time algorithm for finding tree-
decompositions of small treewidth. SIAM J. Comput., 25(6):1305–1317,
1996.
Path-Width and Three-Dimensional Straight-Line Grid Drawings of Graphs 51

[2] H. L. Bodlaender, A partial k-arboretum of graphs with bounded


treewidth. Theoret. Comput. Sci., 209(1-2):1–45, 1998.
[3] F. J. Brandenburg, ed., Proc. International Symp. on Graph Drawing
(GD ’95), vol. 1027 of Lecture Notes in Comput. Sci., Springer, 1996.
[4] I. Bruß and A. Frick, Fast interactive 3-D graph visualization. In [3],
pp. 99–110.
[5] T. Calamoneri and A. Sterbini, 3D straight-line grid drawing of 4-
colorable graphs. Inform. Process. Lett., 63(2):97–102, 1997.
[6] K. Chilakamarri, N. Dean, and M. Littman, Three-dimensional Tutte
embedding. In Proc. 26th Southeastern International Conf. on Combina-
torics, Graph Theory and Computing, vol. 107 of Cong. Numer., pp. 129–
140, 1995.
[7] M. Chrobak, M. Goodrich, and R. Tamassia, Convex drawings of
graphs in two and three dimensions. In Proc. 12th Annual ACM Symp. on
Comput. Geom., pp. 319–328, 1996.
[8] R. F. Cohen, P. Eades, T. Lin, and F. Ruskey, Three-dimensional
graph drawing. Algorithmica, 17(2):199–208, 1996.
[9] I. F. Cruz and J. P. Twarog, 3D graph drawing with simulated anneal-
ing. In [3], pp. 162–165.
[10] H. de Fraysseix, J. Pach, and R. Pollack, How to draw a planar
graph on a grid. Combinatorica, 10(1):41–51, 1990.
[11] E. di Giacomo, G. Liotta, and S. Wismath, Drawing series-parallel
graphs on a box. In S. Wismath, ed., Proc. 14th Canadian Conf. on Com-
putational Geometry (CCCG ’02), The University of Lethbridge, Canada,
2002.
[12] R. G. Downey and M. R. Fellows, Parameterized complexity. Springer,
1999.
[13] V. Dujmović, M. Fellows, M. Hallett, M. Kitching, G. Liotta,
C. McCartin, N. Nishimura, P. Ragde, F. Rosemand, M. Suder-
man, S. Whitesides, and D. R. Wood, On the parameterized complexity
of layered graph drawing. In F. Meyer auf der Heide, ed., Proc. 5th An-
nual European Symp. on Algorithms (ESA ’01), vol. 2161 of Lecture Notes
in Comput. Sci., pp. 488–499, Springer, 2001.
[14] V. Dujmović and D. R. Wood, Tree-partitions of k-trees with applica-
tions in graph layout. Tech. Rep. TR-02-03, School of Computer Science,
Carleton University, Ottawa, Canada, 2002.
[15] P. Eades and P. Garvan, Drawing stressed planar graphs in three di-
mensions. In [3], pp. 212–223.
[16] P. Erdös, Appendix. In K. F. Roth, On a problem of Heilbronn. J.
London Math. Soc., 26:198–204, 1951.
[17] S. Felsner, S. Wismath, and G. Liotta, Straight-line drawings on
restricted integer grids in two and three dimensions. In [28], pp. 328–342.
[18] A. Garg, R. Tamassia, and P. Vocca, Drawing with colors. In J. Diaz
and M. Serna, eds., Proc. 4th Annual European Symp. on Algorithms
(ESA ’96), vol. 1136 of Lecture Notes in Comput. Sci., pp. 12–26, Springer,
1996.
52 Vida Dujmović, Pat Morin, and David R. Wood

[19] A. Gupta and N. Nishimura, Sequential and parallel algorithms for em-
bedding problems on classes of partial k-trees. In Proc. 4th Scandinavian
Workshop on Algorithm Theory (SWAT ’94), vol. 824 of Lecture Notes in
Comput. Sci., pp. 172–182, Springer, 1984.
[20] A. Gupta, N. Nishimura, A. Proskurowski, and P. Ragde, Embed-
dings of k-connected graphs of pathwidth k. In M. M. Halldorsson, ed.,
Proc. 7th Scandinavian Workshop on Algorithm Theory (SWAT ’00), vol.
1851 of Lecture Notes in Comput. Sci., pp. 111–124, Springer, 2000.
[21] P. Hlinĕný, Crossing-critical graphs and path-width. In [28], pp. 102–114.
[22] S.-H. Hong, Drawing graphs symmetrically in three dimensions. In [28],
pp. 189–204.
[23] S.-H. Hong and P. Eades, An algorithm for finding three dimensional
symmetry in series parallel digraphs. In D. Lee and S.-H. Teng, eds.,
Proc. 11th International Conf. on Algorithms and Computation (ISAAC
’00), vol. 1969 of Lecture Notes in Comput. Sci., pp. 266–277, Springer,
2000.
[24] S.-H. Hong and P. Eades, An algorithm for finding three dimensional
symmetry in trees. In J. Marks, ed., Proc. 8th International Symp. on
Graph Drawing (GD ’00), vol. 1984 of Lecture Notes in Comput. Sci., pp.
360–371, Springer, 2001.
[25] S.-H. Hong, P. Eades, A. Quigley, and S.-H. Lee, Drawing algorithms
for series-parallel digraphs in two and three dimensions. In S. Whitesides,
ed., Proc. 6th International Symp. on Graph Drawing (GD ’98), vol. 1547
of Lecture Notes in Comput. Sci., pp. 198–209, Springer, 1998.
[26] F. T. Leighton and A. L. Rosenberg, Three-dimensional circuit lay-
outs. SIAM J. Comput., 15(3):793–813, 1986.
[27] B. Monien, F. Ramme, and H. Salmen, A parallel simulated annealing
algorithm for generating 3D layouts of undirected graphs. In [3], pp. 396–
408.
[28] P. Mutzel, M. Jünger, and S. Leipert, eds., Proc. 9th International
Symp. on Graph Drawing (GD ’01), vol. 2265 of Lecture Notes in Comput.
Sci., Springer, 2002.
[29] D. I. Ostry, Some Three-Dimensional Graph Drawing Algorithms. Mas-
ter’s thesis, Department of Computer Science and Software Engineering,
The University of Newcastle, Australia, 1996.
[30] J. Pach, T. Thiele, and G. Tóth, Three-dimensional grid drawings of
graphs. In G. Di Battista, ed., Proc. 5th International Symp. on Graph
Drawing (GD ’97), vol. 1353 of Lecture Notes in Comput. Sci., pp. 47–51,
Springer, 1998.
[31] Z. Peng, Drawing Graphs of Bounded Treewidth/Pathwidth. Master’s the-
sis, Department of Computer Science, University of Auckland, New Zealand,
2001.
[32] T. Poranen, A new algorithm for drawing series-parallel digraphs in 3D.
Tech. Rep. A-2000-16, Dept. of Computer and Information Sciences, Uni-
versity of Tampere, Finland, 2000.
Path-Width and Three-Dimensional Straight-Line Grid Drawings of Graphs 53

[33] W. Schnyder, Planar graphs and poset dimension. Order, 5(4):323–343,


1989.
[34] M. Thorup, All structured programs have small tree-width and good reg-
ister allocation. Information and Computation, 142(2):159–181, 1998.
[35] C. Ware and G. Franck, Viewing a graph in a virtual reality display
is three times as good as a 2D diagram. In A. L. Ambler and T. D.
Kimura, eds., Proc. IEEE Symp. Visual Languages (VL ’94), pp. 182–183,
IEEE, 1994.
[36] C. Ware, D. Hui, and G. Franck, Visualizing object oriented soft-
ware in three dimensions. In Proc. IBM Centre for Advanced Studies Conf.
(CASCON ’93), pp. 1–11, 1993.
[37] R. Weiskircher, Drawing planar graphs. In M. Kaufmann and
D. Wagner, eds., Drawing Graphs: Methods and Models, vol. 2025 of Lec-
ture Notes in Comput. Sci., pp. 23–45, Springer, 2001.
[38] D. R. Wood, Queue layouts, tree-width, and three-dimensional graph
drawing. Tech. Rep. TR-02-02 (revised), School of Computer Science, Car-
leton University, Ottawa, Canada, August, 2002.
Drawing Outer-Planar Graphs
in O(n log n) Area


Therese Biedl

School of Computer Science, University of Waterloo,


Waterloo, ON N2L 3G1, Canada, biedl@uwaterloo.ca

Abstract. In this paper, we study drawings of outer-planar graphs in


various models. We show that O(n log n) area can be achieved for such
drawings if edges are allowed to have bends or if vertices may be rep-
resented by boxes. The question of straight-line grid-drawings of outer-
planar graphs in o(n2 ) area remains open.

1 Introduction
A planar graph is a graph that can be drawn without crossing. Fáry, Stein and
Wagner [Fár48,Ste51,Wag36] proved independently that every planar graph has
a drawing such that all edges are drawn as straight-line segments. De Fraysseix,
Pach and Pollack [FPP90], and independently Schnyder [Sch90] established that
in fact O(n2 ) area suffices for a straight-line drawing of an n-vertex planar graph,
with vertices placed at grid points. This is asymptotically optimal, since there
are planar graphs that need Ω(n2 ) area [FPP88].
A number of other graph drawing models (e.g., poly-line drawings, orthogonal
drawings, visibility representations) exist for planar graphs. See Section 2 for
precise definitions. In all these models, O(n2 ) area can be achieved for planar
graphs, see for example [Kan96,FKK97,Wis85]. On the other hand, Ω(n2 ) area
is needed, even in these models, for the graph in [FPP88].
Our paper was motivated by the question whether an area of o(n2 ) is pos-
sible, at least in some models, for subclasses of planar graphs such as trees,
series-parallel graphs, and outer-planar graphs. Every tree has a straight-line
drawing in O(n log n) area [Shi76], and in O(n) area if the maximum degree is
asymptotically smaller than n [GGT96]. On the other hand, one can easily con-
struct a series-parallel graph that requires Ω(n2 ) area if the planar embedding
must be preserved (see also Fig. 11). The question of whether every series-parallel
graph can be drawn in o(n2 ) area when the planar embedding may be changed
appears to be open. See [DBETT98] for many other upper and lower bounds
regarding drawings of trees and series-parallel graphs under special restrictions.
Not many drawing results are known for outer-planar graphs. Leiserson [Lei80]
showed that outer-planar graphs have an orthogonal point-drawing in O(n) area

Research supported by NSERC. The author would like to thank Erik Demaine,
Henk Meijer, Steve Wismath and the Algorithmic Problem Session Group at the
University of Waterloo for inspiring discussions.

M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 54–65, 2002.

c Springer-Verlag Berlin Heidelberg 2002
Drawing Outer-Planar Graphs in O(n log n) Area 55

if the maximum degree is at most 4. By splitting vertices of higher degrees,


and combining them in the resulting drawing after replacing each grid-line with
Δ grid-lines (where Δ is the maximum degree), one can obtain orthogonal box-
drawings of area O(Δ2 n). However, this is an improvement over the O(n2 ) bound
only if Δ is small.
In another result, any n points in general position can be used for a straight-
line drawing of any outer-planar graph [CU96]. However, O(n2 ) area is needed
to create n grid points in general positions, so this result does not lead to smaller
area bounds either.
In this paper, we provide the following results:
– Every outer-planar graph has an orthogonal box-drawing with area O(nlog n).
– By converting this drawing, it follows easily that every outer-planar graph
has a poly-line grid drawing in area O(n log n).
– Every outer-planar graph has a visibility representation in O(n log n) area;
however, not all vertices are necessarily drawn on the outer-face.
The question whether o(n2 ) area is possible for straight-line drawing remains
open. In fact, not even any lower bounds better than the obvious Ω(n) appear
to be known; we provide some partial results for lower bounds as well.

2 Definitions
Let G = (V, E) be a graph with n = n(G) = |V | vertices. We assume that G
is simple, i.e., it has no loops and multiple edges. Throughout this paper, we
will assume that G is planar, i.e., that G can be drawn without crossing. Such
a planar drawing can be characterized by the cyclic order of edges around each
vertex. A planar drawing splits the plane into connected pieces; the unbounded
piece is called the outer-face, all other pieces are called interior faces.
An outer-planar graph is a planar graph that can be drawn such that all
vertices are incident to the outer-face. Throughout this paper we will assume
that G is outer-planar; in fact, we will assume that it is maximal outer-planar,
i.e., no edge can be added to G without destroying simplicity or outer-planarity.
(If G is not maximal outer-planar, simply add edges until it is, draw the resulting
graph, and delete the extra edges from the drawing.) A maximal outer-planar
graph consists of an n-cycle with chords and every interior face is a triangle.
We use the following drawing models (see also Fig. 1):
– Straight-line drawings: Vertices are points, all edges are straight-line seg-
ments.
– Poly-line drawings: Vertices are points, all edges are contiguous sequences of
straight-line segments.
– Orthogonal point-drawings: A poly-line drawing where all edge segments are
horizontal or vertical. Such drawings exist only if the maximum degree is at
most 4.
– Orthogonal box-drawings: Vertices are (axis-parallel) boxes, edges are con-
tiguous sequences of horizontal or vertical segments.1
1
In this paper, the term “box” is referring to an axis-parallel box.
56 Therese Biedl

Fig. 1. The same graph in a straight-line drawing, a poly-line drawing, an orthogonal


point-drawing, an orthogonal box-drawing, and a visibility representation.

– Visibility representations: Vertices are boxes, edges are horizontal or vertical


segments.
For a planar graph, such drawings should be planar, i.e., have no crossing.
We also assume that all defining features have integral coordinates; in particu-
lar points of vertices and transition-points (bends) in the routes of edges have
integral coordinates, and boxes of vertices have integral corner points. We allow
boxes to be degenerate, i.e., to be line segments or points.
The width of a box is the number of vertical grid lines (columns) that are
occupied by it. The height of a drawing is the number of horizontal grid lines
(rows) that are occupied by it. A drawing whose minimum enclosing box has
width w and height h is called an w × h-drawing, and has area w · h.

3 Orthogonal Box-Drawings
Let G = (V, E) be a maximal outer-planar graph. In this section, we show how
to construct an orthogonal box-drawing of G in a grid of area O(n log n). For
the remainder of this section, “drawing” will refer to “orthogonal box-drawing”.
We use induction on the number of vertices with the following induction
hypothesis (see also Fig. 2): Let (u, v) be an edge on the outer-face of G, with v
after u in clockwise order on the outer-face. Then G has a drawing such that
– u occupies the top right corner of the drawing,
– v occupies the bottom right corner of the drawing,
– vertices have height 1, i.e., each vertex intersects only one row,2
– edges that attach horizontally at an endpoint have no bend.
In the base case (n = 2), simply place u atop v; see Fig. 2. The conditions of
the induction hypothesis are clearly satisfied.
For n ≥ 3, let w be the third vertex on the interior face incident to (u, v).
Let G1 be the graph induced by the vertices between w and u in clockwise order
on the outer-face (we call this the graph attached to edge (u, w); see also Fig. 3).
Let G2 be the subgraph attached to (w, v). Note that G1 or G2 may contain
only one edge. We will for now assume that n(G1 ) ≤ n(G2 ); the other case will
be treated later.
2
In our drawings, we “fatten” vertices for better visibility.
Drawing Outer-Planar Graphs in O(n log n) Area 57

u v u

u
v
v

Fig. 2. Illustration of the induction hypothesis, and the base case n = 2.

u v
Ga
u v
x G2
w
G1 Gb
w G2

Fig. 3. Breaking the graph into parts (and breaking G1 further in Case 2).

We have two sub-cases:


Case 1: If G1 has only two vertices u and w, then recursively draw G2 with
respect to edge (w, v). Place u to the right of w, extend v, and draw the new
edge as straight line. See Fig. 4. One can easily verify the induction hypothesis.

u v
w u

G2
w G2
v

Fig. 4. The case when G1 consists of only one edge.

Case 2: If G1 contains at least three vertices, then let x be the third vertex
on the face other than {u, v, w} incident to (u, w). Let Ga and Gb be the two
subgraphs attached to edges (u, x) and (x, w); see also Fig. 3. Recursively draw
Ga , Gb and G2 , with respect to edges (u, x), (x, w) and (w, v), respectively, and
let Γa , Γb and Γ2 be the corresponding drawings.
We now modify Γa to achieve an additional property. By the induction hy-
pothesis, vertex x occupies the bottom right corner of Γa . We say that x spans
the bottom of Γa if additionally x occupies the bottom left corner, i.e., if x oc-
cupies the complete bottom row of Γa . As we show now, we can always modify
Γa by adding at most one row so that this holds. For if x does not occupy the
bottom left corner of Γa , then add one more row below Γa , move x into it and
expand x so that it occupies the whole width of the drawing. Now re-route the
incident edges of x. All edges that attach vertically at x can simply be extended.
58 Therese Biedl

If an edge (z, x) attaches horizontally at x, then (by the induction hypothesis)


this edge has no bend. Since x only intersects one row by induction hypothesis,
this implies that z occupies part of the last row of Γa . Therefore, we can route
edge (z, x) vertically from z to x, which is now one row below. See also Fig. 5.

u u

x x

Fig. 5. Modifying Γa into Γa .

Let Γa be the drawing that we obtain from Γa by making x span the bottom.
In a similar fashion, we modify Γb such that x spans the top, i.e., x occupies both
top corners. (By induction hypothesis x already occupies the top right corner of
Γb .) Call this new drawing Γb .
Now we obtain a drawing of G by placing Γ2 , Γb and Γa next to each other.
See Fig. 6 for an illustration of the following process. Stretch Γa or Γb , if nec-
essary, until both drawings have the same height. (Note that any orthogonal
box-drawing can be stretched by inserting empty rows.) Next, stretch Γ2 , if nec-
essary, such that it is at least two units taller than Γa and Γb . Now place Γ2 ,
then Γb (turned upside down) and then Γa such that their tops are aligned.
By the placement, the two boxes of w are adjacent in the same row and can
simply be rejoined. Since Γa and Γb have the same height, and since x spans both
drawings Γa and Γb , the boxes of x are also adjacent in the same row and can be
rejoined. Since Γ2 is at least two units taller than Γa , there are two empty rows
underneath Γa and Γb . We use these to extend v to the right bottom corner and
to route edge (w, u) with two bends. Edge (u, v) is a vertical line in the rightmost
column. One easily verifies the induction hypothesis.

w w u

Γ2 Γb Γa
x x

Fig. 6. Combining Γa , Γb and Γ2 .

Thus we are done with the case n(G1 ) ≤ n(G2 ). The case n(G1 ) > n(G2 ) is
symmetric; we do not give the details here and refer to Fig. 7.
Drawing Outer-Planar Graphs in O(n log n) Area 59

u v
u

G1
G1 w
w v
u v u
Ga
w x x
G1 x
Γ1 Γb Γa
Gb

w w v

Fig. 7. The construction if n(G1 ) > n(G2 ).

Theorem 1. Every outer-planar graph has an orthogonal box-drawing such that


the following holds:
– The height is at most 3 log n − 1,
– the width is at most 52 n − 4,
– the planar embedding is respected,
– the total number of bends is at most n − 2,
– every edge has at most two bends, every edge on the outer-face has no bends.
Proof. The construction is given above. The bounds on the width, height and
number of bends are easily verified in the base case and in Case 1 of the recursion,
so we will only focus on Case 2. Let G1 , G2 , Ga , Gb , Γ2 , Γa , Γb , Γa and Γb be
defined as before.
Since n(G1 ) ≤ n(G2 ), we have n(Ga ) ≤ n2 . Therefore by induction Γa has
height at most 3 log n(Ga ) − 1 ≤ 3 log n − 4. We add one grid line to obtain Γa ,
so Γa has height at most 3 log n − 3. Similarly Γb has height at most 3 log n − 3.
Finally, Γ2 has height at most 3 log n − 1 by induction. When stretching the
drawings to achieve suitable heights, we will not exceed these bounds. Finally,
during the merging process (Fig.6), we use two more grid lines near Γa and Γb ,
resulting in a total height of at most 3 log n − 1.
The width of the drawing is the combined width of Γ2 , Γa and Γb , with three
more columns added. Since n(G2 ) + n(Ga ) + n(Gb ) = n + 2, and using induction,
the width is at most
5 5 5 5 5
3 + n(G2 ) − 4 + n(Ga ) − 4 + n(Gb ) − 4 = 3 + (n + 2) − 12 = n − 4.
2 2 2 2 2
Similarly, the total number of bends is at most

2 + n(G2 ) − 2 + n(Ga ) − 2 + n(Gb ) − 2 = 2 + (n + 2) − 6 = n − 2.

Every edge receives at most 2 bends, if it is edge (w, u). Note in particular
that this can be the case only for a chord; any edge on the outer-face of G is
drawn as a straight line.
60 Therese Biedl

4 Poly-line Drawings
From any orthogonal box-drawing, we can easily obtain a poly-line drawing
with asymptotically the same area as follows: Add empty grid-lines until every
segment of every edge has length at least 2. Now for every vertex v, create a
point for v at an arbitrary grid point inside the box of v. For each incident edge
e of v, re-route e to end at this point by placing a new bend (if needed) at
the grid-line incident to the box of v. (Such a grid-line must exist, and does not
contain any other vertex, since e had length at least 2 by assumption.) See Fig. 8
for an illustration.

Fig. 8. Converting to a point-drawing.

If we start with the orthogonal box-drawing obtained in Section 3, then by


analyzing the construction more carefully, we can improve this general construc-
tion as follows:
– We only need to add log n new rows, since only in the base case and in the
construction in Fig. 5 vertical edge segments of length 1 can be created.
More precisely, we can show by induction on the number of vertices similarly
as before that there exists an orthogonal box-drawing of height 4 log n − 1
and width 52 n − 4 such that all vertical edges segments have length at least
2. This is obtained by adding one extra row with the base case, and one
extra row whenever we need to modify the drawing to make a vertex span
the bottom or top of a drawing.
– We need not add new columns, since every vertex has height 1, and therefore
horizontal edge segments can simply be extended without adding a bend.
– We can achieve at most three bends per edge with a good choice of grid
points for vertices. Note that every edge obtains at most one extra bend at
every endpoint, so we only have to be careful for edges that had two bends
in the orthogonal drawing. By construction, this happens only for an edge
(w, u) added during Case 2 of the recursive construction.
If (w, u) is such an edge, with say w as the left endpoint (see also Fig. 6),
then place the grid point for w at the column where edge (w, u) attaches to
w. Note that every vertex is at most once the left endpoint of an edge with
two bends, so this is well-defined. Edge (w, u) now does not receive an extra
bend at w, and hence has at most three bends as well.
Combining the bounds of Theorem 1 with the above observations, we obtain
the following results:
Drawing Outer-Planar Graphs in O(n log n) Area 61

Theorem 2. Every outer-planar graph has a poly-line grid-drawing in a ( 52 n −


4) × (4 log n − 1)-grid such that all vertices are on the outer-face. Every edge has
at most 3 bends.
For an outer-planar graph G with maximum degree Δ ≤ 4, we can similarly
obtain an orthogonal point-drawing with area O(n log n), by starting with an
orthogonal box-drawing, adding rows and columns to make vertex boxes suffi-
ciently big, and then replacing each box with a subgraph to connect all edges
to a point. However, note that this is not an improvement over the known O(n)
area bound for orthogonal point-drawings of outer-planar graphs with maximum
degree 4 [Lei80].

5 Visibility Representations
In this section, we show that by changing the planar embedding we can avoid
the bends in Fig. 6 and obtain a visibility representation.
The construction is very similar to the one in Section 3. No bends are added
in either the base case or Case 1 of the recursion. The only change to the con-
struction thus occurs in Case 2 of the recursion.
Define Ga , Gb , G2 , Γa , Γb and Γ2 as in Case 2 of Section 3. Recall that u
occupies the top right and x occupies the bottom right corner of Γa . We showed
that by adding one row, we can modify Γa such that x spans the bottom of
the drawing. By applying this modification twice and adding two rows, we can
obtain a drawing such that x spans the bottom of the drawing and u spans the
top of the drawing. Call the resulting drawing Γa .
Similarly we can modify Γb into Γb by adding at most two rows such that
now w spans the bottom and x spans the top of the drawing.
Now we combine Γ2 , Γb and Γa similar as before, but route (u, w) with a
horizontal segment (see Fig. 9). Note that this removes x from the outer-face of
the drawing. We save the two columns needed for edge (w, u) before, and hence
have a smaller width. Using induction, one can show that the height is at most
3 log n − 1 as before, and the width is at most 32 n − 1.
Theorem 3. Every outer-planar graph has a visibility representation in a ( 32 n−
2) × (3 log n − 1)-grid.

w w u

Γ2 Γb Γa

x x

Fig. 9. Combining without bends.


62 Therese Biedl

6 Towards Lower Bounds


6.1 The Snowflake Graph
We have shown that O(n log n) drawings are possible in a variety of drawing
models. We suspect that this is best-possible, in particular for the graph shown
in Fig. 10 (and referred to as the snowflake graph).

Fig. 10. The snowflake graph.

Conjecture 1. Any poly-line drawing of the snowflake graph has Ω(n log n) area.

We have not been able to prove this conjecture, but believe it to be true
based on the following observations:
– It appears to be the case that in any drawing of this graph, at least one
dimension is Ω(n). Is this true, and how can this be shown?
– It also appears to be the case that in any drawing of this graph, both dimen-
sions are Ω(log n). Is this true, and does the fact that any edge separator
(i.e., any set of edges whose removal splits the graph into two graphs that
are a constant fraction smaller) has Ω(log n) size help in proving this?
Note that if this conjecture is true, then the lower bound would hold or-
thogonal box-drawings as well by the results in Section 4, and therefore also
for visibility representations. Of course, this conjecture would also imply an
Ω(n log n) lower bound for straight-line drawings.

6.2 A More Restrictive Model


As a second contributions to lower bounds, we would like to give an Ω(n2 ) lower
bound on the area in a special model. One possible criticism of the orthogonal
box-drawings obtained with our algorithm is that although all vertices are tech-
nically on the outer-face, they are not clearly visible as being on the outer-face.
For example, vertex x in Fig. 6 appears removed from the outer-face, because it
is far from the boundary of the enclosing rectangle.
Drawing Outer-Planar Graphs in O(n log n) Area 63

Another model for drawing outer-planar graphs would thus be to require


all vertices are placed on the boundary of the minimum enclosing rectangle
(respectively touch it if they are boxes). It is known that trees may require
Ω(n log n) are in this model [Ull83, p.83ff]. We show now that for outer-planar
graphs, Ω(n2 ) area is required in this model.
Theorem 4. There exists an outer-planar graph G such that any poly-line draw-
ing Γ of G with all vertices on the boundary of the minimum enclosing rectangle
of the graph has area Ω(n2 ).
Proof. Let G be the outer-planar graph illustrated in Fig. 6.2. It consists of 5
groups of n/5 vertices, connected with chords between them.

Now assume we have a drawing Γ such that all vertices are on the boundary
B of the minimum enclosing rectangle. By planarity, and since the outer-face is
a cycle, the order of vertices along B must be the same as the order around the
outer-face. Therefore, at least one of the five groups of the graph entirely on one
side of B, say the top. Consider the subgraph induced by this group of vertices.
We can duplicate its drawing and flip it upside down to obtain a drawing of
asymptotically the same area. This drawing is a drawing of a multi-graph well-
known to need Ω(n2 ) area in any drawing that preserves this planar embedding
(see also Fig. 11). So the area of the original drawing must have been Ω(n2 ) as
well.

+ =

Fig. 11. Any poly-line drawing must have Ω(n2 ) area.

We note here without proof that the same graph, with a similar proof, also
yields a lower bound of Ω(n2 ) for various other models of “being visible on the
outer-face”, such as “having a horizontal or vertical segment that reaches to the
boundary of the enclosing rectangle”, or even “having an escape hatch” (see
[Lei80]).
64 Therese Biedl

7 Conclusion
In this paper, we studied planar drawings of outer-planar graphs. Using a simple
recursive algorithm, we achieved an orthogonal box-drawing in O(n log n) area.
This can be converted into a poly-line drawing in O(n log n) area. With a slight
variation, we can also obtain visibility representations, at the cost of not having
all vertices drawn on the outer-face. Some partial results towards lower bounds
were provided as well.
Many open problems remain:
– What is the correct area bound for straight-line drawings of outer-planar
graph? Can we achieve o(n2 ) for all outer-planar graphs?
Note that o(n2 ) can be achieved for all outer-planar graphs that are balanced
in some sense. The adjacencies between the interior faces of an outer-planar
graph form a tree. It is relatively straightforward to show that if this “dual
tree” has diameter d, then the graph has a straight-line drawing in a d × n-
grid (Erik Demaine and the author, private communication).
Unfortunately, there are outer-planar graphs for which the dual tree is a
path, and which therefore d = n − 3. While these graphs can be drawn in
o(n2 ) area (in fact, in O(n) area), it is not clear how to handle outer-planar
graphs for which the dual tree has diameter Ω(n), but is not a path.
– We gave visibility representations of area O(n log n), but at the cost of not
respecting the planar embedding. Can we obtain visibility representations of
area O(n log n) even with all vertices drawn on the outer-face?
– As illustrated in the drawing of the snowflake graph in Figure 12, our draw-
ings may have small area, but are somewhat disappointing in other aspects.
In particular, the aspect ratio of the drawing is Ω(n/ log n), and the aspect
ratio of some boxes may be Ω(n).

Fig. 12. The drawing of the snowflake graph created with our algorithm.

Is it true that any poly-line drawing of aspect ratio O(1) requires Ω(n2 )
area? (We believe this to be true for the snowflake graph.) And what can
be said about drawings where vertex boxes may not have arbitrary aspect
ratios, e.g., orthogonal box-drawings in the Kandinsky-model [FK96] or the
PG-model [BMT98]?
– What can be said about series-parallel graphs? Does every series-parallel
graph have a drawing in o(n2 ) area if we are allowed to change the pla-
nar embedding? (This is not possible if all edges are required to be drawn
“upward”, see [BCDB+ 94].)
Drawing Outer-Planar Graphs in O(n log n) Area 65

References
BCDB+ 94. P. Bertolazzi, R.F. Cohen, G. Di Battista, R. Tamassia, and I.G. Tollis.
How to draw a series-parallel digraph. Intl. J. Comput. Geom. Appl.,
4:385–402, 1994.
BMT98. T. Biedl, B. Madden, and I. Tollis. The three-phase method: A unified
approach to orthogonal graph drawing. In Graph Drawing (GD’97), vol-
ume 1353 of Lecture Notes in Computer Science, pages 391–402. Springer-
Verlag, 1998.
CU96. N. Castañeda and J. Urrutia. Straight line embeddings of planar graphs on
point sets. In Canadian Conference on Computational Geometry (CCCG
’96), pages 312–318, 1996.
DBETT98. G. Di Battista, P. Eades, R. Tamassia, and I. Tollis. Graph Drawing:
Algorithms for Geometric Representations of Graphs. Prentice-Hall, 1998.
Fár48. I. Fáry. On straight line representation of planar graphs. Acta. Sci. Math.
Szeged, 11:229–233, 1948.
FK96. U. Fößmeier and M. Kaufmann. Drawing high degree graphs with low
bend numbers. In F. Brandenburg, editor, Symposium on Graph Drawing
95, volume 1027 of Lecture Notes in Computer Science, pages 254–266.
Springer-Verlag, 1996.
FKK97. U. Fößmeier, G. Kant, and M. Kaufmann. 2-visibility drawings of planar
graphs. In S. North, editor, Symposium on Graph Drawing, GD 96, vol-
ume 1190 of Lecture Notes in Computer Science, pages 155–168. Springer-
Verlag, 1997.
FPP88. H. de Fraysseix, J. Pach, and R. Pollack. Small sets supporting fary embed-
dings of planar graphs. In Twentieth Annual ACM Symposium on Theory
of Computing, pages 426–433, 1988.
FPP90. H. de Fraysseix, J. Pach, and R. Pollack. How to draw a planar graph on
a grid. Combinatorica, 10:41–51, 1990.
GGT96. A. Garg, M.T. Goodrich, and R. Tamassia. Planar upward tree drawings
with optimal area. International J. Computational Geometry Applications,
6:333–356, 1996.
Kan96. G. Kant. Drawing planar graphs using the canonical ordering. Algorith-
mica, 16:4–32, 1996.
Lei80. C. Leiserson. Area-efficient graph layouts (for VLSI). In 21st IEEE Sym-
posium on Foundations of Computer Science, pages 270–281, 1980.
Sch90. W. Schnyder. Embedding planar graphs on the grid. In 1st Annual ACM-
SIAM Symposium on Discrete Algorithms, pages 138–148, 1990.
Shi76. Y. Shiloach. Arrangements of Planar Graphs on the Planar Lattice. PhD
thesis, Weizmann Institute of Science, 1976.
Ste51. S. Stein. Convex maps. In Amer. Math. Soc., volume 2, pages 464–466,
1951.
Ull83. J.D. Ullman. Computational Aspects of VLSI. Computer Science Press,
1983.
Wag36. K. Wagner. Bemerkungen zum Vierfarbenproblem. Jahresbericht der
Deutschen Mathematiker-Vereinigung, 46:26–32, 1936.
Wis85. S. Wismath. Characterizing bar line-of-sight graphs. In 1st ACM Sympo-
sium on Computational Geometry, pages 147–152, Baltimore, Maryland,
USA, 1985.
Computing Labeled Orthogonal Drawings

Carla Binucci, Walter Didimo, Giuseppe Liotta, and Maddalena Nonato

Università di Perugia
{binucci,didimo,liotta,nonato}@diei.unipg.it

Abstract. This paper studies the problem of computing labeled orthog-


onal drawings. A label is modeled as a rectangle of prescribed size and
it can be associated with either a vertex or an edge. Several optimiza-
tion goals are taken into account. Namely, the labeled drawing can be
required to have minimum total edge length, minimum width, minimum
height, or minimum area. We present ILP models to compute optimal
drawings with respect to the first three objectives and an algorithm ex-
ploiting these models which computes a drawing of minimum area (the
compaction problem is known to be NP-complete in general).

1 Introduction
The increasing demand of visualization technologies to display maps and schemas
with textual or multimedia content associated with vertices and/or edges has
been motivating a significant research effort towards designing algorithms and
systems that display labeled drawings of graphs. Among the application do-
mains where these technologies are relevant we mention Cybergeography (Web
maps and Internet maps), Software Engineering (UML schemas), and Informa-
tion Systems (data-base schemas, organization charts). (See also [5,9] for more
application domains).
At a first sight, one might think that computing a labeled drawing of a
graph is “yet-another-version” of the well-known labeling placement problem
that has attracted a lot of research in the computational geometry and car-
tography communities (see, e.g. [7,8,10,13,14] and the on-line bibliography of
Strijk and Wolff [17]). Namely, one possible approach for solving the problem is
that of removing the labels, computing a drawing, and putting back the labels.
However, this approach has several drawbacks in practice. For example, most
graph drawing algorithms and systems draw all vertices as boxes having the
same (usually quite small) size: if labels have to be drawn inside vertices (such
as in a UML schema), a global re-scaling of the drawing may be required at each
label insertion. Further, if the graph to display is large (such as a portion of
the Web graph), then most graph drawing systems would try to draw groups of
edges close with each other so to avoid unnecessary wastes of space on the com-
puter screen. However, this strategy may contrast with the necessity of adding
large textual labels on the edges in a post-processing phase while maintaining
readability and compactness of the diagram.
On the other hand, the graph drawing labeling problem allows more flexibility
than the labeling placement problem. While in the latter problem the geometry of

M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 66–73, 2002.

c Springer-Verlag Berlin Heidelberg 2002
Computing Labeled Orthogonal Drawings 67

the map to be labeled is fixed and given as part of the input, in the graph drawing
context the geometry is part of the output. This observation has suggested a
radically different approach to the problem, based on computing a drawing of
the input graph by taking into account also the space needed for adding the
labels [2,4,11].
This paper studies the problem of computing labeled orthogonal drawings. A
label is modeled as a rectangle of prescribed size and it can be associated with
either a vertex or an edge. Several optimization goals are taken into account.
The labeled drawing can be required to have minimum total edge length, mini-
mum width, minimum height, or minimum area. Previous papers on this subject
include the seminal paper by Klau and Mutzel [11], the first to present an ILP
model for orthogonal drawings of minimum total edge length with labeled ver-
tices, and the work in [2] where several heuristics for orthogonal drawings of
minimum area with labeled edges are presented. Both problems of computing
orthogonal drawings of minimum area and minimum total edge length are NP-
complete, even when edges and vertices are not labeled [16].
The main contributions of this paper are as follows.
– An ILP model for orthogonal drawings with labels both on edges and on
vertices is presented. Given a labeled orthogonal representation H, the ILP
model can be used to compute a labeled orthogonal drawing of H with
minimum total edge length. Variants of the model compute a drawing of
minimum width or of minimum height. We remark that the model in this
paper is the first ILP model for edge labeling of orthogonal representations.
Concerning vertex labeling, our model is different from the one proposed by
Klau and Mutzel [11] in which a vertex v is mapped to a point and a label
of v is drawn as a box whose perimeter includes v. In our model the label
of v is also a box, but v can be either a point on the perimeter or a point
inside the box. Our choice is motivated by applications in which vertices are
identified with labels, such as drawing UML diagrams and ER-diagrams.
– We describe a strategy for computing a labeled orthogonal drawing with
minimum area among those preserving a given orthogonal representation.
Our approach is based on computing several solutions of the ILP model for
width minimization under a certain constraint on the height of the drawing.
Our solution strategy is markedly different from standard integer quadratic
programming techniques, which appear to be not as effective as our method
for handling the specific problem of area minimization. We experimentally
observe that the number of ILP solutions required by our algorithm is quite
small (5 on the average) and that this number does not seem to depend on
the number of vertices of the input graph.
– As a special case, our algorithm for area minimization can be used for un-
labeled drawings. As far as we know, no other algorithm is known in the
literature to this aim, except for some specific classes of orthogonal repre-
sentations [3].
For reasons of space several details are omitted in this abstract. A more com-
plete version including extensive experimental analysis and heuristics for labeled
drawings is available at [1].
68 Carla Binucci et al.

2 Labeled Orthogonal Drawings

We assume familiarity with graph theory [6], graph planarity [15], and graph
drawing [5,9]. Let G = (V, E) be a 4-planar graph. An orthogonal drawing of
G is a drawing of G such that each vertex of G is mapped to a distinct point
of the plane and each edge of G is drawn as a sequence of horizontal and ver-
tical segments between its end-vertices. An orthogonal grid drawing of G is an
orthogonal drawing such that vertices and bends are mapped to points of the
integer grid. An orthogonal representation of G is an equivalence class of planar
orthogonal drawings of G, such that: (i) For each edge (u, v) of G all drawings
in the class have the same sequence of left and right turns (bends) along (u, v),
while moving from u to v. (ii) For each vertex v of G, and for each pair {e1 , e2 }
of clockwise consecutive edges incident on v, all drawings in the class determine
the same angle between e1 and e2 .
Let L = {λ} be a set of rectangular labels of given integer width w(λ) and
given integer height h(λ). We assume that each λ is associated with one edge of
G and no two labels are associated with the same edge. Each λ is an edge-label.
Let N = {ν} be a set of rectangular labels of given integer width w(ν) and
given integer height h(ν) such that each ν is associated with one vertex of G
and such that no two labels are associated with the same vertex. Each ν is a
vertex-label. In the following we shall use the term “label” instead of vertex-label
or edge-label when the context does not give rise to ambiguities.
Consider the triplet (G, L, N ). A labeled orthogonal drawing Γ of (G, L, N )
is a drawing such that: (i) G is represented as a planar orthogonal drawing and
(ii) each label in L ∪ N is represented as a rectangle.
The following definitions characterize a good labeling.

Definition 1. An edge e ∈ Γ with associated an edge-label λ ∈ L is properly


labeled if:

(EL1) λ is a rectangle in Γ with height h(λ) and width w(λ)


(EL2) λ has only one side s contained in one segment i of e, and s is properly
contained in i. We say that λ is drawn on i.

Note that (EL2) implies that there is an intersection between λ and the
segment on which λ is drawn.

Definition 2. A vertex v ∈ V with associated a vertex-label ν ∈ N is properly


labeled if:

(VL1) ν is a rectangle in Γ with height h(ν) and width w(ν)


(VL2) v is a point either on the perimeter or in the interior of ν. We say that ν
is drawn on v.

Note that (VL2) implies that there is an intersection between ν and each
segment incident on the vertex associated with ν.

Definition 3. A labeled drawing Γ is properly labeled if:


Computing Labeled Orthogonal Drawings 69

(EL) Each edge of Γ is properly labeled


(VL) Each vertex of Γ is properly labeled
(NI) There is no overlap between a label and any other element of the drawing,
except for the intersections implied by labels drawn on edges or vertices.

3 An ILP Model for Labeled Orthogonal Drawings

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. In
this section we present an ILP model for computing a properly labeled orthogonal
grid drawing Γ of (G, L, N ) of minimum total edge length among all drawings
with shape defined by HG . The model can be modified to minimize either the
width or the height of the drawing; it can also be used as a basic component
for an algorithm that computes a drawing of minimum area among those whose
shape is defined by HG (see Section 4).
In this abstract we only provide the mathematical foundation and the main
ideas behind our model. We first introduce the notation that will be used in
the model (Subsection 3.1); then we show a characterization of properly labeled
orthogonal drawings and describe the idea behind the ILP model (Subsection
3.2).

3.1 Notation

We need a mathematical formalism for translating the conditions given by Defini-


tions 1, 2, and 3 in the ILP model. We introduce first some notation for segments
of Γ representing edges of G. Then we focus on labels and consider relations be-
tween labels, vertices and edges. The notation is similar to that introduced in
previous works on the same topic [11,12].
Let Γ be a (not necessarily properly) labeled orthogonal drawing of (G, L, N ).
Let X h = {χh } and X v = {χv } be the set of the maximal horizontal and vertical
chains of edge segments of Γ , respectively. Note that a chain may consist of a
single point which we treat as a zero-length segment. Let S h be the union of the
segments of all the maximal horizontal chains, and let S v be the union of the seg-
ments of all the maximal vertical chains. Let S = S h ∪S v . We enumerate the edge
segments of Γ by associating each element i of S with a distinct positive integer
number, called index of i. We denote by f irst(χh ) and f irst(χv ) the segment
of minimal index in χh and χv , respectively. Given a horizontal (resp. vertical)
segment i of Γ , we denote by C(i) its y-coordinate (resp. x-coordinate). Each
non-zero length segment i ∈ S is bounded by two maximal chains orthogonal
to i denoted by sup(i) and inf (i) with C(f irst(sup(i))) > C(f irst(inf (i))).
The length of a segment i is given by C(f irst(sup(i))) − C(f irst(inf (i))).
Each vertex u ∈ V belongs to a unique maximal horizontal chain, χh (u) and
to a unique maximal vertical chain, χv (u). Let Cx (u) = C(f irst(χv (u))) and
Cy (u) = C(f irst(χh (u))) denote the x-coordinate and the y-coordinate of ver-
tex u, respectively.
70 Carla Binucci et al.

Let λ ∈ L be an edge-label associated with an edge e of G. Label λ can be


drawn on any of the segments representing e. S(λ) denotes the set of segments
of e and S(L) is the set of all candidate segments for edge-labels, i.e. S(L) =
∪ S(λ). We say that λ overlaps a segment i ∈ S(λ) if the intersection between
λ∈L
i and one of the two sides of λ parallel to i is not empty. Note that if λ is drawn
on i then λ overlaps i (see (EL2) in Definition 1). However, if λ overlaps i but
the drawing is not properly labeled, then λ may be not drawn on i.
For each edge-label λ and for each edge segment i ∈ S(λ), we define a 4-
i,λ
tuple Σ i,λ = {σoi,λ , σO , σpi,λ , σPi,λ } of segments. Roughly, the elements of Σ i,λ
describe the position of the sides of the rectangle representing λ with respect
to i. The elements of Σ i,λ are defined as follows (in our notation o, O stand for
“orthogonal” and p, P stand for “parallel”):
i,λ
– if λ overlaps i, then σoi,λ and σO are the sides of λ orthogonal to i; σpi,λ and
i,λ i,λ
σP are the sides of λ parallel to i. Also, C(σO ) > C(σoi,λ ) and C(σPi,λ ) >
i,λ
C(σp ).
i,λ
– if λ does not overlap i, then σoi,λ = σO = σpi,λ = σPi,λ are zero-length seg-
ments, C(σPi,λ ) = C(σpi,λ ) = C(i), and C(σO i,λ
) = C(σoi,λ ) = C(f irst(sup(i))).
We also define Σ L = ∪ Σ i,λ .
i∈S(L)
Similar definitions are given for vertex-labels. Given a vertex v ∈ Γ and its
vertex-label ν ∈ N , let S(ν) be the set of edge segments incident on v. Let
Σ ν = {σoν , σO
ν
, σpν , σPν } be the 4-tuple of label segments introduced to represent
ν on Γ , according to the following convention: σoν and σO ν
are vertical; σpν and σPν
are horizontal; C(σO ) > 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. Sim-
ilar 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 or-
thogonal 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

– If i ∈ S(λ) ∩ S v then δ(i, σzi,λ ) = w(λ) and δ(σO
i,λ
, σoi,λ ) = h(λ).

– If i ∈ S(λ) ∩ S then δ(i, σz ) = h(λ) and δ(σO , σoi,λ ) = w(λ).
h i,λ i,λ

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.
(PLD3) Let ν ∈ N be the label associated with vertex v ∈ V , then δ(σO ν
, σ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 con-
straints 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 Γ , respec-
tively.
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 Carla Binucci et al.

4 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Γ +
Mh · hΓ ) and add a new constraint hΓ < hm where Mh is an upper bound of
1

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

of Pareto optimal solutions of the multiobjective function M in , where Γ

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 con-
strained 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 = M h + 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 represen-


tation 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
increasing, hm can be updated to wΓopt · hoptΓ /w Γ instead of hm = hΓ . We
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 73

5 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 orthog-
onal 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. Vis-
mara. 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 stat-
echarts. 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 Ge-
ometry: Theory and Applications, 19:47–67, 2001.
17. T. Strijk and A. Wolff. The map labeling bibliography. on-line: http://www.math-
inf.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ünchen, Germany
sabine.bachl@sdm.de
2
University of Passau, 94030 Passau, Germany
brandenb@informatik.uni-passau.de

Abstract. The isomorphic subgraph problem is finding two disjoint sub-


graphs of a graph which coincide on at least k edges. Then the graph
partitions into a large subgraph, its copy and a remainder. The prob-
lem 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 heuris-
tic 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 un-
derstanding the structural relation modelled by the graph. Bad drawings are mis-
leading. 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 invari-
ant. 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 ap-
plications 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&copy 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 par-
allels 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 Sabine Bachl and Franz-Josef Brandenburg

2 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 node-
induced 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 sub-
graphs 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, sub-
graph 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 re-
mainder 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 = degree(v1 ) + degree(v2 )
– w2 = |degree(v1 ) − degree(v2 )|
– w3 = the number of common neighbours
– w4 = the number of new neighbours of v1 and v2 which are not in H1 ∪ H2
– w5 = the graph-theoretical distance between v1 and v2
– w6 = 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 neigh-
bours (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 im-
plementation. 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 isomor-
phism. 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 sub-
graphs, 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)
50 degree (w1)
number of nodes in every subgraph

difference of degree (w2)


common neighbours (w3)
new neighbours (w4)
40 distance (w5)
isomorphic edges (w6)

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)
14 difference of degree (w2)
number of nodes in every subgraph

common neighbours (w3)


new neighbours (w4)
12 distance (w5)
isomorphic edges (w6)
10

10 15 20 25 30 35 40 45 50
number of nodes in the graph

Fig. 3. Isomorphic node-induced subgraphs of dense graphs


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 isomor-
phic subgraphs and display them symmetrically. The Reingold and Tilford algo-
rithm [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 in-
troduced 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, isomor-
phic 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 struc-
tures. 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 separa-
tion 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 83

Fig. 5. 4 × 4-grid. Fig. 6. Complete graph with 10 nodes.

Figure 4 describes the main steps of the isomorphism preserving spring al-
gorithm. 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 im-
provements. 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), 286-
296.
2. S. Bachl. Erkennung isomorpher Subgraphen und deren Anwendung beim Zeich-
nen von Graphen. Dissertation, University of Passau, (2001), http://elib.ub.uni-
passau.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. Spek-
trum 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ößen durch
ein Springembedder-Verfahren. Diplomarbeit, Universität Passau, (1999).
14. A. Frick, A. Ludwig and H. Mehldau. A fast adaptive layout algorithm for undi-
rected 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 Group-Theoretic Method
for Drawing Graphs Symmetrically

David Abelson1 , Seok-Hee Hong2 , and Donald E. Taylor1


1
School of Mathematics and Statistics, University of Sydney, Australia,
dabe4090@mail.usyd.edu.au, D.Taylor@maths.usyd.edu.au
2
School of Information Technologies, University of Sydney, Australia,
shhong@it.usyd.edu.au

Abstract. Constructing symmetric drawings of graphs is NP-hard. In


this paper, we present a new method for drawing graphs symmetrically
based on group theory. More formally, we define a n-geometric automor-
phism group of a graph that can be displayed as symmetries of a drawing
of the graph in n dimensions. Then we present an algorithm to find all
2- and 3-geometric automorphism groups of a graph. We implement the
algorithm using Magma [11] and the experimental results shows that our
approach is very efficient in practice. We also present a drawing algorithm
to display a 2- or 3-geometric automorphism group.

1 Introduction
Symmetry is one of the most important aesthetic criteria that represent the
structure and properties of a graph visually. To construct a symmetric drawing
of a graph, we need two steps. The first step, called the symmetry finding step,
is to find geometric automorphisms of the graph, which can be displayed as
symmetries of a drawing of the graph. The second step, called the drawing step,
is to construct a drawing that displays these automorphisms.
However, the problem of determining whether a graph has a nontrivial strict
geometric automorphism in two dimensions is NP-complete [8]; it is probably
strictly harder than graph isomorphism. For planar graphs, there is a polynomial
time algorithm [5]. The problem of determining whether a graph can be drawn
symmetrically in three dimensions is also NP-complete [6] and a polynomial time
algorithm is given for planar graphs [6].
In this paper, we present a group-theoretic method to find all 2- and 3-
geometric automorphism groups of a graph. First we define an n-geometric au-
tomorphism group of a graph that can be displayed as symmetries of a drawing
of the graph in n dimensions.
Next we present an algorithm to find all 2- and 3-geometric automorphism
groups of a graph, based on the classification of the 2- and 3-geometric automor-
phism groups in [1]. This is done by first calculating the automorphism group

This research has been supported by a grant from the Australian Research Council.
Full version of this paper is available from
http://www.cs.usyd.edu.au/∼shhong/publication.htm [1].

M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 86–97, 2002.

c Springer-Verlag Berlin Heidelberg 2002
A Group-Theoretic Method for Drawing Graphs Symmetrically 87

Aut(G) of a graph G and then looking for subgroups satisfying the classification.
More specifically, we use conjugacy classes of the automorphism group to find
the subgroups.
The main contribution of this paper is that we provide an algorithm for
finding all 2- and 3-geometric automorphism groups of a graph. A heuristic for
finding an axial symmetry in two dimensions is presented by de Fraysseix [4].
Buchheim and Junger present a branch and cut approach to find either a ro-
tational symmetry or an axial symmetry in two dimensions [2]. However, our
method is the first to find dihedral groups, which have two generators, in two
dimensions and fourteen different kinds of groups, with up to three generators,
in three dimensions.
We implement the algorithm using Magma [11], a computational algebra sys-
tem for algebra, number theory, geometry and combinatorics, which incorporates
nauty [12] for finding automorphism groups of graphs. The worst case time com-
plexity is exponential in theory, but experiments show in practice it is very fast.
For example, for our first data set, which consists of graphs with |V | < 50 and
| Aut(G)| < 1000, it takes 0.022 seconds to compute all 2-geometric groups and
0.037 seconds to compute all 3-geometric groups on average. For our second data
set, which consists of graphs with |V | < 50 and 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. Further, we show that our method
is much faster than the branch and cut approach [2]. The average times for the
graphs from the same data set of [2] are below 0.015 seconds. The worst case
time is 2.60 seconds, whereas the worst case time of [2] was 9197.55 seconds.
Finally we present and implement a drawing algorithm to display a 2- or
3-geometric subgroup. Examples of the outputs are illustrated in Figure 1. It
shows a drawing of four-cell displaying dihedral symmetry in two dimensions
and a drawing of four-cube displaying octahedral symmetry in three dimensions.

Fig. 1. Examples of our results.


88 David Abelson, Seok-Hee Hong, and Donald E. Taylor

In the next section, we review the background and define n-geometric au-
tomorphism group. In Section 3, we describe our methods for finding 2- and
3-geometric automorphism groups. The drawing algorithm is described in Sec-
tion 4 and Section 5 concludes.

2 Background
2.1 Symmetry
Let In (R) be the group of isometries of Rn and let On (R) be the subgroup of
In (R) that fixes the origin. A matrix A is orthogonal if and only if A.AT = I. The
elements of On (R) are represented by orthogonal matrices and we use SOn (R)
to denote the subgroup corresponding to the matrices of determinant 1.
A symmetry α of a set of points Q in Rn is an isometry Rn → Rn such
that α(Q) = Q. The symmetries of the point set Q form a group S(Q) and by
translating Q if necessary we may suppose that S(Q) is a subgroup of On (R).

2.2 Symmetric Graph Drawing and Geometric Automorphism


Group
An automorphism of a graph G = (V, E) is a permutation p of V such that if
{u, v} ∈ E then {p(u), p(v)} ∈ E. The set of automorphisms of a graph form
a group Aut(G). A straight-line drawing D of graph G is an injective function
D : V → Rn (n ≥ 0). A vertex v is placed at D(v) and an edge {u, v} is
represented as the straight-line segment joining D(u) and D(v).
The concept of geometric automorphism group in two dimensions was intro-
duced by Eades and Lin [3]. An automorphism α of a graph G is geometric if
there is a drawing D of G which displays α as a symmetry of D. Note that not
every automorphism is geometric; see Figure 2(a). A subgroup H of Aut(G) is
geometric if there is a single drawing of the graph that displays every element of
H. Note that the two geometric automorphism groups may not be combinable;
see Figure 2(b) and (c).

00
11
11
00
1 2 3 00
11
11
00
00
11 11
00
00
11 11
00
00
11 1
0 1
0
0
1 0
1

11
00
11
00
11
00
00
11 1
0 1
0 1
0 11
00 1
0
00
11 0
1 0
1 0
1 00
11 0
1
4 5

(a) (b) (c)

Fig. 2. (a) The automorphism (1,2,3)(4,5) is not geometric. (b) A drawing of K4


displaying a geometric automorphism group of size 8. (c) A drawing of K4 displaying
a geometric automorphism group of size 6.
A Group-Theoretic Method for Drawing Graphs Symmetrically 89

2.3 The n-Geometric Automorphism Group


We generalize the notion of a geometric automorphism group [3] to n dimensions.
A group H ⊆ Aut(G) is n-geometric if there is a drawing D that displays all the
elements of H in n dimensions. Note that because we always assume that D is
centered on the origin, H will be represented as a subgroup of On (R).

Lemma 1. A group H ⊆ Aut(G) is n-geometric with respect to a drawing D if


and only if there exists a homomorphism φ : H → On (R) such that for all v ∈ V
and h ∈ H, D(hv) = φ(h)D(v).

A homomorphism φ : H → On (R) is called a representation of H. In matrix


terms, each element of H is represented by an orthogonal matrix. The represen-
tation is faithful if φ is injective.
We use basic terminology from group theory [10]. Let H be a group acting
on a set U . For u ∈ U , let Hu = {x ∈ U | x = gu for some g ∈ H} ⊆ U be
the orbit of u and Hu = {g ∈ H | g(u) = u} ⊆ H be the stabilizer of u. The
orbits divide the set U into equivalence classes, each of which can be specified
by a representative element. Two elements a and b of a group H are conjugate if
there exists h ∈ H such that b = hah−1 . Conjugacy is an equivalence relation and
the equivalence classes of H are called conjugacy classes. We now characterize
n-geometric groups.

Theorem 1. A group H ⊆ Aut(G) is n-geometric if and only if there is an in-


jective homomorphism θ : H → On (R) such that for a representative v1 , . . . , vk ∈
V of each orbit of H acting on V , there are corresponding distinct points a1 , . . .,
ak ∈ Rn such that θ(Hvi ) = θ(H)ai .

3 Finding Geometric Automorphism Groups


We now outline our method of finding all 2- and 3-geometric automorphism
groups based on the classification in [1]. It follows from Theorem 1 that a
permutation group A acting on a graph is n-geometric if it is isomorphic (as an
abstract group) to a finite subgroup H of On (R) and

1. if A fixes more than one vertex, then H fixes a point other than the origin;
2. for every vertex v, the stabilizer Av is isomorphic to the stabilizer in H of a
point of Rn .

When the value of n is clear from the context we shall simply refer to A as
a geometric group. The group H will be referred to as the type of A.
Our search for the geometric subgroups of Aut(G) is facilitated by the fortu-
nate fact that all of the finite subgroups of O2 (R) and O3 (R) have very simple
presentations. That is, they can be expressed in the form H =  X | R , where
X is a list of generators for H and R is a list of relations between the generators.
Furthermore, there are at most three generators and in many cases the relations
simply specify the orders of the generators and the orders of their products.
90 David Abelson, Seok-Hee Hong, and Donald E. Taylor

3.1 The Finding Algorithm


To find the geometric subgroups of the automorphism group Aut(G) of a graph
G = (V, E) we look for elements that satisfy the relations of its presentation. We
are only interested in finding these subgroups up to conjugacy because, as the
next lemma shows, conjugate n-geometric subgroups have essentially the same
drawings. Let Sym(V ) be the group of all permutations of V .
Lemma 2. Let H be an n-geometric subgroup of Aut(G) with respect to a draw-
ing D and suppose that H  = g −1 Hg ⊆ Aut(G), where g ∈ Sym(V ). Then H  is
n-geometric with respect to the drawing D defined by D (v) = D(gv).
Computing the conjugacy classes of a group is a hard problem but highly
optimized algorithms for this purpose are part of Magma. Moreover, in searching
for geometric automorphisms it is often possible to restrict to a proper subgroup
of Aut(G). To take a simple example, if g is a 2-geometric automorphism of order
m > 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 3-
geometric 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 ).

Algorithm for the 3-geometric groups of types Dn , (Dn | Cn ) and


(D2n | Dn )
1. Find representatives for the conjugacy classes of geometric elements using
the previous algorithm.
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 H =  g, a  is a dihedral group.
5. 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 ).
6. 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)| <
A Group-Theoretic Method for Drawing Graphs Symmetrically 93

51, 000, 000. A third test data was a set of graphs with highly symmetric graphs
such as regular graphs, the cage graphs, non-Hamiltonian graphs, the platonic
solids and incidence planes from Groups & Graphs [9].
The first experiment was done on DEC Alpha 600 5/333. Tables 1 and 2
display the experimental results from the first experiment with three data sets.
First we present the time for Computing Aut(G) and the size of Aut(G). Each
row shows the time for finding each of 2- and 3-geometric groups. For each case,
we present the average and worst case of time, the average and maximum size
of the maximal subgroup.

Table 1. Results for 100 graphs

|Aut(G)| < 1, 000 |Aut(G)| > 1, 000


Time Size Time Size
Av Max Av Max Av Max Av Max
Aut(G) 0.00152 0.017 238 820 0.0042 0.017 1812375 50803200
Ck2 0.017 0.1 23.1 47 0.11 0.634 8.9 24
Dk2 0.0057 0.034 46.1 94 0.29 3.8 16.1 24
Av for 2D 0.022 0.41
Ck3 0.017 0.1 23.1 47 0.11 0.63 8.9 24
(C2k |Ck3 ) 0.005 0.017 5.3 20 0.0058 0.033 7.3 24

Ck3 0.002 0.0125 6 6 0.34 5.0 8.5 12
3
Dk 0.002 0.016 46.1 94 0.35 5.0 16.1 24
(Dk |Ck3 ) 0.002 0.0202 46.1 94 0.373 5.26 16.1 24
(D2k |Dk3 ) 0.002 0.025 46.1 94 0.362 5.1 16.1 24

Dk3 0.005 0.033 8 8 0.678 8.7 15.7 28
T 0.0002 0.016 12 12 0.23 2.9 12 12
T∗ 0.0003 0.017 0 0 0.0039 0.067 24 24
(O|T ) 2e-5 0.0005 24 24 0.033 0.558 24 24
O 2e-5 0.0005 0 0 0.033 0.558 24 24
O∗ 5e-5 0.001 0 0 0.0029 0.05 48 48
I 0 0 0 0 0.048 0.617 60 60
I∗ 0 0 0 0 0 0 120 120
Av for 3D 0.037 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 ex-
ample, 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 auto-
morphisms, 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 Size
Av Max Graph Av Max Graph
Aut(G) 0.00102125 0.011 grafo10316.100.lgr 5.0617 1920 grafo8507.75.lgr
BestCycle 0.00909117 0.12 grafo5890.48.lgr 1.6825 3 grafo206.12.lgr

4 Displaying a Geometric Automorphism Group

4.1 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 1 1

3 4
2 5 5 2
4 3

3 4 2 5 5 2 4 3
1a) 1b) 1c) 1d)

Fig. 3. Using different representations to display the same group

4.2 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.
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:
1. Find the stabilizer Hvi of vi .
2. If Hvi = H, define D(vi ) to be the origin.
3. 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.
4. 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.
5. 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.)
6. 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 dis-
playing cyclic symmetry (d) the dodecahedron displaying dihedral symmetry.
A Group-Theoretic Method for Drawing Graphs Symmetrically 97

5 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ünger, 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 Sci-
ence 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 Sci-
ence, 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.
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 prob-
lem are also N P-hard. We provide an Integer Linear Programming for-
mulation 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 presenta-


tion of relationships between entities, and in many disciplines it is the expected
format. The most widely used method of drawing graphs hierarchically is, per-
haps, 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 di-
rection. 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 prob-
lem 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. Al-
though the algorithms are fundamentally incomparable since they layer accord-
ing 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 be-
cause 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
with u ∈ Vj and v ∈ Vi add so-called dummy nodes di+1 i+2 j−1
e , de , . . . , de to
layers Vi+1 , Vi+2 , . . . , Vj−1 respectively, replacing edge (u, v) by the directed
path (u, dj−1
e , . . . , di+1
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 de-
note 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 lay-
ering 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 indepen-
dent 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 101

3.1 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 ⎝ kxuk − kxvk ⎠ (1)
(u,v)∈E k=ϕ(u) k=ϕ(v)


ρ(v)
Subject to xvk = 1 ∀v ∈ V (2)
k=ϕ(v)


k 
ρ(v)
xui + xvi ≤ 1 ∀k ∈ L(u) ∩ L(v), ∀(u, v) ∈ E (3)
i=ϕ(u) i=k

wv xvk + Dk ≤ W ∀k = 1, . . . , H (4)
v∈Vk∗

xvk ≥ 1 ∀k = 1, . . . , π(G) (5)
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)
Dk = wed ⎝ xul − xvl ⎠
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
102 Patrick Healy and Nikola S. Nikolov

v0 v1 v1 v1
v2
v2
v4 v0 k v0 k
v3 v5 v2
v3 v6 v4 v3
v6 v4
v6 v7 v7 v7 v5

(a) A random draw- (b) Node v2 placed (c) Node v2 placed


ing of the DAG G2 above layer Vk 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 ap-
proach to finding capacity-related valid inequalities of the DAG Layering poly-
tope.

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 simulta-
neously 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


2
xuk + α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 
ρ(v)
xui + xvi ≤ 1 (7)
i=ϕ(u) 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 v
u v k u k u v k

(a) A (γ = 0) (b) B (γ = 1) (c) AB

v v v v
v v
u k u v k u k u v k

(d) C (γ = 2) (e) AC (f) BC (g) ABC

v ρ(v ) v ρ(v ) v ρ(v ) v ρ(v )


v v v v
v k+3 v v v
v v v
v v
u k u k u k u v k
u u u u
u u u u
u ϕ(u ) u ϕ(u ) u ϕ(u) u ϕ(u)

(h) D (γ = 3) (i) CD (j) BCD (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 generat-
ing 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 algo-
rithm 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 dis-
cussed 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 com-
putational 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” in-
stances becomes too long and much too resource-consuming, which shows that
2
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.
3
We obtained the AT&T DAG set from http://www.graphdrawing.org.
Branch-and-Cut Approach to the Directed Acyclic Graph Layering Problem 107

600 1800
ULair without cutting-plane generation
ULair without cutting-plane generation ULair with cutting-plane generation
ULair with cutting-plane generation 1600
500
Running Time (centiseconds)

Running Time (centiseconds)


1400

400 1200

1000
300
800

200 600

400
100
200

0 0
10 20 30 40 50 60 70 80 90 100 10 20 30 40 50 60 70 80 90 100
Node Count Node Count

(a) W = 0.9WGans , H = 1.1HGans (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 ex-
cluded 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 program-
ming 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 Running time (centisec.)


fH /fW Cutting planes
attg. no cuts MIP cuts
23.37 1.2 / 0.7 45 11 15 A:1, AB:1, BC:3, ABC:4
1.2 / 0.8 330 9 17 A:6, AB:1, C:1, BC:4, ABC:9
29.2 1.2 / 0.7 235 174 29 AC:1, ABCD:17
1.2 / 0.8 172 186 115 A:3, BC:5, ABC:15, BCD:7
32.1 1.2 / 0.7 16,919 85 24 AB:1, ABC:8, ABCD:7
1.2 / 0.8 524 78 137 A:1, AB:9, AC:2, BC:2, ABC:1, ABCD:5
56.5 1.2 / 0.7 9,852 60,000+ 945 ABCD:94
1.2 / 0.8 60,000+ 60,000+ 945 ABCD:95
94.0 1.2 / 0.7 38,478 4,237 585 ABCD:157
1.2 / 0.8 9,009 3,882 631 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 strat-
egy helps for optimizing “hard” instances of DAG layering. The last column in
Table 4, Cutting planes, contains for each infeasible pattern the number of gen-
erated 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 (de-
picted 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 109

(a) (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 extend-
ing 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ünger, 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ěk Kučera, 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 hier-
archical system structures. IEEE Transaction on Systems, Man, and Cybernetics,
11(2):109–125, February 1981.
Geometric Systems of Disjoint Representatives

Jiřı́ Fiala1 , Jan Kratochvı́l1, , and Andrzej Proskurowski2,


1
Institute for Theoretical Computer Science†
and Department of Applied Mathematics,
Charles University, Prague
{fiala,honza}@kam.mff.cuni.cz
2
Department of Computer and Information Science,
University of Oregon, Eugene
andrzej@cs.uoregon.edu

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 gen-
eralizes the well known problem of distinct representatives, while in Eu-
clidean 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 polyno-
mial 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 sub-


sets 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 pro-
vide 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 Jiřı́ Fiala, Jan Kratochvı́l, and Andrzej Proskurowski

2 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 113

3 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 Man-
hattan 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 Man-
hattan metric.

Proof. We show a reduction from the planar 3-SAT problem, whose NP-comple-
teness 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řı́ Fiala, Jan Kratochvı́l, and Andrzej Proskurowski

P1 N1
P2 N2

Fig. 1. Variable gadget.

P1 N1
1 2 3 4 5 12 13 14 15 16
P2 11 N2
6
7 8 9 10

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 corre-
sponding 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 de-
fine 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 straight-
forward.
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&down-
most 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 vari-
able 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řı́ Fiala, Jan Kratochvı́l, and Andrzej Proskurowski

B c)
a) b)
P1 N1

P2 N2

d)

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 coor-
dinates 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 representa-
tives, 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 place-
ment, 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ć and Sue Whitesides

School of Computer Science, McGill University, 3480 University St.,


Montreal, Québec, 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 Param-
eter 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 Minimiza-
tion 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ünger and Mutzel
[13] gave an exact integer linear programming algorithm for the 1-Sided Cross-
ing Minimization problem. They also surveyed heuristics and made perfor-
mance 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 algo-
rithm 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 pa-
rameterized 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
to derive an O(k · 6k + |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 Vida Dujmović and Sue Whitesides

2 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 per-
mutations 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 ver-
tices in L2 . The crossing number cvw is the number of crossings that edges in-
cident 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<w∈π2

where the summation is over all ordered pairs v < w of elements of π2 ; further-
more,
 
min(cvw , cwv ) ≤ cr(G, π1 , πopt ) ≤ max(cvw , cwv ), (2)
v,w∈L2 v,w∈L2

where the summations are over all unordered pairs v, w of vertices of L2 .

3 Properties of Optimal Drawings


In this section, we establish a property of optimal drawings (G, π1 , πopt ) (see
Lemma 1) that will be fundamental for our algorithm in the next section.
For each vertex v in L2 , let lv denote the leftmost neighbor of v in L1 , and
let rv denote the rightmost neighbor of v in L1 . Note that if v ∈ L2 has degree
1, then lv = rv .
Now consider two vertices v and w in L2 . We say that v and w are a suited
pair if rv ≤ lw , or if rw ≤ lv ; otherwise we call the pair unsuited. For example,
in Fig. 2 v, u is a suited pair and so is pair w, u; pair v, w is not suited. If v and
w each have degree 1 and have the same neighbor in L1 (i.e. lv =rv =lw =rw ),
we say that v and w are a trivial suited pair. The following fact, which is an
immediate consequence of Fact 1 and the definition of unsuited pair, indicates
the importance of the notion of suitable pairs.
Fact 4. A pair of vertices v, w ∈ L2 is unsuited if and only if cvw ≥ 1 and
cwv ≥ 1.
On the other hand, the edges of a suited pair v, w do not cross if v and w
appear in their natural ordering in π2 , i.e., if v < w when rv ≤ lw , and w < v
when rw ≤ lv . If v, w is a trivial suited pair, then cvw = 0 and cwv = 0, and we
say that both v < w and w < v are natural orderings for the pair v, w.
The notion of natural ordering leads to a useful fact for our algorithm.
122 Vida Dujmović and Sue Whitesides

lv rv L1 , π1 f ixed

v w u L2 , π2 f ree

Fig. 2. Pair v, w is unsuited, while v, u and w, u are suited pairs.

Fact 5. Suppose v, w is a suited pair for π1 with natural ordering v < w. Then
for any π2 , the drawing (G, π1 , π2 ) satisfies: (i) cvw =0; (ii) if rv = lw , then cwv =
dv · dw ; (iii) if rv = lw , then cwv = (dv · dw ) − 1; and finally, (iv) unless v and w
are a trivial suited pair, cwv > 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:

t
cr(G, π1 , π2 ) = cr(G, π1 , π2 ) + (cvi+j vi − cvi vi+j ). (3)
j=1

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. 2
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.

lv rv
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
cU v < cvU . (4)
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ć 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 interme-
diate 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 end-
point 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 inter-
sect, 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 inci-
dent to U that is not in EL .
cwU ≥ dw · |EL | : The edges incident to w and the edges in EL all pairwise in-
tersect, 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. 2

4 An Efficient FPT Algorithm

4.1 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 com-
putation 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 non-
trivial 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ć 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 simul-
taneously. 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) deter-
mines 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 simultane-
ously. 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 bud-
get 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ć 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+2 k
given that B0 ≤ k, it follows that sB0 < φ√5 + φ√+1 5
− 1 < 1.9 · φk . Thus the
search tree has O(φ ) nodes.
k

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 |). 2

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 expo-
nential 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 ex-


perimentally 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ć, 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ć, 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ünger 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ñoz, U Unger, and I Vrťo. 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ünger2 , and Petra Mutzel1


1
Institut für Computergraphik und Algorithmen, Technische Universität Wien
Favoritenstraße 9–11, A-1040 Wien, Austria
{barth, mutzel}@ads.tuwien.ac.at
http://www.ads.tuwien.ac.at/
2
Institut für Informatik, Universität zu Köln
Pohligstraße 1, D-50969 Köln, Germany
mjuenger@informatik.uni-koeln.de
http://www.informatik.uni-koeln.de/ls juenger/

Abstract. We consider the problem of counting the interior edge cross-


ings 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 seg-
ments. 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 cardinal-
ity 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 intersec-
tions 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 permuta-
tions π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 cross-


ings 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 bi-
layer cross count for the subgraph induced by the two layers, while keeping Lfixed
132 Wilhelm Barth, Michael Jünger, 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 dras-
tic 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 dis-
tinctions 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 |) al-


gorithms 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 Mal-
hotra [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 imple-
mented 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 com-
puted 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 ap-
proaches based on counting inversions. We do not know if such an algorithm
exists.
134 Wilhelm Barth, Michael Jünger, and Petra Mutzel

3 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
of inversions, and since there are |E| 2 inversions in the worst case, we have
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ünger, and Petra Mutzel

Fig. 4. Building the accumulator tree and counting the crossings

we have used above, or are explained in comments, respectively. The identi-


fier 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<q) firstindex *= 2;
treesize = 2*firstindex - 1; /* number of tree nodes */
firstindex -= 1; /* index of leftmost leaf */
tree = (int *) malloc(treesize*sizeof(int));
for (t=0; t<treesize; t++) tree[t] = 0;

/* count the crossings */

crosscount = 0; /* number of crossings */


for (k=0; k<r; k++) { /* insert edge k */
index = southsequence[k] + firstindex;
tree[index]++;
while (index>0) {
if (index%2) crosscount += tree[index+1];
index = (index - 1)/2;
tree[index]++;
}
}
printf("Number of crossings: %d\n",crosscount);
free(tree);

Fig. 5. C program fragment for simple bilayer cross counting


Simple and Efficient Bilayer Cross Counting 137

4 Computational Experiments
In order to obtain an impression of how old and the new algorithms for bilayer
cross counting perform in direct comparison, we made an empirical study.
We implemented the following algorithms in the C programming language as
functions and used them in various computational experiments:

SAN is the algorithm by Sander [10] that runs in O(|E| + |C|) time and O(|E|)
space,
WAM is the algorithm by Waddle and Malhotra [12] that runs in O(|E| log |V |)
time and O(|E|) space,
MER is a merge sorting algorithm (Section 2) that runs in O(|E| log RUN (π))
time and O(|E|) space,
INS is a plain insertion sorting algorithm (Section 3, step 1) that runs in O(|E|+
|C|) time and O(|E|) space,
BJM is the algorithm of Section 3, step 2, that runs in O(|E| log |Vsmall |) time
and O(|E|) space.

In order to make the comparison as fair as possible, all C-functions have the
same parameters:

int p: p is the number of nodes in the northern layer,


int q: q is the number of nodes in the southern layer (q ≤ p),
int r : r is the number of edges,
int∗ NorthNodePos: NorthNodePos[k] ∈ {0, 1, . . . , p − 1} is the position of the
northern end node of edge k ∈ {0, 1, . . . , r − 1} in the northern permutation
πN ,
int∗ SouthNodePos: SouthNodePos[k] ∈ {0, 1, . . . , q − 1} is the position of the
southern end node of edge k ∈ {0, 1, . . . , r − 1} in the southern permutation
πS .

No assumption is made about the ordering of the edges, e.g., MER and BJM
start by computing southsequence by a two phase radix sort. Likewise, the other
algorithms compute the internally needed information from the given data that
should be readily available in any reasonable implementation of a Sugiyama-style
layout algorithm. Furthermore, the functions are responsible for allocating and
freeing temporarily needed space. We made an effort in implementing all five
algorithms as well as we could.
All experiments were performed under Linux on a SONY VAIO PCG-R600
notebook with an 850 MHz INTEL Mobile Pentium III processor and 256 MB
of main memory. The software was compiled by the GNU gcc compiler with
optimization option O3. All uniformly distributed random numbers needed in our
experiments were generated by the C-function gb unif rand of Donald Knuth’s
Stanford GraphBase [7]. In all subsequent plots, data points are averages for 100
instances each.
The crossing minimization phase of a Sugiyama-style layout algorithm typ-
ically starts with random permutations of the nodes on each layer, and in the
138 Wilhelm Barth, Michael Jünger, and Petra Mutzel

course of the computation, the edges become more and more untangled. This
means that a bilayer cross counting algorithm is likely to be initially confronted
with random permutations πN and πS and later with permutations that induce
significantly less crossings. In our experiments, we take this phenomenon into
account by running each layer pair twice – first with random permutations and
then with permutations generated by a crossing minimization algorithm. The
fastest method with good practical results we know is the so-called MEDIAN
crossing minimization algorithm [4]. While the node permutation in one of the
two layers is temporarily fixed, the nodes of the other layer are reordered accord-
ing to the median positions of their neighbors in the fixed layer. The MEDIAN
heuristic can be implemented to run in O(|E|) time and space. After some ex-
perimentation, we decided that four iterations (reorder southern, then northern,
then southern, and finally northern layer) give reasonable results. The second
run is performed after such a reordering.
In our first experiment, we consider sparse graphs with 1,000 to 30,000 nodes
on each layer and 2,000 to 60,000 randomly drawn edges. The average running
times are plotted in Fig. 6. Here and in the subsequent figures, the suffix “RAN”
indicates that the running times are for the instances with random permutations
of the two layers and the suffix “MED” indicates that the running times are for
the MEDIAN-ordered instances.

Fig. 6. Running time for sparse graphs

The first observation is that SAN and INS are unpractical for large instances
while all other procedures have very reasonable running times. This behavior
extends to very large graphs as can be seen in Fig. 7 for instances up to 500,000
nodes on each layer and 1,000,000 randomly drawn edges. BJM dominates all
other methods for up to about 50,000 nodes both for the “RAN” and for the
“MED” instances, for larger instances BJM leads in the “MED” case and MER
leads in the “RAN” case. However, the differences are so small that they can
Simple and Efficient Bilayer Cross Counting 139

Fig. 7. Running time for large sparse graphs

possibly be attributed to system or implementation peculiarities, just like the


slight peak for 350,000 nodes in Fig. 7.
Now we study the behavior of the algorithms for instances of increasing
density with 1,000 nodes on each layer. The number of edges grows from 1,000
to 100,000. Fig. 8 shows the results.
As before, SAN and INS are not competitive. Up to about 30,000 edges, BJM
is the best method and beyond, WAM is slightly better.
Finally, we ran the algorithms on a selection of real-world graphs compiled
from the AT&T directed graph collection by Michael Krüger of the Max-Planck-
Institut für Informatik in Saarbrücken. We used the first phase of the AGD
Sugiyama implementation in order to obtain layerings with the Longest-Path

Fig. 8. Running time for graphs with increasing density


140 Wilhelm Barth, Michael Jünger, and Petra Mutzel

and Coffman-Graham options from which we extracted the resulting layer pairs
as test instances. Thus, we compiled two collections of 30,061 instances and
57,300 instances, respectively. For each instance, we applied 10 random shuffles
of the northern and southern layers, each followed by a MEDIAN-ordered run
as explained above. So we ran a total of 601,220 and 1,146,000 instances of the
Longest-Path generated layer pairs and the Coffman-Graham generated layer
pairs, respectively.
In the Longest-Path case, the number of northern nodes varies between 1 and
6,566, with 63 on the average, the number of southern nodes varies between 1
and 5,755, with 57 on the average, and the number of edges varies between 1 and
6,566, with 64 on the average. For the random shuffles, the number of crossings
varies between 0 and 10,155,835, with 24,472 on the average and for the MEDIAN
ordered layers, the number of crossings varies between 0 and 780,017, with 182
on the average.
In the Coffman-Graham case, the number of northern nodes varies between 1
and 3,278, with 142 on the average, the number of southern nodes varies between
1 and 3,278, with 137 on the average, and the number of edges varies between
1 and 3,276, with 141 on the average. For the random shuffles, the number of
crossings varies between 0 and 2,760,466, with 47,559 on the average and for the
MEDIAN ordered layers, the number of crossings varies between 0 and 2,872,
with 4 on the average.

Fig. 9. Running time for AT&T graphs

The total running times are reported in Fig. 9. The low crossing numbers in
the MEDIAN case explain why INS and MER are the clear winners. With very
few inversions and very few runs, INS and MER have almost nothing to do while
the other methods do not profit much from this fact. We doubt, however, that
we picked “typical real world data”. Further experiments may lead to hybrid
methods that choose the algorithm according to the problem characteristics.
Nevertheless, our experiments indicate that WAM, MER, and BJM are safe
choices. It should be kept in mind that the running times of a MEDIAN step
and a bilayer cross counting step with one of the fast algorithms are similar, in
Simple and Efficient Bilayer Cross Counting 141

fact, the latter is asymptotically slower. Therefore, bilayer cross counting may
dominate the work in the second phase of a Sugiyama-style layout algorithm
significantly, unless WAM, MER, BJM, or a method of comparable performance
is used.

References
1. B. Chazelle, Reporting and counting segment intersections. Journal of Computer
and System Sciences 32 (1986) 156–182.
2. B. Chazelle and H. Edelsbrunner, An optimal algorithm for intersecting line seg-
ments in the plane. Journal of the ACM 39 (1992) 1–54.
3. T. H. Cormen, C. E. Leiserson, and R. L. Rivest, Introduction to algorithms. MIT
Press, Cambridge, MA, 1990.
4. P. Eades and N. Wormald, Edge crossings in drawings of bipartite graphs. Algo-
rithmica 11 (1994) 379–403.
5. C. Gutwenger, M. Jünger, G. W. Klau, S. Leipert, and P. Mutzel, Graph
Drawing Algorithm Engineering with AGD. in: S. Diehl (ed.), Software Visu-
alization, International Dagstuhl Seminar on Software Visualization 2001, Lec-
ture Notes in Computer Science 2269, Springer, 2002, pp. 307–323, see also:
http://www.mpi-sb.mpg.de/AGD/
6. M. Jünger and P. Mutzel, 2-layer straight line crossing minimization: performance
of exact and heuristic algorithms. Journal of Graph Algorithms and Applications
1 (1997) 1–25.
7. D. E. Knuth, The Stanford GraphBase: A platform for combinatorial computing.
Addison-Wesley, Reading, Massachusetts, 1993
8. G. S. Lueker, A data structure for orthogonal range queries. Proceedings of the
19th IEEE Symposium on Foundations of Computer Science, 1978, pp. 28–34.
9. G. Sander, Graph Layout through the VCG Tool. in: R. Tamassia and I. G. Tollis
(eds): Graph Drawing 1994, Lecture Notes in Computer Science 894, Springer,
1995, pp. 194-205, see also:
http://rw4.cs.uni-sb.de/users/sander/html/gsvcg1.html
10. G. Sander, Visualisierungstechniken für den Compilerbau. Pirrot Verlag & Druck,
Saarbrücken, 1996.
11. K. Sugiyama, S. Tagawa, and M. Toda, Methods for visual understanding of hier-
archical system structures. IEEE Transactions on Systems, Man, and Cybernetics
11 (1981) 109–125.
12. V. Waddle and A. Malhotra, An E log E line crossing algorithm for levelled graphs.
in: J. Kratochvı́l (ed.) Graph Drawing 1999, Lecture Notes in Computer Science
1731, Springer, 1999, pp. 59–70.
Orthogonal 3D Shapes of Theta Graphs

Emilio Di Giacomo1 , Giuseppe Liotta1 , and Maurizio Patrignani2


1
Università di Perugia, Italy
{digiacomo,liotta}@diei.unipg.it
2
Università di Roma Tre, Italy
patrigna@dia.uniroma3.it

Abstract. The recent interest in three dimensional graph drawing has


been motivating studies on how to extend two dimensional techniques to
higher dimensions. A common approach for computing a 2D orthogonal
drawing of a graph separates the task of defining the shape of the drawing
from the task of computing its coordinates. First results towards finding
a three-dimensional counterpart of this approach are presented in [8,9],
where characterizations of orthogonal representations of paths and cycles
are studied. In this note we show that the known characterization for
cycles does not immediately extend to even seemingly simple graphs such
as theta graphs. A sufficient condition for recognizing three-dimensional
orthogonal representations of theta graphs is also presented.

1 Introduction
The recent interest in three-dimensional graph drawing has been motivating
studies on how to extend two dimensional techniques to 3D space. Work in this
direction includes extensions of simulated annealing techniques, spring embedder
techniques, and incremental techniques (see e.g., [3,5,11,15]). However, while a
rich body of literature is devoted to three-dimensional orthogonal drawings, little
is known on the challenging task of extending to 3D the well-known topology-
shape-metrics approach [18].
In order to reach such an ambitious research target, a crucial step is to find
a three-dimensional counterpart of the well-known two-dimensional characteri-
zation of orthogonal representations (see, e.g. [18,19]). More precisely, a solution
to the following problem has to be found.
Let G be a graph such that each edge is directed and labeled with a label
in the set {U p, Down, East, W est, N orth, South}. Does a three-dimensional or-
thogonal drawing of G exist such that no two edges intersect and each edge has
a direction consistent with its associated label?
This question has been addressed by Di Battista et al. [7,8,9] for simple
classes of graphs, namely paths and cycles. The goal of this note is to shed
some more light on the above basic question. Namely, we show that the known

Work partially supported by European Commission - Fet Open project COSIN IST-
2001-33555 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. 142–149, 2002.

c Springer-Verlag Berlin Heidelberg 2002
Orthogonal 3D Shapes of Theta Graphs 143

characterization for cycles does not immediately extend to even seemingly simple
graphs such as theta graphs, that is, graphs composed by two nodes of degree
three and three disjoint paths, of length at least two, joining them. Also, we give a
sufficient condition for recognizing three-dimensional orthogonal representations
of theta graphs.
We remark that theta graphs have been studied extensively in the litera-
ture. For example, they arise in problems concerning graph planarity (see, e.g.,
[1,4,17]), graph bandwidth (see, e.g., [12,14,16]), and chromatic polynomials (see,
e.g., [2]).

2 Preliminaries

We assume familiarity with basic graph drawing terminology (see, e.g. [6]). A
direction label is a label in the set {U, D, E, W, N, S} specifying the directions
Up, Down, East, West, North, South, respectively. Three distinct labels are also
used to identify an octant of the reference system, which is assumed to be open.
Let e be an undirected edge of a graph whose end-vertices are u and v. We
use the term darts for the two possible orientations (u, v) and (v, u) of edge e.
A 3D shape graph γ is an undirected labeled graph such that (i) each dart is
associated with one direction label; (ii) the two darts of the same edge have
opposite labels; and (iii) each label in the set {U, D, E, W, N, S} appears at least
once in γ.
A three dimensional orthogonal drawing of a graph is such that vertices are
mapped to grid points of an integer three dimensional grid and edges are seg-
ments along the integer grid lines connecting the end points. An intersection in
a three dimensional orthogonal drawing is a pair of edges that overlap in at least
a point that does not correspond to a common end-vertex.
A 3D shape graph γ is simple if there exists an orthogonal drawing Γ of
γ such that no two edges of Γ intersect and each oriented edge satisfies the
direction constraint defined by the direction labels associated with its darts.
The simplicity testing problem for a 3D shape graph γ is to decide whether γ is
simple.
Obviously, if γ is simple, no vertex of γ has two entering (or leaving) darts
with the same label. For example, this implies that no vertex of γ can have
degree greater than six. Also, we restrict our attention to the class of shape
graphs that do not have vertices of degree two whose entering darts are given
opposite direction labels, since it can be shown (we omit the details for the
sake of brevity) that each instance for which this property does not hold has an
equivalent instance in this class.
Let γ be a 3D shape graph. A flat F ⊂ γ is a connected subgraph of γ that
is maximal with respect to the property that in every orthogonal drawing with
the shape of γ all edges in F are co-planar. Observe that the labels of γ come
from the union of two oppositely directed pairs of directions. Also, the definition
above extends the analogous definitions given in [7,8,9].
144 Emilio Di Giacomo, Giuseppe Liotta, and Maurizio Patrignani

Let π be a 3D shape path with vertices p1 , p2 , . . . , pk and suppose to walk


along π from p1 to pk . The label path of π, denoted by σπ , is the sequence of
labels associated with darts (p1 , p2 ), . . . , (pi , pi+1 ), . . . ,(pk−1 , pk ). Similarly, let
C be a 3D shape cycle with vertices p1 , p2 , . . . , pk and suppose to walk along
C from p1 to pk . The label cycle of C, denoted by σC , is the sequence of label
associated with darts (p1 , p2 ), . . . , (pi , pi+1 ), . . . , (pk−1 , pk ), (pk , p1 ).
Given a label path or cycle σ, a not necessarily consecutive subsequence
τ ⊆ σ, where τ consists of k elements, is a canonical sequence [9,8] provided
that: (i) 1 ≤ k ≤ 6; (ii) the labels of τ are distinct; (iii) no flat of σ contains
more than three labels of τ ; and (iv) if a flat F of σ contains one or more labels
of τ , then τ ∩ F form a consecutive subsequence of σ.
The following basic result for paths is given in [9]:
Theorem 1. [9] Let π be a 3D shape path with vertices p1 , p2 , . . . , pk and let
σπ be the label path associated with the sequence of darts (p1 , p2 ), . . . , (pi , pi+1 ),
. . . , (pk−1 , pk ). Shape path π admits an intersection free orthogonal drawing with
p1 at the origin and pk in the UNE octant if and only if σπ contains a canonical
sequence of three labels in the set {U, N, E}.
A characterization of simple shape cycles is given in [8]:
Theorem 2. [8] A 3D shape cycle C described by a sequence of direction labels
σC is simple if and only if it contains a canonical sequence of length six.
A theta graph is a graph with two non adjacent nodes of degree three and
all other nodes of degree two [13]. Thus, a theta graph consists of two nodes of
degree three and three disjoint paths, of length at least two, joining them. We
will call 3D theta shape a 3D shape for a theta graph.
In the following we will denote by p and q the two degree-three nodes of a
theta shape. Also, given a shape path πx from p to q, and a shape path πy from
q to p, we denote Cx,y the shape cycle obtained by joining πx and πy . Observe
that given a theta shape, three paths πx , πy , and πz , and three cycles Cx,y , Cx,z ,
and Cy,z , are defined.

3 A Forbidden Theta Shape


In this section we show that the simplicity of the cycles composing a theta shape
does not imply the simplicity of the theta shape itself. We use the following
notation: given a shape path π (say DW U N E) we will denote by π (DW U N E
in the example) the shape path obtained by orienting each edge in the opposite
direction and changing its label with the opposite one (DW U N E = W SDEU ).
Also, we will use a dot to denote a series composition of paths (for example
π1 = π2 · π 3 ). Given two distinct vertices v and w of a shape path (shape
cycle, theta shape, respectively) γ, we say that v is Y with respect to w, where
Y ∈ {U, D, E, W, N, S}, if in any drawing of γ, denoted Πv and Πw the two
planes orthogonal to Y containing v and w respectively, the two planes may be
joined by a segment oriented from Πw to Πv which has direction Y . Observe
that, if v is Y with respect to w, w is Y with respect to v.
Orthogonal 3D Shapes of Theta Graphs 145

Ez

D
?
b Ez q
U6 B

N
Ez

N
δ (B,e,U)
δ (B,e,W)
U6
a  δ (B,e,E)
N W

N
e
p D δ (B,e,D)
?
U6 
W

(a) (b)

Fig. 1. (a) A not simple theta shape and (b) the definition of δ(B, e, X).

Theorem 3. There exists a 3D shape graph that is not simple even if all its
induced cycles are simple.
Proof. Let ϑ be the theta shape composed by the three paths: π1 = W N U ED,
π2 = DW U N E, and π3 = N U EN (see Fig. 1.a). The three cycles C1,2 , C1,3 ,
and C2,3 defined by ϑ are simple. Namely, we have:
C1,2 = W N U ED · DW U N E = W N U EDW SDEU
C1,3 = W N U ED · N U EN = W N U EDSW DS
C2,3 = DW U N E · N U EN = DW U N ESW DS
and each of them satisfies the hypotheses of Theorem 2. In fact, C1,2 con-
tains, for example, the canonical sequence identified by the checked labels in the
sequence W Ň U E ĎW̌ ŠDĚ Ǔ ; C1,3 contains, for example, the canonical sequence
identified by the checked labels in the sequence W Ň Ǔ ĚDŠ W̌ ĎS; and C2,3 con-
tains, for example, the canonical sequence identified by the checked labels in the
sequence DW̌ Ǔ Ň ĚSW ĎŠ.
Suppose for a contradiction that ϑ is simple. Consider a non intersecting
orthogonal drawing Γ of ϑ. Let σ be the label path EN U EN W from a to b.
By Theorem 1, since the only canonical sequences of length three contained in
σ are of type NUW or NUE, then b is NUW or NUE with respect to a in each
non intersecting drawing of σ. Let σ  be the label path N U EDW from a to
b. By Theorem 1, since the only canonical sequences of length three contained
in σ  are of type NUE, NDE, or NDW, then b is NUE, NDE, or NDW with
respect to a in each non intersecting drawing of σ  . Let σ  be the label path
EDW U N from a to b. By Theorem 1, since the only canonical sequences of
length three contained in σ  are of type NUW, NDE, or NDW, then b is NUW,
NDE, or NDW with respect to a in each non intersecting drawing of σ  . We have
a contradiction, the three conditions above can not be simultaneously verified
and thus one intersection necessarily occurs.
146 Emilio Di Giacomo, Giuseppe Liotta, and Maurizio Patrignani

4 Triply Expanding Drawings

Let π1 , π2 , . . . , πn be n shape paths starting from a common point p. Denote by


mi the number of edges of πi , and by ei,h , with h = 1, . . . , mi , the h-th edge
of πi starting from p. An expanding drawing of π1 , π2 , . . . , πn is a simple 3D
orthogonal drawing for which edges e1,m1 , e2,m2 , . . . , en,mn can be replaced by
arbitrarily long segments without creating any intersection with the drawing.
The bounding box of an expanding drawing is the bounding box of the drawing
when edges e1,m1 , e2,m2 , . . . , en,mn are removed. In [8] Di Battista et al. showed
the following sufficient condition for the existence of an expanding drawing of
two paths (doubly expanding drawing).

Theorem 4. [8] A shape path π with n edges admits a doubly expanding drawing
if it either consists of exactly two edges or contains at least two flats.

A triply expanding drawing is an expanding drawing of three paths. The next


theorem extends Theorem 4 to triply expanding drawings.

Theorem 5. Let πx , πy , and πz be three shape paths starting from a common


point p. If the paths πx · πy , πx · πz , and πy · πz consist of exactly two edges or
contain at least two flats, then πx , πy , and πz admit a triply expanding drawing.

Due to space limitations we omit the proof of Theorem 5 and refer to [10] the
interested reader. Roughly, the theorem can be proved by construction, after a
suitable case analysis, and by using the following lemma.

Lemma 1. A shape graph γ that admits a three dimensional orthogonal drawing


such that no intersection occurs between two edges of the same flat is simple.

Proof. The statement can be proved by construction. Namely, given a three


dimensional orthogonal drawing Γ such that no intersection occurs between two
edges of the same flat, an iterative process can be used to produce an orthogonal
drawing Γ  without intersections. Consider an intersection between two edges e1
and e2 that do not belong to the same flat. The following technique eliminates
the intersection, without introducing a new one. Consider a plane p common to
e1 and e2 and a direction d orthogonal to p. Move one unit in the d direction
all the nodes in the open half-space determined by p and d, the end-points of
e1 , and the end-points of all the edges of the flat F of e1 perpendicular to d, if
any. It can be shown that the obtained drawing is a 3D orthogonal drawing of γ,
that the intersection between e1 and e2 has been removed, and that no other
intersection has been introduced (see [10] for details).

By virtue of the preceding lemma, intersections occurring between edges (and


nodes) that do not share a flat can be neglected, assuming that they could be
easily eliminated in a post processing step.
Orthogonal 3D Shapes of Theta Graphs 147

5 A Sufficient Condition for Theta Shapes Simplicity


Let Θ be a theta shape composed by three shape paths π1 , π2 , and π3 from point
p to point q. Let eij , with j = 1, . . . , mi , the j-th edge of πi . In the following we
denote by lij the label associated with eij when directed according to πi . Recall
that when πi is reversed, as in Ck,i = πk · πi , the label associated with eij is the
opposite of lij , that is lij .
Theorem 6. Let Θ be a theta shape composed by three shape paths π1 , π2 , and
π3 from point p to point q. If for each πi there exist three edges ei1 , ei2 , and
ei3 , such that for each pair of paths πi and πj , i, j = 1, 2, 3, i = j, the six labels
li1 , li2 , li3 , lj1 , lj2 , and lj3 form a canonical sequence τi,j for the shape cycle
Ci,j = πi · πj , then Θ is simple .
Proof. By using the canonicity of τ1,2 , τ1,3 , and τ2,3 , the following properties for
labels lij can be verified:
1. The labels lij of the same path are different, i.e., lij = lik , i, j, k = 1, 2, 3,
j = k.
2. No two labels lij of the same path are opposite, i.e., lij = lik , i, j, k = 1, 2, 3,
j = k.
3. No two labels lij of different paths are opposite, i.e., lij = lhk , i, j, h, k =
1, 2, 3, i = h.
It follows that, for each i = 1, 2, 3, labels li1 li2 li3 are a permutation of the same
three labels, one for each oppositely directed pair. We assume, without loss of
generality, that lij ∈ {U, N, E} with i, j = 1, 2, 3.
The nine edges eij (i, j = 1, 2, 3) bound eight connected subgraphs of the
theta graph. We call Gi,j the subpath of πi from eij to ei(j+1) , (i = 1, 2, 3,
j = 1, 2). Further, we call Gp the subgraph composed by the three paths from p
to ei1 with i = 1, 2, 3, and Gq the subgraph composed by the three paths from
ei3 with i = 1, 2, 3 to q.
Observe that Gi,j , with i = 1, 2, 3, and j = 1, 2 admits a doubly expanding
drawing. In fact, since the labels associated with eij and ei(j+1) are canonical, it
follows that, if they are not consecutive, they do not share a flat, and Theorem 4
applies. Also, observe that Gp admits a triply expanding drawing. In fact, since,
for each pair i, j, ei1 and ej1 are canonical in Ci,j , it follows that, if they are not
consecutive, they do not share a flat, and Theorem 5 applies. Analogously, Gq
admits a triply expanding drawing.
We draw a doubly expanding drawing Γi,j for each Gi,j , with i = 1, 2, 3, and
j = 1, 2.Theorem 4. Let L be the maximum length of a side of a bounding box
of the drawings obtained above. We draw a triply expanding drawing Γp of Gp
and a triply expanding drawing Γq of Gq .
Now we show how to set the lengths λij , i, j = 1, 2, 3, of the part of each
edge eij that is not contained in the bounding box of any expanding drawing,
since the actual lengths of the edges can be easily computed from it.
Denote by Bp , Bq , and Bi,j , with i = 1, 2, 3 and j = 1, 2, the bounding boxes
of Γp , Γq , and Γi,j , respectively. Since edges ei1 , with i = 1, 2, 3, have labels in
148 Emilio Di Giacomo, Giuseppe Liotta, and Maurizio Patrignani

{U, N, E}, there are three pairwise orthogonal sides of Bp from which edges ei1
may come out. Denote by vBp the only point common to these sides. Denote by
vBq the point common to the analogous sides of Bq . Place the drawings Γp and
Γq in such a way that vBp has coordinates (−2L − 1, −2L − 1, −2L − 1) and vBq
has coordinates (2L + 1, 2L + 1, 2L + 1).
Now we show how to add the drawing of Γi,1 and Γi,2 , for i = 1, 2, 3. Given a
bounding box B, an edge e protruding from it, and a direction label X orthogonal
to e, we denote by δ(B, e, X) the distance of e from the side of B in the X
direction (see Figure 1.b). We determine λij , with i, j = 1, 2, 3, by considering
the following equalities.
λi,1 = 4L + 2 + δ(Bq , ei3 , li1 ) − δ(Bi,2 , ei3 , li1 )+
+δ(Bi,2 , ei2 , li1 ) − δ(Bi,1 , ei2 , li1 ) (1)

λi,2 = 4L + 2 + δ(Bp , ei1 , li2 ) + δ(Bq , ei3 , li2 )−


−δ(Bi,1 , ei1 , li2 ) − δ(Bi,2 , ei3 , li2 ) (2)

λi,3 = 4L + 2 + δ(Bp , ei1 , li3 ) − δ(Bi,1 , ei1 , li3 )+


+δ(Bi,1 , ei2 , li3 ) − δ(Bi,2 , ei2 , li3 ) (3)
Now we show that no intersection between edges sharing a flat has been
introduced in the drawing. By Theorems 4 and 5 no intersection occurs in each
(doubly or triply) expanding drawing.
There is no intersection between two edges of the same πi . In fact, since
0 ≤ δ(Bi,j , e, X) ≤ L, and by equations 1, 2, and 3, each λij , with i, j = 1, 2, 3
is at least 2L + 2 and each one of Bp , Bq , Bi,1 , and Bi,2 is in a different octant.
Intersections between edges belonging to different paths involve edges that
do not share a flat, and thus, by Lemma 1, can be removed. Indeed, suppose
for a contradiction that ex and ey are two intersecting edges belonging to two
different paths πx and πy and that ex and ey are on the same flat F . Edges ex
and ey do not belong to the same expanding drawing, since otherwise they could
not intersect.
There must exist a path π ∗ joining ex and ey , entirely contained in F , and
containing p or q. In π ∗ there can be at most three of the edges eij , with i = x, y,
and j = 1, 2, 3, since otherwise there would be more than three canonical labels
on the same flat for the cycle Cx,y , contradicting the hypothesis that τx,y is
a canonical sequence. Since edges eij in π ∗ are on the same flat F and are
canonical, they are necessarily adjacent, and thus if they are consecutive they
are orthogonal with each other. If ex and ey coincide with two edges eij , then they
can not intersect since they are parallel or adjacent and orthogonal. Otherwise,
since edges eij are the only ones to transition between octants, then ex and ey
belong to two different octants and they can not intersect.
Orthogonal 3D Shapes of Theta Graphs 149

References
1. D. S. Archdeacon and J. Širáň. Characterizing planarity using theta graphs. J.
Graph Theory, 27:17–20, 1998.
2. J. Brown, C. Hickman, A. Sokal, and D. Wagner. On the chromatic roots of
generalized theta graphs. J. of Combinatorial Theory, Series B, to appear.
3. I. Bruß and A. Frick. Fast interactive 3-D graph visualization. In F. J. Bran-
denburg, editor, Graph Drawing (Proc. GD ’95), volume 1027 of Lecture Notes
Comput. Sci., pages 99–110. Springer-Verlag, 1996.
4. G. Chartrand and F. Harary. Planar permutation graphs. Ann. Inst. H. Poincaré,
Sect B, 3:433–438, 1967.
5. I. F. Cruz and J. P. Twarog. 3D graph drawing with simulated annealing. In
F. J. Brandenburg, editor, Graph Drawing (Proc. GD ’95), volume 1027 of Lecture
Notes Comput. Sci., pages 162–165. Springer-Verlag, 1996.
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, G. Liotta, A. Lubiw, and S. Whitesides. Embedding problems
for paths with direction constrained edges. In Annual International Computing
and Combinatorics Conference, (COCOON 2000), volume 1858 of Lecture Notes
Comput. Sci., pages 64–73. Springer-Verlag, 2000.
8. G. Di Battista, G. Liotta, A. Lubiw, and S. Whitesides. Orthogonal drawings of
cycles in 3d space. In J. Marks, editor, Graph Drawing (Proc. GD ’00), volume
1984 of Lecture Notes Comput. Sci. Springer-Verlag, 2001.
9. G. Di Battista, G. Liotta, A. Lubiw, and S. Whitesides. Embedding problems for
paths with direction constrained edges. J. of Theor. Comp. Sci., 2002. to appear.
10. E. Di Giacomo, G. Liotta, and M. Patrignani. On orthogonal 3d shapes of theta
graphs. Tech. Report RT-DIA-71-2002, Dept. of Computer Sci., Univ. di Roma
Tre, 2002. http://web.dia.uniroma3.it/research/.
11. D. Dodson. COMAIDE: Information visualization using cooperative 3D diagram
layout. In F. J. Brandenburg, editor, Graph Drawing (Proc. GD ’95), volume 1027
of Lecture Notes Comput. Sci., pages 190–201. Springer-Verlag, 1996.
12. D. Eichhorn, D. Mubayi, K. O’Bryant, and D. B. West. Edge-bandwidth of theta
graphs. J. Graph Theory, 35:89–98, 2000.
13. F. Harary. Graph Theory. Addison-Wesley, Reading, Mass., 1969.
14. T. Jiang, D. Mubayi, A. Shastri, and D. B. West. Edge-bandwidth of graphs.
SIAM Journal on Discrete Mathematics, 12(3):307–316, 1999.
15. A. Papakostas and I. G. Tollis. Algorithms for incremental orthogonal graph draw-
ing in three dimensions. Journal of Graph Algorithms and Applications, 3(4):81–
115, 1999.
16. G. Peck and A. Shastri. Bandwidth of theta graphs with short paths. Discrete
Mathematics, 103, 1992.
17. I. Sciriha and S. Fiorini. On the characteristic polynomial of homeomorphic images
of a graph. Discrete Mathematics, 174:293–308, 1997.
18. R. Tamassia. On embedding a graph in the grid with the minimum number of
bends. SIAM J. Comput., 16(3):421–444, 1987.
19. G. Vijayan and A. Wigderson. Rectilinear graphs and their embeddings. SIAM J.
Comput., 14:355–372, 1985.
Separating Thickness from Geometric Thickness

David Eppstein

Dept. of Information and Computer Science


University of California, Irvine
Irvine, CA 92697-3425, USA
eppstein@ics.uci.edu

Abstract. We show that graph-theoretic thickness and geometric thick-


ness are not asymptotically equivalent: for every t, there exists a graph
with thickness three and geometric thickness ≥ t.

1 Introduction

The graph-theoretic property of thickness and its variants formalize the concept
of layered graph drawing, in which a graph must be drawn in multiple layers
(or with multiple colors) so that each edge belongs to a single layer and no two
edges in the same layer cross. The vertices of the graph should be represented
as points and should exist in the same positions in each layer. There are three
important variants of thickness:

– The thickness of a graph G, denoted θ(G), is the minimum number of layers


for which a drawing of G exists, without restriction on the number of bends
per edge [11].
– The geometric thickness of a graph G, denoted θ̄(G), also known as real
linear thickness, is the minimum number of layers for which a drawing exists
without any bends in the edges: each edge must be represented as a straight
line segment [5, 11].
– The book thickness of a graph G, denoted bt(G), is the minimum number of
layers for which a drawing exists without any bends in the edges and with
all vertices placed in convex position [4].

Since each variant imposes additional constraints on the previous one, these
parameters are always ordered: θ(G) ≤ θ̄(G) ≤ bt(G), and it is of interest to
determine how tight these inequalities are. Due to Fáry’s theorem [7], the graphs
with thickness one and geometric thickness one coincide (both are just the planar
graphs), and are a strict superset of the graphs with book thickness one (the
outerplanar graphs). Thickness and geometric thickness were known to differ
for infinitely many graphs: in particular, complete graphs on n vertices have
thickness n/6 + O(1) [1, 2, 3, 13, 14] but have geometric thickness ≥ n/5.646 [5].
In previous work [6] we showed that book thickness can not be bounded by any
function of the geometric thickness: for any t there exists a graph with geometric

M.T. Goodrich and S.G. Kobourov (Eds.): GD 2002, LNCS 2528, pp. 150–162, 2002.

c Springer-Verlag Berlin Heidelberg 2002
152 David Eppstein

Fig. 2. Graph G3 (5). The circular vertices represent singleton subsets, and the trian-
gular 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 sub-
graph 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
 
For instance, in the proof of Theorem 1, we choose c = t−1 2 + t − 1, e = 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 prop-
erty: 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.
Separating Thickness from Geometric Thickness 155

Fig. 4. Forced crossings in an inner drawing, from Lemma 6.

graph, containing a complete 2 × 2 subgrid. (The quadrilaterals of this grid need


not always be convex, but this does not affect our argument.)
Because we chose tripletons using only every other singleton from the order-
ing, it is now possible to find singletons a and b that lie between the three low
edges forming the 2 × 2 subgrid, and e and f that lie between the three high
edges forming the subgrid (Figure 4). Therefore, any tripleton with a low edge
to a or b and a high edge to e or f must be forced to lie within a particular
square of the subgrid.
Extend the two middle line segments of the subgrid into lines across curve C
(the thin dotted lines of the figure), partitioning C into three curves: the curve
clockwise of both extended lines, the curve counterclockwise of the extended
lines, and the curve between the two lines. The four points n/2 − 2, n/2 − 1, n/2,
n/2 + 1 lie between b and e, and by the pigeonhole principle we can find two of
these points c < d that are both within the same one of these three curves.
If c and d are both in the center curve of the three curves (shown in the left
side of the figure) then tripletons ace and bdf must have crossing middle edges.
If c and d are both in the counterclockwise curve (shown on the right side of the
figure), then tripletons adf and bce must have crossing middle edges; the case
in which c and d belong to the clockwise curve is symmetric. Thus, in all cases
two tripletons have crossing middle edges, contradicting the assumption that we
have a three-layer drawing with no crossings. 


Lemma 7. If every graph G3 (n) has geometric thickness three, then every G3 (n)
has an outer drawing.

Proof. Assume without loss of generality that n is sufficiently large that, by


Lemma 6, no inner drawing of G3 (n) exists. Let r = R3 (n; 2), as shown to exist
in Lemma 1. By Lemma 4, we can assume G3 (r) has a coherent drawing. Let C
be the convex hull of the singletons of this drawing, and perturb C if necessary
so that it remains convex and does not pass through any tripletons. Partition
the tripletons of the drawing into two classes according to whether they are
inside or outside C, and apply Lemma 1 with c = 2 and e = 3 to find a drawing
156 David Eppstein

Fig. 5. Left: Forced crossing in an outer drawing of type 201, from Lemma 9. Right:
Sharp angles in an outer drawing of type 021, from Lemma 10.

of G3 (n) in which all triples are inside C or all triples are outside C. Since no
inner drawing exists, all triples are outside C, and we have an outer drawing of
G3 (n). 


6 Classification of Outer Drawings


In an outer drawing, the three angles formed by the three edges incident to a
tripleton must include an angle greater than 180◦ , and we can order the three
edges clockwise starting at this large angle. Define the type of a tripleton to be
a symbol xyz, where x, y, and z form a permutation of 0, 1, and 2, and where
the positions of the low, middle, and high number in the symbol are the same
as the positions of the low, middle, and high edge in the clockwise ordering at
the tripleton. There are six possible types: 012, 021, 102, 120, 201, and 210. If
all tripletons in a drawing have the same type xyz, we say that the drawing is
of type xyz.

Lemma 8. If every graph G3 (n) has geometric thickness three, then every G3 (n)
has an outer drawing in which all tripletons have the same type.

Proof. By the previous lemma, we can assume that we have an outer drawing
with sufficiently many vertices, to which we can apply Lemma 1 with c = 6 and
e = 3. 


We now successively analyze each type of outer drawing and show that, for
sufficiently large n, each type must lead to a crossing.

Lemma 9. For n ≥ 4, G3 (n) has no outer drawing of type 201 or 120.

Proof. In a drawing of type 201, each low edge of a tripleton must cross the
convex curve C between the middle and high sigletons adjacent to the tripleton.
Therefore, in a drawing of G3 (4), the low edge from tripleton 012 would cross
the low edge from tripleton 123, as shown in Figure 5. Type 120 is equivalent
Separating Thickness from Geometric Thickness 157

to type 201 under mirror reversal of the drawing and reversal of the clockwise
ordering of the singletons. 


Lemma 10. In any outer drawing of G3 (4) of type 021, let θi denote the angle
at singleton i on the convex hull of the singletons. Then θ1 + θ2 < 180◦ .
Proof. In order to be of type 021, tripleton 012 must lie in a wedge outside C
bounded by lines 02 and 12 (the shaded area on the upper right of Figure 5).
The low edge e0 from 0 to 012 crosses line 12 on the boundary of this wedge.
Similarly, the low edge e1 from 1 to tripleton 123 crosses line 23. In order for
e1 to reach this line without crossing e0 , tripleton 123 must be clockwise from
singleton 0 as viewed from singleton 1, so angle 123-1-2 must be greater than
θ1 . But in order for the crossing of e1 with line 23 to be on the boundary of
the wedge containing 123 (shown as the lower shaded area in the figure), angle
123-1-2 must be less than 180◦ − θ2 . Combining these two inequalities gives the
result. 


Lemma 11. For n ≥ 6, G3 (n) has no outer drawing of type 021 or 102.
Proof. By applying Lemma 10 twice, θ1 + θ2 + θ3 + θ4 < 360◦ , but this is not
possible in a convex polygon. Type 102 is equivalent to type 021 under mirror
reversal. 


Lemma 12. In an outer drawing of G3 (n) of type 012, the middle edges adjacent
to singletons 2, 3, . . ., n − 3 all pass across line segment 0-(n − 1).
Proof. By the assumption that the drawing is of type 012, the middle edges of
the tripletons 0i(n − 1) all pass across this segment (Figure 6, left). In any other
singleton abc, the middle edge must pass from b across line segment ac within
the convex curve C. Unless b = 1 or b = n − 2, this crossing with ac must occur
within a strip bounded by two of the middle edges of tripletons 0i(n − 1), and
the only way for the middle edge from b to exit C is at the end of this strip,
where it meets segment 0-(n − 1). 


Lemma 13. Suppose we have an outer drawing of G3 (n) of type 012, in which
all middle edges cross segment 0-(n − 1). Draw a tangent line to convex curve
C parallel to line 0-(n − 1), on the opposite side of C from that line, and let h
be a point where the tangent line touches C. Then, for every tripleton ijk where
i is clockwise from h, the low edge from i to ijk crosses C either at a point
counterclockwise from h or between singletons 0 and n − 1.
Proof. By the assumption of the drawing type, all low edges must cross line 0-
n − 1 to the left of the crossing point of the middle edge, which is between points
0 and n − 1. If the low edge’s crossing is not also between points 0 and n − 1, it
must be to the left of point 0. But, within the strip between line 0-(n − 1) and
the parallel tangent line, the portion of C between 0 and h separates the rest of
C (containing i) from the points left of point 0 (as shown in Figure 6, right), so
the low edge most cross C before it reaches its crossing with line 0-(n − 1).  
158 David Eppstein

Fig. 6. Analysis of outer drawings of type 012. Left, the middle edges of the triple-
tons 0i(n − 1) form tracks that force the remaining middle edges to cross segment
0-(n − 1) (Lemma 12). Right, low edges from clockwise of the tangent point h cross C
counterclockwise of the tangent point (Lemma 13).

Symmetrically, the high edges from counterclockwise of h must cross C clock-


wise of h.

Lemma 14. For sufficiently large n, G3 (n) has no outer drawing of type 012.

Proof. Start with an outer drawing of type 012, and remove singletons 1 and
n−2 if necessary so that (by Lemma 12) all middle edges cross segment 0-(n−1).
Form the tangent point h described in Lemma 13, and assume without loss of
generality that at least half of the remaining singletons lie clockwise of h on
convex curve C. (The case that at least half the singletons lie counterclockwise
of h is symmetric.) Remove from the drawing all points counterclockwise of h.
The result is an outer drawing of type 012 of a graph G3 (m), with at least
m ≥ (n − 2)/2 singletons, in which all low and middle edges cross segment 0-
(m − 1). We can now apply the same reasoning as in Lemma 6: by choosing an
appropriate set of tripletons, we can find a set of low and middle edges forming
a grid that contains a complete 2 × 2 subgrid, and use the subgrid to constrain
the locations of two more tripletons, forcing two high edges to cross. 


Lemma 15. In an outer drawing of G3 (n) of type 210, each middle edge is
completely exterior to convex curve C.

Proof. Suppose to the contrary that a middle edge for tripleton ijk crosses C at
point x. If x is clockwise of j, an edge from ijk to C clockwise of the middle edge
can only reach singletons in the range from j to x, contradicting the requirement
(from the assumption of the drawing type) that the low edge i-ijk must be
clockwise of the middle edge. Symmetrically, if x is counterclockwise of j, an
edge counterclockwise of the middle edge can only reach singletons in the range
Separating Thickness from Geometric Thickness 159

Fig. 7. In an outer drawing of type 210, low edges from singletons 0 and 1 cross disjoint
ranges of the convex curve C (Lemma 17).

from x to j, contradicting the requirement that the high edge must be clockwise
of the middle edge. 

The same reasoning as above also proves the following lemma:
Lemma 16. In an outer drawing of G3 (n) of type 210, suppose that the low edge
of tripleton ijk crosses the convex curve C. Then the crossing point is clockwise
of singleton i.

Lemma 17. Suppose that G3 (n) has a convex drawing of type 210, and let n =
2k − 2 Then we can select a subset S of the singletons, with |S| = k, such that
no member of S is incident to a low edge that crosses the convex hull of S.
Proof. We use induction on k. As a base case, for k = n = 2, G3 (2) has no
edges. Otherwise, consider the sets of low edges incident to singletons 0 and
1 that cross convex curve C. Since these two sets of low edges do not cross
each other (Figure 7), we can partition the portion of C clockwise of 1 into
two parts, where the clockwise part of C is crossed only by low edges from 0
and the counterclockwise part of C is crossed only by low edges from 1. One
of these two parts contains at least (n − 2)/2 singletons. If the clockwise part
contains many singletons, we apply the induction hypothesis to these singletons,
and form S by adding singleton 1 to the resulting set. On the other hand, if the
counterclockwise part contains many singletons, we add singleton 0 to the set
formed by applying the induction hypothesis to the singletons in this part.
In either case, we get a set S of (k − 1) + 1 = k singletons. The low edges
from 0 or 1 (whichever was included in the set) can not cross the hull, because
of how we chose which part of C to apply the induction hypothesis to. The low
edges from the remaining members of S can not cross the hull between 0 or 1
and the rest of S, by Lemma 16, and they can not cross the hull elsewhere by
induction. Therefore S fulfills the conditions of the lemma. 


Lemma 18. Not every graph G3 (n) has an outer drawing of type 210.
Proof. By Lemma 17, if G3 (n) has such a drawing, then we can find a set of k
singletons, and a convex curve C (the hull of this set), forming an outer drawing
160 David Eppstein

Fig. 8. Schematic view of drawing of G3 (8) with geometric thickness three.

of G3 (k) in which all low and middle edges avoid the interior of convex curve
C; here k = log2 (n + 2). We can now apply the same reasoning as in Lemmas
6 and 14: by choosing an appropriate set of tripletons, we can find a set of low
and middle edges forming a grid that contains a complete 2 × 2 subgrid, and use
the subgrid to constrain the locations of two more tripletons, forcing two high
edges to cross. 


7 Completion of the Proof

Lemma 19. Not every graph G3 (n) has geometric thickness at most three.

Proof. This follows from Lemma 8 (showing that we can restrict our attention
to outer drawings of fixed type) and Lemmas 9, 11, 14, and 18 (showing that
each fixed type leads to a forced crossing). 


The largest n for which G3 (n) has no thickness-three drawing must be at


least nine, as G3 (8) has geometric thickness at most three: draw four singleton
subsets in a large square, with the remaining four singletons and all tripletons
clustered near the center of the square. The edges incident to the inner four
singletons form a planar graph, consisting of a cube G3 (4), 24 two-edge paths
across the faces of the cube, and 24 tripletons with only a single edge to one of
the inner singletons. By choosing an appropriate Fáry embedding of this planar
graph, we can draw it in a single layer, and use an additional layer for the edges
incident to each pair of opposite outer singletons. Figure 8 shows this drawing in
a schematic view, with the outer four vertices and inner cube visible but omitting
the remaining tripletons.

8 Conclusions

We have shown that thickness and geometric thickness are not asymptotically
equivalent. Some interesting open questions remain:
Separating Thickness from Geometric Thickness 161

– What can be said about two-layer drawings? It is known that there exist
graphs, for instance K6,8 , for which θ(G) = 2 and θ̄(G) > 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 graph-
theoretic 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 con-
stant 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 geo-
metric 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čakov. 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áry. 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 Mathemati-
cal 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. Eu-
roconf. Combinatorics, Graph Theory, and Applications, pp. 310–315. Univ.
Autònoma de Barcelona, Centre de Recerca Matemàtica, 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à 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.
wismath@cs.uleth.ca

Abstract. An optimal O(n)-time algorithm to compute an upward two-


page book embedding of a series-parallel digraph with n vertices is pre-
sented. 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 pre-
vious result by Chung, Leighton, and Rosenberg [5] who proved sub-
hamiltonicity for a subset of planar series-parallel graphs. Also, this pa-
per investigates the problem of mapping planar digraphs onto a given
set of points in the plane, so that the edges are drawn upward pla-
nar. 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 Coun-
cil 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 Yan-
nakakis [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 em-
bedding 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 em-


bedding 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 series-
parallel (undirected) graphs are necessarily sub-hamiltonian.

2 Preliminaries
2.1 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 fol-
lowing) 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 TTSP-
digraph.
– 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 series-
parallel 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 de-
composition 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 assign-
ment 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 Prop-
erty 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 with-
out 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 com-
mon 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 z v v z

v v w z z

w w v w v=w

u u u u u=w u

(a) (b) (c) (d) (e) (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 re-
move 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 post-
order 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 .

1111
0000 v
0000
1111
111
000u k+1= v 0000
1111
0000
1111
0000
1111
000
111
νk 0000
1111
0000
1111
0000
1111
0000
1111
v 000
111 0000
1111
0000
1111
0000
1111
000
111uk 0000
1111
0000
1111
0000
1111
0000
1111
0000
1111
0000
1111
0000
1111
0000
1111
ν1 1111
0000
ν2
0000
1111 νk
0000
1111
0000
1111
0000
1111
0000
1111
0000
1111
0000
1111
0000
1111
1111
0000
0000
1111
0000
1111
ν2 11
00 0000
1111
u3 0000
1111
00
11 0000
1111
0000
1111
0000
1111
0000
1111
00
11 0000
1111
0000
1111
0000
1111
111
00000
11
u2 0000
1111
0000
1111
0000
1111
000
111
ν1 0000
1111
0000
1111
0000
1111
0000
1111
000
111 0000
1111
0000
1111
0000
1111
u
000
111 u= u 0000
1111
0000
1111
0000
1111
0000
1111
1 u

(a) Case Q (b) Case S (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.
168 Emilio Di Giacomo et al.

8 14 P−NODE l =left
r =right 35
15 S−NODE
15
7 1 Q−NODE
(1,2) 34
15 33 (1,8) l
14
6
12 1 9 32
13 8 14 22 31 (15,8)
(1,2) (5,6)

l l r
5 11
10 30
4 4 7 (6,8) 13 18 21 25 29 (11,15)
3 9 r
10 l
2 2 3 5 6 11 12 16 17 19 20 23 24 26 27 28
(2,3) (3,5) (2,4) (4,5) (6,7) (7,8) (1,9) (9,11) (1,10) (10,11) (11,12) (12,15) (11,13) (13,14) (14,15)

1 l r l r l r l r l r l r l l r

(a) (b)

L 1={1,2} L 13={6,7,8} L 25={11,12,15}


8
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} 6
27

L 4={2,3,5} L 16={1,9} L 28={14,15} 5


3
L 5={2,4} L 17={9,11} L 29={11,13,14,15} 4
L 6={4,5} 2
L 18={1,9,11} L 30={11,15} 15
L 7={2,4,5} L 19={1,10}
L 31={11,13,14,12,15} 12
L 8={2,4,3,5} L 20={10,11} L 32={15,8} 14
13
L 9={5,6} L 21={1,10,11} L 33={1,10,9,11,13,14,12,15,8}
11
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} 9
10
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}
1
L 12={7,8} L 24={12,15}

(c) (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 algo-


rithm 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 Theo-
rem 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 pre-
cedes 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 171

4 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 series-
parallel 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 three-
cycle 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 sub-
hamiltonian is NP-Complete [5]
Theorem 3. Let G be a TTSP-graph with n vertices. Then G admits a two-
page 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 em-
beddability 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
b b

a a 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 point-


set 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 trian-
gulation 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 de-


coding) 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-mono-
tone 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 draw-
ings 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 175

2 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 us-
ing 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 us-
ing 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 us-
ing 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 us-
ing 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
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 bicon-


nected 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 ex-
ist 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 out-
going 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 con-
nect 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, in-
coming 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 ex-
actly 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 in-
coming 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 u1 (= vl ), u2 , . . . , ut (=
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 ui and ui+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 reconstruct-
ing 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 comple-
tion 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  = s1 s2 . . . sm , where each si contains the lengths of all
the line-segments of edge ei = (vj , vk ), placed in the order the corresponding line-
segments 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: Sup-
pose 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 line-
segment 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 line-
segments 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 line-
segment 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 us-
ing 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 us-
ing 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 us-
ing 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 information-
theoretically 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ýkora1 , László A. Székely2 , 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úbravská 9, 842 35 Bratislava, Slovak Republic

Abstract. Adamec and Nešetřil [1] proposed a new the so called frac-
tional 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 exper-
imentally 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šetřil [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 con-
firmed that the number of crossings is one of the most important aesthetic mea-
sures 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 un-
derstand 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 Ondrej Sýkora, László A. Székely, and Imrich Vrt’o

2 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 2-
layer 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

Length(G) = min |f (u) − f (v)|.
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 
c1 ≤ fl(D) ≤ c2 cr(D) + n log n.
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ýkora, László A. Székely, 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) = √ . (3)
2 A
From (1) and (2) we get
cr(D) + n L √ √ 
√ ≤ √ ≤ A ≤ c3 cr(D) + n log n.
4 A 2 A
Hence 
1 cr(D) + n L √ 
√ ≤ √ ≤ c3 cr(D) + n log n. (4)
c3 log n 2 A
Finally, substituting (3) into (4) we get the result. 2
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.
Fractional Lengths and Crossing Numbers 191

4 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 cross-
ing 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 coor-
dinates 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
1 1
c1 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 2 1
c4 dLength(G) ≤ bcr(G) + nd ≤ bcr(D) + nd2 , (6)
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 √
Length(G) ≤ L ≤ 2Length(G). (7)
Finally, combining (5),(6) and (7) and noting that fl(D) = L/n, we get
√ √
bcr(D) 2bcr(D) 2
≤ fl(D) ≤ + d,
5dn c4 dn c4
which implies the claim. 2

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ýkora, László A. Székely, 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
 
1   dv   dv 
fl(D) ≥ bcr(D) + n − 1 +
n 2 2
v∈T

√  
2   dv   dv 
fl(D) ≤ bcr(D) + n − 1 +
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. 2

References
1. Adamec, J., Nešetřil, 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 Sympo-
sium 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ýkora, O., Székely, 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 Sympo-
sium 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 inappropri-
ate 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 cross-
ings. 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
Lij = k=1 wik i = j i, j = 1, . . . , n.
−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

n
bi = 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

1  
n
EH (G, y) = wij (yi − yj − δij )2 = wij (yi − yj − δij )2 . (1)
2 i,j=1
(i,j)∈E

Clearly, EH ≥ 0 for any digraph and any vector of coordinates. We define an op-
timal 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 en-
ergy
ncan be written in the compact form EH = E0 + y T Ly − 2y T b, where E0 =
1 2
2 i,j=1 wij δij . For a proof see the full version of this paper [1]. Differentiating this
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 exam-
ples. 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 2 2/3
−1 1 0 y = −1 =⇒ y = −1/3 ,
−1 0 1 −1 −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 2 2/3
−1 2 −1 y = 0 =⇒ y = 0 .
−1 −1 2 −2 −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 23 and increasing y1 − y3 to 43 . The height differences
cannot achieve their targets, resulting in a strictly positive hierarchy energy EH (y  ) =
( 23 − 1)2 + ( 23 − 1)2 + ( 43 − 1)2 = 13 .

1 1

3 2 3 2

(a) (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 ⎟ ⎜ 1/4 ⎟

⎝ 0 −1 2 −1 ⎠ y = ⎝ 0 ⎠ =⇒ y =⎝
0⎠
,
−1 −1 −1 3 −1 −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 · ( 14 − 1)2 + ( 12 − 1)2 = 2.5.

y
1
2 4
1

1 3
4 2

1
4 4
3

(a) (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
yi = n . (2)
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 )

yi = n ,
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. Di-
rectional 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 ‘swap-
ping 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 sug-
gested 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 posi-
tive 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
n [3]. The solution is obtained by minimizing the energy function ELA =
i,j=1 ij |xi − xj |, where (x1 , . . . , xn ) is a permutation of (1, . . . , n). This is
1
2 w
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

− ymin

. The larger the Δy  , the more hierarchical the digraph. One
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

Δy  y  − ymin

H= = 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 invert-
ing 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.

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 struc-
tures. 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 x-
coordinates 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| x-coords y-coords total


time time time
Nos6 675 1290 0.000 0.015 0.015
Nos7 729 1944 0.000 0.016 0.016
Dwa512 512 1004 0.000 0.016 0.016
Dw2048 2048 4094 0.015 0.11 0.125
Dw8192 8192 17,404 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 203

(a) (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-coordina-
tes 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 y-
coordinates 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 Opti-
mization”, 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: Magnetic-
Spring 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 obser-
vation 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 al-
gorithmically 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 David Harel and Yehuda Koren

2 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:

duv − 2δv,u
i
 |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:

duv  dpi v + dpi u = dpi v + dpi v + (dpi u − dpi v ) = 2δv,u


i
+ |X i (v) − X i (u)|
=⇒ duv − 2δv,u
i
 |X i (v) − X i (u)|

Thus if we denote the minimal distance between {v, u} and P ivots by:
def
v,u = min dpi j ,
i∈{1,...,m},j∈{v,u}

then there exists an axis i such that |X i (v) − X i (u)|  duv − 2v,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
the drawing. We denote the vectors of centered data by X̂ 1 , . . . , X̂ m , defined as:

X̂ i (j) = X i (j) − mi , i = 1, . . . , m, j = 1, . . . , n
We now construct an m × n matrix, X, whose rows are the (centered) coordinates:
⎛ 1 ⎞
X̂ (1) . . . X̂ 1 (n)
⎜ . ... . ⎟
X=⎜ ⎝ .


... .
X̂ m (1) . . . X̂ m (n)
The covariance matrix S, of dimension m × m, is defined as
1
S= 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:

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 (u2 = 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 T 1 1
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 (1)
u
subject to: u2 = 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 << n, the running time is negligible (taking in practice less
than a millisecond) and there is no need for more complicated techniques. The basic
idea is as follows. Say we are given an m × m symmetric matrix A with eigenvectors
u1 , u2 , . . . , um , whose corresponding eigenvalues are λ1 > λ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
ûi ← random
ûi ← ûûii 
do
ui ← ûi
% orthogonalize against previous eigenvectors
for j = 1 to i − 1 do
ui ← ui − (ui · uj )uj
end for
ûi ← Sui
ûi ← ûûii  % normalization
while ûi · ui < 1 −  % halt when direction change is negligible
ui ← û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 13 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 ex-
ample, 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
516 [14] 516 729 0.00 0.00 0.00
Fidap006§ 1651 23,914 0.03 0.02 0.01
4970 [14] 4970 7400 0.08 0.03 0.05
3elt† 4720 13,722 0.09 0.05 0.05
Crack‡ 10,240 30,380 0.30 0.14 0.08
4elt2† 11,143 32,818 0.25 0.16 0.09
Sphere† 16,386 49,152 0.81 0.47 0.16
Fidap011§ 16,614 537,374 0.75 0.59 0.13
Sierpinski (depth 10) 88,575 177,147 1.77 0.89 0.77
grid 317 × 317 100,489 200,344 2.59 1.59 0.89
Ocean† 143,437 409,593 7.16 5.74 1.25
mrngA† 257,000 505,048 13.09 10.66 2.19
grid 1000 × 1000 1,000,000 1,998,000 50.52 41.03 8.48
mrngB† 1,017,253 2,015,714 57.81 47.83 8.84
§
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 dimen-
sional 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 pos-
sibly 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 advan-
tages 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 diffi-
culties 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 com-
plexity 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 us-
ing 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 force-
directed 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. Never-
theless, 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 edge-
weighted 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, force-
directed 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 Force-
Directed 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 Visu-
alization (InfoVis) 2002.
11. Y. Koren, “On Spectral Graph Drawing”, manuscript, 2002.
12. A. Quigley and P. Eades, “FADE: Graph Drawing, Clustering, and Visual Abstraction”, Pro-
ceedings 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ünger1 , Sebastian Leipert2 , Petra Mutzel3 ,


Merijam Percan1 , and René Weiskircher3
1
Universität zu Köln, Institut für Informatik,
Pohligstraße 1, 50969 Köln, Germany†
{mjuenger,percan}@informatik.uni-koeln.de
2
caesar research center,
Friedensplatz 16, 53111 Bonn, Germany
{gutwenger,leipert}@caesar.de
3
Technische Universität 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 ver-
tices 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 non-
connected 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 ver-
tices 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 in-
duced planar connectivity augmentation presented in [GJL+ 02]. For an undi-
rected 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 GW 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 Preliminaries
2.1 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 -,Q-
and 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 cy-
cles, 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 combinato-
rial 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 R-
and 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 223

s s s s
B1 e1
v1 v1
B2 e2 C1 C2 C3 e1 e2 e3 e4
v2 v2
B3 e3
t t t t

(a) Case S-node (b) Case P -node

s s
U1 U2 e1 e2
U3 e3
U4 U5 e4 e5

t t

(c) Case R-node

Fig. 1. The structure of biconnected graphs and the skeleton of the root of the corre-
sponding SPQR-tree

1 Q-node
4

5
1

2 3
P-node
4

1 1

6 5
2 3

4 6

4 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 rep-
resents 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 SPQR-
tree 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 con-
ditions 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 clus-
ter 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 augmen-
tation 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 non-


connected 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 cor-
responds 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 c-
planar. 

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 non-
trivial 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 com-
ponent 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 non-
connected 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 non-
connected 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 con-
structed 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, connect-
ing 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 con-
nected 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 non-
connected 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 ev-
ery 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 com-
puted 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 com-
ponent 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 num-
ber 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 non-
connected 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 PQ-
trees [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 non-
connected 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 non-
connected 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 com-
ponent 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 ar-
bitrary clustered graph where all other clusters are connected and G is planar.
If the two clusters are contained in two different connected components (if ad-
ditionally 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 indepen-
dently. 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ünger, 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 Sym-
posium, 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ünger, S. Leipert, P. Mutzel, M. Percan, and


R. Weiskircher. Subgraph induced planar connectivity augmentation. Tech-
nical report, Institut für Informatik, Universität zu Köln, 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,


raitner@fmi.uni-passau.de

Abstract. We introduce the base architecture of a software library


which combines graphs, hierarchies, and views and describes the interac-
tions between them. Each graph may have arbitrarily many hierarchies
and each hierarchy may have arbitrarily many views. Both the hierar-
chies 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 hierarchi-
cally 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 bio-
chemical 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 col-
lapsed 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 inclu-
sion 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 ex-
plore 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
H over G consists of nodes V (H) = V (G)∪V ˙ i (H), cross edges Ec (H) and a
grouping function cH : V (H) → P(V (G)) such that

(i) ∀ v ∈ V (G) : cH (v) = {v}


(ii) ∃ v ∈ Vi (H) : cH (v) = V (G)
(iii) ∀ u, v ∈ V (H) : cH (u) ∩ cH (v) = ∅ ⇒ (cH (v) ⊆ cH (u) ∨ cH (u) ⊆ cH (v))
(iv) ∀ 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 cor-
responding 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

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

graph
+ graph()
+ new_node() : node
+ new_edge(node, node) : edge
+ delete_node(node)
+ delete_edge(edge)

observer
observable_graph
+ observer(observable_graph&)
+ observable_graph() 1 1..* + new_node_handler(node)
+ add(observer&) observed observers + new_edge_handler(edge)
+ remove(observer&) + delete_node_handler(node)
+ delete_edge_handler(edge)

hierarchy view
+ hierarchy(observable_graph&) + view(hierarchy&, InputIterator, InputIterator)
+ new_node(InputIterator, InputIterator) : node + expand(node)
+ get_root() : node + collapse(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

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 navi-
gation 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 243

4 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 implemen-
tation 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ät für Mathematik und Informatik, Universität 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 hierar-
chically 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). saidur@nishizeki.ecei.tohoku.ac.jp
2
Graduate School of Information Sciences, Tohoku University, Aoba-yama 05,
Sendai 980-8579, Japan. nishi@ecei.tohoku.ac.jp
3
Department of Computing Science, University of Alberta, Edmonton, Alberta T6G
2E8, Canada. On leave from Bangladesh University of Engineering and Technology
(BUET). shubhash@cs.ualberta.ca

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 technol-
ogy has accelerated the development of many graph drawing styles, and differ-
ent algorithms have been developed for producing these graph drawing styles
[DETT99]. Among different drawing styles a “rectangular drawing” has at-
tracted 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 rectangu-
lar 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.

b
a d

m m
a m P a P l
l 2 n f
1 l
b o k e
b o p o p k
c p
c
k q j g
n q d n q
d u s u t s i
r
e j e r j
t r
f i h
f g h i P s u
g h 3 t
(a)
(b) (c)
m
m
l b a
f e d
g c n n p k
t c
u
h
i s u s
k e j
j o r
r
q
p g h
(d) (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 floor-
planning [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 linear-
time 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 3-
connected 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 def-
initions and presents preliminary results. Section 3 presents the necessary and
sufficient conditions for a planar graph of Δ ≤ 3 to have a rectangular draw-
ing. 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-edge-
connected 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 rectangu-
lar 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 des-
ignated 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. Further-
more, 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-connect-
ed and has a rectangular drawing. Then a plane embedding Γ  of G has a rect-
angular 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 Con-
dition (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.
Algorithm Subdivision-Draw(G)
begin
Let Γ be any plane emebedding of G;
1 Examine whether Γ has a regular 3-legged cycle C;
2 if Γ has no regular 3-legged cycle then
begin{ G is cyclically 4-edge-connected.}
3 Find a face F in Γ which satisfies Conditions (i)–(iii)
in Theorem 1(a);
4 if Γ has such a face F then
begin
5 Let Γ  be the plane embedding of G whose outer face is F ;
6 Find a rectangular drawing of Γ  by the algorithm in [RNN02]
end
7 else
8 G has no rectangular drawing;
end
9 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;
10 Examine whether Γ1 , Γ2 and Γ3 have rectangular drawings by
the algorithm in [RNN02];
11 if Γ1 , Γ2 or Γ3 , say Γ1 , has a rectangular drawing then
12 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 2-
legged 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 253

x1 x2
x1 x2

C1
C1 C2
C2

y1 y1 y2
Γ1 y2 Γ2

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.

4 Algorithm
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.

Algorithm Planar-Rectangular-Draw(G)
begin
Let Γ be any plane emebedding of G;
1 Examine whether Γ has a regular 2-legged cycle;
2 if Γ has no regular 2-legged cycle then
{ G is a subdivision of a planar 3-connected cubic graph.}
3 Examine by Algorithm Subdivision-Draw whether G has a
rectangular drawing and find a rectangular drawing of G if it exists;
4 else {G is not a subdivision of a planar 3-connected cubic graph.}
begin
5 let x1 , y1 , x2 , y2 , · · · , xl , yl be the leg-vertices of regular 2-legged
6 cycles C1 , C2 , · · · , Cl in Γ ;
7 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;
8 Examine whether G+ is planar;
9 if G+ is not planar then
G has no rectangular drawing
else
begin
10 Find a planar embedding Γ + of G+ such that z is embedded
on the outer face;
11 Delete from Γ + the dummy vertex z and all dummy edges
incident to z,
254 Md. Saidur Rahman, Takao Nishizeki, and Shubhashis Ghosh

and let Γ ∗ be the resulting plane graph;


12 Let C1 and C2 be the two minimal regular 2-legged cycles
in Γ ∗ ;
13 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 ;
14 Examine whether Γ1 , Γ2 Γ3 and Γ4 have rectangular drawings
by the algorithm in [RNN02];
15 if Γ1 , Γ2 , Γ3 or Γ4 , say Γ1 , has a rectangular drawing then
16 Find a rectangular drawing of Γ1 by the algorithm in [RNN02]
else
17 G has no rectangular drawing;
end
end.

We now have the following theorem on Algorithm Planar-Rectangular-


Draw.
Theorem 4. Let G be a planar biconnected graph of Δ ≤ 3. Then Algorithm
Planar-Rectangular-Draw examines in linear time whether G has a rectan-
gular 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 255

H93. X. He, On finding the rectangular duals of planar triangulated graphs, SIAM
J. Comput., 22(6), pp. 1218-1226, 1993.
H01. X. He, A simple linear time algorithm for proper box rectangular drawings
of plane graphs, Journal of Algorithms, 40(1), pp. 82-101, 2001.
HT73. J. E. Hopcroft and R. E. Tarjan, Dividing a graph into triconnected compo-
nents, SIAM J. Comput., 2(3), pp. 135-158, 1973.
KH97. 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.
KK84. 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.
L90. T. Lengauer, Combinatirial Algorithms for Integrated Circuit Layout, John
Wiley & Sons, Chichester, 1990.
MKI00. S. Munemoto, N. Katoh and G. Imamura, Finding an optimal floor layout
based on an orthogonal graph drawing algorithm, J. Archit. Plann. Enviro-
ment Eng. AIJ, No. 524, pp. 279-286, 2000.
NC88. T. Nishizeki and N. Chiba, Planar Graphs: Theory and Algorithms, North-
Holland, Amsterdam, 1988.
RNN98. M. S. Rahman, S. Nakano and T. Nishizeki, Rectangular grid drawings of
plane graphs, Comp. Geom. Theo. Appl., 10(3), pp. 203-220, 1998.
RNN99. M. S. Rahman, S. Nakano and T. Nishizeki, A linear algorithm for bend-
optimal orthogonal drawings of triconnected cubic plane graphs, Journal of
Graph Alg. Appl., 3, No.4, pp. 31-62, 1999.
RNN00. M. S. Rahman, S. Nakano and T. Nishizeki, Box-rectangular drawings of
plane graphs, Journal of Algorithms, 37(2), pp. 363-398, 2000.
RNN02. 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.
TTSS91. K. Tani, S. Tsukiyama, S. Shinoda and I. Shirakawa, On area-efficient draw-
ings of rectangular duals for VLSI floor-plan, Mathematical Programming,
52, pp. 29-43, 1991.
T84. 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.
T92. C. Thomassen, Plane cubic graphs with prescribed face areas, Combinatorics,
Probability and Computing, 1, pp. 371-381, 1992.
U53. 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
nishi@ecei.tohoku.ac.jp

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 257

(a) Rectangular outer face (b) L-type outer face

(c) T-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*= G F

fc
F F

(a) (b)

F
F

(c) (d)
.
.
.

(e) (f)

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 illus-
trated 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 desig-
nated 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 ex-
tended 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 rectan-
gular 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 (b) An extended rectangular
outer corners 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 v e1 v e2 v
e1 e3
R e2 S L

C C C

Fo Fo Fo
(a) A convex corner v (b) A non-corner v (c) A concave corner v
of C and Fo of C and Fo 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.
2
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

e2
e3 v v e
e1 v e3 v e1 2
e1 L' e3
R' e1 R' e2 L' e3
e2
C
C C C

Fo Fo Fo Fo
(a)A convex corner v of C (b) A non-corner v of C (c) A concave corner v of C (d) A non-corner v of C

Fig. 6. Illustration for Case 3.

e3 e3
e1 v e3 e1 v
v
R e R' e1 R' e2
2 e2

C C C

Fo Fo Fo
(a) A convex corner v of C (b) A convex corner v of C (c) A non-corner v of C

Fig. 7. Illustration for Case 4.

(a) if λ(C, v) = R, then v is a convex corner of C.


(b) if λ(C, v) = S, then v is a non-corner of C.
(c) if λ(C, v) = L, then v is a concave corner of C.
(d) if λ(C, v) = R , then v is either a convex corner or a non-corner of C.
(e) 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 263

e2
e4 v e4 e1 v e3
e1 e1 v e2
R e3 L e4
S
e2 e3

C C
C

Fo Fo Fo
(a) A convex corner v of C (b) A non-corner v of C (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. (3)
Proof. Omitted in this extended abstract due to the page limitation. 2
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;


⎨S if λ(C, v) = S;
ψC (v) = L if λ(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)
and
nL (C) ≤ nL (ψC ) ≤ nL (C) + nL (C). (5)
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). 2

In the remainder of this section, we give a proof for the sufficiency of The-
orem 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 op-
eration, 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 lem-
mas. 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. 2


Extended Rectangular Drawings of Plane Graphs with Designated Corners 265

G*

G* R G*
F R R
F F
R R R R R R
u Puv u' v u Puv u' v u Puv v=u'
(a) Two outer R-vertices of F (b) Three outer R-vertices of F (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. 2

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 sin-
gle 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 S L

R S L S S L
R P* G*
v R S
G* v v R P* G*
P* S
S S
F F F
R R R

(a) (b) (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∗ . 2
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. 2

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 R-
vertices 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. 2
Extended Rectangular Drawings of Plane Graphs with Designated Corners 267

4 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. G. Di Battista, P. Eades, R. Tamassia and I. G. Tollis, Graph Drawing,
Prentice Hall, NJ (1999).
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.
GT97. A. Garg and R. Tamassia, A new minimum cost flow algorithm with appli-
cations to graph drawing, Proc. of Graph Drawing’96, Le