1 / 44

Testing planarity part 1

Testing planarity part 1. Thomas van Dijk. Preface. Appendix of Planar Graph Drawing Quite hard to read So we’ll try to explain it, not just tell you about it. Preface. “ There are a number of efficient algorithms for planarity testing, which are unfortunately all difficult to implement.”

elisha
Download Presentation

Testing planarity part 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Testing planaritypart 1 Thomas van Dijk

  2. Preface • Appendix of Planar Graph Drawing • Quite hard to read • So we’ll try to explain it, not just tell you about it

  3. Preface • “There are a number of efficient algorithms for planarity testing, which are unfortunately all difficult to implement.” • (www.mathworld.com)

  4. Preface • “There are a number of efficient algorithms for planarity testing, which are unfortunately all difficult to implement.” • (www.mathworld.com) • Implementation in Mathematica was actually bugged until version 4.2.1 (!) • (Also mathworld.com)

  5. What is planarity testing? • Whether a graph can be drawn on the plane without edge crossings • Equivalently, whether a “planar embedding” of the graph exists

  6. Embedding • Adjacency-list representation of the graph • Order in the list defines clockwise order of the edges

  7. Embedding • Adjacency-list representation of the graph • Order in the list defines clockwise order of the edges 1 2 2 4 3 4 3 1 3 4 1 2 4 3 1 2

  8. Embedding • Adjacency-list representation of the graph • Order in the list defines clockwise order of the edges 2 4 3 1 1 2 2 4 3 4 3 1 3 4 1 2 4 3 1 2 3 3 4 1 2 4 3 1 2 1 4 2

  9. Overview • “Vertex addition algorithm” • First presented by Lempel et al (’67) • Improved to linear time byBooth and Lüker (’76) • We present this second algorithm

  10. Main idea • Start with one vertex • Add vertices and their edges one by one • make sure we don’t break planarity • If you can’t add the next vertex, graph is not planar • add the vertices in an order such that if we fail, we that know that using any other order wouldn’t have worked either

  11. We need to know about • Some general observations • st-Numbering • Bush forms / PQ-Trees

  12. O(m) is O(n) for planar graphs • Remember from Euler’s Theorem we have thatm ≤ 3n-6for simple plane graphs • Algorithm can just reject graphs with too many edges. • So from now on, O(m) is O(n)

  13. Biconnected components • Definition:A graph G is biconnected ifffor every two distinct vertices there exist two internally disjoint paths between them • Also iff G contains no cut-vertices • i.e.: cannot be made unconnected by removing a single vertex

  14. Biconnected components • Theorem:A graph is planar iffall its biconnected components are planar • Proof:Induction on the number of biconnected components

  15. Biconnected components • If the graph is planar, clearly its biconnected components are planar • A graph is planar iff its connected components are planar • A connected graph with no biconnected components is a tree; trees are planar

  16. Biconnected components • If a graph has one biconnected component, then all vertices not in it are in trees. So the graph is planar iff the biconnected component is planar

  17. Biconnected components • Induction step: • The next biconnected component is connected to the rest of the graph by a cut-vertex v.

  18. Biconnected components • Induction step: • The next biconnected component is connected to the rest of the graph by a cut-vertex v. • Since the biconnected component itself is planar, an embedding with v on the exterior exists. (As Hans showed us.)

  19. Biconnected components • The biconnected components of a graph can be found in linear time • (If you are interested, an exercise in Cormen et al explains it) • So from now on, we can assume graphs are biconnected.

  20. st-Numbering • From the ‘main idea’ slide:“Add the vertices in an order such that if we fail, we that know using any other order wouldn’t have worked either”

  21. 8 1 st-Numbering • Special nodes: source s (“1”) and sink t (“n”) • “1” and “n” adjacent

  22. 8 1 st-Numbering • Special nodes: source s (“1”) and sink t (“n”) • “1” and “n” adjacent • j V-{s,t}: i, k Adj(j)st(i)<st(j)<st(k)

  23. 8 1 7 2 st-Numbering • Special nodes: source s (“1”) and sink t (“n”) • “1” and “n” adjacent • j V-{s,t}: i, k Adj(j)st(i)<st(j)<st(k) • So 2 must be next to 1and n-1 must be next to n

  24. 8 5 1 7 2 3 6 4 st-Numbering • Special nodes: source s (“1”) and sink t (“n”) • “1” and “n” adjacent • j V-{s,t}: i, k Adj(j)st(i)<st(j)<st(k) • So 2 must be next to 1and n-1 must be next to n

  25. 2 1 4 6 3 5 11 12 9 7 10 8 5 4 1 3 2 Some st-numbering examples

  26. st-Numbering • Theorem:Every biconnected graph has an st-numbering • Proof:We give an algorithm and show that it works if the graph is biconnected • Our graph is biconnected, so anst-numbering exists.

  27. Finding an st-numbering • First step, standard DFS. • Can visit children in any order • Calculate and store per vertex: • Parent • “Depth first search number:” DFN • Low-point: the lowest DFN among nodes that can be reached by a path using any amount of tree edges followed by 1 back edge

  28. G

  29. G DFS

  30. DFN 6 G 5 4 3 2 DFS 1

  31. DFN LOW 6 3 G 5 3 4 1 3 1 2 1 DFS 1 1

  32. Finding an st-numbering • Push the vertices onto a stack and pop them off • Four rules for what to push and pop • Assign increasing numbers to the vertices when they are popped off for the last time • Example follows

  33. Initial setup • The node with DFN 2 is called the ‘source’ • The node with DFN 1 is called the ‘sink’ • Stack with sourceon top of sink • Source and sinkare “old” b a d c ac e f

  34. Rule “2” • There is a “new” tree edge: follow it and take the path that leads to its low point • Push the vertices on the path ontothe stack • Mark all as old. b a abc d c e f

  35. No matches for vertex a • There are now no rule matches for a. • Pop it off the stack and give it the next available number • This node is ready b 1 d c bc e f

  36. Rule “3” • There is a “new” back edge into this node: from the other end, go back up tree edges to an “old” vertex • Push the vertices onthe path ontothe stack • Mark all as old bfedc b 1 d c e f

  37. No matches for vertex b • So the vertex is ready and gets its number fedc 2 1 d c e f

  38. No matches for vertex f • So the vertex is ready and gets its number edc 2 1 d c e 3

  39. Et cetera… 2 1 5 6 4 3

  40. Correctness • All vertices are numbered • The numbering is indeed an st-numbering

  41. Algorithm recap • For linear complexity, we need thatO(m) = O(n). • For correctness, we need that the graph is biconnected

  42. After the break … • Ron will tell you about: • bush forms and PQ-trees • how it all fits together into a planarity testing algorithm

  43. Any questions?

  44. Any questions? • http://www.planarity.net/

More Related