MA Algorithms for Crossing Minimization in Book Drawings
Total Page:16
File Type:pdf, Size:1020Kb
Algorithms for crossing minimisation in book drawings Master Thesis of Jonathan Klawitter At the Department of Informatics Institute of Theoretical Informatics Chair of Algorithmics I Reviewer: Prof. Dr. Dorothea Wagner Second reviewer: Priv.-Doz. Dr. Martin Nöllenburg Advisor: Dr. Tamara Mchedlidze Duration:: 23. October 2015 – 22. April 2016 KIT – University of the State of Baden-Wuerttemberg and National Research Center of the Helmholtz Association www.kit.edu I declare that I have developed and written the enclosed thesis completely by myself, and have not used sources or means without declaration in the text. Karlsruhe, 20th April 2016 ......................................... (Jonathan Klawitter) Abstract A book with k pages consists of a line (the spine) and k half-planes (the pages ), each with the spine as boundary. In a k-page book drawing of a graph the vertices lie on the spine, and each edge is drawn as arc in one page. The minimal number of edge crossings in a k-page book drawing of a graph is called its k-page crossing number, which, in general, is -hard to determine [BE14]. A book drawing can be described by an order of the NP vertices on the spine and a distribution of the edges to pages. To compute book drawings, we combine vertex order heuristics with edge distribution heuristics and create heuristics that compute both simultaneously. We experimentally evaluate the performance of these heuristics on a new test suite that is centred on di↵erent graph classes. It turns out that our new heuristics produce drawings with fewer crossings for most of the tested graphs. We further investigate the optimisation of book drawings with force-based approaches, greedy and evolutionary algorithms as well as the successful combinations of the latter two. Zusammenfassung Ein Buch (book )mitk Seiten besteht aus einer Geraden (dem Bund (spine)) und k Hal- bebenen (den Seiten (pages )), die jeweils den Bund als Grenze haben. In einer k-seitigen Buchzeichnung (k-page book drawing) eines Graphen wird jeder Knoten auf den Bund und jede Kante als Kreisbogen auf eine Seite gezeichnet. Die minimale Anzahl von Kan- tenkreuzungen in einer k-seitigen Buchzeichnung eines Graphen nennt man seine k-Seiten Kreuzungszahl (k-page crossing number), welche im Allgemeinen -schwer zu bestimmen NP ist [BE14]. Eine Buchzeichnung kann durch die Ordnung der Knoten auf dem Bund und die Verteilung der Kanten auf die Seiten beschrieben werden. Um eine Buchzeichnung zu erzeugen, kombinieren wir Heuristiken zum Bestimmen von Knotenordnungen und Kan- tenverteilungen sowie neue Heuristiken, die beides simultan berechnen. Wir evaluieren die Performanz dieser Heuristiken anhand einer neuen Testsammlung, welches auf ver- schiedenen Graphklassen basiert. Wir konnten zeigen, dass unsere neuen Heuristiken fur¨ die meisten der getesteten Graphen Zeichnungen mit weniger Kreuzungen erzeugen. Des Weiteren betrachten wir die Optimierung von Graphzeichnungen mit kr¨aftebasierten und evolution¨aren Ans¨atzen, sowie Greedyalgorithmen und vielversprechende Kombinationen selbiger. v Contents 1. Introduction 1 1.1. Book drawings and book embeddings . 1 1.2. Motivation . 3 1.3. Related work . 4 1.4. Outline ...................................... 6 2. The problem 7 2.1. Basicresults.................................... 7 2.1.1. Trees.................................... 7 2.1.2. Biconnected components . 10 2.1.3. Outerplanar graphs . 10 2.1.4. Fixed vertex order . 11 2.2. NP-hardness . 12 2.2.1. Book embedding . 12 2.2.2. Crossing number . 13 2.3. Exact solution . 14 2.3.1. SAT.................................... 14 2.3.2. Weighted MAX-SAT . 16 2.4. Counting crossings . 17 2.4.1. Counting and reporting . 17 2.4.2. Open edges sweep . 17 2.4.3. Transformation to two-layer cross counting . 18 2.4.4. Evaluation . 19 3. Heuristic approaches 23 3.1. Vertexorderheuristics . 23 3.1.1. Depth-first search . 24 3.1.2. Breath-first search . 24 3.1.3. Max-neighboring . 25 3.1.4. Connectivity . 25 3.2. Edgedistributionheuristics . 27 3.2.1. Greedy .................................. 27 3.2.2. Slope . 28 3.2.3. Ear decomposition . 29 3.3. Fulldrawingheuristics . 30 4. Evaluation of heuristics 33 4.1. Linear number of edges . 34 4.1.1. Experimentalresults . 34 4.2. Outerplanar graphs . 36 4.3. Cartesian product of cycles . 37 4.3.1. Experimentalresults . 38 vii viii Contents 4.4. Planar graphs . 39 4.4.1. Finding Hamiltonian cycle . 40 4.4.2. Distributingperfectly . 41 4.4.3. Average number of crossings . 41 4.5. 1-planar graphs . 44 4.5.1. Experimentalresults . 44 4.6. K-trees....................................... 46 4.6.1. Experimentalresults . 46 4.7. Hypercubes and t-ary d-cubes . 48 4.7.1. Experimentalresults . 48 4.8. Complete graphs . 49 4.9. Complete bipartite graphs . 51 4.9.1. Experimentalresults . 51 4.10. Quadratic number of edges . 52 4.11. Conclusion . 54 5. Optimisation 57 5.1. Greedy optimisation . 57 5.1.1. Greedy vertex order optimisation . 57 5.1.2. Greedy edge distribution optimisation . 58 5.1.3. Greedy book drawing optimisation . 58 5.1.4. Evaluation . 59 5.2. Evolutionary algorithms . 60 5.2.1. Mimicing evolution in nature . 60 5.2.2. Implementation . 62 5.2.3. Algorithms . 64 5.3. Evaluation of optimisation algorithms . 65 5.4. Force-based optimisation . 67 5.4.1. Mean & median iteration vertex order . 67 5.4.2. Force-based edge distribution . 69 5.5. Further approaches . 71 5.5.1. Graph partitioning & clustering . 71 5.5.2. Maximal independent set . 72 6. Summary and outlook 73 Bibliography 76 Appendix 89 A. Graph generation . 89 A.1. Trees.................................... 89 A.2. Outerplanar graphs . 89 A.3. Maximal planar graphs . 89 A.4. Hamiltonian planar graphs . 90 A.5. 1-planar graphs . 90 A.6. K-trees .................................. 91 A.7. Random graphs . 91 A.8. Shu✏ing.................................. 91 B. Further experiment results . 91 B.1. 1-planar graphs . 91 B.2. Hypercubes and t-ary d-cubes . 92 B.3. Random graphs . 92 C. Toolsandmachines................................ 93 viii 1. Introduction In this thesis we evaluate heuristics and optimisation algorithms for the NP-hard problem of crossing minimisation in book drawings. We start with basic definitions and then proceed with our research question and related work. At the end of the chapter we give an overview of this thesis. 1.1. Book drawings and book embeddings We draw undirected graphs into topological structures fittingly called books. They can be defined as follows. Definition 1.1. For k 1,ak-page book,orabookwithk pages, consists of a line in ≥ three dimensional space (the spine) and k half-planes (the pages) bounded by this line. Less formal, a book consist solely of a spine with attached pages. A graph is drawn into a book by representing its vertices as distinct points on the spine and drawing each edge as a circular arc in exactly one page. In Figure 1.1 a graph with eight vertices is drawn into a book with four pages. page 1 page 3 1 8 spine page 2 page 4 Figure 1.1.: A 4-page book drawing of a graph, where vertices (from 1 to 8) are placed on the spine (shown twice) and edges are distributed to pages. Pages 1 and 2 are crossing-free, whereas the edges in page 3 and 4 produce several crossings. We note that we can turn around the book, meaning reverse the order of the vertices, and still have a proper book drawing. Furthermore, the numbering of the pages has no further relevance. The drawing stays combinatorially and topologically equivalent. Another feature of book drawings becomes apparent, if we transform them into circular drawings by bending the spine into a cycle, as shown in Figure 1.2. Here, vertices are 1 2 1. Introduction placed on a circle and edges are drawn as chords. If we cut the circle at a di↵erent position than where we joined the ends of the spine, we get a new drawing with rotated order of the vertices. This is also illustrated in Figure 1.2. To represent pages in circular drawings the edges are assigned to layers or are drawn in di↵erent colours. Figure 1.3 depicts the 4-page book from Figure 1.1 as circular drawing. Throughout this thesis, we will call the order (respectively circular order) of the vertices, vertex order, and the assignment of edges to pages, edge distribution. Joining these insights, we can now define the book drawings from the combinatorial point of view. Figure 1.2.: The 1-page book drawing on the left is converted into a circular drawing. The latter is then cut between two other vertices to obtain a book drawing with rotated spine. 1 8 page 1 page 2 page 3 page 4 Figure 1.3.: A circular drawing of the book drawing in Figure 1.1, where the pages are represented by the colours of the edges. Definition 1.2. A k-page book drawing of a graph G =(V,E) is defined by a vertex order, a circular order of its vertices V ,andanedgedistribution,amapofitsedgesE to k pages. Similar to planar drawings, there can also be crossings of edges in book drawings. We say two edges uv and xy cross if their arcs (respectively chords) cross. See for example again Figures 1.1 and 1.3 where pages 3 and 4 contain crossings. These are in fact the same crossings, since the transformation described above preserves them. We further observe that a crossing is only possible between non-incident edges and if their end vertices alternate. Hence, we get the following definition for crossings in book drawings. Definition 1.3. In a book drawing of a graph G =(V,E),twoofitsedgesuv, xy E 2 cross if they are on the same page and their endpoints alternate in the vertex order.