Constrained Graph Drawing

Dissertation

zur Erlangung des akademischen Grades des Doktors der Naturwissenschaften

vorgelegt von

Barbara Pampel, geb. Schlieper

an der Universit¨at Konstanz

Mathematisch-Naturwissenschaftliche Sektion

Fachbereich Informatik und Informationswissenschaft

Tag der mundlichen¨ Prufung:¨ 14. Juli 2011 1. Referent: Prof. Dr. Ulrik Brandes 2. Referent: Prof. Dr. Michael Kaufmann II

Teile dieser Arbeit basieren auf Ver¨offentlichungen, die aus der Zusammenar- beit mit anderen Wissenschaftlerinnen und Wissenschaftlern entstanden sind. Zu allen diesen Inhalten wurden wesentliche Beitr¨age geleistet.

Kapitel 3 (Bachmaier, Brandes, and Schlieper, 2005; Brandes and Schlieper, 2009)

Kapitel 4 (Brandes and Pampel, 2009)

Kapitel 6 (Brandes, Cornelsen, Pampel, and Sallaberry, 2010b) Zusammenfassung

Netzwerke werden in den unterschiedlichsten Forschungsgebieten zur Repr¨asenta- tion relationaler Daten genutzt. Durch geeignete mathematische Methoden kann man diese Netzwerke als Graphen darstellen. Ein Graph ist ein Gebilde aus Kno- ten und Kanten, welche die Knoten verbinden. Hierbei k¨onnen sowohl die Kan- ten als auch die Knoten weitere Informationen beinhalten. Diese Informationen k¨onnen den einzelnen Elementen zugeordnet sein, sich aber auch aus Anordnung und Verteilung der Elemente ergeben. Mit Algorithmen (strukturierten Reihen von Arbeitsanweisungen) aus dem Gebiet des Graphenzeichnens kann man die unterschiedlichsten Informationen aus verschiedenen Forschungsbereichen visualisieren. Graphische Darstellungen k¨onnen das Verst¨andnis von Datenmengen entscheidend unterstutzen¨ und bilden eine hervorragende Basis fur¨ weitere Untersuchungen und neue Erkenntnisse. Die Aussagekraft und der Informationsgehalt sowie die Verst¨andlichkeit solcher Graphen h¨angen von verschiedenen Gesichtspunkten ab. Dazu geh¨oren Knoten- verteilung, Planarit¨at (kreuzungsfreie Einbettung) und weitere ¨asthetische Ei- genschaften. Die besonderen Informationskonstellationen und Strukturmerkmale verschiedener Datenmengen erfordern Graphen, deren Darstellungsform der Pro- blemstellung angepasst ist. So ist es wichtig, effiziente Algorithmen zum Zeich- nen von Graphen zu finden und zu untersuchen, die aufgrund der Anforderungen konkreter Anwendungen spezielle geometrische Eigenschaften haben. Fur¨ einige Problemstellungen konnten im Rahmen dieser Arbeit Algorithmen zum automa- tisierten Zeichnen solcher Graphen entworfen werden. Bedingung fur¨ die entwi- ckelten Methoden war die korrekte Wiedergabe der Daten, Optimierungsziel ist die Lesbarkeit. Fur¨ andere Probleme konnte deren Zugeh¨origkeit zur Komple- xit¨atsklasse der -schweren Probleme bewiesen werden, was bedeutet, dass NP es kaum Hoffnung auf eine effiziente und exakte L¨osung gibt. Ist ein Problem als -schwer oder -vollst¨andig bekannt, rechtfertigt dies eine Lockerung NP NP der Vorgaben, motiviert die Suche nach Heuristiken und N¨aherungsverfahren sowie nach anderen Anforderungen an die Zeichnung, welche eventuell ¨ahnliche Vorteile fur¨ die Interpretation haben. IV

Ergebnisse

Winkel und Abst¨ande Zu entscheiden, ob ein allgemeiner Graph mit festgelegten Knotenabst¨anden oder Winkeln zwischen benachbarten Kanten kreuzungsfrei gezeichnet werden kann, ist als -schwer bekannt. Wir schr¨anken die Problemstellungen auf eine h¨aufig NP verwendete Teilklasse von Graphen ein: B¨aume sind zusammenh¨angende Gra- phen, bei denen es zwischen je zwei Knoten nur genau einen Weg im Graphen gibt. So werden Wegskizzen aufgrund ihrer Struktur mit Abzweigungen und We- gen als B¨aume dargestellt. Bedingungen an den Verlauf der Kanten helfen dem Nutzer bei der Interpretation. Ahnliche¨ Problemstellungen tauchen auch in an- deren Anwendungen auf. Phylogenetische B¨aume repr¨asentieren zum Beispiel Verwandtschaftsverh¨altnisse zwischen verschiedenen Tieren oder Pflanzen, wo- bei jeder Knoten eine Spezies repr¨asentiert und die L¨ange eines Weges zwischen zwei solchen Knoten die evolution¨are Distanz dieser Spezies widerspiegeln soll. Phylogenetische B¨aume haben also festgelegte, aber m¨oglicherweise unterschied- liche Kantenl¨angen. In Kapitel 3 wurden nun Linearzeit-Algorithmen zum kreuzungsfreien Zeich- nen von B¨aumen entwickelt, fur¨ welche die geometrischen Abst¨ande je zweier durch eine Kante miteinander verbundenen Knoten, die Winkel zwischen be- nachbarten Kanten oder beides vorgegeben sind.

Reihenfolge Oft erleichtert eine schematisierte Darstellung eines Graphen seine Interpretati- on. Fur¨ den Betrachter wichtige Eigenschaften des ursprunglichen¨ Layouts, wie zum Beispiel die relative Lage der Knoten bei der Ver¨anderung geographischer Netzwerke, sollten bei der Schematisierung erhalten bleiben. (Misue, Eades, Lai, and Sugiyama, 1995) diskutierten, wie wichtig die Erhaltung einer soge- nannten ”mental map”bei der Ver¨anderung von Graphen ist. Eines der Modelle ist die Erhaltung der orthogonalen Reihenfolge der Knoten, ihrer senkrechten und waagrechten Anordnung. In Kapitel 4 wurde fur¨ drei typische Anforderungen an eine schematisierte Zeichnung untersucht, ob sie unter der Bedingungen, die orthogonale Reihen- folge der Knoten einzuhalten, effizient erfullt¨ werden k¨onnen. Eine M¨oglichkeit die Zeichnung eines Graphen zu vereinfachen ist, fur¨ die Kanten nur bestimmte Richtungen - zun¨achst nur waagrecht und senkrecht - zu erlauben. Da der Stil, in dem U-Bahnpl¨ane typischerweise gezeichnet werden, von Betrachtern als beson- ders ubersichtlich¨ und leicht verst¨andlich empfunden wird, ist das Schematisieren von Pfaden, so dass alle Kanten entweder waagrecht, senkrecht oder diagonal im V

Winkel von 45◦ gezeichnet werden, besonders interessant. Eine weitere m¨ogliche Einschr¨ankung ist, die L¨ange der Kanten festzulegen. Hier wurde das Problem betrachtet, einen Pfad zu schematisieren, so dass alle Kanten dieselbe L¨ange haben. Es konnte bewiesen werden, dass das Problem, zu entscheiden, ob ein Graph nach einer dieser Vorgaben schematisierbar ist, ohne Kantenkreuzungen oder Kanten der L¨ange null einzufuhren,¨ unter Erhaltung der orthogonalen Kno- tenreihenfolge -schwer ist. NP Richtungen Gegeben sei eine Menge von Knoten und eine Menge von Pfaden, wobei jeder Pfad eine Sequenz von Knoten ist. Beim Zeichnen der Pfade bekommt jeder Kno- ten Koordinaten zugewiesen. Eine Problemstellung ist nun, die Koordinaten der Knoten so zu w¨ahlen, dass alle Pfade streng monoton wachsend in eine Richtung sind. Hier kann weiter unterschieden werden, ob eine solche Monotonie-Richtung parallel zu einer der Dimensions-Achsen sein soll, oder beliebig ist. Solche Pfa- de auf einer Knotenmenge k¨onnten unter anderem zur Veranschaulichung von Karrieren genutzt werden, zum Beispiel von Trainern, die zwischen den Mann- schaften einer Liga wechseln. Ein verwandtes Problem ist das betweennes-Problem. Gegeben ist eine Menge von Punkten und eine Menge von betweennes-Beziehungen, in dem Sinne, dass fur¨ zwei Punkte ein dritter angegeben wird, der in mindestens einer der Dimen- sionen zwischen den beiden anderen liegen muss. Die betweennes-Beziehungen k¨onnen also durch Pfade der L¨ange 2 beschrieben werden, die in Richtung einer der Dimensionen streng monoton sein mussen.¨ Die Frage ist also, ob man in d- Dimensionen den Punkten so Koordinaten zuweisen kann, dass alle betwenness- Beziehungen erfullt¨ sind. Das Problem ist im eindimensionalen als -schwer bekannt. NP In Kaptitel 5 konnte sowohl fur¨ das betweennes-Problem, als auch das Ent- scheidungsproblem fur¨ streng monotone Trajektorien das -schwere-Resultat NP in den 2- und in den 3-dimensionalen Raum ubertragen¨ werden, ebenso wie das Entscheidungsproblem fur¨ streng monotone Trajektorien in den d-dimensionalen Raum.

Form W¨ahrend in einem Graphen jede Kante genau zwei Endknoten hat, sind Hy- pergraphen allgemeiner definiert. Eine Hyperkante ist eine Teilmenge der Kno- tenmenge. Damit k¨onnen Hypergraphen uberall¨ dort Verwendung finden, wo eine Menge von Elementen weiter aufgeteilt wird, zum Beispiel bei Datenbank- systemen oder sozialen Netzwerken. Eine M¨oglichkeit solche Hypergraphen zu VI zeichnen sind Tr¨ager. Ein Tr¨ager eines Hypergraphen ist ein Graph, in dem jeder durch eine Hyperkante induzierte (d.h. alle Knoten der Hyperkante enthaltende) Teilgraph zusammenh¨angend ist. Motiviert durch die Ubersichtlichkeit¨ von U- Bahn-Pl¨anen wurde in Kapitel 6 die Anforderung untersucht, dass jeder durch die Hyperkante induzierte Teilgraph ein Pfad ist. Neben einigen Ergebnissen zu monotonen, minimalen und planaren pfadbasierten Tr¨agern ist unser zentra- les Resultat eine Charakterisierung der Hypergraphen, die einen pfadbasierten Baumtr¨ager haben und ein Algorithmus, um einen solchen effizient zu berechnen, falls er existiert. Acknowledgements

I am so glad that my dream of achieving a PhD in has come true, even though I have not been a typical PhD-student. While following my husband’s employments through the world and especially after the birth of my daughter Sophia, I had to count on the flexibility and the support of so many people and I am deeply grateful for all the help I have received! First and foremost I would like to thank Ulrik Brandes for being a great advisor. His enthusiasm and his knowledge are impressing and inspiring. I am grateful for his encouragement, his patience, and for making it possible to continue my work while following my family. I thank all my colleagues from the algorithmics research group at the Uni- versity of Konstanz and especially our secretary, Christine Agorastos, for being my link to Konstanz by helping me with whatever needed local access, and for the warm welcome and the great time whenever I returned for a few months. I would like to acknowledge the financial, academic and technical support of the University of Konstanz and I am thankful for the support I received from the State of Baden-Wuerttemberg through a LGFG-scholarship. Even though my traveling made it more complicated, doing research was most exciting when I could work on a problem together with other scientists. I thank Christian Bachmaier, Ulrik Brandes, Sabine Cornelsen, Michael Kaufmann, and Arnauld Sallabary for their contribution to our joint work and for everything I have learned from them. Further thanks to Lars Volkhardt and Dina Tantawy for implementing some of the drawing . During my stays abroad, I had the opportunity to visit other research groups. Thanks to Antonios Symvonis at the National Technical University of Athens and especially to Andrea Pietracaprina, Geppino Pucci and their group members for having me as their guest at the DEI during my eight months in Padova. I also want to thank Michael Kaufmann for being my second referee and examiner and Michael Berthold for joining my examination committee. I am so grateful to my family, my parents Meinolf and Rita Schlieper, and my sister Claudia, for their never-ending support and for always being proud of VIII me. I thank my kids, Sophia and David, for being the cutest distraction from my work and for showing me what really matters in life. Last but not least, I would like to thank my husband Christian, whose calm and even temper give me so much strength and perseverance. I am deeply grateful for his understanding and his patience - and for his love. Contents

1 Introduction 1 1.1 Angles and Distances ...... 2 1.2 Ordering ...... 3 1.3 Directions ...... 4 1.4 Shape ...... 5

2 Preliminaries 7

3 Angles and Distances 11 3.1 Angle Constraints ...... 12 3.2 Distance Constraints ...... 16 3.2.1 Radial Drawings ...... 19 3.2.2 Circle Drawings ...... 26 3.3 Angle and Distance Constraints ...... 38 3.3.1 Straight-Line Realizability ...... 38 3.3.2 Polyline Representation ...... 38 3.3.3 Curve Representation ...... 50

4 Ordering 55 4.1 Rectilinear Drawings ...... 56 4.1.1 Unions of Paths ...... 57 4.1.2 Single Path ...... 59 4.1.3 Totally Ordered Vertices ...... 61 4.2 Octilinear Drawings ...... 63 4.2.1 Unions of Paths ...... 63 4.2.2 Single Path ...... 65 4.2.3 Totally Ordered Vertices ...... 65 4.3 Drawings with Uniform Edge Lengths ...... 67 4.3.1 Unions of Paths ...... 68 4.3.2 Single Path ...... 68 X Contents

5 Directions 71 5.1 General Idea ...... 72 5.2 Axis-Parallel Directions ...... 72 5.2.1 Hardness in 2D ...... 72 5.2.2 Hardness in 3D ...... 75 5.2.3 Hardness in dD ...... 78 5.3 Arbitrary directions ...... 80 5.3.1 Hardness in 2D ...... 80 5.3.2 Hardness in 3D ...... 83

6 Shape 87 6.1 Path-Based Supports ...... 89 6.1.1 Monotone Path-Based Supports ...... 90 6.1.2 Minimum Path-Based Supports ...... 93 6.1.3 Planar Path-Based Supports ...... 94 6.2 Path-Based Tree Supports ...... 94 6.2.1 Constructing a Tree Support from the Hasse . . . 94 6.2.2 Choosing the Connections ...... 95 6.2.3 Correctness ...... 99 6.2.4 Run Time ...... 105

7 Conclusion 107 7.1 Angles and Distances ...... 107 7.2 Ordering ...... 107 7.3 Directions ...... 108 7.4 Shape ...... 108

List of Figures 109

List of Algorithms 111

Bibliography 113 Chapter 1

Introduction

Our world is full of networks. The linking relationships might be quite abstract, such as friendship or metabolic processes or even more concrete, like roads or railways, but are still hard to overlook. One way to deal with such a network, is to mathematically model it as a graph with vertices representing the entities and edges the relationships. Graphs are widely used to visualize relational data. The that deals with the theory and algorithmic questions of graph is conventionally called graph drawing and is covered by the annual International Symposium on Graph Drawing and several books (see e.g. Di Battista, Eades, Tamassia, and Tollis (1994, 1999); Kaufmann and Wagner (2001); Sugiyama (2002)). The usefulness of a drawing depends on aesthetic criteria as well as on the amount of information contained in the data which can be revealed by the drawing. Especially relevant for the readability is the minimization of edge cross- ings (see Purchase (1997)), which is why many methods yield intersection-free drawings if the input graph is planar. Yet the respective importance of the dif- ferent criteria depends on the application. An aesthetically good drawing might not display relevant information or might even be misleading. A good vertex distribution for example can be helpful to overview a data set, but the relative closeness of objects might be interpreted as the strength of their relationship. Likewise, further information can be assigned not only to the elements, vertices and edges, but can also be displayed through their absolute and relative posi- tions. Various criteria can be described by formal constraints. With the help of such geometric constraints, the graphs can meet the different requirements of concrete applications. In this thesis various types of fundamental constraints on relevant classes of graphs are studied. 2 Chapter 1. Introduction

1.1 Angles and Distances

We consider planar drawings that must satisfy constraints on the angles between edges incident to a common vertex, on the distances between adjacent vertices, or both. These requirements arise naturally in many applications. The decision problems are known to be hard for either constraint on graph layouts. We apply them to trees.

pseudomona nico-tabac nico-syl-A arabidopsi gylcine--- chara----- bryopsis-- gonium---- chlamydomo chlorella- astasia--- euglena--- raphidonem ochromonas (b) route sketch cynophora coscinodis cyclotella laminaria- porphyra-- smithora-- gracilaria anacystis- plectonema gloeobacte myco-gentl (c) molecule thermotoga borrelia-b ChlamydiaB Tthermophi Taquaticus deinonema- bacillus-- salmonella ecoli----- micrococcu shewanella (a) (d) Fibonacci caterpillar (Duncan, Eppstein, Goodrich, Kobourov, and N¨ollenburg, 2011)

Figure 1.1: Trees

Vertex distances can represent evolutionary divergence of taxons or species in phylogenetic trees for instance (Fig. 1.1(a)). Vertex distances and angles be- tween incident edges are of interest when derived from an original geographic setting. Route sketches (Fig. 1.1(b)) for example are mostly trees. When draw- ing chemical structures (Fig. 1.1(c)), distances and angles are given following the bond lengths and angles of the reacting atoms represented by the vertices. 1.2. Ordering 3

Furthermore, to improve the readability of a drawing, a good angular resolution may be intended. The tree drawing in Fig. 1.1(d) has perfect angular resolution. When investigating the constraints separately, we demand each edge to be a straight line. Since a straight-line drawing satisfying both angle and distance constraints is fully determined up to rotation and scaling, we test for planarity and allow bended and curved edges here.

1.2 Ordering

There are several scenarios in which a given drawing of a graph is to be modified while subject to preservation constraints. Examples include shape simplification, sketch-based, and dynamic graph layout. The orthogonal ordering of vertices is a natural constraint and is frequently pursued for preserving the user’s mental map of a changing drawing.

(a) actual geographic positions (b) ordering preserving layout

Figure 1.2: The New South Wales rail network (Dwyer, Koren, and Marriott, 2006)

Figure 1.2 shows how the readability of a rail network drawing can be im- proved while preserving the orthogonal ordering of the vertices representing the stations. 4 Chapter 1. Introduction

We investigate three basic drawing conventions with respect to the orthogo- nal ordering constraint: the rectilinear drawing problem, where each edge must be either horizontal or vertical, the octilinear drawing problem, especially inter- esting for metro map drawings, and the problem of drawing graphs with equal edge lengths.

1.3 Directions

Figure 1.3: Internal preference map (Dunn and Goldman, 1998)

Figure 1.3 shows an internal preference map illustrating ten different rank- ings by corresponding axes of monotonicity. The problem of deciding whether there are geometric positions for the items such that each (complete) ranking is strictly monotone increasing in some direction is a special case of the problem we introduce: the trajectory drawing problem. The input consists of a set of paths, called trajectories, each on a subset of a common vertex set. By satisfying suit- able constraints on the shape of the trajectories, additional information can be carried for several practical visualization problems. We concentrate on the basic constraint that each path must be strictly monotone in some direction . 1.4. Shape 5

1.4 Shape

While a graph consists of a set of vertices and a set of pairs of vertices, called edges, a is more general. It is defined on a set of vertices and a set of non-empty subsets (not necessarily of size two) of the vertex set, called hyper- edges. can be used wherever subsets of element sets occur, such as schemata of relational databases and social networks. One main way of drawing hypergraphs is the Euler diagram style, where each vertex is drawn as a point and each hyperedge as a region containing only the points of the hyperedge’s vertices. To make the Euler diagram style more concrete, the drawing can be represented as a graph. A graph is called a support if for each hyperedge the induced subgraph is connected.

v13 v13

v v v v v v v 3 v4 5 6 7 8 9 v10 14 v3 v4 v5 v6 v7 v8 v9 v10 v14

v1 v11 v1 v11

v2 v12 v2 v12 (a) Euler diagram (b) support

v13

v v v v v v v v 14 3 4 5 6 7 8 9 v10

v1 v11

v2 v12 (c) metro map like drawing

Figure 1.4: Three representations of a hypergraph

We investigate an additional constraint on supports. Motivated by the aes- thetics of metro map layouts the subgraph of the support should be a simple path for each hyperedge. 6 Chapter 1. Introduction Chapter 2

Preliminaries

This chapter contains the main definitions and notation used in this thesis.

Graphs A graph G = (V,E) consists of a set of vertices V and a set of edges E with each e E is a 2-element subset of V . Let n = V denote the number of vertices and∈m = E the number of edges. We say| an| edge is incident to its end vertices and call| | the connected vertices adjacent. Two edges are called incident if they are incident to a common end vertex. With v, w we refer to an undirected edge while an edge (u, v) is directed from u to{v and} is called a (directed or undirected) loop if u = v. The set of vertices adjacent to a vertex v is called the set of v’s neighbors N(v). A vertex u with (u, v) E is called a parent of v, and referred to with parent(v), while for an edge (v,∈ w) E the vertex w is a child of v. We refer to the set of children of a vertex v with∈ children(v). A source does not have any parents, a sink no children and an inner vertex has at least one parent and one child. The degG(v) denotes the number of edges in G incident to a vertex v (the subscript may be omitted if it is clear which graph is referred to). The outdegree outdegG(v) denotes the number of outgoing and the indegree indeg(v) the number of ingoing edges. G is called multigraph if we explicitly allow loops and multiple edges like e = (u, v), e0 = (u0, v0) where u = u0 and v = v0, simple otherwise. In this thesis we are interested in drawing simple graphs. A subgraph G0 = (V 0,E0) of a graph G = (V,E) is a graph on a subset V 0 V of vertices connected by a subset E0 E of edges. ⊂ ⊂ A walk in a graph G(V,E) is a subgraph that is a finite sequence of vertices v . . . vk such that (vi, vi ) E for each 1 i k. A walk is a (directed or 1 +1 ∈ ≤ ≤ undirected) path P = (v1, . . . , vk) if all edges are distinct and the length of P is k 1. A path is simple if for any vertex vi with 1 < i < k it is deg (v) = 2. A − G path is a (directed or undirected) cycle if v1 = vk. A graph is acyclic if none of its subgraphs is a cycle. A graph G = (V,E) is called bipartite if V can be partitioned into two disjoint 8 Chapter 2. Preliminaries sets V ,V V where V V = V such that no two vertices in V and no two 1 2 ⊂ 1 ∪ 2 1 vertices in V2 are adjacent.

Trees A tree T = (V,E) is a connected and acyclic graph. We use root(T ) to refer to the only vertex r of a directed tree T that has indegG(r) = 0. Tree edges are viewed as directed away from the root. Even if a root is given, it will sometimes be convenient to consider the tree as being rooted at another vertex. If some vertex r V is made the root of T , the resulting tree is denoted ∈ by Tr, so that root(Tr) = r. In a rooted tree, each vertex v V root(T ) has a unique parent and a set of children. From v there is a∈ directed\{ path to} each of v’s descendants, while a vertex a is called an ancestor of v if there is a directed path from a to v. We will only consider subtrees induced by a vertex and its descendants with respect to some root (rather than arbitrarily connected subgraphs) and refer to the subtree of a tree Tr induced by v V as Tr(v). If it is clear at which vertex the tree was rooted, we can refer to the∈ subtree induced by v as T (v). For a subtree T (v) of T leaves (T (v)) denotes the set of its leaves which consists of all vertices v in T (v) with deg(v) = 1 in T . Since directions depend on the root, we use u, v to refer to an edge when the root is not clear { } from context. A tree T = (V,E) is called binary if degT (v) 3 for every vertex v V . A rooted tree T is complete if the length of the shortest≤ path from a leaf l to∈ the root is the same for every leaf l V . ∈

Hypergraphs A hypergraph is a pair H = (V,A) where V is a finite set and A is a (multi-)set of non-empty subsets of V . The elements of V are called vertices and the elements of A are called hyperedges. We denote by n = V the number P | | of vertices, m = A the number of hyperedges, and N = h∈A h the sum of the sizes of all hyperedges| | of a hypergraph H. The size of the hypergraph| | H is then N +n+m. A hypergraph is a graph if all hyperedges contain exactly two vertices. A hypergraph H = (V,A) is closed under intersections if h1 h2 A for h , h A. ∩ ∈ ∪ {∅} 1 2 ∈ A support (or host graph) of a hypergraph H = (V,A) is a graph G = (V,E) such that each hyperedge of h H induces a connected subgraph of G, i.e., such that the graph G[h] := (h, e∈ E, e h ) is connected for every h A. An Euler diagram of a hypergraph{ ∈H =⊆ (V,A}) is a drawing of H in the∈ plane in which the vertices are drawn as points and each hyperedge h A is drawn as a simple closed region containing the points representing the vertices∈ in h and not the points representing the vertices in V h. The of a hypergraph H = (V,A) is the \ with vertex set A v ; v V and ∪ {{ } ∈ } there is an edge (h1, h2) if and only if h2 ( h1 and there is no set h A with ∈ h2 ( h ( h1. Fig. 6.1(a) shows an example of a Hasse diagram. 9

Layout, Drawing A graph is said to be embedded (combinatorially) if for each v V the, say, counterclockwise cyclic ordering of edges incident to v is pre- scribed.∈ For a graph G(V,E) that is drawn in d dimensions a geometric position x(v) = (x1(v), . . . , xd(v)) is assigned to each vertex v V . A graph G(V,E) is called planar if there is a planar drawing of G, i.e., if it∈ can be drawn such that any two edges e = e0 E intersect only in a vertex they are both incident to. 6 ∈ If the task is to redraw a graph that has an initial layout, let x0(v) be the position of a vertex v in the resulting layout. By preserving the orthogonal ordering of the vertices in the plane we mean that if for two vertices vi, vj it is 0 0 x1(vi) x1(vj) in the original layout, x1(vi) x1(vj) holds also for the resulting ≤ ≤ 0 0 layout and for x2(vi) x2(vj) in the original layout it is x2(vi) x2(vj) in the resulting layout. For a≤ 2-dimensional drawing of a (sub)-path P we≤ call the strip between the vertical line through P ’s rightmost vertex and the one through the leftmost vertex the x1-range of P , and analogously the strip between the horizontal line through P ’s highest vertex and the one through the lowest vertex P ’s x2-range. A direction is an oriented line through the origin of the coordinate system. A path P in a (possibly curvilinear) drawing is strictly monotone increasing in some direction a if every line perpendicular to a intersects the drawing of p in at most one point. A path P in a straight-line drawing is strictly monotone increasing in some direction a if and only if the orthogonal projections of the vertices of P on a appear along a totally ordered in the order induced by P . We adopt the convention that the edges incident to v are to be drawn in counterclockwise order, i. e., for a vertex v with deg(v) = k the edge e(i+1) mod k is the counterclockwise first after ei for 0 i k. In a tree for an inner vertex other than the root the counterclockwise≤ first≤ edge after the incoming edge is that of the first child. A triangle (quadrangle) is described by its three (four) vertices in counter- clockwise order and an angle or an area between two (half-)lines g and h is swept out counterclockwise from g to h.

Complexity We provide an intuition of the complexity classes and and the concept of -completeness. For a more detailed and formalP introductionNP see Garey and JohnsonNP (1979). A problem consists of a formal description of the relevant parameters and the properties a solution must have. We receive an instance of a problem by fixing all parameters. For a decision problem a possible solution can only be either YES or NO. The class (for polynomial) is the set of decision problems for which there is an algorithmP that gives a correct solution for each instance in polynomial time. 10 Chapter 2. Preliminaries

A certificate (or witness) proves that the solution for an instance of a decision problem is YES. The class (for nondeterministic polynomial) is the set of decision problems for whichNP there is a polynomial time which can verify a certificate and one can nondeterministically (finite number of options per step) generate a guess for a certificate in polynomial time. A reduction from a decision problem Π to another decision problem Π0 is an algorithm A that generates an instance I0 of Π0 for each I of Π. For a polynomial time reduction the runtime of A is bounded by a polynom of the size of I. As long as the question whether = is not answered, it would be helpful to identify the problems in whichP areNP not in if = . We can find problems that are especially hard:NP A problem is P-hardPif 6 andNP only if there is a polynomial time reduction from a problem thatNP is known to be -complete, i.e., -hard and . (Note that furthermore it is sufficientNP to find a reductionNP from another∈ N P -hard problem.) If any -hard problem was in , all -hard problemsNP would be as well. NP P NP A Boolean variable is an element that can have one of two values, e.g., either true or false. The satisfiability problem (SAT) is a decision problem, with each instance a Boolean expression written using only variables, parentheses and the logical operations conjunction (AND) , disjunction (OR) and negation (NOT). The question is whether there is an assignment of values to the variables such that the entire expression is true.A literal is either a variable or the negation of a variable. A clause is a disjunction of literals. We only consider instances which are conjunctions of clauses, i.e., in the conjunctive normal form (CNF). In MONOTONE 3-SAT each clause contains exactly three literals either all negated (negative clause) or all non-negated (positive clause). This problem is known to be -hard Garey and Johnson (1979). An instance I = (B,C) of NP the MONOTONE 3-SAT-problem is a set of Boolean variables B = b , . . . , bn { 1 } and a set of clauses C = C ,C ,...,Ck with each clause Ci = li li li . { 1 2 } { 1 ∨ 2 ∨ 3} Chapter 3

Angles and Distances

When representing a data set, information can be assigned to the vertices and edges of a graph but also to their relative position. Standard graph drawing algorithms do not take into account these criteria. In this chapter the impli- cations of the following two formal constraints on drawings of a graph G are investigated.

Angle constraints: For an embedded graph G = (V,E), let A E E be the ⊆ × angle set, where (ei, ei ) A if and only if both edges share a vertex v +1 ∈ and ei+1 is the counterclockwise next edge after ei around v. A drawing of an embedded graph G = (V,E) satisfies angle constraints α : A (0, 2π), if the angle between all pairs (ei, ei ) A is exactly → +1 ∈ α(ei, ei+1). Note that α is frequently called an angle assignment. A necessary requirement for angle constraints to be satisfiable is that they sum to 2π around every vertex and to (dG(f) 2)π around every inner − face f with dG(f) vertices. Such a set of angle constraints is called locally consistent and we assume that all given angle constraints are.

Distance constraints: A drawing of a graph G = (V,E) satisfies distance constraints δ : E R+ if all pairs of adjacent vertices v, w E are exactly at distance→δ(v, w). { } ∈

A graph with angle and/or distance constraints is called realizable in the straight-line model (or straight-line realizable for short) if there exists a planar straight-line drawing in the plane such that all constraints are satisfied. Testing straight-line realizability is known to be -complete for both angle-constrained graphs (Garg, 1995) and distance-constrainedNP graphs, even if all edges are con- strained to have unit length (Eades and Wormald, 1990). Hence, we will focus on trees. 12 Chapter 3. Angles and Distances

Trees are widely used as a data structure and to represent hierarchical data. Standard tree drawing algorithms (Eades, 1992; Reingold and Tilford, 1981; Walker, 1990) place the vertices on concentric circles or horizontal lines, re- spectively. While achieving a good vertex distribution and an apparent level structure, information about the relative position of vertices and edges, possibly relevant for the data, is lost. We study the problem of drawing trees considering given vertex distances, edge angles or both. For trees, arbitrary distance and (locally consistent) angle constraints can be satisfied, though not necessarily in the same drawing. We present linear time algorithms for drawing trees satisfying angle constraints (Sect. 3.1) and distance constraints (Sect. 3.2). In Sect. 3.3 we describe how to test whether a tree has a straight line drawing that satisfies both angle and distance constraints and show how using polylines and curves for the edges makes it possible to draw any tree with the desired edge angles and vertex distances.

3.1 Angle Constraints

Not only can a good angular resolution improve the readability of a drawing, edge angles can also carry information which is relevant for a data set as for example in geographic networks. We describe a linear time algorithm to draw a tree T (V, E, α) in a balloon layout style (Melan¸conand Herman, 1998) without introducing any intersection other than the common vertex of two incident edges and keeping the edge length positive for each edge.

Theorem 1. For any tree T = (V,E) with locally consistent angle constraints α, a planar straight-line drawing satisfying α can be determined in linear time.

The basic idea of the algorithm is to assign a circle cw with center w to every vertex w = root(T ) in which the subtree T (w) is drawn. Starting with fixing the absolute6 angle of one arbitrary edge, we can extend α : A (0, 2π) to α : A E (0, 2π] with α(e) being the absolute angle of each edge→ e E and ∪ → ∈ α(ei, ei+1) = (α(ei+1) α(ei)) mod 2π. The vertex w must be positioned on the halfline hl(w) from w−’s parent v with the outgoing angle α(v, w). To make sure cw is not intersecting with any circle of another neighbor of v, cw is placed in a wedge rooted in v and with bisector hl(w). The position of w on hl(w) is determined by placing cw nearest possible to v but without causing intersections with the wedge borders. To determine the position of a child w of v, we compute the wedge size ω(w) of the wedge belonging to w. Therefore the two sectors between (v, w) and the clockwise next edge incident to v and between (v, w) and the counterclockwise next edge are divided among the wedges of their target vertices. We divide 3.1. Angle Constraints 13

Figure 3.1: Dividing a sector a sector proportional to the radius of the two corresponding circles. Assume a vertex v has k children w1 . . . wk in counterclockwise order. The wedge size ω(wi) of a vertex wi is double the minimum of the two sector parts assigned to wi. If a wedge cannot occupy the full part of a sector, the counterclockwise or the clockwise next wedge should be allowed to use more. We compute initial wedge sizes counterclockwise from w1 to wk and update them in a second coun- terclockwise traversal. To simplify the computation, we introduce temporary  vertices w0 and wk+1, edges e0 and ek+1 with angles α(e0) = α(ek+1) = α (v, u) r(w1) if u = parent(v) or α(e ) = α(ek ) = (α(e ) α(ek, e ) ) mod 2π 0 +1 1 1 r(w1)+r(wk) − · ◦ if v = root(T ), the corresponding wedge sizes ω(w0) = ω(wk+1) = 0 and radii r(w0) = r(wk+1) = 0. To avoid complications, no wedge should be wider than π. Then the initial wedge size of a vertex wi for 1 i k is: ≤ ≤

ω(wi−1) r(wi) π ω(wi) = 2 min α(ei−1, ei) , α(ei, ei+1) , (3.1) · { − 2 · r(wi) + r(wi+1) 2 }

Then we update the wedge sizes counterclockwise from w1 to wk:

ω(wi−1) ω(wi+1) π ω(wi) = 2 min α(ei− , ei) , α(ei, ei ) , (3.2) · { 1 − 2 +1 − 2 2 }

After this, except for the sectors between ek and e1, there are no two suc- cessive sectors that both have a sector-part not occupied by any wedge. Hence, 14 Chapter 3. Angles and Distances

Algorithm 1: BALLOON-LAYOUT

Input: Rooted tree T = (V, E, α), minimal radius rmin Data: Vertex arrays r (radius of subtree), ω (wedge size), Edge array δ (edge length) Output: Coordinates x(v) = (x (v), x (v)) for all v V 1 2 ∈ begin postorder traversal (root(T )) x(root(T )) (0, 0) preorder traversal← (root(T ))

procedure postorder traversal(vertex v) if deg(v) = 1 then r(v) rmin ← else r(v) 0◦ k ←outdeg(v) ← let e1, . . . , ek = v.outedges() in counterclockwise order for{i = 1 to k}do let wi ei.target() ← postorder traversal(wi)

Edges e0, ek+1; Vertices w0, wk+1 ◦ r(wk+1) 0; ω(w0) ω(wk+1) 0 if v = root←(T ) then← ← 6 α(e ) α(ek ) (α(inedge(v)) + π) mod 2π 0 ← )+1 ← else r(w1) α(e0) α(ek+1) (α(e1) α(ek, e1) ) mod 2π ← ← − · r(w1)+r(wk) for i = 1 to k do ω(wi−1) r(wi) π ω(wi) 2 min α(ei−1, ei) , α(ei, ei+1) , ← · { − 2 · r(wi)+r(wi+1) 2 } for i = 1 to k do ω(wi−1) ω(wi+1) π ω(wi) 2 min α(ei−1, ei) 2 , α(ei, ei+1) 2 , 2 ← r·(wi) { − − } δ(ei) ω(wi) ← sin( 2 ) if δ(ei) + r(wi) > r(v) then r(v) δ(ei) + r(wi) ← Delete e0, ek+1, w0, wk+1

procedure preorder traversal(vertex v) if v = root(T ) then u6 parent(v); e inedge(v) x(←v) x(u) + δ(←e) (cos α(e), sin α(e)) ← · foreach w children(v) do preorder∈traversal(w) 3.1. Angle Constraints 15

(a) example tree

(b) balloon layout

Figure 3.2: Layout of a tree with given absolute angle for each edge 16 Chapter 3. Angles and Distances no wedge can be widened without narrowing another wedge. Placing a circle cw in the wedge with the center on its bisector hl(w) and the circle touching r(wi) the wedge-borders, indicates the length of the edge (v, w): δ(v, w) = ω(wi) . sin 2 Given also the radius r(w) for every child w of v, the circle with radius r(v) = max r(w) + δ(v, w) w is child of v will contain the entire subtree. All edge lengths are computed{ in a postorder-traversal.} With the angle also given for every edge, the layout is determined up to translation and scaling and can be computed in a preorder-traversal. Algorithm 2 shows the complete code. In Fig. 3.2 we show an example of a tree laid out with Algorithm 2. Each edge is labeled with the desired absolute angle. We thank Dina Tantawy for implementing our algorithm using yFiles version 2.7 (Wiese, Eiglsperger, and Kaufmann, 2002).

3.2 Distance Constraints

In a straight-line drawing of a graph satisfying distance constraints, the given vertex distances are exactly the desired edge lengths. A typical application are phylogenetic trees. Phylogeny is the study of evolutionary relationships within a group of organisms. A phylogenetic tree represents the evolutionary distances among the organisms represented by its leaves. Due to the increasing size of data sets, drawings are essential for exploration and analysis. In addition to the usual requirements for arbitrary tree structures, drawings of phylogenetic trees should clearly display given edge lengths (since they represent evolutionary distances) and leaf names. Standard methods from the graph drawing literature do not take these criteria into account. Popular software tools in computational biology such as TreeView (Page, 2000), PAUP∗ (Swofford, 2002), or PHYLIP (PHYLIP, 1993) provide limited documentation and usually no analyses of their incorporated layout algorithms. Two essential classes of graphical representation for phylogenetic trees can be distinguished (see, e. g., Carrizo (2004) for an overview of variants). Both classes are related to dendrograms, likely because many algorithms for the construction of phylogenetic trees are based on clustering (see, e. g., Swofford, Olsen, Waddell, and Hillis (1996); Felsenstein (2004)). They differ in that leaf labels are either placed monotonically along one axis or around the . While the first class of representations is very similar to standard dendrograms and easy to layout automatically, it is somewhat difficult to understand the nesting of subtrees from the resulting drawings. Here we focus on the algorithmically more challenging and graphically more appealing second class of representations, and further differentiate two subclasses called radial and circular tree drawings. In radial tree drawings, edges extend radially monotonic away from the root, and we discuss a linear time algorithm that preserves all edge lengths exactly. 3.2. Distance Constraints 17

chlorella-

astasia---

euglena--- raphidonem

ochromonas chlamydomo

gonium----

bryopsis-- cynophora chara-----

pseudomona gylcine--- coscinodis

nico-tabac arabidopsi cyclotella nico-syl-A nico-syl-A

arabidopsi laminaria- nico-tabac gylcine--- porphyra-- pseudomona chara----- shewanella bryopsis-- smithora-- gonium---- micrococcu gracilaria chlamydomo ecoli----- anacystis- chlorella- salmonella bacillus-- astasia--- plectonema deinonema-

Taquaticus gloeobacte euglena--- Tthermophi

raphidonem myco-gentl

thermotoga borrelia-b

ochromonas ChlamydiaB cynophora coscinodis (b) circular dendrogram (ignor- cyclotella ing lengths) laminaria- porphyra--

chlorella-

astasia---

euglena--- smithora-- raphidonem

gracilaria ochromonas chlamydomo gonium----

bryopsis-- anacystis- cynophora chara----- plectonema gylcine--- coscinodis

gloeobacte arabidopsi myco-gentl cyclotella nico-syl-A

thermotoga laminaria- nico-tabac borrelia-b ChlamydiaB porphyra-- pseudomona shewanella Tthermophi smithora-- Taquaticus micrococcu gracilaria deinonema- ecoli----- anacystis- bacillus-- salmonella

bacillus-- salmonella plectonema deinonema-

Taquaticus gloeobacte ecoli----- Tthermophi

micrococcu myco-gentl

thermotoga borrelia-b

shewanella ChlamydiaB (a) dendrogram (showing edge lengths) (c) weighted barycenter of children (Dwyer and Schreiber, 2004)

borelia-b

thermotoga

ChlamydiaB

myco-gentl

smithora--

chlamydomo TthermophiTaquatius

gonium---- deinonema- chlorella- laminaria- bryopsis--

porphyra-- micrococcu cyclotella gracilaria coscinodia glycine--- ochromonas salmonella ecoli----- cynophora shewanella arabidopsi pseudomona porphyra--

smithora-- cynophora bacillus-- nico-syl-A ochromonas laminaria- nico-tabac coscinodia gracilaria plectonema chara----- anacystis- cyclotella gloeobacte raphidonem euglena--- pseudomona

micrococcu euglena--- astasia---

astasia--- shewanella raphidonem chlorella- chara----- salmonella

anacystis- ecoli----- chlamydomogonium---- bryopsis-- bacillus-- gloeobacte nico-tabac nico-syl-A ChlamydiaB

thermotoga

arabidopsi plectonema borelia-b

myco-gentl

glycine--- Taquatius

Tthermophi

deinonema- (d) our radial approach (e) our circular approach

Figure 3.3: Drawings of an example from Dwyer and Schreiber (2004) 18 Chapter 3. Angles and Distances

(a) radial drawing algorithm (b) circular drawing algorithm

Figure 3.4: Complete binary tree with n = 213 1 vertices −

In circular tree drawings, leaves are placed equidistantly on the perimeter of a circle and the tree is confined to the inside of that circle. Note that it may be impossible to preserve edge lengths in this representation. We give an algorithm that heuristically minimizes length deviations and, even though based on solving a system of linear equations, runs in linear time as well. Both algorithms yield drawings that are unique in a well-defined sense up to scaling, rotation, and translation. Since each subtree is confined to its own wedge rather than a line interval, their nesting structure is more apparent than in vertical or horizontal representations. Even though phylogenetic trees are frequently restricted to ex- tended binary trees, our algorithms apply to general trees as well. The behavior of our algorithms are nicely compared on complete binary trees with uniform edge length as shown in Fig. 3.4. A comparison with other drawing techniques on a real-world data set is provided in Fig. 3.3 and larger real-world examples are presented in Figs. 3.9 and 3.13. Effects of extensions are illustrated in Figs. 3.8 and 3.12. Note that the root of each tree is indicated by a dot. Typical tree reconstruction methods yield rooted trees in which most inner vertices have two children. The leaves of a phylogenetic tree typically represent species, molecules, or DNA sequences (invariably referred to as taxa) under study and its inner vertices represent virtual or hypothetical ancestors. The length of an edge represents the evolutionary distance between its incident vertices and the entire tree represents a tree metric fitted to a (potentially noisy and incomplete) dissimilarity defined over all taxa. Since we want to indicate δ(e) by the length of the line segment depicting e E, only positive values can be represented. If a method ∈ 3.2. Distance Constraints 19 for tree construction (see, e. g., Felsenstein (1973); Fitch (1971); Michener and Sokal (1957); Saitou and Nei (1987)) assigns negative or zero length to an edge, the range of values is shifted appropriately.

3.2.1 Radial Drawings In this section, we describe a drawing algorithm that yields a planar radial drawing of a phylogenetic tree T = (V, E, δ). For general graphs it is - complete to decide whether it can be drawn in the plane satisfying distanceNP constraints, even if the graph is planar and all edges have unit lengths (Eades and Wormald, 1990).

Theorem 2. For any tree T = (V,E) with distance constraints δ, a planar straight-line drawing satisfying δ can be determined in linear time.

3.2.1.1 Basic Algorithm The main idea is to assign to all subtrees a wedge of angular width proportional to some weight function c. Given a rooted tree T , weights c (T (v)) will later be defined for all v V root(T ) . Weights of other subtrees are then implied via P ∈ \{ } c(T ) = v∈children(root(T )) c(T (v)) and the following condition:

Complementarity Property: For all edges u, v , c(Tu(v)) + c(Tv(u)) = c(T ). { }

Note that Tu(v) = T (v) if u = parent(v), so that at most one term is unknown in each of the above equations. A straightforward symmetry consideration shows that the extension to subtrees with respect to other roots is well-defined. We say that subtree weights are complementary if they satisfy the Complementarity Property. To determine the layout, the wedge of an inner vertex is divided among its children and tree edges are drawn along wedge angle bisectors so that they can have any length without violating planarity. See Fig. 3.5 for an illustration. Algorithm 2 is therefore based on a preorder-traversal of the input tree, where a child w of an inner vertex v is placed at distance δ(v, w) on the angular bisector of the wedge reserved for w. The following theorem shows that the layouts determined by Algorithm 2 are essentially the only ones that fulfill all natural requirements for radial drawings of trees with given edge lengths, and that the weights can be defined with respect to any root. We give two examples of interesting subtree weighting schemes in the next subsection. 20 Chapter 3. Angles and Distances

u

v u ±

) , ( !v/2 !v/2

v

w v ± ) , ( 1

(,)! !w ± v ww 2 1/2 1 !w 2/2 w 2 !w 1 2/2

!w 1 w T w 2 ( 1) leaves !w 2

)) ( ( T w T w 1 ( 2)

2 (T ( w )) leaves

Figure 3.5: Wedges of vertex v’s neighbors

Algorithm 2: RADIAL-LAYOUT Input: Rooted tree T = (V, E, δ), vertex array c (subtree weight) Data: Vertex arrays ω (wedge size) and τ (angle of right wedge border) Output: Coordinates x(v) for each vertex v V ∈ begin x(root(T )) (0, 0) ω(root(T )) ← 2π τ(root(T )) ← 0 preorder traversal← (root(T ))

procedure preorder traversal(vertex v) if v = root(T ) then u6 parent(v) ←   x(v) x(u) + δ(u, v) cos(τ(v) + ω(v) ), sin(τ(v) + ω(v) ) ← · 2 2 η τ(v) foreach← w children(v) do ∈ ω(w) c(T (w)) 2π ← c(T ) · τ(w) η η η←+ ω(w) preorder← traversal(w) 3.2. Distance Constraints 21

Theorem 3. For an ordered phylogenetic tree with complementary subtree weights, there is a unique planar radial drawing up to rotation, translation and scaling that satisfies the following properties independent of which vertex is chosen as the root:

1. Edge lengths are proportional to evolutionary distances.

2. Disjoint subtrees are confined to disjoint wedges.

3. The angular width of a subtree’s wedge is proportional to its weight.

4. Subtrees are centered at the bisectors of their wedges.

Moreover, it can be determined in linear time.

Proof. Let T = (V, E, δ) be a phylogenetic tree with complementary subtree weights c and fix any vertex as the root. With relative edge lengths and angles fixed, the only degrees of freedom left are translation, rotation, and scaling. Because of Property 1, edge lengths are fixed up to scaling. It remains to show that angles between incident edges are fixed as well. By Property 3, the width of a subtree wedge is θ c(T (v)) for each v · 2π ∈ V . By Property 2 and the definition of c(T ), we have θ = c(T ) . Because of P complementarity, c(T ) = w∈children(v) c(Tv(w)) holds for all v V , so that the total width of all subtree wedges for the children of a vertex v∈is 2π. Together with Property 4 this implies that the angles between incident edges are fixed. Clearly, Algorithm 2 determines the desired layout in linear time.

A tree drawing is said to have convex faces if the path between all consecutive pairs of leaves is a convex arch, i. e., a polygonal chain in which the maximum angular difference between two edges is π and the edges occur sorted by their absolute angles. In a tree drawing with convex faces, the edge lengths can be chosen arbitrarily without causing intersections.

Lemma 1. Algorithm 2 yields a drawing with convex faces.

Proof. Assume P = (e1 . . . ep) is the path from one leaf z to the counterclockwise 0 next leaf z in Tz. Consider any two edges ei and ej with i < j. Since for the sizes ω(ej) ω(ei) 2π the wedge of ej is contained in the wedge of ei with the right wedge≤ borders≤ parallel and each edge is drawn on the bisector of its wedge, the relative angle between the ei and ej is at most π and the edges in P are sorted by their absolute angles. 22 Chapter 3. Angles and Distances

Labels of leaves can be placed on the angle bisector of the respective wedge. Since the angle of a leaf wedge may be small, labels placed close to their leaf may not fit into the wedge. When using a font of height h, non-overlapping labels are guaranteed if the labels of all leaves v V are placed at a distance of at least ∈ h (3.3) 2 tan (π c(T (v)) / c(T )) · · from parent(v).

3.2.1.2 Subtree Weights While any complementary subtree weighting scheme is admissible, the following two seem to be especially relevant.

Count of Leaves

It is easy to see that the proportion of leaves in a subtree yields complemen- tary subtree weights. This weighting scheme we proposed (Bachmaier, Brandes, and Schlieper, 2005) when we were not aware of the description of the following algorithm (Felsenstein, 2004) implemented in PHYLIP (1993). In a preorder traversal, where the angle of each edge is determined for a tree with l leaves, let leaves(T ) = z , . . . , zl . With a reference leaf z , the leaves { 1 } 1 are arranged around the unit circle in counterclockwise order with zi positioned at angle i αi = 2π for 1 i l. (3.4) · l ≤ ≤

For an edge e let zp, z p l, . . . , zq be the set of leaves separated from { ( +1) mod } z1 by e. Then the angle α(e) of e is 1 α(e) = (α + α ). (3.5) 2 p q To determine vertex coordinates during the preorder-traversal of the tree starting at the reference vertex z1, each neighbor w of the current vertex v is pushed away from v in the direction specified by α(v, w) such that (v, w) has length δ(v, w). We next show that this algorithm yields exactly the same drawings as Algo- rithm 2 with subtree weights equal to their number of leaves. Since the straight-line drawing of a tree is fully determined if the angle and length is determined for each edge and evolutionary distances are preserved in both algorithms, we only have to show that the two algorithms compute the same 3.2. Distance Constraints 23

angle for each edge. Let r = z1. It is easy to see that in our basic algorithm 2π the angle of the edge ei incident to leaf zi is α(ei) = α(e(i−1) mod l) + l , where e(i−1) mod l denotes the edge incident to leaf z(i−1) mod l, because the wedge borders 2π of consecutive leaves are parallel and for each leaf z the wedge size is l . Thus the angle for each edge incident to a leaf is the same up to rotation for both algorithms (see (3.4)).For the remaining edges, note that we place every edge e on the bisector of the wedge assigned to e’s target vertex. Let zp, z(p+1) mod l, . . . , zq be the set of leaves separated from the root by e. Since{ the counterclockwise} first wedge border of vp and the last of vq are parallel to v’s wedge borders, we 1 have α(e) = 2 (αp + αq) as in (3.5).

Count of Forks

Carlson and Eppstein (2007) present an algorithm to draw trees with convex faces and optimal angular resolution in linear time. We will show that this can be seen as a special case of Algorithm 2 using an appropriate weighting scheme. A path is a (sub)tree with all vertices having a degree of at most two. A rake is a (sub)tree with all vertices having a degree of at most three and a path which connects all degree-three vertices. A triple rake is a tree with a maximum vertex degree of three and the minimal spanning subtree of all degree-three vertices contains exactly one degree three vertex. For a tree that is a path, rake or triple rake, algorithms are given that draw any such tree with optimal angular resolution. In the following we assume T is none of these special cases. A fork at a vertex v V is a subsequence of two or more children such that the subtrees rooted at the∈ first and the last (order given by the embedding of T) child are paths and all intermediate child subtrees are rakes. Let F (T ) be the set of forks in a (sub)tree T . For max deg(v) v∈V = 3 let Ts be the minimal subtree spanning all degree- { } three vertices of T . Because T is neither a path, rake nor triple rake, Ts contains a vertex with a degree of at least three. To guarantee optimal angular resolution, a valid root r must satisfy the following property:

Root Property: deg(r) 4 if max deg(v) v∈V 4, deg (r) = 3 otherwise. ≥ { } ≥ Ts Theorem 4 (Carlson and Eppstein (2007)). For a (possibly unrooted) tree T , 2π a drawing with convex faces having the optimal angular resolution |F (T )| can be found in linear time.

The algorithm (after choosing a valid root if T is unrooted) places the slopes of the edges such that in a subtree T (v) the angular difference between the edge 24 Chapter 3. Angles and Distances leading to the (counterclockwise) first and the one to the last leaf in T (v) is 2π|F (T (v))| |F (T )| and v’s ingoing edge is lying on the bisector of this angle. Note that a path does not contain any fork. Lemma 2. Fork counts yield complementary subtree weights. Proof. For the root altered such that u = parent(v) becomes a child of v in the newly rooted tree T 0, we prove c (T 0(u)) + c (T (v)) c(T 0) = c(T ). Let r be the root of T and r0 the root of T 0. Of≤ course F (T 0(u)) F (T 0). 0 ⊆ For the path P connecting v and r , each fork in F (T (v)) at any vertex vp on P that does not involve any edge of P is also in F (T 0). At least there is no fork in F (T (v)) at any vertex vp on P that involves any edge of P , because by the choice of possible root vertices r0 P can neither lie in a path nor a rake. ∈ Since the wedge size for any leaf is 0, using the count of forks as subtree weights, we compute the same layout with our basic algorithm having optimal angular resolution for drawings with convex faces. Corollary 1. Let T be a phylogenetic tree satisfying the Root Property. Then the unique drawing with convex faces and optimal angular resolution satisfying all properties from Theorem 3 can be determined in linear time.

3.2.1.3 Postprocessing Using fork counts as subtree weights guarantees optimal angular resolution for drawings with convex faces while the edges can be arbitrarily long without caus- ing intersections. However, as soon as the edge lengths are fixed, requesting con- vex faces results in a fair amount of wasted drawing space. We may thus wish to relax this requirement and increase angles between incident edges where possi- ble. This can be achieved during post-processing using a postorder-traversal, in which the angles between outgoing edges of a vertex v are scaled to the maximum value possible within the wedge of v rooted at parent(v) (see Fig. 3.7). Note that labels need to be taken into account in this angular spreading step, and that the resulting drawings depend on the choice of the root. Our experiments suggest that placing the root at the center of the tree, e. g., a vertex for which the leaves are evenly distributed over the children’s subtrees, yields favorable results. The procedure is only reasonable if v has at least two children. As input we use T = (V, E, δ) together with the layout computed by Algorithm 2, i. e., the coordinates x(v) of each vertex v. Thus, the absolute angle α((u, v)) of each edge (u, v) is also given. To avoid an anew computation we reuse the wedge sizes ω(v) computed by Algorithm 2. We recompute the positions of the vertices in a postorder-traversal: First we describe the case of v having only two children and show the procedure 3.2. Distance Constraints 25

u

v

w2 z

w1

Figure 3.6: Unused area

®(,)u v u b !v k 2 2 d - v u ± kxv x z ) , ( b u b ¯ 0 z1 °z v ° z kx x z v z - k 2 2 b wk z

wk v

(a) computing the rotation angle for (b) the leaf z2 does not define the a leaf z maximum rotation angle

Figure 3.7: Spreading

for the clockwise last subtree T (w2). See Fig. 3.7(a) for an illustration. The computations for the second subtree T (w1) are symmetric. We rotate T (w2) counterclockwise around v towards the border of v’s wedge rooted in u as long as no vertex in T (w2) crosses it. To avoid a vertex of T (w2) being placed too close to another subtree, we keep small buffers parallel to the wedge border and (u, v) of constant size b smaller than the minimum of all edge lengths δ. Technically we shorten the distance d from v to the border by b to keep the buffer to the wedge border and ensure that the angles β between lines from v   to some leaf z in T (w ) and (u, v) stay larger than arcsin b to keep 2 kx(v)−x(z)k2 the buffer to the edge (u, v). If for one z in T (w2), β is already smaller, we do not rotate T (w2). A priori it is not clear which leaf in T (w2) is the first that touches the border (see Fig. 3.7(b)). An inner vertex of T (w2) can never be the first vertex crossing the wedge border because the angle from its last outgoing to its ingoing edge is at most π. Thus we compute for every leaf z in T (w2) the 0 desired angle γz of the line between v and z with (3.6). The rotation angle of 0 T (w2) is 1 = min (γz γz) mod 2π z is a leaf in T (w2) for γz the absolute angle of the line from{ v−to z. | } 26 Chapter 3. Angles and Distances

ω  d = sin v δ ((u, v)) b , 2 · − ( π ωv , if x(v) x(z) 2

For the case that v has more than two children, i. e., w1, . . . , wk in coun- terclockwise direction, spreading the subtrees is slightly more complicated. We rotate the outer subtrees T (w1) and T (wk) as before, i. e., as much as possible. We do not change the subtree T (w k ) in the middle of the wedge. The sub- d 2 e trees between the fix middle subtree T (w k ) and the last subtree T (wk) are 2 k d e rotated by an adapted angle i, 2 < i k. To preserve planarity, we must take care that these inner subtreesd e are not≤ crossing the wedge border rooted at the grandparent u. Thus for computing k, we must also check the leaves of all inner subtrees. For a child wi we compute

 k  i 2 i = k − . (3.7) · k  k  − 2

To rotate a subtree T (wi), we must update the position of every vertex y in T (wi): We increase the absolute angle γ of the line from v to y by i. Sym- metrically we do the same for the subtrees between T (w1) and T (wd k e). We 2 spread the tree from the leaves to the children of the root. Algorithm 3 shows the complete code. Since we recompute the coordinates of a vertex whenever we rotate a subtree in which it is contained, the time complexity is (n2). O

3.2.2 Circle Drawings

Since it can be difficult to place labels in radial tree drawings (Fig. 3.9), we describe a second method to draw phylogenetic trees. Here leaves are placed equidistantly along the perimeter of a circle. Again, each leaf thus obtains a 2π wedge of angular width | leaves(T )| , but now the radius of the circle determines the maximum height of the font. It is easy to see that with this constraint it might not be possible to draw all edges e E with length proportional to δ(e). Edge length preservation therefore turns into∈ an optimization criterion. 3.2. Distance Constraints 27

borelia-b

thermotoga

ChlamydiaB

myco-gentl

smithora--

TthermophiTaquatius

deinonema- laminaria-

cyclotella porphyra-- micrococcu coscinodia salmonellaecoli----- shewanella pseudomona

cynophora bacillus-- ochromonas

gracilaria plectonema anacystis- gloeobacte raphidonem

euglena--- astasia---

chlorella- chara-----

chlamydomogonium---- bryopsis--

nico-syl-Anico-tabac

arabidopsi

glycine---

(a) basic algorithm

astasia---

chlamydomo

gonium----

ochromonas

euglena---

chlorella- coscinodia bryopsis-- cynophora cyclotella

gracilaria arabidopsiglycine--- laminaria-

raphidonem

porphyra--

smithora--

nico-syl-A myco-gentl nico-tabac anacystis- chara-----

gloeobacte thermotoga

plectonema

bacillus-- Tthermophi deinonema- Taquatius borelia-b

ecoli-----salmonella

ChlamydiaB

shewanella

pseudomona

micrococcu (b) spreading extension (central root)

Figure 3.8: Postprocessing 28 Chapter 3. Angles and Distances

Type-58 Type-55 Type-57

Type-49 Type-84 Type-51 Type-78

Type-56 Type-50

Type-83

Type-52 Type-74 Type-53 Type-54 Type-69 Type-88 Type-77 Type-86 Type-48

Type-79 Type-47

Type-85 Type-75 Type-76 Type-87 Type-64 Type-80 Type-71 Type-73 Type-62 Type-60 Type-72 Type-65 Type-59 Type-66 Type-82 Type-63Type-70Type-61 Type-67 Type-68Type-46

Type-25 Type-21 Type-24 Type-20 Type-22 Type-19 Type-09Type-14 Type-23 Type-08 Type-01 Type-37 Type-27 Type-26 Type-36 Type-04 Type-41 Type-28 Type-15 Type-31 Type-16 Type-42 Type-43 Type-81 Type-39 Type-30 Type-32 Type-02 Type-07

Type-18 Type-35 Type-17 Type-10 Type-38 Type-45 Type-44 Type-11 Type-03

Type-06 Type-05

Type-40 Type-33 Type-34

Type-13 Type-12 (a) Hordeum88 (with overlap-avoidance extension)

3092melana2579kunthi m3230flavu5302rupest

6054moscha5752inaequ 5796hanelt 2369macros3828panicu 3366turkes5049turkes m1525caeru 6057pamiri 5243eremop3735caerul 3779tangut 3688elegan2561caesiu 6033tereti 5802kopetd 3201oligan5432schoen m0266fistu9174fistul 5712praemim5016oscha 5238vavilo5239vavilom1810cepaAm4000cepa 2592kareli 3339litvin 5336cupani 3849cyaneu3872cyaneu

2760altaic m1994pskem 2772maximo m2560fedsc 3040petrae6058margar 6018fedsch 2198ampelo3969iranic 3376talasi 6070sikkim 5561altaic m1729galan 5226schmit 6043monade m3900asare 5337sphaer 3158obliqu 2903schoen 6028semeno

2912atrosa

m1319sativ 6084forres 5376atrovi 2211beesia 3446schoen 5619conden m5152royle 3662crysta2290scorod 6063conden 2573filide5772dregea m3170ledeb

6093aciphy 3674filide 5037brevid m0433altyn 2646umbilim3660griff 5055parvul

3135hymeno2418kaschi 2539polyrh6004subang 2365bident m5402vodop3192vodopj2349anisop3249tenuis 3140filifo 2373mongol3163czemal5091dentig 2905platys2570caroli m1609ruben3401rubens5738stelle 2396amblyo 3765albidu 2744tuvini1968spiral2750senescm3161nutan2747austro 3470caucas3764incens 2761eduard2745eduard 1977caucas5736flaves m3407chine 2927lusita2778angulo 2015chinen1963thunbe6046komaro 5089przewa

m1330jodan6032tenuic5703kurame 1070xiphop6030sordid2791drepan6027oreopr6022drobov3898scabri 6048sulphu3998trachi 2333gunibi

1547ericet 5816linear6024linear 1741daghes 2769ubsico 6003montib 5578ochrol3883ochrol 6044flavid3390montib 1603suaveo2827pseudo 494Nothosc 5618monant5617monant 2165Tulbag3458Ipheiom2621noth. 6045chamar 2471Dichel 6053malysc 6086kingdo

m3384splen 6081milula6080milula 2825cyatho 5737rupest 6087mairei m2013hooke6088fascic m2104maire 3165clathr m6000gilgi m2441walli 0230insubr 5404strict m2454tuber m2797nerinm2379nerin 4247cyatho m6100wesch validum 5221togash6060leucoc m0023subhi 5000oreopr 2755ramosu zebdanense m2735ramosm3643oreop 6090prattim2582trico neapolitan 5092ovalif m3487fimbr3045glandu 1117moly sanbornii 1657parado3269trique1350ursinuchamaemolyroseum 2811brevis m2673victo1300microd m3154cernu bolanderi m3471goodim0200drumm stellatumm0682cernu dichlamyde 1502backho

3220bulgarm0093sicul amplectens

m2517aroid m0348oreop hyalinum unifolium

3661gypsac m3625kujuk

3133komaro

m3673saraw

m2257stipi

m3680sergi

1650nigrum

5255regeli

3940materc

1920cristo

m3652suvor

3947cardio

m2989karat

m2182verti (b) Allium200

Figure 3.9: Radial drawing examples 3.2. Distance Constraints 29

Algorithm 3: SPREADING Input: Ordered rooted tree T = (V, E, δ), constant buffer size b, coordinates x(v) and wedge size ωv for each v V ∈ Output: Updated coordinates x(v) for each vertex v V ∈ foreach v children(root(T )) do postorder traversal(v) ∈ procedure postorder traversal(vertex v)  k  k deg(v) 1; m ; let w , . . . , wk = children(v) in ← − ← 2 { 1 } counterclockwise order for i = 1 to k do postorder traversal(wi); ei (v, wi) ← if k 2 then ≥ u parent(v); e (u, v) ← ωv ← d sin( ) δ(e) b; 1 k ← 2 · −  ← ← ∞ α arccos x1(v)−x1(u) ; if x (v) < x (u) then α 2π α ← δ(e) 2 2 ← − Sm−1 foreach leaf z T (wi) T (w ) do ∈ i=1 ∪ 1 β π ωv ← 2 − 2 if x(v) x(z) 2> d then k − k   β β + arccos d ← kx(v)−x(z)k2 n  o γ0 α π + max β, arcsin b ← − kx(v)−x(z)k2  x1(z)−x1(v)  γ arccos ; if x2(z) < x2(v) then γ 2π γ ← kx(v)−x(z)k2 ← −  min (γ γ0) mod 2π,  ; if  < 0 then  0 1 ← { − 1} 1 1 ← Sk foreach leaf z T (wi) do ∈ i=m+1 β π ωv ← 2 − 2 if x(v) x(z) 2> d then k − k   β β + arccos d ← kx(v)−x(z)k2 n  o γ0 α + π max β, arcsin b kx(v)−x(z)k2 ← −  γ arccos x1(z)−x1(v) ; if x (z) < x (v) then γ 2π γ kx(v)−x(z)k2 2 2 ← 0 ← − k min (γ γ) mod 2π, k ; if k < 0 then k 0 ← { − } ← if k = 2 then subtree coordinates(v, w ,  ); subtree coordinates(v, w ,  ) 1 − 1 2 2 else for i 1 to m 1 do ← i−m− i  ; subtree coordinates(v, wi, i) ← 1 · m−1 for i m + 1 to k do ← i−m i k ; subtree coordinates(v, wi, i) ← · k−m

procedure subtree coordinates(vertex v, vertex w, angle ) foreach vertex y T (w) do ∈  x1(y)−x1(v)  γ arccos ; if x2(y) < x2(v) then γ 2π γ ← kx(v)−x(y)k2 ← − γ γ +  ← x(y) x(v) + (cos(γ) x(v) x(y) , sin(γ) x(v) x(y) ) ← · k − k2 · k − k2 30 Chapter 3. Angles and Distances

3.2.2.1 Basic Algorithm We use a variant of the weighted version of Tutte’s barycentric layout algo- rithm (Tutte, 1960, 1963). The general idea is to fix some vertices to the bound- ary of a convex polygon and then to place all other vertices vi V in the weighted ∈ barycenter of their neighbors vj V with vi, vj E, i. e., vi is positioned at ∈ { } ∈ X x(vi) = (aijx(vj)) (3.8)

vj ∈V

where aij is the relative influence of vj on vi. For circular drawings, the leaves of a tree T are fixed to a circle and we define weights aij by (3.9). These weights reflect the desired edge lengths, i. e., the shorter an edge vi, vj should be, the more influence x(vj) has on the resulting { } 1 coordinate x(vi). In the original Tutte algorithm aij = . Note that the deg(vi) weights aij sum up to 1 for each vi so that vi is placed inside of the convex hull of its neighbors. Since we fix leaves to the perimeter of a circle, we can expect in general that an inner vertex of a tree is placed between its children on the one side and its parent on the other side. To counterbalance the accumulated radial influence of the children, their weight is scaled down.

 1  if vi = parent(vj), δ(vi, vj) (deg(vi) 1) sij = · −  1  if vj = parent(vi) δ(vi, vj) (3.9)  sij P if vi, vj E, sij0 { } ∈ aij = {vi,vj0 }∈E 0 otherwise

In the following, let V = v1, . . . , vn with leaves(T ) = v1, . . . , vk . After fixing the leaves equidistantly{ around the} circle, we need to solve{ }   x(v )   1   a . . . a   x(v ) k+1,1 k+1,n   k+1  . .   .   .   . .   .  =  .  . (3.10) ·   an,1 . . . an,n   x(vn) x(vn) By the following lemma, this can be done in linear time by traversing the tree first in postorder to resolve the influence of leaves and then in preorder passing down positions of parents. 3.2. Distance Constraints 31

Lemma 3. For vi V and vp = parent(vi), define coefficients ∈

 0 if vi leaves(T ) root(T ) ,  api ∈ ∪ { } ci = otherwise (3.11a) 1 P (a c )  ij j − (vi,vj )∈E and offsets  x(vi) if vi leaves(T ),  ∈ d = P (3.11b) i (vi,vj )∈E(aijdj)  P otherwise . 1 (aijcj) − (vi,vj )∈E

Then (3.10) has a unique solution with

( di if vi = root(T ), x(vi) = (3.12) cix(vp) + di otherwise

for all inner vertices vi V leaves(T ). ∈ \

Proof. We use induction over the vertices. For the base case let vi be an inner vertex having only leaves as children. Then for the case vi = root(T ), let vp be 6 the parent of vi and thus

X x(vi) = apix(vp) + (aij x(vj))

(vi,vj )∈E | {z } =dj P a (v ,v )∈E(aijdj) = pi x(v ) + i j 1 0 p 1 0 (3.13) − − P api (vi,vj )∈E(aijdj) = P x(vi) + P 1 (aijcj) 1 (aijcj) − (vi,vj )∈E − (vi,vj )∈E = cix(vp) + di .

The case vi = root(T ) is a special case of (3.13), which uses only the second addend. For the inductive step, now let vi = root(T ) be an inner vertex and vp 6 32 Chapter 3. Angles and Distances

the parent of vi. Then X x(vi) = apix(vp) + (aijx(vj))

(vi,vj )∈E i. h. X = apix(vp) + (aij(cjx(vi) + dj))

(vi,vj )∈E X X = apix(vp) + x(vi) (aijcj) + (aijdj)

(vi,vj )∈E (vi,vj )∈E   (3.14) X X x(vi) 1 (aijcj) = apix(vp) + (aijdj) ⇔ − (vi,vj )∈E (vi,vj )∈E P api (vi,vj )∈E(aijdj) x(vi) = P x(vp) + P ⇔ 1 (aijcj) 1 (aijcj) − (vi,vj )∈E − (vi,vj )∈E = cix(vpp) + di .

The proof for vi = root(T ) is a special case of (3.14), which uses only the second addend.

Theorem 5. For a rooted ordered phylogenetic tree T = (V, E, δ), there is a unique planar circle drawing up to rotation, translation, and scaling that satisfies the following properties:

1. Leaves are placed equidistantly on the perimeter of a circle.

2. Disjoint subtrees are confined to disjoint wedges.

3. Inner vertices are placed in the weighted barycenter of their neighbors with weights defined by (3.9).

Moreover, it can be determined in linear time.

Proof. Uniqueness is proven in Lemma 3 and linear run time is obvious from Algorithm 4. For planarity we may assume that inner vertices have a degree of at least three since a degree-two vertex can be replaced by an edge and degree-one vertices are fixed. Adding dummy edges between neighboring leaves on the circle then yields a triconnected graph with all leaves incident to the same face. Since our weights yield strictly convex combinations for the positions of inner vertices, planarity follows from a generalization of Tutte’s original theorem in (Gortler and Thorston, 2006). Note that our influence weights are not symmetric. 3.2. Distance Constraints 33

Algorithm 4: CIRCLE-LAYOUT Input: Ordered rooted tree T = (V, E, δ) Data: Vertex arrays c (coefficient), d (offset), and edge array s (weighting) Output: Coordinates x(v) in/on the unit circle for each vertex v V ∈ begin i 0 ← k 0 ← foreach v V do ∈ if deg(v) = 1 then k k + 1 ← postorder traversal (root(T )) preorder traversal (root(T ))

procedure postorder traversal(vertex v) foreach w children(v) do ∈ postorder traversal(w) // ordered by h(w) + δ(v, w)

if is leaf(v) or (v = root(T ) and deg (root(T )) = 1) then cv 0 ← 2πi  2πi  dv cos , sin // fix vertex on circle ← k k i i + 1 ← else S 0 ← foreach adjacent edge e v, w do ← { } if v = root(T ) or w = parent(v) then 1 se ← δ(e) else 1 se ← δ(e)·(deg(v)−1) S S + se ← t t0 0 ← ← foreach outgoing edge e (v, w) do se ← t t + S cw 0← 0 se· t t + dw ← S · if v = root(T ) then 6 e (parent(v), v) ← se cv ← S·(1−t) t0 dv ← 1−t procedure preorder traversal(vertex v) if v = root(T ) then x(v) dv else ← u parent(v) ← x(v) cv x(u) + dv ← · foreach w children(v) do ∈ preorder traversal(w) 34 Chapter 3. Angles and Distances

v

e ® P ® w ¯ ¯

z

(a) angles (b) T (v) crosses wedge borders

Figure 3.10: Each subtree is drawn in a wedge

It remains to show that the resulting layouts satisfy the subtree-wedge con- dition. Since every inner vertex is placed within the convex hull of its neighbors, they all, especially the root r, lie within the circle. Thus for deg(r) 2, all leaves lie in the wedge of r with size 2π. In the special case of deg(r) =≥ 1 (deg(r) = 0 is trivial), we traverse downwards until a vertex with at least two outgoing edges or a leaf is found, take this vertex as the new root, and treat r as a leaf. For any inner vertex w V r and the corresponding angle α between the incoming edge e and the∈ first\{ outgoing} edge is α π, because w is placed within the convex hull of its neighbors. See Fig. 3.10(a)≤ for an example. Let z be the leaf in T (v) found by subsequently following the first outgoing edge. Let P be the unique simple path from v to z, which is denoted as the left contour of T (v). The left border of the wedge of v is a straight line from v to z. See Fig. 3.10(b) for an example. Now assume P crosses this border. Then there must be at least one angle α > π on P , which is a contradiction to the above. Otherwise, there is a crossing of P with itself or with the right contour of T (v), which contradicts planarity. Symmetrically the same holds for the right contour of T (v) and angles β between the last outgoing edges and corresponding incoming edges.

The most general version of Tutte’s algorithm for arbitrary graphs fixes at least one vertex of each component and simply places each vertex in the barycen- ter of its neighbors, which yields a unique solution. The run time corresponds to solving n symmetric equations, which can be done in (n3) time. For planar graphs (n log n) time can be achieved (Lipton, Rose, andO Tarjan, 1979), but it is not knownO whether this is also a lower bound. We showed that for trees with 3.2. Distance Constraints 35

v

Figure 3.11: Children ordered according to subtree height all leaves in convex position, the run time is in (n). Giving up planarity this result can be generalized to trees having arbitraryO fixed vertices (at least one). Consider a fixed inner vertex v and let each other vertex w in the subtree T (v) be free. Then T (v) collapses to the position of v. On the other hand, if v has a fixed ancestor u, then all positions of the vertices in T (v) are computed and for the rest a restart on T T (v) v computes all remaining positions. It follows by induction that our algorithm\ ∪ { computes} the unique solution in (n) time. O Note, the desirable property of disjoint subtree wedges together with the circular leaves constraint further restricts the class of edge lengths that can be represented exactly. Nevertheless, our experiments indicate that typical phylo- genetic tree metrics are represented fairly accurately.

3.2.2.2 Extensions

Our weights depend on the choice of the root vertex since re-rooting the tree changes weights along the path between the previous and the new root. The rationale behind reducing the influence weights of children suggests that the tree should be rooted at its center (minimum eccentricity element). Using weights independent of the parent-child relation, the layout can be made independent of the root just like the radial layouts discussed in the previous section. It is easy to see that by fixing the order of leaves we are also fixing the child order of all inner vertices. If no particular order is given, we can permutate the children of inner vertices to improve edge length preservation. Ordering the children of each vertex v according to ascending height h(w) of the subtrees T (w) plus δ(v, w) ensures that shallow and deep subtrees are never placed in an alternating order. See Fig. 3.11. Though sorting the children leads to (n log n) preprocessing time in general, most phylogenetic trees have boundedO degree, meaning that sorting can be performed in linear time. Since correct edge lengths cannot be guaranteed in circle drawings, we use the following coloring scheme to depict the error: Let 36 Chapter 3. Angles and Distances

chlamydomo

deinonema- gonium----

thermotoga chlorella- borelia-b

ChlamydiaB bryopsis--

gracilaria

Tthermophi glycine--- ochromonas myco-gentl Taquatius cynophora bacillus-- arabidopsi porphyra-- gloeobacte salmonella

nico-syl-A smithora-- plectonema ecoli-----

laminaria- pseudomona nico-tabac anacystis- coscinodia micrococcu chara----- cyclotella cyclotella shewanella

euglena--- pseudomona coscinodia raphidonem

micrococcu astasia--- astasia--- laminaria- shewanella euglena--- raphidonem smithora-- salmonella chara----- anacystis- ecoli----- porphyra-- nico-tabac

bacillus-- gloeobacte nico-syl-A cynophora ChlamydiaB arabidopsi thermotoga

plectonema borelia-b glycine---

ochromonas bryopsis--

myco-gentl gracilaria

Taquatius

chlorella- Tthermophi

deinonema- chlamydomo gonium---- (a) basic algorithm (b) re-rooted at the center

Figure 3.12: Circular drawing examples

P e=(u,v)∈E x(v) x(u) 2 σ = Pk − k (3.15) e∈E δ(e) be the mean resolution of the drawing, i. e., the scaling factor between drawn units and length units of δ. Then we obtain the (multiplicative) error of an edge e = (u, v) by

x(u) x(v) 2 fe = k − k , (3.16) σ δ(e) · which we encode into a color rgb: R+ [0; 1]3 by →

 1 (0, 0, 1) if fe ,  ≤ 2  1 (0, 0, log2(fe)) if 2 < fe < 1, rgb(fe) = − (3.17) (log (f ), 0, 0) if 1 f < 2,  2 e e  ≤ (1, 0, 0) if 2 fe . ≤ With this, that blue and red signify edges that are too short and too long, respectively. 100% red means that the edge is at least twice as long as desired whereas 100% blue means that the edge should be at least twice as long. Weaker saturation reflects intermediate values. Black edges have the correct lengths. 3.2. Distance Constraints 37

Type-44 Type-67 Type-66 Type-61 Type-70 Type-63 Type-72 Type-62

Type-65 Type-45 Type-03 Type-02 Type-71 Type-05 Type-06 Type-64 Type-04 Type-12 Type-46 Type-13 Type-68 Type-07 Type-10 Type-51 Type-11 Type-49 Type-15 Type-16 Type-50 Type-17 Type-48 Type-18 Type-53 Type-08 Type-52 Type-14 Type-09 Type-47 Type-19 Type-69 Type-20 Type-54 Type-21 Type-56 Type-25 Type-55 Type-27 Type-26 Type-58 Type-28 Type-57 Type-29 Type-74 Type-30 Type-84 Type-22 Type-78 Type-23 Type-24 Type-83 Type-37 Type-77 Type-36 Type-79 Type-31 Type-32 Type-75 Type-35 Type-76 Type-33 Type-34 Type-80 Type-01 Type-42 Type-88 Type-43 Type-41 Type-39 Type-38 Type-86 Type-40 Type-85 Type-87 Type-73 Type-60 Type-59 Type-82 Type-81 (a) Hordeum88

2827pseudo 1603suaveo 3883ochrol 6054moscha 1741daghes 5752inaequ

1547ericet 6057pamiri 3779tangut

5049turkes6033tereti 6058margar3366turkes

3040petrae

3376talasi 5619conden3158obliqu 6063conden

5578ochrol 2333gunibi 3898scabri 3998trachi 6048sulphu 6022drobov 6027oreopr 2791drepan 2198ampelo3969iranic 1070xiphop 6030sordid 5703kurame 5337sphaer m1330jodan m1319sativ 6032tenuic 6024linear 5816linear 5376atrovi 3390montib 2290scorod 6003montib 5772dregea 2769ubsico 6044flavid 3662crysta 6045chamar 6053malysc 2573filide m3384splen 3674filide 5737rupest 5037brevid 3165clathr 2646umbili 5404strict 6060leucoc m3660griff 5221togash 5055parvul 5089przewa 2579kunthi 2761eduard 5302rupest 2745eduard 3828panicu 2365bident 3092melana 3163czemal 2373mongol m3230flavu 5091dentig 2369macros 2539polyrh 5336cupani 6004subang 5802kopetd 3192vodopj m5402vodop 3735caerul m1525caeru 3249tenuis 2349anisop 2561caesiu 2927lusita 3688elegan 2778angulo 5243eremop 1977caucas 5796hanelt 5736flaves 3470caucas 3339litvin 3764incens 2903schoen 3765albidu 2418kaschi 3401rubens 3135hymeno m1609ruben 3140filifo 5738stelle 2570caroli 2744tuvini 2905platys 1968spiral 2396amblyo 2750senesc 2747austro m3407chine m3161nutan 2015chinen m2621noth 1963thunbe 494Nothosc 6046komaro 3458Ipheio 5432schoen 2165Tulbag 3201oligan 2471Dichel 2592kareli 5617monant 5618monant 2772maximo m2441walli 5226schmit m0093sicul 3446schoen 3220bulgar m3170ledeb 6088fascic m0433altyn m2013hooke m4000cepa 0230insubr 1117moly m1810cepaA 5239vavilo 1350ursinu 1657parado 5238vavilo 3269trique m3900asare m0023subhi m5152royle zebdanense m5016oscha neapolitan 5712praemi roseum chamaemoly m1994pskem validum m1729galan 3045glandu 9174fistul 2811brevis m0266fistu m0200drumm 2760altaic m3471goodi 5561altaic m3487fimbr sanbornii 3872cyaneu m3154cernu 3849cyaneu m0682cernu stellatum 6070sikkim bolanderi 2211beesia dichlamyde 6093aciphy amplectens 6084forres hyalinum unifolium m2379nerin m2560fedsc m2797nerin 6018fedsch 6090pratti 5092ovalif 6028semeno m2582trico 1300microd m2673victo 6043monade2912atrosa m0348oreop m3625kujuk 1502backho m2517aroid 3661gypsac m6100wesch 3133komaro 4247cyatho m3673saraw m2257stipi m3680sergi 1650nigrum 2825cyatho 5255regeli 3940materc 6081milula 6080milula

m2104maire6087mairei 6086kingdo

2755ramosu

m2735ramosm2454tuber 5000oreopr m3643oreop m6000gilgi m2182verti 1920cristo 3947cardio

m2989karat

m3652suvor (b) Allium200

Figure 3.13: for examples from Figure 3.9

Acknowledgement We wish to thank Lars Volkhardt for implementing our algorithms in Java using yFiles version 2.3 (Wiese, Eiglsperger, and Kaufmann, 2002), and Falk Schreiber from the Institute of Plant Genetics and Crop Plant Research in Gatersleben for providing real-world data. 38 Chapter 3. Angles and Distances

3.3 Angle and Distance Constraints

3.3.1 Straight-Line Realizability Straight-line drawings of trees with both angle and distance constraints are com- pletely determined (up to translation and rotation). Theorem 6. Straight-line realizability of trees with both angle and distance con- straints can be tested in linear time. Proof. We show that straight-line realizability testing is equivalent to testing simplicity of polygonal chains, which can be done in linear time (Chazelle, 1991). Since a polygonal chain can be viewed as a tree with angle and distance con- straints, trees cannot be tested faster than polygonal chains. On the other hand, an embedded tree with l leaves can be covered by l paths P1,...,Pl connecting each leaf with the first leaf encountered in a right-first search. Due to the given constraints, each path corresponds to a polygonal chain, and the tree is realiz- able if and only if all Pi, 1 i l are simple. Since the union of these paths corresponds to an Euler tour≤ around≤ the tree, the total size of the polygonal chains is 2m = 2n 2. − 3.3.2 Polyline Representation If an angle and distance constrained tree is not straight-line realizable, it can still be drawn without edge intersections by allowing polylines. In the remainder of the section, we will prove the following theorem. Theorem 7. For a tree, a planar polyline drawing that satisfies locally consis- tent angle and distance constraints and has at most two bends per edge can be determined in linear time.

In the first step we calculate an initial layout of Tr for an arbitrary root r V with the length-preserving Algorithm 2 and given edge lengths δ. The algorithm∈ assigns a wedge of size ω(v) to each vertex v V that contains the whole subtree ∈ Tr(v) of v and is then divided among the children. With these vertex positions, we look at the unrooted tree T and all the wedges of v’s neighbors are rooted in v. The vertex w0, which had been v’s parent in Tr, is now lying in an opposed wedge with size ω(w0) = 2π ω(v) (see Fig. 3.14). We exploit this invariant characteristic of the computed− layouts: Theorem 8. For a tree with given vertex positions, a planar polyline drawing that satisfies locally consistent angle constraints and has at most two bends per edge can be determined in linear time, if the given vertex positions are such that disjoint subtrees are contained in disjoint wedges. 3.3. Angle and Distance Constraints 39

Figure 3.14: Wedges for vertex v

This is a special case of the problem to find a drawing of a with fixed vertices and pre-specified angles between the edges incident to the same vertex (Brandes, Shubina, and Tamassia, 2000). A related problem is embedding a planar graph on a fixed set of points in the plane. The graph can be drawn without edge intersections using at most two bends per edge in polynomial time, if the mapping between the vertices V and the points P is not fixed (Kaufmann and Wiese, 2002). However, if the mapping is fixed, i. e., each vertex has a fixed position such that the straight-line drawing is not necessarily planar, up to O(n) bends per edge can be necessary to guarantee planarity and this bound is known to be asymptotically optimal in the worst case (Pach and Wenger, 1998). Note that these strategies do not yield drawings that satisfy angle constraints. Angle constraints have to be satisfied for example when drawing graphs with good angular resolution. A planar graph can be embedded and drawn planar with at most one bend per edge such that for each (e1, e2) A sharing a vertex v V it 1 ∈ ∈ is α(e1, e2) deg(v) (Cheng, Duncan, Goodrich, and Kobourov, 1999). For not necessarily≥ planar graphs, angular resolution and the number of edge crossings can be improved by modifying a force- drawing algorithm into an algorithm for drawing graphs with curved edges (Finkel and Tamassia, 2005). Note that for these drawings no distance constraints are to be satisfied. 40 Chapter 3. Angles and Distances

Figure 3.15: Polylines for the edge v, w { }

In our drawings, edges will be represented as polylines. The polyline of an edge v, w will be determined by the endpoints of two control segments incident to v and{ w} (see Fig. 3.15). We guarantee the planarity in two steps: For a vertex v V ∈ we determine the direction of each initial control segment. • we determine the length for each initial control segment. • In Sect. 3.3.2.1 we define a rotation angle β to guarantee certain situations regarding the angles of the initial control segments incident to a vertex v and those of the straight lines from v to the corresponding neighbors. In Sect. 3.3.2.2 we determine the control segment lengths to avoid intersections in the remaining situations.

Figure 3.16: Rotating the angle template 3.3. Angle and Distance Constraints 41

We will focus on each vertex a constant number of times and look at all incident edges such that the overall run time is linear.

Let v V be a vertex with k incident control segments s . . . sk− (in coun- ∈ 0 1 terclockwise order) belonging to the k polylines of edges e0 . . . ek−1 to the k neighbors w0 . . . wk−1 of v. We refer to the absolute angle of a control segment Pi 0 si with γi = γ0 + t=0 α(et−1, et) and li its length. Further, let si be the control 0 0 segment for ei incident to wi with angle γi and length li. Let pi denote the target 0 0 point of si and pi the target point of si, λi the absolute angle of the line from v 0 to wi and λi the angle of the same line, but from wi to v.

Figure 3.17: Routing e around v

3.3.2.1 Control Segment Angles

Since only the relative angles between consecutive control segments incident to v are given, to determine the final layout we must choose the absolute angle for one of the control segments. We start with γ0 = λ0 and then rotate the whole angle template by an angle β, i. e., update each angle γi = γi β (see Fig. 3.16). ± For a neighbor wi of v, the angular deviation is θ(i) = (γi λi) mod 2π. We − say that wj lies between si and wi if (γi λj) mod 2π < (γi λi) mod 2π, whereas − − a control segment sj lies between si and wi if (γi γj) mod 2π < (γi λi) mod 2π. − − In Fig. 3.18(a) for example, s0 and w0 lie between si and wi. We assume that the 0 0 0 endpoint pi of the control segment si and the neighbor wi which si is incident to, lie on the same side of the line (v, pi) such that the polyline of ei can only cross the wedge of a neighbor wj with either pi itself within wj’s wedge or wj between si and wi for θ(i) < π and wj between wi and si for θ(i) > π (see Fig. 3.17). We will assure this when determining the control segment lengths (see (3.23)). 42 Chapter 3. Angles and Distances

The following two situations will cause intersections in the starting configu- ration because ei will be intersecting with e0 (see Fig. 3.18 for illustration). For a pair si, wi we say that

i and 0 are clockwise crossing if (3.18) θ(i) π and w ,s lie between si and wi, ≤ 0 0

i and 0 are counterclockwise crossing if (3.19) θ(i) π and w ,s lie between wi and si. ≥ 0 0

(a) clockwise crossing (b) counterclockwise crossing

Figure 3.18: Two cases in the start situation

Lemma 4. At any vertex v V there are either clockwise or counterclockwise crossings, if any. ∈

Proof. Assume i1 fulfills Equation (3.18) and i2 Equation (3.19), then s0 lies between si1 and si2 and w0 lies between wi2 and wi1 . The orders of the control segments and of the neighbors are fixed, hence i1 < i2 and i1 > i2, which is a contradiction.

If a vertex v has a neighbor wi such that i and 0 are clockwise crossing, we rotate v’s angle template counterclockwise. If i and 0 are counterclockwise crossing for an 0 i k 1, this is the mirrored case and can be solved by rotating clockwise.≤ ≤ − Assume w.l.o.g. that there are only clockwise crossings at v. Out of all pairs si, wi for which i and 0 are clockwise crossing, let i be the one for which the { } min angular deviation θ(i) is minimal and of all pairs si, wi for which i and 0 are { } not clockwise crossing but θ(i) < π let imax be the one for which θ(i) is maximal. 3.3. Angle and Distance Constraints 43

We rotate the angle template counterclockwise by an angle β with

0 π θ(i ) < β < π θ(i ) π (3.20) ≤ − min − max ≤ Lemma 5. For every vertex v there is a feasible rotation β, i. e. θ(imin) > θ(imax).

Proof. For imax > imin, the vertex wimax lies between w0 and wimin because the order of neighbors is fixed. It is θ(imax) < π but imax and 0 are not clockwise crossing, hence simax lies between w0 and wimax . So it must be θ(imin) > θ(imax) because both simax and wimax lie between simin and wimin . The proof for the case imax > imin is analogous, as for imin > imax simax lies between simin and s0.

Lemma 6. These bounds are sharp.

Proof. For β π θ(i ) it would still be that θ(i ) π after rotation ≤ − min min ≤ and both w0 and s0 would still lie between simin and wimin , hence eimin would be intersecting with e0. For β π θ(i ) it would be true that θ(i ) π after rotation and both ≥ − max max ≥ wimin and simin would lie between wimax and simax , hence eimin would be intersecting with eimax .

Within these bounds we can now optimize any objective function, for example the sum over all squared angular deviations θ(i)2 for 0 i k 1. See Brandes, Shubina, and Tamassia (2000) for other reasonable objective≤ ≤ functions.− After rotating the angle template we will have (see Fig. 3.19):

Lemma 7 (counterclockwise sheering). For 0 i, j k 1, wj lies between wi ≤ ≤ − and si with angular deviation θ(i) > π, if and only if si also lies between wj and sj with θ(j) > π.

Lemma 8 (clockwise sheering). For 0 i, j k 1, wj lies between si and wi ≤ ≤ − with angular deviation θ(i) < π, if and only if si also lies between sj and wj with θ(j) < π. In these two situations we can avoid intersections by determining the control segment lengths in Sect. 3.3.2.2. We say si is pulled between sj and wj if it was (λj γi) mod 2π < π before − rotation, but is (λj γi) mod 2π > π after rotation and si lies between sj and − wj. We say si is pushed over wj if it was (λj γi) mod 2π < π before rotation, − but is (λj γi) mod 2π > π and wj lies between si and wi after rotation. To prove− Lemma 7 and Lemma 8, we first prove the following: 44 Chapter 3. Angles and Distances

(a) counterclockwise sheering (b) clockwise sheering

Figure 3.19: Two solvable situations

Lemma 9. If θ(i) > π after rotation for 0 i k 1, before and after rotation ≤ ≤ − neither w0 nor s0 can lie between wi and si.

Proof. If θ(i) > π before rotation, w0 and s0 cannot have lain between wi and si because i and 0 would have been counterclockwise crossing. We rotate counter- clockwise by an angle β < π keeping θ(i) > π, hence they cannot after rotation as well. If θ(i) π before rotation but θ(i) > π after, i and 0 must have been ≤ clockwise crossing before rotation, hence w0 and s0 cannot lie between wi and si after rotation.

Lemma 10. If θ(i) < π after rotation for 0 i k 1, w and s cannot both ≤ ≤ − 0 0 lie between si and wi.

Proof. Before rotation, i and 0 cannot have been clockwise crossing. So by rotating counterclockwise by an angle β < π from the start situation λ0 = γ0, it can only happen that either si is pushed over w0 or s0 is pulled between si and wi.

Lemma 11. For any i with 0 i k 1, wi and si cannot both lie between s ≤ ≤ − 0 and w0.

Proof. It is θ(0) = β < π. Assume both wi and si lie between s0 and w0. For θ(i) < π, i and 0 would have been counterclockwise crossing before rotation. For θ(i) > π, both w0 and s0 would have lain between wi and si before rotation, which is contradicted by Lemma 9.

Corollary 2. For the angular deviation of a vertex wi, it is impossible that θ(i) = π after rotation for any 0 i k 1. ≤ ≤ − 3.3. Angle and Distance Constraints 45

Proof. of Lemma 7 If wj lies between wi and si with θ(i) > π, neither s0 nor w0 can lie between wi and si (Lemma 9), so w0 cannot lie between wi and wj and we have j < i. Because the order of control segments is fixed, s0 cannot lie between si and sj, hence s0 must lie between sj and wi and s0 lies between sj and wj. If it is θ(j) < π, s0 must have been pulled between sj and wj (Lemma 10) so s0 must have lain between wi and si, which is a contradiction to Lemma 9. If si lies between wj and sj with θ(j) > π, neither s0 nor w0 can lie between wj and sj (Lemma 9) so s0 cannot lie between si and sj and we have j < i. Because the order of neighbors is fixed, w0 cannot lie between wi and wj, hence w0 must lie between sj and wi and w0 lies between si and wi. If it is θ(i) < π, si must have pushed over w0 (Lemma 10), so sj must have also pushed over w0, hence w0 must have lain between wj and sj, which is a contradiction to Lemma 9.

Proof. of Lemma 8 If wj lies between si and wi, wi cannot be between wj and sj with θ(j) > π (Lemma 7). For j < i, w0 lies between wj and wi. w0 can not lie between wj and sj (Lemma 9, thus sj can not lie between w0 and wi. s0 cannot lie between si and wi (Lemma 10) and as θ(0) = β < π, si lies between s0 and w0. Further, s0 must lie between sj and si because the order of control segments is fixed. sj cannot lie between s0 and w0 (Lemma 11), thus we have si lies between sj and wj with θ(j) < π after rotation. For i < j, s0 must lie between si and sj. wi can not lie between sj and s0 (Lemma 9). If sj lies between si and wi, s0 must lie between si and wj (Lemma 9 excludes s0 between wj and sj), while w0 lies with θ(0) = β < π. Again, sj cannot lie between s0 and w0 (Lemma 11), thus si lies between sj and wj with θ(j) < π after rotation. If si lies between sj and wj, sj cannot be between wi and si with θ(i) > π (Lemma 7). For j < i, s0 lies between sj and si. w0 cannot lie between sj and wj (Lemma 10) and it must be θ(0) = β < π. wi can not lie between s0 and wj (Lemma 11), hence wj lies between si and wi with θ(i) < π after rotation. For i < j, w0 must lie between wi and wj because the order of control segments is fixed. If wi was between sj and wj, w0 must lie between si and wj (Lemma 9). s0 cannot lie between sj and wj as well (Lemma 10), hence, both wi and si would lie between s0 and w0 (contradicted by Lemma 11). Thus wj lies between si and wi with θ(i) < π after rotation.

3.3.2.2 Control Segment Lengths In the remaining situations we can avoid intersections by determining the lengths of an edge’s control segments. First we focus on edges ei = v, wi incident to { } 46 Chapter 3. Angles and Distances a vertex v and make sure that they do not intersect with each other (at a point different from v itself). We assure that the polyline of ei can only cross the wedge of a neighbor wj with either wj between si and wi for θ(i) < π and wj between wi and si for θ(i) > π, or pi itself within wj’s wedge. We further determine the radius rv of the circle containing all control seg- ments incident to a vertex v such that:

control segments incident to different neighbors of v can not intersect • the control segments incident to v can not intersect with a control segment • incident to any of v’s neighbors

For an edge e = v, w , the maximal possible length l of e’s control segment s incident to v is determined{ } such that:

neither the middle segment of e nor the control segment s can intersect • with a control segment incident to another neighbor neither the middle segment of e nor the control segment s can intersect • with the middle segment of another edge

With these control segment lengths we can draw the polylines incident to v neither intersecting each other nor with any polyline in T . We will show the latter when proving that curves incident to v are not intersecting with any other curve in T (Lemma 13) as the polyline of an edge is the border of the hull containing the edge’ s curve. The polyline of ei incident to v can only cross the wedge of a neighbor wj with wj between si and wi for θ(i) < π and wj between wi and si for θ(i) > π pi 0 if wi and the endpoint pi of ei’s control segment incident to wi lie on the same 0 0 side of the line (v, pi). We assure this by choosing the length li of si such that 0 0 si does not intersect with the line (v, pi). If the halfline from wi through pi does 0 not intersect with (v, pi), the length of si is not relevant. Otherwise we use the following: If (γ0 λ0 ) mod 2π > π (see Fig. 3.20): i − i The angle between (v, pi) and (v, wi) is ( (γi λi) mod 2π if θ(i) < π η = − (3.21) (π λi + γi) mod 2π otherwise − Further we use the angle κ with: π κ = η λi + γi (3.22) 2 − − 3.3. Angle and Distance Constraints 47

Figure 3.20: (γ0 λ0 ) mod 2π > π and θ(i) > π i − i

Since sin(η + π) = sin(η) and cos(κ) = sin(κ + π ), we summarize: − 2

0 sin(γi + π λi) δ(ei) li < − 0· 0 (3.23) sin( γi + λi λ + γ ) − − i i Since for (γ0 λ0 ) mod 2π < π we get: i − i

0 sin(λi γi π) δ(ei) li < − − 0· 0 (3.24) sin( λi + γi γ + λ ) − − i i 0 0 0 0 we do not even have to distinguish (γi λi) mod 2π > π and (γi λi) mod 2π < π but instead only need (3.23). − − Let wi be one neighbor of v. We call the (smallest) sector of wi’s wedge, in 0 which the control segment si incident to wi is lying, the range of wi. If another control segment sj incident to v is lying within this range, the polylines of ei and ej can be intersecting without i and j clockwise or counterclockwise sheering. 0 0 0 We avoid this by choosing the length li of si such that si is not intersecting with the line (v, pj) for any j = i (see Fig. 3.21). The computation is analog to (3.23). 6 To guarantee that the control segments incident to one neighbor are not intersecting with the control segments of another neighbor, we determine for 0 i k 1: ≤ ≤ −

( ωwi sin 2 wi v 2 if ωwi < π rw < · k − k (3.25) i ωwi sin(π ) wi v otherwise − 2 · k − k2 48 Chapter 3. Angles and Distances

Figure 3.21: Range of wi

We must also guarantee that the control segments incident to v are not intersecting with the control segments incident to one of v’s neighbors:

1 rv min δ(ei) ≤i≤k− (3.26) ≤ 2 { }0 1 We first compute (3.25) for each vertex v V and then (3.26) to determine ∈ rv, which we will need in the following. A neighbor wi cannot be involved both in a clockwise and a counterclockwise sheering. Let i and (i + 1) mod k (we will write i + 1 in the remainder) be counterclockwise sheering. We have to further determine the length li+1 of the control segment si+1. The polyline of an edge ei+1 might intersect with ei or another edge incident to 0 wi if a line through pi+1 and pi+1 would be intersecting with the circle containing all control segments incident to wi. We can avoid this by choosing li+1 such that 0 si+1 is not intersecting with any tangent line to wi’s circle through pi+1. Further, 0 si+1 must not intersect with the line gi = (pi, pi). As we might not know the 0 0 0 0 final lengths of si+1 and si we use that 0 < li+1 rwi+1 and 0 < li rwi . See Figure 3.22(a) for illustration. ≤ ≤

The computations for a length li+1 such that si+1 is not intersecting with one of these lines are all very similar. We show the computation here for a line g where φi is the angle between g and si in (3.27) (see Figure 3.22(b) for illustration):

sin φi li li+1 < · (3.27) sin(π φi α(ei, ei )) − − +1 3.3. Angle and Distance Constraints 49

(a) lines (b) length of si+1

Figure 3.22: Bounding control segments

Note that not only i + 1 and i can be counterclockwise sheering but also i + 1 and j for any j < i. As from this, i + 1 and any j0 with i < j0 < j are counterclockwise sheering and since we have considered j0 before i, it is sufficient to focus on i when determining li+1. These procedures imply that li must be calculated first. Therefore we create a vertex list L+ containing v0s neighbors sorted by increasing index and θ(i) < π for + each wi L . If for v there is a pair i and (i 1) mod k clockwise sheering, this is symmetrically∈ the same situation and will− be solved with the same strategy. We will need a vertex list L− sorted by decreasing index and θ(i) > π for each − wi L . We can create both types of vertex lists by testing all neighbors wi for ∈ 0 i k 1 in counterclockwise order. There must be a neighbor wi to start ≤ ≤ − with, i. e., such that li−1 does not have to be calculated first. We prove:

Lemma 12. Neither the vertex list L+ nor L− will contain all neighbors of v.

Proof. We start with the angular deviation θ(0) = 0. If we do not have to rotate v’s angle template, the neighbor w0 will be in none of the vertex lists. If and only if there is a neighbor wi of v such that i and 0 are clockwise crossing, we rotate counterclockwise by an angle β < π until θ(i) > π. After rotation it will be θ(0) < π, hence w0 and wi will be in different vertex lists. Rotating clockwise is the mirrored case.

In Fig. 3.26(a) a tree after determining the vertex positions is displayed with an arbitrary rotation angle for each vertex v and control segment lengths smaller than rv. In Fig. 3.26(b) the rotation angle is determined as shown in Sect. 3.3.2.1 and the control segment lengths as in Sect. 3.3.2.2. 50 Chapter 3. Angles and Distances

Figure 3.23: B´eziercurves

3.3.3 Curve Representation Instead of using polylines, we can also represent the edges as smooth curves. A cubic B´eziercurve is determined by two endpoints b0, b3 and two inner control points b1, b2. We call the segments b0b1 and b3b2 the (initial) control segments, while b1b2 is called the inner segment. A B´eziercurve is contained within the convex hull of its defining points. The tangents at its endpoints are collinear with the initial control segments, so the outgoing angle of a B´eziercurve is the angle of its control segment. See Fig. 3.23 for examples. For the B´ezier curve of an edge we use the control segments of the corre- sponding polyline as initial control segments. We refer to the B´eziercurve from v to wi for 0 i k 1 with ci and Hi the convex hull of its control points. In the remainder≤ of≤ this− section we will proof the following theorem.

Theorem 9. For a tree, a planar drawing that satisfies locally consistent angle and distance constraints while representing edges as continuously differentiable curves consisting of at most two cubic B´eziercurves and a straight line segment, can be determined in linear time.

Even if the polylines of two edges are not intersecting, the hulls of the corre- sponding B´ezier curves can intersect. Three borders of a curve’s hull are the line segments of the corresponding polyline. When determining the control segment lengths we avoided most intersections, but in case of a clockwise or counterclock- wise sheering, we must split an edge’s curve by adding control segments. Let i and i + 1 be counterclockwise sheering. When all the control segment lengths in the tree are determined, we split a curve ci. Let qi be the intersection 0 0 point of the lines vpi+1 and pipi. The splitting point mi must lie on pipi between the point qi and pi. Rooted at mi we add two diametral opposed control segments m1 m2 0 m1 m2 0 si and si on pipi, with si pointing towards pi and si pointing towards pi. 3.3. Angle and Distance Constraints 51

Figure 3.24: Splitting a curve

(See Fig. 3.24 for illustration.) Now we can describe ci with two B´eziercurves smoothly attached (continuously differentiable, because the angle at mi is π), m1 0 m2 one by si and si and one by si and si . When we later focus on wi, we might have to split ci to avoid intersections with curves incident to wi. If then the splitting point may not lie between qi and pi, we will add a second splitting 0 point on pipi and ci (still continuously differentiable) will consist of two B´ezier 0 curves incident to v and wi and a straight line segment on pipi. Otherwise one splitting point will be sufficient. Lemma 13. The resulting tree layout is planar.

Proof. For any vertex v, the curve or polyline of an edge ei+1 incident to v can cause problems if the hull Hi+1 is intersecting with the wedge of another neighbor of v. With the strategy presented previously we made sure that Hi and Hi+1 are not intersecting. By determining the length of si+1 in (3.27), we made it impossible for Hi+1 to intersect with the circle containing the control segments incident to wi (or the circle for any other neighbor wj with i + 1 and j counterclockwise sheering). Hence Hi+1 cannot intersect with any wedge or control segment of one of wi’s neighbors different from v since the vertices of disjoint subtrees are contained in disjoint wedges. With this, Hi+1 cannot intersect with any line from a point in wi’s circle to a point in the wedge of one of wi’s neighbors different from v, thus Hi+1 cannot intersect with any hull of a curve incident to wi or any vertex in the subtree Tv(wi). See Fig. 3.25 for illustration. Hull Hi+1 intersecting with the 52 Chapter 3. Angles and Distances

Figure 3.25: Hi+1

wedge of the neighbor wi+2 is the mirrored case. Hi+1 does not intersect with any curve in Twi+1 (v). As we also focus on Hi+1 when considering wi+1 and its neighbors, Hi+1 cannot intersect with any curve in Tv(wi+1) as well. 3.3. Angle and Distance Constraints 53

(a) random rotation

(b) polylines

(c) curves

Figure 3.26: Drawings of a tree with fixed vertices and angles 54 Chapter 3. Angles and Distances Chapter 4

Ordering

In several scenarios, a graph drawing algorithm receives as input not only a graph, but also an initial (possibly partial) drawing. The task is to redraw the graph while maintaining selected features of the input drawing. Examples of this kind are embedding-constrained graph layouts, shape simplification, sketch- based drawing, and dynamic graph layouts. A cartographic application of particular interest is the simplification of lines. Given a polygonal path, the task is to generate a simpler representation of the path, for instance by omitting vertices (see Douglas and Peucker, 1973; Imai and Iri, 1986) (level of detail) or by restricting the allowable types of segments (see Neyer, 1999; Merrick and Gudmundsson, 2007) (schematization). Maintaining a user’s mental map by preserving the orthogonal ordering (Misue, Eades, Lai, and Sugiyama, 1995) of stations and landmarks seems particularly appropriate in this scenario and has been tried, e.g., by Dwyer, Koren, and Marriott (2006). For layout stability (B¨ohringerand Paulisch, 1990) and similarity (Bridgeman and Tamassia, 1998) the relative position of vertices, strongly related to the orthogonal ordering, is considered, used (Lee, Lin, and Yen, 2006) and tested (Bridgeman and Tamassia, 2002) helpful. Alternative constraints include preser- vation of the cyclic ordering of neighbors (N¨ollenburg and Wolff, 2006) and dis- tance from original positions using various metrics (Neyer, 1999; Merrick and Gudmundsson, 2007). For orthogonal-order preserving graph drawing, even the decision problems in the rectilinear, the octilinear model and the equal edge length, are - hard. Hardness in the rectilinear implies, e.g., that bend-minimum orthogonalNP layout is hard under ordering constraints. The octilinear drawing problem is of special interest for drawing metro maps. Our result is in contrast to the direction-restricted models studied by Neyer (1999) and Merrick and Gudmunds- son (2007), where paths or vertices must be within a given distance (according to the Fr´echet or Euclidean metric) of the original and the number of bends can 56 Chapter 4. Ordering

(a) ei pulls ej horizontally and ej (b) ei pulls ej vertically and ej pushes ei vertically pushes ei horizontally

Figure 4.1: Dependency of edges be minimized in polynomial time. The algorithm introduced by Delling, Gemsa, N¨ollenburg, and Pajor (2010) preserves the orthogonal ordering of vertices at least for each monotone subpath of a path. The equal edge length model is in- teresting, since drawing with given edge lengths is hard for general graphs (Eades and Wormald, 1990), but easy for trees (see Sect. 3.2). We use reductions from MONOTONE 3-SAT for the hardness proofs. We treat the rectilinear case in Sect. 4.1, the octilinear case in Sect. 4.2 and the equal edge length case in Sect. 4.3.

4.1 Rectilinear Drawings

The first problem we address is the following:

Orthogonal-order preserving rectilinear drawing problem: Given a plane graph, we want to decide whether we can draw each edge either horizontally or vertically, without changing the horizontal or the vertical order of vertices while keeping all edge lengths positive.

The possible direction of an edge might depend on the direction of other edges. Figure 4.1 shows how an edge ei can determine the direction of an edge ej. More formal: We say an edge ei pulls another edge ej horizontally, if ej lies completely within the x2-range of ei’s. Hence, to keep the vertical order of vertices, ej must be horizontal if ei is horizontal. This of course also means that ei cannot be drawn horizontally if ej is vertical, in which case we say ej pushes ei vertically. Analogously we say an edge ei pulls another edge ej vertically if ej lies within ei’s x1-range, and therefore also ej pushes ei horizontally. We use this to construct the main gadgets for the -hardness proof. NP Consider a path P = (e1, e2, e3) of three edges as shown in Fig. 4.2, if there is a horizontal edge with one vertex in the x1-range of e1 and one vertex in the x1-range of e3, at least one of P ’s edges must be drawn horizontally (see 4.1. Rectilinear Drawings 57

(a) horizontal decision unit (b) vertical decision unit

Figure 4.2: Decision units

(a) positive link (b) negative link

Figure 4.3: Possible links l for ei and ej

Fig. 4.2(a)). We call the edges in P literal edges, the horizontal edge framing edge and the whole set a horizontal decision unit.A vertical decision unit is defined analogously and shown in Fig. 4.2(b). We use these decision units to represent 3-SAT clauses. In Fig. 4.3 two edges ei = ej are linked by a third edge l = ei, ej. We call l 6 6 the positive link for ei and ej if ej pulls l horizontally and l pushes ei horizontally such that ei, ej and l are all horizontal if ej is horizontal (see Fig. 4.3(a)). Of course this also means that if ei is vertical, l and ej also must be vertical. A negative link is defined analogously and shown in Fig. 4.3(b). We will use these links to tie together edges corresponding to the same variable.

4.1.1 Unions of Paths We now use the described edge-dependency elements to create a union of paths for a given instance of MONOTONE 3-SAT in order to prove the following theorem:

Theorem 10. The orthogonal-order preserving rectilinear drawing problem is -hard for unions of paths. NP 58 Chapter 4. Ordering

Figure 4.4: Union of paths for a MONOTONE 3-SAT-instance I

For an instance I = (B,C) of MONOTONE 3-SAT, we create a union of paths as follows. Each variable in B has several corresponding edges that will have to be drawn horizontally (vertically) if and only if the corresponding vari- able is assigned true (false). For each positive clause Ci C we place a horizontal ∈ decision unit U(Ci) and for each negative clause Cj C a vertical decision unit ∈ U(Cj) with the literal edges on a diagonal line as shown in Fig. 4.4 such that initially the ordering constraints of each gadget are independent from those in other gadgets. The framing edges of the decision units can be placed on a hor- izontal and a vertical line near the borders of the drawing. The literal edges in the decision units correspond to the literals in the decision unit’s clause. We then place a variable path (e(b1), . . . , e(bn)) on the diagonal of the drawing with n edges corresponding to the n variables in B. We add a positive and a negative link between each literal edge and the edge in the variable path corresponding to the same variable. Figure 4.4 shows a union of paths for the instance I with C = (x x xn),C = (x xn− xn),C = (x x xn),C = (x x xn− ). 1 1 ∨ 2 ∨ 2 2 ∨ 1 ∨ 3 1 ∨ 2 ∨ 4 1 ∨ 2 ∨ 1 4.1. Rectilinear Drawings 59

Lemma 14. If the union of paths has a valid drawing, I is satisfiable.

Proof. Because of the links all edges corresponding to the same variable are drawn alike. We set a variable true if the corresponding edges are drawn hori- zontally and false if they are drawn vertically such that for a valid drawing all clauses are satisfied.

Lemma 15. If I is satisfiable, the union of paths has a valid drawing.

Proof. We draw all edges corresponding to a true variable horizontally and all edges corresponding to a false variable vertically. Since there is a true literal in any clause, a valid drawing for each decision units is induced.

4.1.2 Single Path Theorem 11. The orthogonal-order preserving rectilinear drawing problem is -hard for paths. NP To show -hardness also for paths we must connect the union of paths constructed inNP Sect. 4.1.1. We must add edges that do not have any effect on the drawability. We start with horizontal and vertical edges connecting the decision units and the links for different decision units (see Fig. 4.6). They have no effect on the drawability because edges which are already horizontal or vertical cannot pull other edges. Additionally, the horizontal and vertical edges we add do not lie in the range of any edge not yet horizontal or vertical and therefore cannot push other edges. Links belonging to the same decision unit are also connected, but as con- nections might lie within the range of edges in the variable path, we can not 0 0 use edges already horizontal or vertical. For two incident edges ei and ej in one decision unit and edges ei and ej in the variable path corresponding to the same variables, let li and lj be the positive links. For ei and ej not incident, let lc be 0 0 connecting the positive links. Figure 4.5 shows that even if ei and ej are drawn alike, edges lying between ei and ej in the variable path can be drawn in either direction.

Lemma 16. The connected path is drawable if and only if the union of paths was drawable.

Proof. The edges we used have a valid drawing, if the union of paths was draw- able. On the other hand, the edges in the union of paths are also kept in the connected path. Hence, if the union of paths had not been drawable, the path is not drawable. 60 Chapter 4. Ordering

(a) before (b) lc horizontal (c) ei . . . ej vertical

Figure 4.5: lc is connecting li and lj

Figure 4.6: Single path for the instance I 4.1. Rectilinear Drawings 61

4.1.3 Totally Ordered Vertices

Different vertices having the same x1- or x2- coordinates are very restrictive if the task is to preserve the orthogonal order of vertices. If we further request that planarity is to be preserved, we can prove hardness also for unions of paths and paths with totally ordered vertices, i. e., no two vertices have the same x1- or x2-coordinates. A framing edge of a horizontal decision unit is horizontal, but we can replace it with a pair eh and ef of incident edges as shown in Fig. 4.7(a). ef lies in the x1-range of eh and eh in the x2-range of ef such that the only possibility for avoiding intersections is to draw eh horizontally and ef vertically. Since eh must be drawn horizontally, at least one of the literal edges in the decision unit also must be drawn horizontally. In order to prevent ef from pulling any other edge vertically, we place ef ’s vertex that is not incident to eh such that no vertex lies in the x1-range of ef . Because the framing edges of the decision units are placed near the borders of the drawing, we can easily guarantee that ef does not lie in the x2-range of any other edge, and thus cannot push other edges vertically. The strategy for the vertical decision units is the same and shown in Fig. 4.7(b). We also make sure that no two vertices of different positive links for the same edge in the variable path lie on the same vertical line, for example by making each positive link shorter than the one above it (likewise for negative links). Finally we have a union of paths with totally ordered vertices that is drawable if and only if I is satisfiable. (See Fig. 4.8(a)). For connecting the edges of the union of paths with totally ordered vertices we might also use edges that are not yet but can be drawn horizontally (or vertically) in the resulting path since there are no vertices within their x1- (or x2-ranges).

(a) eh and ef (b) ev and ef

Figure 4.7: Decision units without horizontal or vertical edges 62 Chapter 4. Ordering

(a) union of paths

(b) single path

Figure 4.8: Avoiding horizontal or vertical edges 4.2. Octilinear Drawings 63

e' e

Figure 4.9: Dependency of edges

4.2 Octilinear Drawings

Orthogonal-order preserving octilinear drawing problem: Given a plane graph, we want to decide whether we can draw each edge either horizontally, vertically or diagonally at 45◦, without changing the horizontal or the vertical order of vertices while± keeping all edge lengths positive.

While in the rectilinear model (except for the generalization to total orders) we could arrange all necessary edge dependencies without requiring that pla- narity is to be preserved, in the octilinear model we need this restriction. For two incident edges e and e0 with e0 lying within both the x- and y-range of e we have to draw e diagonally to prevent e and e0 from overlapping (see Fig. 4.9). For the path segments that will represent the 3-SAT clauses, we also use the fact that for diagonal edges, their x1- and x2-range have the same size. Figure 4.10(a) shows a path with three edges e1, e2, e3 that can be drawn either horizontally or diagonally and edges e4...e12 with only one possible direction because of their relative position. The edge e7 must be drawn horizontally. Let the length of e7 be δ. The path (e1, e2, e3) must have hight 2δ (the hight of (e5, e6)) and width δ (the width of e12). Therefore one edge from (e1, e2, e3) must be drawn horizontally. We use this path to represent a clause with only non-negated literals. Again, we call the edges e1, e2 and e3 literal edges, the others framing edges and the whole path horizontal decision path .A vertical decision path to represent a clause with only negated variables is constructed analogously. (See Fig. 4.10(b).)

4.2.1 Unions of Paths We now use the described edge-dependency elements to create a union of paths for a given instance of MONOTONE 3-SAT to prove the following theorem:

Theorem 12. The orthogonal-order preserving octilinear drawing problem is -hard for unions of paths if planarity is to be preserved. NP 64 Chapter 4. Ordering

(a) horizontal decision path (b) vertical decision path

Figure 4.10: Decision paths

The construction of a union of paths for a given instance I of MONOTONE 3-SAT is similar to Sect. 4.1.1. Different is that we do not use a variable path, but connect the decision paths directly using only positive links. We add a positive link between each literal edge in a horizontal decision path and any literal edge in a vertical decision path corresponding to the same variable. Lemma 17. If there is a valid drawing for the union of paths, I is satisfiable. Proof. In a valid drawing there is no edge drawn horizontally in a horizontal decision path that is linked to an edge drawn vertically in a vertical decision path. We set the variable corresponding to an edge horizontal in a horizontal decision path true and to an edge vertical in a vertical decision path false. With this all clauses are satisfied and the other variables can be set arbitrarily. Lemma 18. If I is satisfiable, the union of paths has a valid drawing. Proof. For a given assignment that satisfies I we can create a valid drawing as follows: For each positive clause, we choose one of the variables set true and draw the corresponding edge in the corresponding decision path horizontally. The other literal edges in this decision path we draw diagonally. From each negative clause we also choose one variable set false and draw the corresponding edge in the corresponding decision path vertically and the other literal edges diagonally. Now all decision paths have a valid drawing. As an edge drawn vertically in a vertical decision path can not correspond to a true variable it can not be linked to an edge drawn horizontally in a horizontal decision path. Hence, the linked edge is drawn diagonally and the link can be drawn vertically. Analogous for horizontal edges in horizontal decision paths. We draw a link horizontally, if the variable corresponding to the linked edges is true and vertically if it is false. 4.2. Octilinear Drawings 65

Figure 4.11: Union of paths for a MONOTONE 3-SAT-instance I

4.2.2 Single Path

Theorem 13. The orthogonal-order preserving octilinear drawing problem is -hard for paths if planarity is to be preserved. NP

Connecting the union of paths to a single path can be done analogous to the strategy in the rectilinear model. Figure 4.12 shows a single path that has a valid octilinear drawing if and only if I is satisfiable.

4.2.3 Totally Ordered Vertices

Figure 4.13(a) shows a horizontal decision path without vertices having the same x1- or x2-coordinates. For δ being the length of e7 still the path (e1e2e3) can have at least hight 2δ and at most length δ.A vertical decision path to represent a clause with only negated variables is constructed analogously (see Fig. 4.13(b).) Replacing the decision paths we can find a union of paths as well as a single path with totally ordered vertices that is drawable if and only if I is satisfiable. 66 Chapter 4. Ordering

Figure 4.12: Single path for the instance I

(a) horizontal decision path (b) vertical decision path

Figure 4.13: Decision paths with totally ordered vertices 4.3. Drawings with Uniform Edge Lengths 67

Figure 4.14: ei forcing ej

e 3 e 2 e 1

Figure 4.15: Horizontal decision unit

4.3 Drawings with Uniform Edge Lengths

Orthogonal-order preserving equal edge lengths drawing problem: Given a graph in the plane, we want to decide whether we can draw each edge with length 1 changing neither the horizontal nor the vertical order of the edges’ vertices.

The constraint that all edges have equal length, w.l.o.g. length 1, may also be exploited to force some of them to be drawn horizontally or vertically. We can use the concept of linking edges like in the previous sections. Edge ei in Fig. 4.14 forces ej to be drawn horizontally because otherwise ej would not be short enough to have the same length as ei. We can also define decision units. In the example in Fig. 4.15 the path P = (e1, e2, e3) of literal edges must have length 3 and the only possibility of achieving this is to draw the framing edges horizontally and vertically to give the path the room of a 1 2-rectangle in which × the longest possible path monotone in x1- and x2- direction has length 3. It is easy to see that one edge of P must be drawn horizontally and the other two edges vertically.

Let a horizontal decision unit be a 3-edge-path monotone in x1- and x2- direction contained within a 1 2-rectangle while a vertical decision unit is × also a 3-edge-path monotone in x1- and x2- direction, but contained within a 2 1-rectangle. × 68 Chapter 4. Ordering

Figure 4.16: The union of paths for the instance I from Sect. 4.1.1

4.3.1 Unions of Paths We now use these edge-dependency elements to create a gadget for a given instance of MONOTONE 3-SAT to prove the following theorem: Theorem 14. The orthogonal-order preserving equal edge lengths drawing prob- lem is -hard for unions of paths. NP The proof is analogous to Sect. 4.2.1. Figure 4.16 shows a union of paths that has a valid drawing if and only if I is satisfiable.

4.3.2 Single Path Theorem 15. The orthogonal-order preserving equal edge lengths drawing prob- lem is -hard for paths. NP Connecting the gadgets to show -hardness also for paths is a little bit more complicated then in the previousNP models. The total lengths of the path- segments connecting the gadgets for the clauses and links are restricted by their count of edges, while the gadgets itself may slightly change their relative position for different direction assignments for the neighbored edges (see Fig. 4.17). We will use path-segments that have flexible rages-sizes to counterbalance this. 4.3. Drawings with Uniform Edge Lengths 69

(a) (b) (c)

Figure 4.17: Difference in relative position

copy

intraclause copy links

(a) basic situation (b) total ordering

Figure 4.18: Intraclause links

To reduce the number of cases, we copy the decision units such that each copy has exactly one link to one copy of another decision unit. The copies are placed diagonally next to each other and linked such that each copy has to be drawn equally (see Fig. 4.18). Figure 4.19 shows one example for two decision units, the corresponding link and a connector that can be used to connect gadgets lying above or under these decision units. The initial situation is shown in Fig. 4.19(a). Figure 4.19(b) and 4.19(c) show how the connecting path-segments adapt for the different relative positions of the decision units and the link. The connected path is drawable if and only if the union of paths was drawable. The orthogonal-order preserving equal edge lengths drawing problem is -hard also for paths. Totally ordered vertices can be achieved analogously toNP the strategy in the previous sections. 70 Chapter 4. Ordering

(a)

(b) (c)

Figure 4.19: Flexible connection Chapter 5

Directions

The trajectory drawing problem (TDP) generalizes and unifies several well-known others. The input consists of a set of paths, called trajectories, and the task is to determine a (straight-line) drawing such that each trajectory has a certain shape.1 Here we consider versions of the following natural shape requirement: Definition 1 (Strictly Monotone Trajectory Drawing Problem). Given a set of vertices V and a set of paths P where each path is a sequence of vertices in V . Find geometric positions for the vertices such that each path is strictly monotone increasing in some direction. Note that strict monotonicity excludes the degenerate solution with all ver- tices in the same position. It also implies that paths do not self-intersect, so that the problem is related to simultaneous graph drawing (Brass, Cenek, Dun- can, Efrat, Erten, Ismailescu, Kobourov, Lubiw, and Mitchell, 2003). While it is more general by allowing partial paths, it is more restrictive because of the direction requirement. The problem reduces to acyclicity testing if only one direction is allowed. However, it is already -hard for two opposing directions (or, equivalently, if a subset of the paths mayNP be reversed), even for paths of length two (Opatrny, 1979). One might hope that more dimensions and additional directions ease the problem, but we will show that this is not the case. An important special case is known as internal preference scaling (a vari- ation of matrix biplots (Gabriel, 1971)), where all paths are Hamiltonian and represent complete rankings of individual preferences among a set of items. The typical approach here consists of rank-two approximations of the subject-by-item matrix of ranks using singular value decomposition. While many variations of

1The problem originates from the Dagstuhl Seminar 08191, where it was formulated to- gether with Stephen G. Kobourov, Anna Lubiw, and Dorothea Wagner in response to a chal- lenge from Stephen P. Borgatti. We thank all of them for their valuable input. 72 Chapter 5. Directions the problem have been studied (for an overview see, e.g., Heiser and de Leeuw (1981)), we are unaware of the status of the decision problem. One may also be reminded of the dimensionality problem for partial orders (which can be decided in polynomial time for one or two dimensions, but is hard for three or more (Yannakakis, 1982)), but we could not establish any relevant correlation. Furthermore, the TDP is closely related to drawing monotone supports for hypergraphs (Sect. 6.1.1). We prove that the TDP is -hard for the practical cases in which admis- sible directions are either the coordinateNP axes or unrestricted in two, three or d dimensions. Interesting variants of the problem include restriction to pairwise linearly independent directions and more general shapes. For instance, in the unimodal TDP, paths have to be drawn such that a prefix is strictly increasing and the remaining postfix is strictly decreasing along some direction, where pre- and postfix may be empty. The corresponding ordering problem for one direction can be decided in linear time (Kosub, Maaß, and T¨aubig,2006).

5.1 General Idea

We use reductions from 3-SAT similar to the one by Opatrny (1979). For each instance of 3-SAT we determine a set of trajectories (with vertices representing variables and literals) that is drawable if and only if the instance is satisfiable. We start with anchor vertices, the relative position of which will define two dis- joint regions that are interpreted as true and false. With the help of anchor paths every other vertex will have to lie in one of these regions with a corre- sponding truth assignment. Consistency with the 3-SAT instance is ensured by the addition of clause paths and variable paths.

5.2 Axis-Parallel Directions

5.2.1 Hardness in 2D Theorem 16. The axis-parallel strictly monotone trajectory drawing problem is -hard in two dimensions, even for paths of length two. NP

We start with the anchor vertices c1 and c2. We assume w.l.o.g. that x1(c1) x (c ) and x (c ) x (c ). For any vertex v two anchor paths (c c v) and≤ 1 2 2 1 ≤ 2 2 1 2 (c1vc2) can only be strictly monotone if x1(c1) < x1(c2), x2(c1) < x2(c2) and either x1(c2) < x1(v) and x2(c1) < x2(v) < x2(c2) or x1(c1) < x1(v) < x1(c2) and x2(c2) < x2(v) (see Fig. 5.1(a)). These two possibilities define two separate 5.2. Axis-Parallel Directions 73

(a) separate regions (b) l3 true

Figure 5.1: Anchor and clause paths

regions. We insert a vertex t with anchor paths (c1c2t) and (c1tc2) and call the region where t is placed true and the other one false. Let I = (V,C) be an instance of 3-SAT. For each variable we insert a vertex v and the corresponding anchor paths, and say it is true if it lies in the region 0 0 true and false otherwise. For any two vertices v and v in a path (vc2v ) strictly monotone in one of the directions (here also in both directions) v and v0 must lie 0 0 in different regions. For any strictly monotone path (vv c2) the vertices v and v must lie in the same region. For each clause we insert three vertices (l1, l2) and l3 for the literals. If a literal (with vertex l) is a negated variable (with vertex v) we add a variable path (lc2v) such that v and l lie in different regions. If a literal (with vertex l) is a non negated variable (with vertex v), we add a variable path (c2lv) to make v and l lie in the same region. We insert two vertices o1 and o2 representing the ORs with clause paths (c2o2t), (l1o1l2) and (o1o2l3). Lemma 19. For each clause, at least one literal vertex is true.

Proof. With (c2o2t) strictly monotone, the vertex o2 must be true. If both l1 and l2 are false, with (l1o1l2) strictly monotone, o1 is false and l3 must be true to make (o1o2l3) strictly monotone as well (see Fig. 5.1(b)).

Corollary 3. I is satisfiable if the set of paths is drawable with each path strictly monotone in at least one direction. Lemma 20. If I is satisfiable, there is a valid drawing for the set of paths. Proof. For a given assignment that satisfies I, we can draw the set of paths as follows: We first place the vertices for each clause. 74 Chapter 5. Directions

If all literals are true, we place the vertices l , l , l , o , o and t with • 1 2 3 1 2 x1(c2) < x1(l3) < x1(o2) < x1(l2) < x1(o1) < x1(l1) < x1(t) and

x2(c1) < x2(l3), x2(o2), x2(l2), x2(o1), x2(l1), x2(t) < x2(c2)

If the first two literals are true and the third false, • x1(c1) < x1(l3) < x1(c2) < x1(o2) < x1(l2) < x1(o1) < x1(l1) < x1(t) and

x2(c1) < x2(o2), x2(l2), x2(o1), x2(l1), x2(t) < x2(c2) < x2(l3).

If the first literal is true and the others false, • x1(c1) < x1(l3) < x1(l2) < x1(c2) < x1(o2) < x1(o1) < x1(l1) < x1(t) and

x2(c1) < x2(o2), x2(o1), x2(l1), x2(t) < x2(c2) < x2(l3), x2(l2).

If the first two literals are false, which makes the third be true (Fig. 5.1(b)), • x1(c1) < x1(l1) < x1(o1) < x1(l2) < x1(c2) < x1(o2) < x1(l3) < x1(t) and

x2(c1) < x2(l3), x2(o2), x2(t) < x2(c2) < x2(l2), x2(o1), x2(l1).

If the first literal is false and the others true, • x1(c1) < x1(l1) < x1(c2) < x1(o1) < x1(l2) < x1(o2) < x1(l3) < x1(t) and

x2(c1) < x2(l3), x2(o2), x2(l2), x2(o1), x2(t) < x2(c2) < x2(l1).

The remaining cases are analogous. • Then we place each vertex v of a true variable such that x1(c2) < x1(l) < x1(v) and x2(c1) < x2(v) < x2(l) < x2(c2) for each literal l that is the non-negated variable v and 0 0 x1(c1) < x1(l ) < x1(c2) < x1(v) and x2(c1) < x2(v) < x2(c2) < x2(l ) for each literal l0 that is the negated variable v. For a false variable we place the vertex v such that x1(c1) < x1(v) < x1(l) < x1(c2) and x2(c2) < x2(l) < x2(v) for each literal l that is the non-negated variable v and 0 0 x1(c1) < x1(v) < x1(c2) < x1(l ) and x2(c1) < x2(l ) < x2(c2) < x2(v) for each literal l0 that is the negated variable v. This makes all added clause and variable paths strictly monotone in the x1-direction. 5.2. Axis-Parallel Directions 75

Figure 5.2: Placement of c1, c2 and c3

5.2.2 Hardness in 3D Theorem 17. The axis-parallel strictly monotone trajectory drawing problem is -hard in three dimensions, even for paths of length two. NP

For three vertices anchor c1, c2 and c3 the paths P1 = (c1c2c3), P2 = (c2c3c1) and P3 = (c2c1c3) can only be strictly monotone if each is strictly monotone in a different direction. We assume w.l.o.g. that x1(c1) < x1(c2) < x1(c3), x2(c2) < x2(c3) < x2(c1) and x3(c2) < x3(c1) < x3(c3) (see Fig. 5.2).

Lemma 21. For any v and paths (c2c1v), (c2vc1), (c3c1v), (c3vc1), (c1c2v) and (c3c2v) the vertex v must lie in one of two separate regions. More precisely it must be that either x1(c1) < x1(v) < x1(c2), x2(c1) < x2(v) and x3(v) < x3(c2) or x1(v) < x1(c1), x2(c3) < x2(v) < x2(c1) and x3(v) < x3(c2).

Proof. Suppose x3(c2) < x3(v). To make both (c1c2v) and (c3c2v) strictly mono- tone, it must be x2(v) < x2(c2) and none of the other paths can be strictly monotone in x2-direction. But with this, v has to be placed such that either x1(v) < x1(c1) and x3(c2) < x3(v) < x3(c1) or x1(c1) < x1(v) < x1(c2) and x3(c1) < x3(v) in order to make (c2c1v) and (c2vc1) strictly monotone, however either x1(v) < x1(c1) and x3(c1) < x3(v) < x3(c3) or x1(c1) < x1(v) < x1(c3) and x3(v) < x3(c1) in order to make (c3c1v) and (c3vc1) strictly monotone. These pos- sible placements exclude each other, so it is x3(v) < x3(c2). With x3(v) < x3(c2), none of the paths (c2c1v), (c2vc1), and (c3vc1) can be strictly monotone in the x3-direction, so it must be either x1(c1) < x1(v) < x1(c2) and x2(c1) < x2(v) or x1(v) < x1(c1) and x2(c3) < x2(v) < x2(c1).

We insert a vertex t with its anchor paths and call the region where it is placed true and the other one false. Let I be an instance of 3-SAT. For each variable we insert a vertex v with the corresponding anchor paths. For each clause we insert vertices l1, l2 and l3 for the literals and o1, o2 representing the ORs. We need to add more paths than in the 2-D case. For each literal (with vertex l) that is a 76 Chapter 5. Directions

Figure 5.3: l1 and l2 false, l3 true

negated variable with (vertex v), it is sufficient to add the path (lc1v) to make them lie in different regions because with x3(l), x3(v) < x3(c2) < x3(c1), the path (lc1v) can not be strictly monotone in the x3-direction. For each literal (with vertex l) that is a non-negated variable with (vertex v) we add paths (c1lv) and (c1vl). Only one of those two paths can be strictly monotone in the x3-direction, thus l and v lie in the same region. For each clause we also add paths (l1o1l2), (c1o1l1), (c1o1l2), (c1o2t), (c1to2), (c1o1o2), (o1o2l3) and (c1l3o2).

Lemma 22. For each clause at least one literal vertex is true.

Proof. For all vertices, the x3-coordinate is smaller than x3(c2), x3(c1) and x3(c3). Figure 5.3 shows a perpendicular projection of one set of valid positions for the vertices onto the x1x2-plane. Suppose l1 and l2 are both false. If (l1o1l2) is strictly monotone in the x1- or x2-direction, o1 is also false. If (l1o1l2) is strictly monotone in the x3-direction, only one of the paths (c1o1l1) and (c1o1l2) can be as well. With this, o1 must be in the same region as either l1 or l2, thus o1 is also false. At most one of the paths (c1o2t) and (c1to2) can be strictly monotone in the x3-direction, thus o2 is true. If o1 is false, o1 and o2 lie in different regions and (c1o1o2) must be strictly monotone in the x3-direction. Only one of the paths (o1o2l3) and (c1l3o2) can be monotone in the x3-direction as well, which makes o2 and l3 lie in the same region and l3 be true.

Corollary 4. I is satisfiable if the set of paths is drawable with each path strictly monotone in at least one direction.

Lemma 23. If I is satisfiable, there is a valid drawing for the set of paths.

Proof. For a given assignment that satisfies I, we can draw the set of paths as follows: We first place the vertices for each clause. 5.2. Axis-Parallel Directions 77

If all literals are true, we place the vertices l , l , l , o , o and t with • 1 2 3 1 2 x1(c1) < x1(l3) < x1(o2) < x1(l2) < x1(o1) < x1(l1) < x1(t) < x1(c2),

x2(c1) < x2(l3), x2(t) < x2(o2), x2(l1), x2(o1) < x2(l2) and

x3(t) < x3(l1), x3(l2), x3(l3), x3(o2) < x3(o1) < x3(c2) < x3(c1).

The paths (l1o1l2), (c1o1l1), (c1o2t), (o1o2l3) and (c1l3o2) are strictly mono- tone in the x1-direction, (c1o1l2) and (c1to2) are strictly monotone in the x2-direction and (c1o1o2) is strictly monotone in the x3-direction. If the first two literals are true and the third false, • x1(l3) < x1(c1) < x1(o2) < x1(l2) < x1(o1) < x1(l1) < x1(t) < x1(c2),

x2(c3) < x2(l3) < x2(c1) < x2(t) < x2(o2), x2(l1), x2(o1) < x2(l2) and

x3(t) < x3(l1), x3(l2), x3(o2) < x3(l3) < x3(o1) < x3(c2) < x3(c1).

The paths (l1o1l2), (c1o1l1), (c1o2t) and (o1o2l3) are strictly monotone in the x1-direction, (c1o1l2) and (c1to2) are strictly monotone in the x2-direction and (c1o1o2) and (c1l3o2) are strictly monotone in the x3-direction. If the first literal is true and the others false, • x1(l3) < x1(l2) < x1(c1) < x1(o2) < x1(o1) < x1(l1) < x1(t) < x1(c2),

x2(c3) < x2(l3) < x2(l2) < x2(c1) < x2(t) < x2(o2), x2(l1), x2(o1) and

x3(t) < x3(l2) < x3(l1), x3(o2) < x3(l3) < x3(o1) < x3(c2) < x3(c1).

The paths (l1o1l2), (c1o1l1), (c1o2t) and (o1o2l3) are strictly monotone in the x1-direction, (c1to2) is strictly monotone in the x2-direction and (c1o1l2), (c1o1o2) and (c1l3o2) are strictly monotone in the x3-direction. If the first two literals are false, which makes the third be true (Fig. 5.3, • x1(l1) < x1(o1) < x1(l2) < x1(c1) < x1(o2) < x1(l3) < x1(t) < x1(c2),

x2(c3) < x2(l2) < x2(o1) < x2(l1) < x2(c1) < x2(l3) < x2(t) < x2(o2) and

x3(l2) < x3(o2) < x3(o1) < x3(l1), x3(l3), x3(t) < x3(c2) < x3(c1).

The paths (l1o1l2), (c1o1l1), (c1o2t) and (o1o2l3) are strictly monotone in the x1-direction, (c1o1l2), (c1to2) and (c1l3o2) are strictly monotone in the x2-direction and (c1o1o2) is strictly monotone in the x3-direction. If the first literal is false, the others true, • x1(l1) < x1(o1) < x1(c1) < x1(o2) < x1(l3) < x1(t) < x1(l2) < x1(c2),

x2(c3) < x2(o1) < x2(l1) < x2(c1) < x2(l2) < x2(l3) < x2(t) < x2(o2) and

x3(l2) < x3(o2) < x3(o1) < x3(l1), x3(l3), x3(t) < x3(c2) < x3(c1). 78 Chapter 5. Directions

The paths (l1o1l2), (c1o1l1), (c1o2t) and (o1o2l3) are strictly monotone in the x1-direction, (c1to2) and (c1l3o2) are strictly monotone in the x2-direction and (c1o1o2) and (c1o1l2) are strictly monotone in the x3-direction. The remaining cases are analogous. • Then we place each vertex v of a true variable such that x1(c1) < x1(l) < x1(v) < x1(c2), x2(c1) < x2(v) < x2(l) and x3(v), x3(l) < x3(c2) for each literal l that is the non-negated variable v and 0 x1(l ) < x1(c1) < x1(v), 0 x2(c3) < x2(l ) < x2(c1) < x2(v) and x3(v), x3(l) < x3(c2) for each literal l0 that is the negated variable v. For a false variable we place the vertex v such that x1(v) < x1(l) < x1(c1), x2(c3) < x2(l) < x2(v) < x2(c1) and x3(v), x3(l) < x3(c2) for each literal l that is the non-negated variable v and 0 x1(v) < x1(c1) < x1(l ), 0 x2(c3) < x2(v) < x2(c1) < x2(l ) and x3(v), x3(l) < x3(c2) for each literal l0 that is the negated variable v.

5.2.3 Hardness in dD Theorem 18. The axis-parallel strictly monotone trajectory drawing problem is -hard in d dimensions, even for paths of length d. NP For d vertices c1 . . . cd the paths Pi = (cici+1 mod dci+2 mod d . . . ci+d−1 mod d) for 1 i d can only be all strictly monotone if each is strictly monotone ≤ ≤ in a different direction. We assume w.l.o.g. that Pi is strictly monotone in the xi-direction with xi(ci) < xi(cj) for i = j. For any vertex v the anchor 6 paths (vc1c2 . . . cd−1) and (c1vc2 . . . cd−1) which can only be strictly monotone in the x1- and in the xd-direction. Thus for v it is either x1(v) < x1(c1) and xd(c1) < xd(v) < xd(c2) or x1(c1) < x1(v) < x1(c2) and xd(v) < xd(c1). We insert a vertex t with corresponding anchor paths and call the region where it will be placed true and the other one false. Let I be an instance of 3-SAT. For each variable, we insert a vertex v with the corresponding anchor paths. For each clause, we insert vertices l1, l2 and l3 for the literals and o1, o2 representing the ORs. For each literal (with vertex l) that 5.2. Axis-Parallel Directions 79

is a negated variable (with vertex v), we add the variable path (lc1vc2 . . . cd−1) to make them lie in different regions, because the path can only be strictly monotone in the x1- or the xd-direction. For each literal (with vertex l) that is a not-negated variable (with vertex v), we add a variable path (c1lvc2 . . . cd−1) such that l and v lie in the same region. For each clause, we add clause paths (l1o1l2c2 . . . cd−1), (l2o1l1c2 . . . cd−1), (c1o2tc2 . . . cd−1), (o1o2l3c2 . . . cd−1) and (l3o2o1c2 . . . cd−1).

Lemma 24. For each clause at least one literal vertex is true.

Proof. The paths (l1o1l2c2 . . . cd−1) and (l2o1l1c2 . . . cd−1) can only be strictly monotone in the x1-, the x2- or the xd-direction, so at least one must be strictly monotone in the x1- or the xd-direction and o1 must be false if both l1 and l2 are false. Therefore the paths (c1o2tc2 . . . cd−1), (o1o2l3c2 . . . cd−1) and (l3o2o1c2 . . . cd−1) can only be strictly monotone in the x1- or the xd- direction. Thus o2 is true and l3 is true if o1 is false.

Corollary 5. I is satisfiable if the set of paths is drawable with each path being strictly monotone in at least one direction.

Lemma 25. If I is satisfiable there is a valid drawing for the set of paths.

Proof. For a given assignment that satisfies I we can draw the set of paths as follows: We first place the vertices for each clause.

If all literals are true, we place the vertices l , l , l , o , o and t with • 1 2 3 1 2 x1(c1) < x1(l3) < x1(o2) < x1(l2) < x1(o1) < x1(l1) < x1(t) < x1(c2) and

xd(l1) < xd(o1) < xd(l2) < xd(o2) < xd(l3) < xd(t) < xd(c1) < xd(c2).

If the first two literals are true and the third false, • x1(l3) < x1(c1) < x1(o2) < x1(l2) < x1(o1) < x1(l1) < x1(t) < x1(c2) and

xd(l1) < xd(o1) < xd(l2) < xd(o2) < xd(t) < xd(c1) < xd(l3) < xd(c2).

If the first literal is true and the others false, • x1(l3) < x1(l2) < x1(c1) < x1(o2) < x1(o1) < x1(l1) < x1(t) < x1(c2) and

xd(l1) < xd(o1) < xd(o2) < xd(t) < xd(c1) < xd(l2) < xd(l3) < xd(c2).

In these three cases (l2o1l1c2 . . . cd−1), (c1o2tc2 . . . cd−1) and (l3o2o1c2 . . . cd−1) are strictly monotone in the x1-direction and (l1o1l2c2 . . . cd−1) and (o1o2l3c2 . . . cd−1) in the xd-direction. 80 Chapter 5. Directions

If the first two literals are false, which makes the third be true, • x1(l2) < x1(o1) < x1(l1) < x1(c1) < x1(o2) < x1(l3) < x1(t) < x1(c2) and

xd(l3) < xd(o2) < xd(t) < xd(c1) < xd(l1) < xd(o1) < xd(l2) < xd(c2).

This makes (l2o1l1c2 . . . cd−1), (c1o2tc2 . . . cd−1) and (o1o2l3c2 . . . cd−1) strictly monotone in the x -direction and (l o l c . . . cd− ) and (l o o c . . . cd 1) 1 1 1 2 2 1 3 2 1 2 − in the xd-direction.

If the first literal is false and the others are true, • x1(l2) < x1(o1) < x1(c1) < x1(l1) < x1(o2) < x1(l3) < x1(t) < x1(c2) and

xd(l3) < xd(o2) < xd(t) < xd(l1) < xd(c1) < xd(o1) < xd(l2) < xd(c2).

This makes (l2o1l1c2 . . . cd−1), (c1o2tc2 . . . cd−1) and (o1o2l3c2 . . . cd−1) strictly monotone in the x1-direction and (l1o1l2c2 . . . cd−1) and (l3o2o1c2 . . . cd−1) in the xd-direction.

The remaining cases are analogous. • Then we place each vertex v of a true variable such that x1(c1) < x1(l) < x1(v) < x1(c2) and xd(l) < xd(v) < xd(c1) for each literal l that is the non-negated variable v and 0 0 x1(l ) < x1(c1) < x1(v) < x1(c2) and xd(v) < xd(c1) < xd(l ) < xd(c2) for each literal l0 that is the negated variable v. For a false variable we place the vertex v such that x1(l) < x1(v) < x1(c1) and xd(c1) < xd(l) < xd(v) < xd(c2) for each literal l that is the non-negated variable v and 0 0 x1(v) < x1(c1) < x1(l ) < x1(c2) and xd(l ) < xd(c1) < xd(v) < xd(c2) for each literal l0 that is the negated variable v. We can choose the other coordinates arbitrarily.

5.3 Arbitrary directions

5.3.1 Hardness in 2D Theorem 19. The strictly monotone trajectory drawing problem is -hard in two dimensions, even for paths of length three. NP

We use a necessary and sufficient condition for two different paths on a set of four vertices to each be strictly monotone increasing in some direction. For a vertex v in a path P strictly monotone in some direction a there is a line l through v (perpendicular to a) such that the vertices of the different parts of 5.3. Arbitrary directions 81

P (separated by v) are on different sides of l. Given four vertices c1, c2, v and v and the anchor paths P1 = (vc1c2v) and P2 = (vc2c1v). A line through ci perpendicular to a possible direction for a path Pj is denoted by lij. A line l11 must have v and c2 on different sides so the set of possible lines for l11 is bounded by the lines through c1 and v and through c1 and c2. We call this set of lines I11. Other sets Iij are defined analogously.

Lemma 26 (necessity). The vertices v and v must lie on different sides of a line through c1 and c2.

Proof. The three vertices c1, c2 and v (v) can not be collinear since they can not be ordered such that there is both a line l1 through c1 and a line l2 through c2 with l1 having v (v) and c1 and l2 having v (v) and c2 on different sides. For P1 being strictly monotone in some direction there must be a line from I21 having v and v on different sides and for P2 being strictly monotone in some direction there must be a line from I12 having v and v on different sides. This does not leave any position for v on the same side of the line through c1 and c2 as v.

Lemma 27 (sufficiency). If the vertices v and v lie on different sides of a line through c1 and c2, each path is strictly monotone increasing in some direction.

Proof. Both I21 and I12 are bounded by the line through c1 and c2. Hence, for any position of v with v and v on different sides of the line through c1 and c2 there is a line from I21 and a line from I12 both having v and v on different sides.

We start with vertices c1, c2, t and f and anchor paths (tc1c2f) and (tc2c1f). The line through c1 and c2 divides the plane into two sides. The vertices t and f must be placed on different sides (Lemma 26) and we call the side on which t is placed true and the other one false. We say a vertex is true if it lies on the same side as t. Let I = (V,C) be an instance of 3-SAT. For each variable we insert vertices v and v and the anchor paths (vc1c2v) and (vc2c1v). We say the variable is true if v is true and false otherwise. For each clause we insert vertices l1, l1, l2, l2, l3 and l3 for the literals together with the corresponding anchor paths (lic1c2li) and (lic2c1li) for i = 1, 2, 3 to make li and li lie on different sides of the line c1c2. If a literal (with vertices l and l) is a negated variable (with vertices v and v), we add variable paths (lc1c2v) and (lc2c1v) such that l and v lie on different sides, otherwise we add variable paths (lclc2v) and (lc2clv) to make v and l lie on the same side. We insert vertices o1 and o2 representing the ORs. We add clause paths (fc1c2o2) and (fc2c1o2) to make o2 true. 82 Chapter 5. Directions

Figure 5.4: l1 and l2 are false, which makes l3 true.

To guarantee that o1 is false if both l1 and l2 are false, we first add vertices 0 0 0 0 0 0 l1 and l2 and clause paths (l2l1c2l2), (l2c2l1l2) and (l1l2c2l1), (l1c2l2l1) such that 0 0 l2 and l2 lie on different sides of the line through l1 and c2 and that l1 and l1 lie 0 on different sides of the line through l2 and c2. Adding clause paths (o1l1c2l2), 0 0 0 (o1c2l1l2) and (o1l2c2l1), (o1c2l2l1) the vertex o1 must lie between the halfline from c2 through l1 and the halfline from c2 through l2. With the same argument we make o2 lie between the halfline from c2 through l3 and the halfline from 0 0 0 c2 through o1 by adding the vertices l3 and o1 and the clause paths (l3o1c2l3), 0 0 0 0 0 0 (l3c2o1l3) and (o1l3c2o1), (o1c2l3o1) as well as (o2o1c2l3), (o2c2o1l3) and (o2l3c2o1), 0 (o2c2l3o1). See Fig. 5.4 for an illustration. Lemma 28. For each clause at least one literal vertex is true.

Proof. If l1 and l2 are false, o1 is also false. With o2 being true and lying between the halflines from c2 through l3 and from c2 through o1, l3 must also be true. Corollary 6. I is satisfiable if the set of paths is drawable with each path strictly monotone in some direction. Lemma 29. If I is satisfiable there is a valid drawing for the set of paths. Proof. For a given assignment that satisfies I, we can draw the set of paths as follows: We place c and c with x (c ), x (c ) = 0, x (c ) = 0 and x (c ) = 0. 1 2 1 1 1 2 2 1 2 2 6 All other vertices we place on the x1-axis: If all literals are true, • 0 0 x1(f) < x1(c1), x1(c2) < x1(o1) < x1(l3) < x1(o2) < x1(l1) < x1(l2) < 0 0 x1(o1) < x1(l3) < x1(l1) < x1(l2) < x1(t). If the first two literals are true and the third false, • 0 0 x1(f) < x1(o1) < x1(l3) < x1(c1), x1(c2) < x1(o2) < x1(l1) < x1(l2) < 0 0 x1(o1) < x1(l3) < x1(l1) < x1(l2) < x1(t). 5.3. Arbitrary directions 83

If the first literal is true and the others false, • 0 0 x1(f) < x1(o1) < x1(l3) < x1(l1) < x1(l2) < x1(c1), x1(c2) < x1(o2) < 0 0 x1(o1) < x1(l3) < x1(l1) < x1(l2) < x1(t). If the first two literals are false, which makes the third be true, • 0 0 0 x1(f) < x1(l2) < x1(l1) < x1(l3) < x1(o1) < x1(l2) < x1(l1) < 0 x1(c1), x1(c2) < x1(o2) < x1(l3) < x1(o1) < x1(t). If the first literal is false and the others true, • 0 0 x1(f) < x1(l2) < x1(l1) < x1(l3) < x1(o1) < x1(c1), x1(c2) < x1(l2) < 0 0 x1(l1) < x1(o2) < x1(l3) < x1(o1) < x1(t). The remaining cases are analogous. • Then we place each vertex v of a true variable such that x1(t) < x1(v) and for a false variable such that x1(v) < x1(f) to make all paths strictly monotone in x1- direction.

5.3.2 Hardness in 3D Theorem 20. The strictly monotone trajectory drawing problem is -hard in three dimensions, even for paths of length four. NP Similar to the proof in two dimensions we use a necessary and sufficient condition for three different paths on a set of five vertices, each being strictly monotone increasing in some direction. For a vertex v in a path P strictly monotone in direction a there is a plane E through v (perpendicular to a) such that the vertices of the different parts of P (separated by v) are on different sides of E. Given three vertices c1, c2 and c3 and paths (c1c2c3), (c2c3c1) and (c3c1c2), the vertices c1, c2 and c3 cannot be collinear because there only exists a plane through the vertex lying in the middle with the other two vertices on different sides. For each vertex v we add another vertex v and paths P1 = (vc1c2c3v), P2 = (vc2c3c1v) and P3 = (vc3c1c2v). We assume w.l.o.g. that x3(c1) = x3(c2) = x3(c3) = 0 and call the plane in which c1, c2 and c3 are lying E. The projection of a vertex v perpendicular to E 0 into a plane E is denoted by vE0 . We say a vertex v lies under (above) a plane 0 E if it is x3(v) < x3(vE0 )(x3(v) > x3(vE0 )). A plane through ci perpendicular to a possible direction for the path Pj is denoted by Eij. The intersection line 0 0 of two planes E and E is denoted by l(E /E). The line l(E21/E) must have c1 and c3 on different sides so there is a set of possible intersection lines bounded by the lines through c2 and c1 and through c2 and c3. We call this area I21.A parallel of the line c1c3 through c2 separates I22 and I23 (see Fig. 5.5(a)). 84 Chapter 5. Directions

Lemma 30 (necessity). The vertices v and v have to lie on different sides of the plane through c1, c2 and c3.

Proof. Assume w.l.o.g. it is both x3(v) > 0 and x3(v) > 0.

Assume the vertex vE is lying within the convex hull of c , c and c . The • 1 2 3 plane E11 must pass under v because v must lie on a different side than c2 and c3 to make the path P1 strictly monotone. The plane E31 is parallel to E11 and must have v on a different side than c1, c2 and v so v is lying under this plane and vE must lie in an area bounded by a line through c3 parallel to the line c2c1 and the line c2c3. With the same argument vE must lie in an area bounded by a line through c1 parallel to the line c3c2 and the line c3c1 to make the path P2 strictly monotone and an area bounded by a line through c2 parallel to the line c1c3 and the line c2c1 to make the path P3 strictly monotone. This is a contradiction, so x (v) 0. (See Fig. 5.5(b).) 3 ≤

Assume vE and c are lying on different sides of the line through c and • 3 1 c2. The vertex v must lie above the plane E33 and v under the plane E23. We take a closer look at the intersection lines of the two planes E11 and E22 with the planes E and E23. The lines l(E11/E) and l(E22/E) intersect in i under the plane E23 because of the ranges of the areas I11,I22 and I23. The vertices v and c2 lie on different sides of the plane E11 and the vertices v and c1 on different sides of the plane E22. Because v must also lie above E23, the lines of l(E11/E23) and l(E22/E23) must intersect in i0 E with x (i) > 0. The line l(E /E ) must go through i and i0. For ∈ 23 3 11 22 the planes E31 and E12 parallel to E11 and E22, the line l(E31/E12) must be parallel to l(E11/E22) and because the intersection point j of l(E31/E) and l(E12/E) is not lying under E23, there is no placement for v under E23 such that x3(v) > 0 having v and c1 on different sides of E31 and v and c2 on different sides of E12 (see Figs. 5.5(c) and 5.5(d)).

The cases where ve and c1 are lying on different sides of the line through c2 and c3 and where ve and c2 are lying on different sides of the line through c1 and c3 are analogous.

Lemma 31 (sufficiency). If the vertices v and v lie on different sides of the plane through c1, c2 and c3, for each of the paths (vc1c2c3v), (vc2c3c1v) and (vc3c1c2v) there a direction in which the path is strictly monotone increasing.

Proof. Let v and v have any position on different sides of E. For i 1, 2, 3 , ∈ { } let Si be the set of planes perpendicular to the possible directions in which Pi is strictly monotone increasing with each plane Ei Si having parallel planes Eji ∈ through the vertices cj for j 1, 2, 3 separating the vertices of the path Pi. ∈ { } 5.3. Arbitrary directions 85

Each Si is bounded by E such that from each set we can find one plane having v and v on different sides.

(a) (b)

(c) (d)

Figure 5.5: v and v lie on different sides of a plane through c1, c2 and c3

With this, hardness can be proven analogous to Sect. 5.3.1. 86 Chapter 5. Directions Chapter 6

Shape

Wherever a data set is divided into subsets that do not necessarily have size two, hypergraphs can be used to represent the data. In contrast to the defini- tion of a graph, the concept of a hyperedge, being an arbitrary sized subset of the vertex set, replaces that of an edge, which is a 2-element subset. While this generalization opens a wider range of possibilities, it results in the difficulty to visualize the hyperedges. There are several approaches to drawing hypergraphs. We will concentrate on graphs associated with hypergraphs - the supports. Sup- ports can be used for hypergraph drawing (Johnson and Pollak, 1987; Kaufmann, van Kreveld, and Speckmann, 2009; Buchin, van Kreveld, Meijer, Speckmann, and Verbeek, 2010; Simonetto, Auber, and Archambault, 2009), e.g. for de- signing Euler . There are various well-formedness conditions for Euler diagrams, see e.g. Flower, Fish, and Howse (2008); Simonetto, Auber, and Ar- chambault (2009). Further applications for supports of hypergraphs are, e.g., in hypergraph coloring (Kr´al’,Kratochv´ıl,and Voss, 2004; Bujt´asand Tuza, 2009) and databases (Beeri, Fagin, Maier, and Yannakakis, 1983). Fig. 6.1 shows three representations of the hypergraph H = (V,A) with hyperedges h = v , v , 1 { 1 2} h2 = v2, v3 , h3 = v3, v4 , h4 = v4, v5 , h5 = v5, v6 , h = v2, v3, v4, v5 , h0 = {v , v , v} , v , v {, and }V = v ,{ . . . , v }. { } { } { 2 3 4 5 7} { 1 7} Recently the problem of deciding which classes of hypergraphs admit what kind of supports became of interest again. It can be tested in linear time whether a hypergraph has a support that is a tree (Tarjan and Yannakakis, 1984), a path or a cycle (Buchin, van Kreveld, Meijer, Speckmann, and Verbeek, 2010). It can be decided in polynomial time whether a hypergraph has a tree support with bounded degrees (Buchin, van Kreveld, Meijer, Speckmann, and Verbeek, 2010) or a cactus support (Brandes, Cornelsen, Pampel, and Sallaberry, 2010a). A minimum weighted tree support can be computed in polynomial time (Korach and Stern, 2003). It is -complete to decide whether a hypergraph has a planar support (Johnson andNP Pollak, 1987), a compact support (Johnson and Pollak, 88 Chapter 6. Shape

v1 v2 v3 v4 v5 v6

v1 v2 v3 v4 v5 v6 V

v7 v7

h0 (b) tree support (c) metro map like drawing

h

h1 h2 h3 h4 h5 v1 v2 v3 v4 v5 v6

v v v v v v v { 1} { 2} { 3} { 4} { 5} { 6} { 7}

(a) Hasse diagram v7

(d) Euler diagram

Figure 6.1: Three representations of a hypergraph

1987; Kaufmann, van Kreveld, and Speckmann, 2009) or a 2-outerplanar sup- port (Buchin, van Kreveld, Meijer, Speckmann, and Verbeek, 2010). A support with the minimum number of edges can be computed in polynomial time if the hypergraph is closed under intersections (Buchin, van Kreveld, Meijer, Speck- mann, and Verbeek, 2010). If the set of hyperedges is closed under intersections and differences, it can be decided in polynomial time whether the hypergraph has an outerplanar support (Brandes, Cornelsen, Pampel, and Sallaberry, 2010a). In this chapter we consider a restriction on the subgraphs of a support that are induced by the hyperedges. A support G of a hypergraph H = (V,A) is called path-based if the subgraph G[h] contains a Hamiltonian path for each hyperedge h A, i.e., G[h] contains a path that contains each vertex of h. This approach∈ was on one hand motivated by hypergraph drawing and on the other hand by the aesthetics of metro map layouts. I.e., the hyperedges could be visualized as lines along the Hamiltonian path in the induced subgraph of the support like the metro lines in a metro map. See Fig. 6.2 for examples of metro maps: In 6.2(a) the local train map of Zurich (www.zvv.ch) and in 6.2(b) the metro map of Amsterdam (www.amsterdam.info) where the union of all lines forms a tree. See Fig. 6.3 for an example of natural sciences drawn in the metro map anthology, and Fig. 6.1(c)+ 6.6(f) for a representation of some hyperedges in such a metro map like drawing. For metro map layout algorithms 6.1. Path-Based Supports 89

(a) local trains of Zurich (b) metro of Amsterdam

Figure 6.2: Metro map drawings see, e.g., N¨ollenburg (2010); Wolff (1970). We briefly consider monotone, planar, and minimum path-based supports. Our main result is a characterization of those hypergraphs that have a path- based tree support and a polynomial time algorithm for constructing path-based tree supports if they exist. E.g., Fig. 6.1 shows an example of a hypergraph H = (V,A) that has a tree support but no path-based tree support. However, the tree support in Fig. 6.1(b) is a path-based tree support for (V,A V ). \{ }

6.1 Path-Based Supports

In a metro map like drawing of a hypergraph vertices are drawn as disjoint simple closed regions in the plane and each hyperedge h is drawn as a curve h with the end points within the regions of different vertices of h, visiting the regionC of every vertex of h exactly once, not visiting the vertices not in h, and such that the pieces of h within the region of a vertex or between two such regions are simple. A path-basedC support of a hypergraph H = (V,A) is a graph G such that G[h] contains a spanning path for every hyperedge h A. ∈ On one hand, a metro map like drawing of a hypergraph H = (V,A) induces a path-based support G = (V,E) of H: For a hyperedge h A let ph : v1, . . . , v|h| be the sequence of vertices of h in the order in which they∈ are visited by the curve representing h. Starting with an empty set E add for every hyperedge h A with ph : v , . . . , v|h| the edges vi− , vi , i = 2,..., h to E. On the other ∈ 1 { 1 } | | 90 Chapter 6. Shape

Figure 6.3: A map of modern science (www.crispian.net). hand, if we have a path-based support G of H and we fix for every hyperedge h A a spanning path ph of G[h] then this induces a metro map like drawing of∈H. In order to have a readable metro map like drawing of a hypergraph it is typically desirable to draw any curve representing a hyperedge without self in- tersection or even monotone.

6.1.1 Monotone Path-Based Supports Let G = (V,E) be a path-based support of a hypergraph H = (V,A). A drawing of G is monotone with respect to H if for each hyperedge h A there is a ∈ spanning path ph of G[h] and a straight line `h such that ph is strictly monotone increasing in direction `h. G is a monotone path-based support of H if G has a monotone drawing with respect to H.

Lemma 32. If G has a monotone drawing with respect to a hypergraph H then G has a straight-line drawing that is monotone with respect to H with the same axes of monotonicity.

Proof. Let a drawing of G that is monotone with respect to H = (V,A) be D given and let ph, h A be a spanning path of G[h] that is strictly monotone ∈ increasing in direction `h. If for each edge v, w of G the line segment between { } 6.1. Path-Based Supports 91

v1 v2

5 7 v1 v2

v5 5 v3 v5 v3 6 7 v4

v4 (a) maximum path-based support (b) minimum path-based support

v1 v2 v3 v4 v5

(c) minimum path-based support w.r.t. an ordering

Figure 6.4: Three different supports for the hypergraph HI . v and w does not contain any vertex of G other than v or w then the straight- line drawing of G, in which the vertices have the same coordinates as in , is monotone with respect to H. D Consider now for two vertices v, w in a hyperedge h the distances disth(v, w) between the orthogonal projections of v and w to `h. Let ∆ be the minimum of all distances disth(v, w) over all h A and v, w h with v = w. Let 0 < ε ∆/3. ∈ ∈ 6 ≤ Consider now the vertices of V in an arbitrary order v , . . . , vn, n = V . For 1 | | k = 1, . . . , n, we can now place vk on the cycle with radius ε around the position of vk in but not on the intersection with the line through the already fixed D drawings of vi and vj, 1 i < j < k. The corresponding straight-line drawing ≤ is monotone with respect to H with the axes of monotonicity `h, h A. ∈

Consider the following hypergraph. Let I = (i, j, k, `); 1 i < j 5, 1 k < ` 5, i < k, i, j k, ` = be{ an index set≤ representing≤ ≤ ≤ { } ∩ { } ∅} unordered pairs of disjoint edges of the K . Let VI = vi; i = 5 { 1,..., 5 vi,j,k,`,x;(i, j, k, `) I, x = 1,..., 3 , let AI = hijk`;(i, j, k, `) I } ∪ { ∈ } { ∈ } for hijk` = vi, vi,j,k,`, , vj, vi,j,k,`, , vk, vi,j,k,`, , v` , (i, j, k, `) I, and let HI = { 1 2 3 } ∈ (VI ,AI ). Figure 6.4 shows three different supports for HI . The small black ver- tices are the vertices vσ,x, σ I, x = 1, 2, 3. The thick red path indicates the ∈ hyperedge h1324. 92 Chapter 6. Shape

Lemma 33. Not every path based support of a hypergraph is monotone.

Proof. Let E contain the edges vi, vi,j,k,`, , vi,j,k,`, , vj , vj, vi,j,k,`, , { 1} { 1 } { 2} vi,j,k,`, , vk , vk, vi,j,k,`, , vi,j,k,`, , v` for (i, j, k, `) I. The resulting path- { 2 } { 3} { 3 } ∈ based support G = (V,E) of HI is shown in Fig. 6.4(a). Note that G[hijk`] is a path for any hyperedge hijk` A visiting the vertices vi, vj, vk, v` in this order. ∈ Consider now any drawing of G. Since a K5 is not planar, there are two straight line segments vivj, vk, v`, (i, j, k.`) I that intersect. Hence, the path G[hijk`] cannot be drawn monotonously. ∈ Lemma 34. Every hypergraph has a monotone path-based support.

Proof. Order the vertices of H = (V,A) with respect to an arbitrary ordering <. The support G< = (V,E<) of H with respect to the ordering < is constructed as follows. For each hyperedge v , . . . , vk A with v < < vk the edge set { 1 } ∈ 1 ··· E< contains the edges vi− , vi , i = 1, . . . , k. Assume now that in a drawing { 1 } of G< the x1-value of a vertex v is smaller than the x1-value of the vertex w if v < w and that the edges are drawn monotonously in x1-direction. Then for each hyperedge h = v , . . . , vk A with v < < vk the path ph : v , . . . , vk { 1 } ∈ 1 ··· 1 is drawn monotonously in x1-direction. See Fig. 6.4(c) for an example. Note that the problem of deciding whether a given support is a support with respect to an ordering and if so, finding such an ordering, is closely related to the betweenness problem (Opatrny, 1979).

Theorem 21. Given a support G of a hypergraph H it is -hard to decide whether NP

1. G is a monotone path-based support of H, or whether

2. there exists an ordering < of the vertex set such that G is the support of H with respect to <, even if G has the minimum number of edges among all supports of H. Proof.

1. Consider an instance of the strictly monotone trajectory drawing problem consisting of a set of paths P on a set of vertices Vt: It is -hard to decide whether a geometric position in the plane can be assignedNP to each vertex such that each path is strictly monotone in some direction.(Theorem 19 in Section 5.3.1)

Consider the hypergraph H = (V,A) with V containing Vt and for each path p P and each edge e p a vertex vep. The set A contains for ∈ ∈ 6.1. Path-Based Supports 93

S each path p P a hyperedge hp = v, v{v,w}p, w as well as the ∈ {v,w}∈p{ } hyperedges v, v{v,w}p and v{v,w}p, w for each edge v, w p. The { } {S S } { } ∈ graph G = (V,E) with E = p∈P e∈p v, vep ; v e is a path-based support of H and has the minimum number{{ of} edges∈ among} all supports of H. G is monotone if and only if P is drawable with each path strictly monotone in some direction.

2. Consider an instance of the betweenness problem consisting of a set of vertices Vb and a set of constraints C. Each constraint c C consists of a sequence of three vertices. It is -hard to decide whether∈ the vertices can be totally ordered such that forNP each constraint c = (u, v, w) the vertex v is between the vertices u and w (Opatrny, 1979).

Consider the hypergraph H = (V,A) with V containing Vb and for each constraint c C vertices vc and vc . The set A contains for each c = ∈ 2 4 (vc1, vc3, vc5) C a hyperedge hc = vc1, . . . vc5 and hyperedges hci = ∈ { } S vci, vc(i+1) for 1 i 4. The graph G = (V,E) with E = c∈C hci; 1 i{ 4 is a} path-based≤ ≤ support of H and has the minimum number{ of edges≤ among≤ } all supports of H. There is an ordering < of V such that G is the support of H with respect to < if and only if Vb can be totally ordered while satisfying all betweenness constraints in C.

6.1.2 Minimum Path-Based Supports Assuming that each hyperedge contains at least one vertex, each hypergraph H = (V,A) has a monotone path-based support G = (V,E) with at most N m edges. − Just take the support G< with respect to an arbitrary ordering < of the vertex set V . It is, however, -complete to find an ordering that minimizes the number of edges among allNP path-based supports of H with respect to an ordering of the vertex set (Johnson, Krishnan, Chhugani, Kumar, and Venkatasubramanian, 2004). Further, note that a path-based support that minimizes the number of edges among all path-based support of a hypergraph H with respect to some ordering of the vertex set might not be a path-based support of H with the minimum number of edges over all path-based supports of H. E.g., consider the hypergraph HI from the previous section (Fig. 6.4) or the hypergraph H with hyperedges 1, 2, 4 , 1, 3, 4 , and 2, 3, 4 for an easier example: the unique minimum {path-based} { support} of H{ is a star} centered at 4 which cannot be created from any ordering of the vertex set. The problem of finding a minimum path-based support remains, however, -complete. NP 94 Chapter 6. Shape

Theorem 22. It is -complete to minimize the number of edges among all path-based supports (orNP among all monotone path-based supports) of a hypergraph – even if the hypergraph is closed under intersections. Proof. It is -complete to decide weather a graph contains a Hamiltonian path i. e., a pathNP that visits every vertex exactly once (Karp, 1972). Let G = (V,E) be a graph. Let H = (V,E V v ; v V ) and K = E . Note that any support of H contains G ∪as { a subgraph.} ∪ {{ } Hence,∈ }H has a path-based| | support with at most K edges if and only if G is a path-based support of H which is true if and only if G contains a Hamiltonian path.

6.1.3 Planar Path-Based Supports For the application of Euler diagram like drawings, planar supports are of spe- cial interest. However, like for general planar supports, the problem of testing whether there is a path-based planar support is hard. Theorem 23. It is -complete to decide whether a hypergraph – even if it is closed under intersectionsNP – has a path-based planar support. Proof. The support that Johnson and Pollak (1987) constructed to prove that it is -complete to decide whether there is a planar support, was already path-based.NP

6.2 Path-Based Tree Supports

In this section we show how to decide in polynomial time whether a given hyper- graph has a path-based tree support. If such a support exists, it is at the same time a path-based support of minimum size and a planar path-based support. So far it is known how to decide in linear time whether there is a path-based tree support if V A (Buchin, van Kreveld, Meijer, Speckmann, and Verbeek, 2010). ∈

6.2.1 Constructing a Tree Support from the Hasse Diagram A support with the minimum number of edges and, hence, a tree support, if one exists, can easily be constructed from the Hasse diagram if the hypergraph is closed under intersections (Buchin, van Kreveld, Meijer, Speckmann, and Ver- beek, 2010). Note, however, that the number of intersections of any subset of hyperedges could be exponential in the size of the hypergraph. To construct a tree support of an arbitrary hypergraph, it suffices to consider the augmented Hasse diagram – a representation of “necessary” intersections of 6.2. Path-Based Tree Supports 95 hyperedges. The definition is as follows. First consider the smallest set A of subsets of V that contains A and that is closed under intersections. Consider the Hasse diagram D of H = (V, A). Note that any tree support of H is also a tree support of H. Let h1, . . . , hk be the children of a hyperedge h in D. The hyperedge h A is implied if the hypergraph (h hk, h , . . . , hk ) is ∈ 1 ∪ · · · ∪ { 1 } connected and non-implied otherwise. Let h , . . . , hk be a maximal subset of { 1 } the children of a non-implied hyperedge in A such that (h hk, h , . . . , hk ) 1 ∪· · ·∪ { 1 } is connected. Then h1 hk is a summary hyperedge. Note that a summary hyperedge might not be∪ · in · ·A ∪. Let A0 be the set of subsets of V containing the summary hyperedges, the hyperedges in A that are not implied, and the sources of D. E.g., for the hypergraph in Fig. 6.1 it holds that A0 = A. In this example, the hyperedge h is a summary hyperedge, h0 is not implied, and V is a source. The augmented Hasse diagram of H is the Hasse diagram D0 of H0 = (V,A0). If H has a tree support, then the augmented Hasse diagram has (n + m) vertices and can be constructed in (n3m) time (Buchin, van Kreveld,O Meijer, Speckmann, and Verbeek, 2010). FurtherO note that if H has a tree support and h A0 is non-implied, then all children of h in D0 are disjoint. ∈ If a tree support G = (V,E) of H exists it can be constructed as fol- lows (Buchin, van Kreveld, Meijer, Speckmann, and Verbeek, 2010). Starting with an empty graph G, we proceed from the sinks to the sources of D0. If 0 h A is not implied, choose an arbitrary ordering h1, . . . , hk of the children of ∈ 0 h in D . We assume that at this stage, G[hi], i = 1, . . . , k are already connected Sj−1 subgraphs of G. For j = 2, . . . , k, choose vertices vj hi, wj hj and add ∈ i=1 ∈ edges vj, wj to E. { } If we want to construct a path-based tree support, then G[hj], j = 1, . . . , k are paths and as vertices vj+1 and wj for the edges connecting G[hj] to the other paths, we choose the end vertices of G[hj]. The only choices that remain are the ordering of the children of h and the choice of which end vertex of G[hj] is wj and which one is vj+1. The implied hyperedges give restrictions on how these choices might be done.

6.2.2 Choosing the Connections When we want to apply the general method introduced in Sect. 6.2.1 to con- struct a path-based tree support G, we need to make sure that we do not create vertices of degree greater than 2 in G[h] when processing non-implied hyperedges contained in an implied hyperedge h. Let h, h0 A0. We say that h, h0 overlap if h h0 = , h h0, and h0 h. Two overlapping∈ hyperedges h, h0 A0 have a conflict∩ if6 there∅ is6⊆ some hyperedge6⊆ in A0 that contains h and h0. Two∈ overlapping hyperedges h, h0 A0 have a 0 0 0 ∈ conflict with respect to hc A if h has a conflict with h , h h hc and hc is ∈ ∩ ⊆ 96 Chapter 6. Shape

4 5 ANC 5 ANC NOT-ANC 5 ANCESTOR(h1) h1 h2 h3 2 2 NOT-CONFLICT DESCENDANT(h2, h2) 3 4 4 DESCENDANT(., h1) h1 h2 2 2 3 NOT-ANC DESCENDANT(h4, h4) DESC(h1) NOT-ANC NOT-ANC 3 3 3 3 3 UP-SEARCH(., h1) h1 h2 h3 h4 2 2 2 CONFLICT(h4) UP-SEARCH(., h4) DESC(h2) DESC(h3) 2 2 2 1 2 2 2 2 h h h 2 h h h h 1 2 3 DESC(h4) 4 5 6 7 NOT -ANC NOT-ANC 1 1 1 1 1 1 1 1 1 1 1 1 1 1 h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 2 3 2 2 DESC(h2) DESC(h1) DESC(h4) DESC(h4) MULTI-DESC MULTI-DESC

4 Figure 6.5: Computation of the potential conflicts for h1

0 0 a child of h or h . We say that h and h are conflicting hyperedges of hc. Note that there might be hyperedges that have a conflict but not with respect to any of their children. In the lemmas in this section, we will prove that it suffices if the algorithm considers only conflicts with respect to some child. We first compute candidates for conflicting pairs of hyperedges, which in the case of hypergraphs having a path-based tree support turn out to be a superset of the set of all conflicts. The idea is that all potential conflicts for a hyperedge h lie on a path in the augmented Hasse diagram from an ancestor of h to one of h’s descendants. The method can be found as pseudocode in Algorithm 5. Afterwards, for each pair h, h0 of hyperedges with a potential conflict with 0 respect to a child hc of h, we check we check whether h h hc. We illustrate Algorithm 5 with an example. Figure 6.5 shows the computation∩ ⊆ of potential 4 conflicts for the hyperedge h1 of the hypergraph H from Figure 6.6(a). The 2 different methods are colored. h5 is the only hyperedge that can be in conflict 4 4 2 with h1 with respect to a child of h1 and if so, with respect to h4. 0 c Let Ah be the set of conflicting hyperedges of a hyperedge h. Let Ah be the 0 set of children hi of h such that h Ahi . Assume now that H has a path-based 0 00 ∈0 0 00 tree support G and let h , h , hc A be such that h and h have a conflict with respect to h. We have three types∈ of restrictions on the connections of the paths.

1. G[h0 h] and G[h00 h] are paths that are attached to different end vertices \ \ of G[h]. Otherwise G[ha] contains a vertex of degree higher than 2 for any 0 00 hyperedge ha h h . ⊇ ∪ c 1 0 2. Assume further that h1 Ah. For all hyperedges h Ah that have a conflict with h with respect∈ to h it holds that G[h1 h] must∈ be appended 1 \ to the end vertex of G[h], which is also an end vertex of G[h1]. Hence, all these paths G[h1 h] must be appended to the same end vertex of G[h]. \ 6.2. Path-Based Tree Supports 97

Algorithm 5: CONFLICT COMPUTATION Input : augmented Hasse diagram D0 of a hypergraph, vertex h 0 0 Output : vertices h with label(h ) = conflict(hc) for all children hc of h Data : there are the following vertex labels 0 0 label(h ) = anc iff h ( h label(h0) = not-anc only if h h0 not contained in any source of D0 0 0 ∪ label(h ) = desc(hc) iff h hc for exactly one child hc of h ⊆ label(h0) = multi-desc iff h0 is contained in more than one child of h label(h0) = not-conflict only if h h0 not contained in any child of h ∩ and h h0 contained in some source of D0 0 ∪ 0 label(h ) = conflict(hc) only if hc h = for a child hc of h ∩ 6 ∅ and h h0 contained in some source of D0 ∪ ancestor(vertex h0) begin foreach parent h00 of h0 do label(h00) anc ← ancestor(h00)

0 descendant(vertex h , vertex hc) begin 0 0 0 if label(h ) = desc(h ), hc = h then c 6 c label(h0) multi-desc ← else 0 label(h ) desc(hc) ← foreach child h00 of h0 do if label(h00) = multi-desc then 6 00 descendant(h , hc)

0 up-search(vertex h , vertex hc) begin foreach parent h00 of h0 do 00 0 0 if label(h ) , conflict(hc), hc = hc then ∈ {∅00 6 } up-search(h , hc) 0 0 0 if label(h ) = conflict(h ), hc = h then c 6 c label(h0) not-conflict ← 0 else if label(h ) = desc(hc) then 00 6 if label(h ) conflict(hc), anc, not-conflict then 0 ∈ { } label(h ) conflict(hc) ← 0 if label(h ) = conflict(hc) then 6 label(h0) not-anc ←

begin clear all labels label(h) not-conflict ← ancestor(h) foreach child hc of h do descendant(hc, hc) 0 0 0 foreach vertex h of D with label(h ) desc(hc); hc child of h do 0 ∈ { } up-search(h , hc) 98 Chapter 6. Shape

c i 0 3. Assume further that h2 Ah, h2 = h1. Let h Ah have a conflict with h ∈ 6 ∈ i with respect to hi, i = 1, 2, respectively. Then G[h h] has to be appended \ to the end vertex of G[h], which is also an end vertex of G[hi]. Hence, G[h1 h] and G[h2 h] must be appended to different end vertices of G[h]. \ \ E.g., consider the hypergraph H = (V,A) in Fig. 6.1. On one hand, h0 has a conflict with h1 and h5 with respect to h. Hence, by the first type of restrictions G[h1 h] and G[h5 h] must be appended to the same end vertex of G[h], i.e. the end\ vertex of G\[h] to which G[h0 h] is not appended. On the other hand, \ h1 and h have a conflict with respect to h2, while h5 and h have a conflict with respect to h . Hence, by the third type of restrictions it follows that G[h h] 4 1 \ and G[h5 h] must be appended to different end vertices of G[h]. Hence, there is no path-based\ tree support for H. This motivates the following definition 0 of conflict graphs. The conflict graph Ch, h A is a graph on the vertex set 0 c ∈ A A . The conflict graph Ch contains the following three types of edges. h ∪ h 1. h0, h00 , h0, h00 A0 if h0 and h00 have a conflict with respect to h. { } ∈ h 2. h0, h , h0 A0 , h Ac if h0 A0 and h0 and h have a conflict with { 1} ∈ h 1 ∈ h ∈ h1 respect to h1. 3. h , h , h , h Ac , h = h . { 1 2} 1 2 ∈ h 1 6 2 E.g., consider the hypergraph H = (V,A) in Fig. 6.1. Then the conflict graph 0 0 Ch contains the edges h , h and h , h of type one, the edges h , h and { 5} { 1} { 2 1} h4, h5 of type 2 and the edge h2, h4 of type 3. Hence, Ch contains a cycle of {odd length,} reflecting that there{ is no} suitable assignment of the end vertices of 0 G[h] to h1, h5 and h . Theorem 24. A hypergraph H = (V,A) has a path-based tree support if and only if

1. H has a tree support,

0 2. no hyperedge contains three pairwise overlapping hyperedges h1, h2, h3 A with h h = h h = h h , and ∈ 1 ∩ 2 2 ∩ 3 1 ∩ 3 0 3. all conflict graphs Ch, h A , h > 1 are bipartite. ∈ | | From the observations before the definition of the conflict graph it is clear that the conditions of Theorem 24 are necessary for a path-based tree support. We prove that the conditions are also sufficient. In the following assume that the conditions of Theorem 24 are fulfilled. We show in Algorithm 6 how to construct a path-based tree support G of H. We 6.2. Path-Based Tree Supports 99 consider the vertices of the augmented Hasse diagram D0 from the sinks to the sources in a reversed topological order, i.e., we consider a hyperedge only if all its children in D0 have already been considered. During the algorithm, a conflicting hyperedge h0 of a hyperedge h is labeled with the end vertex v of G[h] if the path 0 0 G[h h] will be appended to v. We will call this label sideh(h ). Concerning the \ c 0 choice of the ordering of the children in Line 8 , the sets Ah, h A contain at ∈ c most two hyperedges – otherwise the subgraph of Ch induced by Ah contains a triangle and, hence, is not bipartite. Algorithm 6 constructs a tree support G of H (Buchin, van Kreveld, Meijer, Speckmann, and Verbeek, 2010). Before we show that G is a path-based tree support, we illustrate the algorithm with an example. Consider the hypergraph 5 H in Fig. 6.6. We show how the algorithm proceeds h1 and all its descendants 0 1 1 1 1 in D . For the hyperedges h3, h4, h6, and h8 the conflict graphs are empty while for the other leaves we have

2 2 3 4 side 1 (h ) = side 1 (h ) = side 1 (h ) = side 1 (h ) = v , h5 2 h5 3 h5 1 h5 2 5 2 3 side 1 (h ) = side 1 (h ) = v , and h7 4 h7 1 7 2 4 2 2 2 side 1 (h ) = side 1 (h ) = side 1 (h ) = side 1 (h ) = side 1 (h ) = v . h9 4 h9 1 h9 5 h9 6 h9 7 9

2 2 When operating h2 and h3, respectively, we add edges v4, v5 and v5, v6 , 2 { } { 1 } respectively, to G. While the conflict graph of h2 does only contain h5 with 1 2 side 2 (h ) = v , the assignment in C 2 is illustrated in Fig. 6.6(b). h has a h2 5 4 h3 4 1 1 conflict with respect to h7 and h9. Hence, we add edges v7, v8 and v8, v9 2 { } { 3 } to G. The conflict graph of h4 is shown in Fig. 6.6(c). When operating h1 we 2 1 1 1 can choose h = h and h = h since side 2 (h ) = v and side 1 (h ) = v . We 1 3 2 7 h3 3 6 h7 3 7 add the edge v , v to G. The conflict graph C 3 is shown in Fig. 6.6(d). The 6 7 h1 4 { } 2 hyperedge h is implied and we set side 4 (h ) = v . We can finally connect v 1 h1 4 4 3 5 to v4 or v9 when operating h1.

6.2.3 Correctness Lemma 35. Let D0 be the augmented Hasse diagram of a hypergraph that has a 0 path-based tree support and let h and h have a conflict with respect to a child hc 0 0 of h. Then Algorithm 5 applied to D and h labels h with conflict(hc).

Proof. Let G be a path-based tree support of a hypergraph and let h0 and h have a conflict with respect to a child hc of h.

1. Let v be the end vertex of G[h] that is contained in h0. Then v and all its ancestors on the path from v to hc are labeled desc(hc) (and not multi- desc). 100 Chapter 6. Shape

Algorithm 6: PATH-BASED TREE SUPPORT Input : augmented Hasse diagram D0 of a hypergraph H = (V,A) fulfilling the conditions of Theorem 24; 0 c 0 conflict graphs Ch on vertex sets A A , h non-source vertex of D h ∪ h Output : path-based tree support G = (V,E) of H 0 Data : labels sideh(h ) indicating the end vertex of G[h] to which h0 h should be appended \ begin E ← ∅ foreach vertex h of D0 in a reversed topological order of D0 do if h = v for some v V then { } 0 ∈ foreach vertex h of Ch do 0 sideh(h ) v ← else c 8 Let h , . . . , hk be the children of h such that h , . . . , hk− / A 1 2 1 ∈ h if h is non-implied then Let wi, vi+1, i = 1, . . . , k be the end vertices of G[hi] such that 0 sideh (h) = v2 if h A and • 1 ∈ h1 0 sideh (h) = wk if h A • k ∈ hk

Add the edges vi, wi , i = 2, . . . , k to E { } else Let w = vk be the end vertices of G[h] such that 1 6 +1 vk / h and • +1 ∈ 1 w / hk • 1 ∈ c if h1 Ah then sideh(h1) vk+1 ∈ c ← if hk A then sideh(hk) w ∈ h ← 1 Label the remaining vertices of Ch with vk+1 or w1 such that no two adjacent vertices have the same label 6.2. Path-Based Tree Supports 101

5 5 5 h1 h2 h3

4 4 h1 h2

3 3 3 3 h1 h2 h3 h4

2 2 2 2 2 2 2 h1 h2 h3 h4 h5 h6 h7

1 1 1 1 1 1 1 1 1 1 1 1 1 1 h1 h2 h3 h4 h5 h6 h7 h8 h9 h10 h11 h12 h13 h14 v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 v13 v14 (a) augmented Hasse diagram D0 of a hypergraph H

side = v6 side = v5 side = v9 side = v7

3 2 1 1 h1 h2 h7 h9

1 2 4 h5 h5 h1 2 2 (b) conflict graph of hyperedge h3 (c) conflict graph of hyperedge h4

v13 side = v5 side = v7 v3 v4 v5 v6 v7 v8 v9 v10 v14 2 4 h2 h2 v1 v11

1 2 v v h7 h3 2 12 3 (d) conflict graph of hyperedge h1 (e) a path-based tree support of H

v13

v v v v v v v v 14 3 4 5 6 7 8 9 v10

v1 v11

v2 v12 (f) metro map like drawing of the sources of D0

Figure 6.6: Illustration of Algorithm 6. 102 Chapter 6. Shape

0 0 0 2. If there was a descendant of h labeled desc(hc) for a child hc = hc of h, 0 0 6 then hc does not contain h h , contradicting that h and h have a conflict ∩ with respect to hc.

0 Hence, Algorithm 5 labels h with conflict(hc).

0 0 It is easy to see that h is only labeled with hc if h h = and there is some 0 0 ∩ 6 ∅ 0 hyperedge in A that contains h and h , hence, by checking whether h h hc, we identify all conflicts. ∩ ⊆ For Algorithm 6, it remains to show that all hyperedges of H induce a path in G. Since we included all inclusion maximal hyperedges of H in A0, it suffices to show this property for all hyperedges in A0. We start with a technical lemma.

Lemma 36. Let h0 and h00 be two overlapping hyperedges and let h0 be not im- plied. Then there is a hyperedge h A0 with h0 h00 h ( h0. ∈ ∩ ⊆ 0 00 0 Proof. Let hc A be maximal with h h hc ( h . The hyperedge hc is a child of the non-implied∈ hyperedge h0 in∩D. Consider⊆ the summary hyperedge h 0 0 0 with hc h ( h . From the definition of A it follows that h A . ⊆ ∈ 0 For an edge v, w of G let hvw be the intersection of all hyperedges of A { } that contain v and w. Note that then hvw is not implied since v and w cannot 0 both be contained in a subset of hvw. Hence, hvw A . ∈ Lemma 37. Let Conditions 1-3 of Theorem 24 be fulfilled and let G = (V,E) be the graph computed in Algorithm 6. Let h0, h00 A0 have a conflict with respect to a child h of h0 and let G[h0] and G[h00] be paths.∈ Then

00 00 0 0 00 1. sideg(h ) = sideh(h ) for all g A with h h g h, ∈ ∩ ⊆ ⊆ 00 00 2. sideh(h ) h , ∈ 00 0 3. sideh(h ) is an end vertex of G[h ],

4. G[h0 h00] is a path, and \ 00 00 0 5. sideh(h ) is adjacent in G to a vertex of h h . \ Proof. We prove the lemma by induction on the sum of the steps in which h0 and h00 were considered in Algorithm 6. If h0 and h00 had been considered in the first two steps, then at least one of them is a leaf of D0 and, hence, h0 and h00 have no conflict. So there is nothing to show. Let now h0 and h00 be considered in later steps. Let h00 A0 have a conflict with h0 with respect to a child h of h0 and let G[h0] and G[h∈00] be paths. 6.2. Path-Based Tree Supports 103

h0 h00

hvw h x w

h10 h100 v

hvw h h 0 ∩ 00 h h1 vx

hc hc = hvw h ∩ 00 = hvw h h ∩ vx h hvx h ∩

h00 w v x h0 (a) augmented Hasse diagram D0 (b) tree support G

Figure 6.7: Illustration of the proof of Lemma 37.3.

0 00 0 0 00 1. + 2. if h h A : There is nothing to show if h = h h . So let h1 be ∩ ∈ 0 00 00 ∩ the child of h with h1 h h . Then h, h have a conflict with respect ⊇ ∩ 0 00 to h1. Hence, Ch contains the path h , h , h1. By the inductive hypothesis 00 on Property 3, it follows that sideh1 (h ) is an end vertex of G[h], and especially, that h1 and h share an end vertex. By construction it follows 00 that sideh(h1) is the end vertex of h that is not in h1. Hence, sideh(h ) h1 00 00 ∈ and sideh1 (h ) = sideh(h ). By the inductive hypothesis it follows that 00 00 00 sideg(h ) = sideh(h ) for h h g h1. Since the labels in sideh0∩h00 (.) 0 ∩ 00 ⊆ ⊆ 00 0 00 00 are the end vertices of G[h h ], it follows that sideh(h ) h h h . ∩ ∈ ∩ ⊂ 0 00 0 00 00 0 00 00 1. + 2. + 5. if h h / A : Let h1 h be minimal with h h h1. 0 00∩ ∈ ⊆ ∩ ⊂0 00 Since h and h1 overlap, there is an edge v, w E such that v h h 00 0 00 { } ∈ ∈ ∩ and w h h . We show that sideh(h ) = v. ∈ 1 \ By Lemma 36 there is a child hc of hvw that contains h hvw. Since ∩ v h hvw, it follows that w / hc and, hence, v is an end vertex of hc. ∈ ∩ ∈ 00 0 00 Note that by the minimality of h1 it follows that h h hvw. Since 00 0 ∩ 6⊆ G[h ],G[h ] are paths, it follows that hc ( h and, hence, hc = h hvw. Let ∩ hp be minimal with hc ( hp h. Then hp, hvw have a conflict with respect ⊆ to hc and it follows from the inductive hypothesis on Property 5 that 0 0 sidehc (hvw) = v. Let hc be maximal with hc hc ( h. By the inductive ⊆ 0 hypothesis on Property 1 it follows that sidehc (hvw) = v. Since h, hvw 0 have a conflict with respect to hc, it follows by the inductive hypothesis on Property 3 that v is an end vertex of h. In Ch there is the path 0 0 00 0 hc, hvw, h , h . By construction, sideh(hc) is the end vertex of h that is 0 00 not in hc. Hence, sideh(hvw) = sideh(h ) = v. 104 Chapter 6. Shape

00 3.: Let v = sideh(h ). By the construction in Algorithm 6, v is an end vertex of G[h0] if h0 is non-implied. So assume that h0 is implied and that v is not an end vertex of G[h0]. Let w h0 h be a neighbor of v in G. By Property 2 00 ∈ \ 00 it follows that v h . Let hc be the child of hvw that contains hvw h . ∈ 00∩ By the inductive hypothesis on Property 4, it follows that G[hvw h ] is a 00 \ path that contains w but not v. Hence, hc = hvw h = hvw h. ∩ ∩ 0 00 0 0 0 0 00 00 00 0 00 Let h1, h1 A be minimal with h h1 ) h h and h h1 ) h h ∈ 0 ⊇ 00 0∩ ⊇ ∩ , respectively. Assume first that h h A . Then Ch0∩h00 contains the 0 00 ∩ ∈ triangle hvw, h1, h1, hvw and, hence, is not bipartite. Assume now that h0 h00 / A0. By the already proven part of Property 5 ∩ ∈ 00 it follows that there is an edge v, x of G with x h1 h. We have 00 { } ∈ \ hc = hvw h hvw hvx. Further, the child of hvx that contains hvx h ∩ ⊇ ∩ 00 00∩ equals hvx h. Since h1 is implied and hvx not, it follows that h1 = ∩ 0 00 6 hvx and, therefore, hvx h h . Hence, either hvx h hvw h or 0 6⊇ 00 ∩ ∩0 ⊆ ∩ hvw h ( hvx h ( h h . In the first case let h1 A be minimal with ∩ ∩ ∩ ∈ hvw h ( h1 h. Then there is the triangle hvw, hvx, h1, hvw in Ch∩hvw . In ∩ ⊆ 0 the latter case let h1 A be minimal with hvx h ( h1 h. Then there ∈ ∩ ⊆ is the triangle hvw, hvx, h1, hvw in Ch∩hvx . 4.: By the inductive hypothesis, G[h h00] is a path. Further, h and h0 share 00 00 \ sideh(h ) h as a common end vertex. By the precondition of the lemma, G[h0] is a∈ path. Hence, G[h0 h00] is a path. \ 0 00 0 0 00 0 00 5. if h h A : If h = h h , let h1 be the child of h with h h h1. ∩ ∈ 6 ∩ 00 ∩ ⊆ By the inductive hypothesis, sideh1 (h ) is adjacent in G to a vertex of 00 00 0 00 00 h h = h h and by Property 1, sideh (h ) = sideh(h ). \ \ 1 0 00 00 0 00 00 If h = h h , let h1 A be minimal with h ( h1 h . Applying ∩ 00 ∈0 0 00 ⊆ 0 Property 3 with h1 as “h ” and h as “h ” reveals that sideh(h ) is an end 00 00 00 vertex of G[h1]. Since G[h1] is a path it follows that some vertex of h1 h 00 \ is adjacent to sideh(h ).

Lemma 38. If Conditions 1-3 of Theorem 24 are fulfilled, then all hyperedges in A0 induce a path in the graph G constructed in Algorithm 6. Proof. Again, we prove the lemma by induction on the step in which h was considered in Algorithm 6. There is nothing to show if h had been considered in the first step. So assume that h A0 and that G[h] contains a vertex v of degree greater than two. ∈

Let u1, u2, u3 be the first three vertices connected to v in G. Let hi = hvui , i = 1, 2, 3. Then h1, h2, h3 are all three contained in h and its intersection contains v. 6.2. Path-Based Tree Supports 105

Hence, any two of them have a conflict if and only if one of them is not contained in the other. A case distinction reveals that we wouldn’t have appended all three, u1, u2 and u3, to v. h2 = h3: Since h3 contains no vertex of degree higher than two, it follows that u1 / h3, h3 h1 = v . Hence, h1 and h3 have a conflict with respect to the∈ common∩ child {v }, contradicting that v is added in the middle of h . { } 3 h1 = h2 or h1 = h3: These cases are analogous to the first case.

0 h1 ( h3: Like in the first case it follows that u2 / h3. Let hi, i = 2, 3 be the ∈ child of hi that contains v. Then h2 and h3 have a conflict with respect 0 to h , i = 2, 3. Since we add the edge v, ui to G when we process hi, i { } 0 it follows on one hand that sidehi (hi) = v. On the other hand, since h1 0 0 is contained in h3 and v h1, it follows that h1 h3. Hence, h3 has ∈0 ⊆ more than one vertex. If h3 = h3 h2, then v is the only end vertex of 0 6 ∩ G[h3] that is contained in h2. By Lemma 37 Property 2 it follows that 0 0 0 h v 0 h v h h h v v sideh3 ( 2) = and hence, sideh3 ( 3) = . If 3 = 3 2, let = be the 0 6 ∩ 6 h 0 h v other end vertex of 2. Since we know that sideh2 ( 2) = , it follows that 0 0 h v sideh2 ( 3) = . Hence, by Lemma 37 Property 1 we can conclude that 0 0 h v sideh3 ( 3) = . In both cases we have a contradiction. h1 ( h2 or h2 ( h3: These cases are analogous to the third case. h1, h2, h3 pairwise overlapping: Then h1 h2 = h2 h3 = h1 h3 = v . Hence, Condition 2 of Theorem 24 is not∩ fulfilled.∩ ∩ { }

This completes the proof of Theorem 24. We conclude this section with the following corollary.

Corollary 7. Algorithm 6 computes a path-based tree support of a hypergraph H if H has a path-based tree support, i.e., if and only if the conditions of Theorem 24 are fulfilled.

6.2.4 Run Time In this section we give an upper bound for the run time of testing whether a hypergraph has a path-based tree support and, if it exists, of constructing one.

Theorem 25. It can be tested in (n3m) time whether a hypergraph has a path- based tree support and if so, suchO a support can be constructed within the same time bounds. 106 Chapter 6. Shape

Proof. Let H be a hypergraph. First test in linear time whether there is a tree support for H (Tarjan and Yannakakis, 1984). Let D0 be the augmented Hasse diagram of H. The method works in four steps.

1. Start with an empty array conflict indexed with pairs of inner vertices 0 0 of D . Set conflicth,h0 hc if and only if h is labeled conflict(hc) in Algorithm 5 applied to←D0 and h.

0 0 2. For each pair h, h of inner vertices of D , test whether conflicth,h0 contains 0 h h . Otherwise set conflicth,h0 . Now, if H has a path-based tree ∩ 0 ← ∅ support, then h, h has a conflict with respect to the child hc of h if and only if hc = conflicth,h0 .

3. Apply Algorithm 6 to compute a support G. If the algorithm stops without computing a support, then H does not have a path-based tree support.

4. Test whether every hyperedge induces a path in G. If not, H does not have a path-based tree support.

D0 has (n + m) vertices, (n2 + nm) edges, and can be computed in (n3m) time if OH has a tree supportO (Buchin, van Kreveld, Meijer, Speckmann,O and Verbeek, 2010). Algorithm 5 visits every edge of D0 at most twice and, hence, runs in (n2 + nm) time for each of the (n) inner vertices of D0. We mayO assume that the hyperedges areO given as sorted lists of their elements. If not given in advance, these lists could be straight forwardly computed from D0 in (n3 + mn2) time by doing a graph search from each leaf. Now, for each of theO (n2) pairs h, h0 of inner vertices, it can be tested in (n) time whether O 0 O conflicth,h0 contains h h . The sum of the sizes∩ of all conflict graphs is in (n2). Hence, Algorithm 6 runs in (n2 + mn) time. For each of the (m) hyperedgesO h, it can be tested in (n)O time whether G[h] is a path. Hence,O the overall run time is dominated byO the computation of the augmented Hasse diagram and is in (n3m). O Chapter 7

Conclusion

We studied various types of constraints on relevant classes of graphs. While efficient algorithms have been obtained for some cases, others led to hardness results.

7.1 Angles and Distances

We presented linear time algorithms for drawing trees with given edge lengths in radial and circular representations. In radial drawings, the edge lengths are preserved, but labels may be spread unevenly. Whereas in circular drawings, labels are perfectly aligned, but edge lengths may be only approximately cor- rect. Moreover, we showed that these drawings are unique subject to reasonable requirements and discuss possible refinements. The linear running time is par- ticularly interesting in the circular case because our approach is a special case of Tutte‘s barycentric layout algorithm involving the solution of a system of linear equations. We showed that for straight-line drawings the angle constraint is realizable as well, whereas the combination of both classes of constraints in general is not. We proved that straight-line realizability can be tested in linear time for trees with angle and distance constraints. Additionally, we gave an algorithm that produces drawings satisfying both groups of constraints together in a model where edges are represented as polylines with at most two bends per edge or as continuously differentiable curves.

7.2 Ordering

We showed that, unfortunately, preserving the orthogonal ordering of vertices in a changing drawing results in severe algorithmic difficulties, even for the simplest 108 Chapter 7. Conclusion graphs. More precisely, we proved that orthogonal-order preserving uniform edge length, rectilinear and octilinear drawing is -hard even for paths. The reductions are from monotone 3-SAT. NP

7.3 Directions

We provided hardness proofs for practical variants of the trajectory drawing problem, in which all paths must be strictly monotone either along the coordinate axes or an arbitrary direction. The axis-parallel strictly monotone trajectory drawing problem is -hard in two and in three dimensions, even for paths of length two and inNPd-dimensions even for paths of length d. The strictly monotone trajectory drawing problem is -hard in two dimensions even for paths of length three and for three dimensionsNP even for paths of length four. The reductions are from 3-SAT.

7.4 Shape

We have introduced path-based supports for hypergraphs. Hence, as a new model we considered a restriction on the appearance of those subgraphs of a support that are induced by the hyperedges. We have shown that it is -hard to decide whether a given path-based support is monotone or to findNP a path- based support with the minimum number of edges. Further, it is -complete to decide whether there is a planar path-based support. As a mainNP result, we characterized those hypergraphs that have a path-based tree support and we gave an algorithm that computes a path-based tree support in (n3m) run time, if it exists. O List of Figures

1.1 Trees ...... 2 1.2 The New South Wales rail network (Dwyer, Koren, and Marriott, 2006) ...... 3 1.3 Internal preference map (Dunn and Goldman, 1998) ...... 4 1.4 Three representations of a hypergraph ...... 5

3.1 Dividing a sector ...... 13 3.2 Layout of a tree with given absolute angle for each edge ...... 15 3.3 Drawings of an example from Dwyer and Schreiber (2004) . . . . 17 3.4 Complete binary tree with n = 213 1 vertices ...... 18 − 3.5 Wedges of vertex v’s neighbors ...... 20 3.6 Unused area ...... 25 3.7 Spreading ...... 25 3.8 Postprocessing ...... 27 3.9 Radial drawing examples ...... 28 3.10 Each subtree is drawn in a wedge ...... 34 3.11 Children ordered according to subtree height ...... 35 3.12 Circular drawing examples ...... 36 3.13 Circular layout for examples from Figure 3.9 ...... 37 3.14 Wedges for vertex v ...... 39 3.15 Polylines for the edge v, w ...... 40 { } 3.16 Rotating the angle template ...... 40 3.17 Routing e around v ...... 41 3.18 Two cases in the start situation ...... 42 3.19 Two solvable situations ...... 44 3.20 (γ0 λ0 ) mod 2π > π and θ(i) > π ...... 47 i − i 3.21 Range of wi ...... 48 3.22 Bounding control segments ...... 49 3.23 B´eziercurves ...... 50 3.24 Splitting a curve ...... 51 3.25 Hi+1 ...... 52 110 List of Figures

3.26 Drawings of a tree with fixed vertices and angles ...... 53

4.1 Dependency of edges ...... 56 4.2 Decision units ...... 57 4.3 Possible links l for ei and ej ...... 57 4.4 Union of paths for a MONOTONE 3-SAT-instance I ...... 58 4.5 lc is connecting li and lj ...... 60 4.6 Single path for the instance I ...... 60 4.7 Decision units without horizontal or vertical edges ...... 61 4.8 Avoiding horizontal or vertical edges ...... 62 4.9 Dependency of edges ...... 63 4.10 Decision paths ...... 64 4.11 Union of paths for a MONOTONE 3-SAT-instance I ...... 65 4.12 Single path for the instance I ...... 66 4.13 Decision paths with totally ordered vertices ...... 66 4.14 ei forcing ej ...... 67 4.15 Horizontal decision unit ...... 67 4.16 The union of paths for the instance I from Sect. 4.1.1 ...... 68 4.17 Difference in relative position ...... 69 4.18 Intraclause links ...... 69 4.19 Flexible connection ...... 70

5.1 Anchor and clause paths ...... 73 5.2 Placement of c1, c2 and c3 ...... 75 5.3 l1 and l2 false, l3 true ...... 76 5.4 l1 and l2 are false, which makes l3 true...... 82 5.5 v and v lie on different sides of a plane through c1, c2 and c3 ... 85 6.1 Three representations of a hypergraph ...... 88 6.2 Metro map drawings ...... 89 6.3 A map of modern science (www.crispian.net)...... 90 6.4 Three different supports for the hypergraph HI ...... 91 4 6.5 Computation of the potential conflicts for h1 ...... 96 6.6 Illustration of Algorithm 6...... 101 6.7 Illustration of the proof of Lemma 37.3...... 103

1 BALLOON-LAYOUT ...... 14 2 RADIAL-LAYOUT ...... 20 3 SPREADING ...... 29 4 CIRCLE-LAYOUT ...... 33

5 CONFLICT COMPUTATION ...... 97 6 PATH-BASED TREE SUPPORT ...... 100 112 List of Algorithms Bibliography

Bachmaier, C., Brandes, U., Schlieper, B., 2005. Drawing phylogenetic trees. In: Deng, X., Du, D.-Z. (Eds.), Proceedings of the 16th Annual International Symposium on Algorithms and Computation (ISAAC ’05). Vol. 3827 of Lec- ture Notes in Computer Science. Springer, pp. 1110–1121. II, 22

Beeri, C., Fagin, R., Maier, D., Yannakakis, M., 1983. On the desirability of acyclic database schemes. Journal of the Association for Computing Machinery 30 (4), 479–513. 87

B¨ohringer,K.-F., Paulisch, F. N., 1990. Using constraints to achieve stability in automatic graph layout algorithms. In: Proceedings of the ACM Human Factors in Computing Systems Conference (CHI ’90). ACM, The Association for Computing Machinery, pp. 43–51. 55

Brandes, U., Cornelsen, S., Pampel, B., Sallaberry, A., 2010a. Blocks of hyper- graphs. In: Tischler and Radzik (2010), pp. 201–211. 87, 88

Brandes, U., Cornelsen, S., Pampel, B., Sallaberry, A., 2010b. Path-based sup- ports for hypergraphs. In: Tischler and Radzik (2010), pp. 20–33, invited journal version submitted to Journal of Discrete Algorithms. II

Brandes, U., Pampel, B., 2009. On the hardness of orthogonal-order preserving graph drawing. In: Tollis and Patrignani (2009), pp. 266–277, extended version submitted to Journal of Graph Algorithms and Applications. II

Brandes, U., Schlieper, B., 2009. Angle and distance constraints on tree drawing. In: Tollis and Patrignani (2009), pp. 54–65. II

Brandes, U., Shubina, G., Tamassia, R., 2000. Improving angular resolution in visualizations of geographic networks. In: de Leeuw, W., van Liere, R. (Eds.), 2000. Proceedings of the 2nd Joint Eurographics and IEEE TCVG Symposium on Visualization (VisSym ’00). Springer, pp. 23–33. 39, 43 114 Bibliography

Brass, P., Cenek, E., Duncan, C. A., Efrat, A., Erten, C., Ismailescu, D. P., Kobourov, S. G., Lubiw, A., Mitchell, J. S. B., 2003. On simultaneous planar graph embeddings. In: Dehne, F., Sack, J.-R., Smid, M. H. M. (Eds.), Pro- ceedings of the 8th Workshop on Algorithms and Data Structures (WADS ’03). Vol. 2748 of Lecture Notes in Computer Science. Springer, pp. 243–255. 71

Bridgeman, S., Tamassia, R., 1998. Difference metrics for interactive orthogonal graph drawing algorithms. In: Whitesides (1998), pp. 57–71. 55

Bridgeman, S., Tamassia, R., 2002. A user study in similarity measures for graph drawing. Journal of Graph Algorithms and Applications 6 (3), 225–254. 55

Buchin, K., van Kreveld, M., Meijer, H., Speckmann, B., Verbeek, K., 2010. On planar supports for hypergraphs. In: Eppstein and Gansner (2010), pp. 345–456. 87, 88, 94, 95, 99, 106

Bujt´as,C., Tuza, Z., 2009. Color-bounded hypergraphs, II: Interval hypergraphs and hypertrees. Discrete 309 (22), 6391–6401. 87

Carlson, J., Eppstein, D., 2007. Trees with convex faces and optimal angles. In: Kaufmann and Wagner (2007), pp. 77–88. 23

Carrizo, S. F., 2004. Phylogenetic trees: An information visualization perspec- tive. In: Chen, Y.-P. P. (Ed.), Asia-Pacific Conference (APBC 2004). Vol. 29 of CRPIT. Australian Computer Society, pp. 315–320. 16

Chazelle, B., 1991. Triangulating a simple polygon in linear time. Discrete and Computational Geometry 6 (5), 485–524. 38

Cheng, C. C., Duncan, C. A., Goodrich, M. T., Kobourov, S. G., 1999. Draw- ing planar graphs with circular arcs. In: Kratochv´ıl,J. (Ed.), Proceedings of the 7th International Symposium on Graph Drawing (GD ’99). Vol. 1731 of Lecture Notes in Computer Science. Springer, pp. 117–126. 39

Delling, D., Gemsa, A., N¨ollenburg, M., Pajor, T., 2010. Path schematization for route sketches. In: Algorithm Theory - SWAT 2010. Vol. 6139 of Lecture Notes in Computer Science. Springer, pp. 285–296. 56

Di Battista, G., Eades, P., Tamassia, R., Tollis, I. G., 1994. Algorithms for drawing graphs: An annotated bibliography. Computational Geometry: The- ory and Applications 4, 235–282. 1

Di Battista, G., Eades, P., Tamassia, R., Tollis, I. G., 1999. Graph Drawing: Algorithms for the Visualization of Graphs. Prentice Hall. 1 Bibliography 115

Douglas, D. H., Peucker, T. K., 1973. Algorithms for the reduction of the number of points required to represent a digitized line or its caricature. The Canadian Cartographer 10 (2), 112–122. 55

Duncan, C. A., Eppstein, D., Goodrich, M. T., Kobourov, S. G., N¨ollenburg, M., 2011. Drawing trees with perfect angular resolution and polynomial area. In: Brandes, U., Cornelsen, S. (Eds.), Proceedings of the 18th International Symposium on Graph Drawing (GD 2010). Vol. 6502 of Lecture Notes in Computer Science. Springer, pp. 183–194. 2

Dunn, M. E., Goldman, M. S., 1998. Age and drinking-related differences in the memory organization of alcohol expectances in 3rd-, 6th-, 9th-, and 12th-grade children. Journal of Consulting and Clinical Psychology 66 (3), 579–585. 4, 109

Dwyer, T., Koren, Y., Marriott, K., 2006. Stress majorization with orthogonal ordering constraints. In: Healy and Nikolov (2006), pp. 141–152. 3, 55, 109

Dwyer, T., Schreiber, F., 2004. Optimal leaf ordering for two and a half dimen- sional phylogenetic tree visualization. In: Churcher, N., Churcher, C. (Eds.), Australasian Symposium on Information Visualisation (invis.au 2004). Vol. 35 of CRPIT. Australian Computer Society, pp. 109–115. 17, 109

Eades, P., 1992. Drawing free trees. Bulletin of the Institute for Combinatorics and its Applications 5, 10–36. 12

Eades, P., Wormald, N. C., 1990. Fixed edge-length graph drawing is np-hard. Discrete Applied Mathematics 28, 111–134. 11, 19, 56

Eppstein, D., Gansner, E. R. (Eds.), 2010. Proceedings of the 17th International Symposium on Graph Drawing (GD 2009). Vol. 5849 of Lecture Notes in Computer Science. Springer. 114, 118

Felsenstein, J., 1973. Maximum likelihood and minimum-steps methods for esti- mating evolutionary trees from data on discrete characters. Systematic Zool- ogy 22, 240–249. 19

Felsenstein, J., 2004. Inferring Phylogenies. Sinauer Associates. 16, 22

Finkel, B., Tamassia, R., 2005. Curvilinear graph drawing using the force- directed method. In: Pach, J. (Ed.), Proceedings of the 12th International Symposium on Graph Drawing (GD ’04). Vol. 3383 of Lecture Notes in Com- puter Science. Springer, pp. 448–453. 39 116 Bibliography

Fitch, W. M., 1971. Toward defining the course of evolution: Minimum change for a specified tree topology. Systematic Zoology 20, 406–416. 19

Flower, J., Fish, A., Howse, J., 2008. Euler diagram generation. Journal on Visual Languages and Computing 19 (6), 675–694. 87

Gabriel, K. R., 1971. The biplot graphical display of matrices with application to principal component analysis. Biometrika 58 (3), 453–467. 71

Garey, M. R., Johnson, D. S., 1979. Computers and Intractability: A Guide to the Theory of –Completeness. W.H. Freeman & Co. 9, 10 NP Garg, A., 1995. On drawing angle graphs. In: Tamassia, R., Tollis, I. G. (Eds.), Proceedings of the DIMACS International Workshop on Graph Draw- ing (GD ’94). Vol. 894 of Lecture Notes in Computer Science. Springer, pp. 84–95. 11

Gortler, S. J., Thorston, D., 2006. Discrete one-forms on meshes and applications to 3d mesh parameterization. Journal of Computer Aided Geometric Design, CAGD 23 (2), 83–112. 32

Healy, P., Nikolov, N. S. (Eds.), 2006. Proceedings of the 13th International Sym- posium on Graph Drawing (GD ’05). Vol. 3843 of Lecture Notes in Computer Science. Springer. 115, 118

Heiser, W. J., de Leeuw, J., 1981. Multidimensional mapping of preference data. Math´ematiqueset sciences humaines 73, 39–96. 72

Imai, H., Iri, M., 1986. An optimal algorithm for approximating a piecewise linear function. Journal of Information Processing 9 (3), 159–162. 55

Johnson, D. S., Krishnan, S., Chhugani, J., Kumar, S., Venkatasubramanian, S., 2004. Compressing large boolean matrices using reordering techniques. In: Nascimento, M. A., Ozsu,¨ M. T., Kossmann, D., Miller, R. J., Blakeley, J. A., Schiefer, K. B. (Eds.), Proceedings of the 30 th International Conference on Very Large Data Bases (VLDB ’04). Morgan Kaufman, pp. 13–23. 93

Johnson, D. S., Pollak, H. O., 1987. Hypergraph planarity and the complexity of drawing Venn diagrams. Journal of 11 (3), 309–325. 87, 94

Karp, R. M., 1972. Reducibility among combinatorial problems. In: Miller, R., Thatcher, J. (Eds.), Complexity of Computer Computations. Plenum Press, pp. 85–103. 94 Bibliography 117

Kaufmann, M., van Kreveld, M., Speckmann, B., 2009. Subdivision drawings of hypergraphs. In: Tollis and Patrignani (2009), pp. 396–407. 87, 88

Kaufmann, M., Wagner, D. (Eds.), 2001. Drawing Graphs: Methods and Models. Vol. 2025 of Lecture Notes in Computer Science. Springer. 1

Kaufmann, M., Wagner, D. (Eds.), 2007. Proceedings of the 14th International Symposium on Graph Drawing (GD ’06). Vol. 4372 of Lecture Notes in Com- puter Science. Springer. 114, 117

Kaufmann, M., Wiese, R., 2002. Embedding vertices at points: Few bends suffice for planar graphs. Journal of Graph Algorithms and Applications 6 (1), 115– 129. 39

Korach, E., Stern, M., 2003. The clustering matroid and the optimal clustering tree. Mathematical Programming, Series B 98, 385 – 414. 87

Kosub, S., Maaß, M. G., T¨aubig,H., 2006. Acyclic type-of-relationship problems on the Internet. In: Erlebach, T. (Ed.), Proc. 3rd Workshop Combinatorial and Algorithmic Aspects of Networking (CAAN ’06). Vol. 4235 of Lecture Notes in Computer Science. Springer, pp. 98–111. 72

Kr´al’,D., Kratochv´ıl,J., Voss, H.-J., 2004. Mixed hypercacti. Discrete Mathe- matics 286, 99–113. 87

Lee, Y.-Y., Lin, C.-C., Yen, H.-C., 2006. Mental map preserving graph drawing using simulated annealing. In: Misue, K., Sugiyama, K., Tanaka, J. (Eds.), Proceedings of the 2006 Asia-Pacific Symposium on Information Visualisation (APVis ’06). Australian Computer Society, pp. 179–188. 55

Lipton, R. J., Rose, D. J., Tarjan, R. E., 1979. Generalized nested dissection. SIAM Journal on Numerical Analysis 16 (2), 346–358. 34

Melan¸con, G., Herman, I., 1998. Circular drawing of rooted trees. Technical report 9817, Reports of the Centre for Mathematics and Computer Science. URL http://www.cwi.nl/InfoVis/papers/circular.pdf 12

Merrick, D., Gudmundsson, J., 2007. Path simplification for metro map layout. In: Kaufmann and Wagner (2007), pp. 258–269. 55

Michener, C. D., Sokal, R. R., 1957. A quantitative approach to a problem in classification. Evolution 11 (2), 130–162. 19 118 Bibliography

Misue, K., Eades, P., Lai, W., Sugiyama, K., 1995. Layout adjustment and the mental map. Journal on Visual Languages and Computing 6 (2), 183–210. IV, 55

Neyer, G., 1999. Line simplification with restricted orientations. In: Dehne, F., Gupta, A., Sack, J.-R., Tamassia, R. (Eds.), Proceedings of the 6th Workshop on Algorithms and Data Structures (WADS ’99). Vol. 1663 of Lecture Notes in Computer Science. Springer, pp. 13–24. 55

N¨ollenburg, M., 2010. An improved algorithm for the metro-line crossing mini- mization problem. In: Eppstein and Gansner (2010), pp. 381–392. 89

N¨ollenburg, M., Wolff, A., 2006. A mixed-integer program for drawing high- quality metro maps. In: Healy and Nikolov (2006), pp. 321–333. 55

Opatrny, J., 1979. Total ordering problems. SIAM Journal on Computing 8 (1), 111–114. 71, 72, 92, 93

Pach, J., Wenger, R., 1998. Embedding planar graphs at fixed vertex locations. In: Whitesides (1998), pp. 263–274. 39

Page, R. D. M., 2000. TreeView. http://taxonomy.zoology.gla.ac.uk/rod/ treeview.html, university of Glasgow. 16

PHYLIP, 1993. PHYLIP. Phylogeny inference package. http://evolution.genetics.washington.edu/phylip.html. 16, 22

Purchase, H. C., 1997. Which aesthetic has the greatest effect on human un- derstanding? In: Di Battista, G. (Ed.), Proceedings of the 5th International Symposium on Graph Drawing (GD ’97). Vol. 1353 of Lecture Notes in Com- puter Science. Springer, pp. 248–261. 1

Reingold, E. M., Tilford, J. S., 1981. Tidier drawing of trees. IEEE Transactions on Software Engineering 7 (2), 223–228. 12

Saitou, N., Nei, M., 1987. The neighbor-joining method: A new method for reconstructing phylogenetic trees. Molecular Biology and Evolution 4 (4), 406– 425. 19

Simonetto, P., Auber, D., Archambault, D., 2009. Fully automatic visualisation of overlapping sets. Forum 28 (3), 967–974. 87

Sugiyama, K., 2002. Graph Drawing and Applications for Software and Knowl- edge Engineers. World Scientific. 1 Bibliography 119

Swofford, D. L., 2002. PAUP∗. Phylogenetic analysis using parsimony (and other methods). http://paup.csit.fsu.edu/, florida State University. 16

Swofford, D. L., Olsen, G. J., Waddell, J., Hillis, D. M., 1996. Phylogenetic infer- ence. In: Hillis, D. M., Moritz, C., Mable, B. (Eds.), Molecular Systematics, 2nd Edition. Sinauer Associates, pp. 407–514. 16

Tarjan, R. E., Yannakakis, M., 1984. Simple linear-time algorithms to test chordality of graphs, test acyclicity of hypergraphs, and selectively reduce acyclic hypergraphs. SIAM Journal on Computing 13 (3), 566–579. 87, 106

Tischler, G., Radzik, T. (Eds.), 2010. Proceedings of the 21st International Work- shop on Combinatorial Algorithms (IWOCA 2010). Vol. 6460 of Lecture Notes in Computer Science. Springer. 113

Tollis, I. G., Patrignani, M. (Eds.), 2009. Proceedings of the 16th International Symposium on Graph Drawing (GD 2008). Vol. 5417 of Lecture Notes in Computer Science. Springer. 113, 117

Tutte, W. T., 1960. Convex representations of graphs. Proceedings of the London Mathematical Society, Third Series 10, 304–320. 30

Tutte, W. T., 1963. How to draw a graph. Proceedings of the London Mathe- matical Society, Third Series 13, 743–767. 30

Walker, J. Q., 1990. A node-positioning algorithm for general trees. Software— Practice and Experience 20 (7), 685–705. 12

Whitesides, S. H. (Ed.), 1998. Proceedings of the 6th International Symposium on Graph Drawing (GD ’98). Vol. 1547 of Lecture Notes in Computer Science. Springer. 114, 118

Wiese, R., Eiglsperger, M., Kaufmann, M., 2002. yFiles: Visualization and au- tomatic layout of graphs. In: Mutzel, P., J¨unger,M., Leipert, S. (Eds.), Pro- ceedings of the 9th International Symposium on Graph Drawing (GD ’01). Vol. 2265 of Lecture Notes in Computer Science. Springer, pp. 453–454. 16, 37

Wolff, A., 1970. Drawing subway maps: A survey. Informatik-Forschung und Entwicklung 22, 23–44. 89

Yannakakis, M., 1982. The complexity of the partial order dimension problem. SIAM Journal on Algebraic and Discrete Methods 3 (3), 351–358. 72 Index

, 9, 10 assignment, 73 P false, 10, 72 axes of monotonicity, 90 true, 10, 72 , 9, 10 barycenter, 30 NP -complete, 10, 11, 19, 87, 93, 94 bend, 3, 38 -completeness, 9 bisector, 12, 19, 24 -hard, 10, 55, 57, 59, 63, 65, 68, 71, Boolean 72, 75, 78, 80, 83, 92 expression, 10 -hardness, 56 variable, 10 3-SAT, 57, 72, 73 border, 50 MONOTONE 3-SAT, 10, 56, 57 bound, 39, 105 acyclicity, 71 boundary, 30 adjacent, 2, 7, 11 buffer, 25 algorithm, 19, 22, 23, 38, 55, 89 linear time, 12, 16 certificate, 10 polynomial time, 10 child, 7, 12, 18, 38, 95 analysis, 16 circle, 12, 46 ancestor, 8, 18, 35 unit, 22 anchor vertex, 72 class, 16 angle, 11 clause, 10, 57, 63, 65, 73 absolute, 16, 41 negative, 10, 58 angle assignment, 11 positive, 10, 58 angle set, 11 clockwise, 12, 42 pre-specified, 39 clustering, 16 relative, 41 coloring scheme, 35 rotation angle, 40 Complementarity Property, 19 template, 41 complementary, 19 angular conflict, 95 deviation, 41 conflict graph, 98 difference, 21 conjunction, 10 resolution, 3, 12, 23, 39 conjunctive normal form, 10 width, 21, 26 constraint, 1, 11, 38, 55, 67, 93 approximation, 71 angle constraint, 2, 11, 38, 50 Index 121

distance constraint, 2, 11, 16, 38, wedges, 38 50 disjunction, 10 ordering constraint, 55 distance, 55 contradiction, 34, 45 evolutionary, 18 control segment, 40 DNA sequence, 18 initial, 50 drawable, 72 convex drawing, 9, 11, 16, 55 arch, 21 circular, 30 combinations, 32 planar, 2, 9, 50 faces, 21, 24 sketch-based drawing, 55 hull, 30, 50, 84 straight-line, 3, 22, 38, 39, 71, 90 polygon, 30 tree drawing, 16 coordinates, 22 counterclockwise, 9, 11, 12, 22, 24, 41 edge, 1, 7, 12, 38 crossing crossing, 39 curved, 39 clockwise, 42 directed, 7 counterclockwise, 44 framing edge, 57, 63, 67 curve, 3, 12, 46, 89 length, 4, 11, 16, 55, 56 B´eziercurve, 50 literal edge, 57, 63, 67 continuously differentiable, 51 multiple, 7 cycle, 7 undirected, 7 data set, 11, 12, 16, 87 embedding-constrained, 55 decision path equation, 34 horizontal, 63 error, 36 vertical, 63, 65 Euler diagram, 5, 8, 87, 94 decision unit Euler tour, 38 horizontal, 57, 67 exploration, 16 vertical, 57, 67 extension, 18 degree, 7 font, 26 indegree, 7 fork, 23 outdegree, 7 function, 19 dendrogram, 16 objective, 43 descendant, 8 deviation, 18 gadget, 56 dimension, 71, 72 geographic network, 12 direction, 4, 9, 40, 71, 72 graph, 1, 7 -restricted, 55 acyclic, 7 Disjoint, 21 angle-constrained, 11 disjoint, 89, 95 bipartite, 7 subtrees, 38 distance-constrained, 11 122 Index

embedded, 9, 11 link, 57 planar, 9, 39 negative, 57 simple, 7 positive, 57 graph drawing, 1, 55 list force-directed, 39 sorted, 106 orthogonal-order preserving, 55 vertex list, 49 simultaneous, 71 literal, 10, 72, 73 locally consistent, 11 halfline, 12 loop, 7 Hasse diagram, 8, 95 augmented, 94, 95 mapping, 39 horizontal, 18 mental map, 3, 55 host graph, 8 metric hull, 46 Euclidean metric, 55 hyperedge, 5, 8, 88 Fr´echet metric, 55 implied, 95 metro map, 4, 5, 55, 88 non-implied, 95 anthology, 88 summary hyperedge, 95 layout, 88 hypergraph, 5, 8, 72, 87 layout algorithms, 88 coloring, 87 like drawing, 88 drawing, 88 like drawing, 89 molecules, 18 incident, 7 monotone, 90 induction, 35 multigraph, 7 instance, 9, 58, 72, 73, 92 internal preference scaling, 71 negation, 10 intersection, 12, 39, 42, 45, 90 neighbor, 7, 12, 30, 38, 55 invariant characteristic, 38 nesting, 16 network, 1 label, 16, 22, 26 nondeterministic, 10 layout nondeterministic polynomial, 10 balloon layout, 12 barycentric, 30 octilinear, 4, 55, 63 bend-minimum orthogonal, 55 optimization, 26 dynamic, 55 order final, 41 horizontal, 56 initial, 9, 38 reversed topological, 99 stability, 55 vertical, 56 leaf, 16, 22, 38 ordering, 92, 95 length-preserving, 38 cyclic, 55 line, 55, 90 orthogonal, 3, 9, 55, 56 linear time, 23, 38, 50, 106 total, 9 Index 123 parent, 7, 12, 38 property, 35 path, 5, 7, 23, 38, 56, 71, 72 proportional, 21 clause path, 72 pulled between, 43 Hamiltonian path, 71, 88, 94 pushed over, 43 length, 7 quadrangle, 9 polygonal, 55 simple, 7 radius, 13, 46 spanning, 89 rake, 23 variable path, 58, 72 triple, 23 perimeter, 26 range, 47, 56 PHYLIP, 22 ranking Phylogeny, 16 complete, 71 planar, 19, 38 readability, 12 planarity, 19, 32, 34, 40 rectilinear, 4, 55, 56 plane, 39, 56, 89 reduction, 10, 72 point, 39 polynomial time, 10 splitting point, 50 region, 73, 89 polygonal chain, 21, 38 right-first search, 38 polyline, 12, 38, 40, 46 root, 8, 16, 19, 38 planar, 38 valid, 23 polynomial, 9 rotation, 18, 21, 38, 44 polynomial time, 39 run time, 35, 105 position linear, 41 absolute, 1 saturation, 36 relative, 1, 55, 72 scaling, 18, 21 vertex position, 38 sector, 12 postorder-traversal, 16 set, 89 prefix, 72 of points, 39 preorder-traversal, 16, 19, 22 sheering problem, 9, 39 clockwise, 43, 50 betweenness problem, 92 counterclockwise, 43, 48, 50 decision problem, 9, 55 similarity, 55 decision problem, 2 simple, 89 dimensionality problem, 72 simplification, 3, 55 octilinear drawing problem, 55 shape, 55 ordering problem, 72 sink, 7, 95 satisfiability problem, 10 solution, 9 strictly monotone trajectory draw- source, 7, 95 ing problem, 71, 83, 92 species, 18 trajectory drawing problem, 4, 71 straight-line, 9, 11, 16 124 Index

realizability, 11, 38 unimodal, 72 strictly monotone unique, 93 decreasing, 72 increasing, 9, 71, 72 variable, 58, 72 subclass, 16 negated, 63, 65, 73 subgraph, 7, 88, 95 non negated, 73 subpath, 56 vertex, 1, 7, 12, 56, 71, 89 subset, 4 anchor vertex, 72 subtree, 16, 21, 38 distribution, 1 support, 5, 8, 72, 87 inner, 7 cactus, 87 vertical, 18 compact, 87 walk, 7 cycle, 87 wedge, 12, 19, 38 minimum path-based, 89, 93 size, 12 monotone path-based, 89, 92, 93 weighting scheme, 19 outerplanar, 88 witness, 10 path, 87 path-based, 88, 89 path-based tree, 89 planar, 87, 94 planar path-based, 94 planar path-based, 89 tree, 87, 94 symmetry, 19

TDP, 71, 72 time linear, 72, 87 polynomial, 56, 72, 87–89 trajectories, 4, 71, 72 translation, 18, 21, 38 tree, 8, 12, 38, 50, 56, 88 binary, 8, 18 complete, 8 embedded, 38 phylogenetic tree, 2, 16, 18 rooted, 18 subtree, 8 unrooted, 38 triangle, 9 truth assignment, 72