1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.

Slides:



Advertisements
Similar presentations
Graph Algorithms Algorithm Design and Analysis Victor AdamchikCS Spring 2014 Lecture 11Feb 07, 2014Carnegie Mellon University.
Advertisements

Lecture 15. Graph Algorithms
Great Theoretical Ideas in Computer Science
Octagonal Drawing Johan van Rooij. Overview What is an octagonal drawing Good slicing graphs Octagonal drawing algorithm for good slicing graphs Correctness.
Chapter 9 Graphs.
Every edge is in a red ellipse (the bags). The bags are connected in a tree. The bags an original vertex is part of are connected.
Divide and Conquer. Subject Series-Parallel Digraphs Planarity testing.
Chapter 10: Trees. Definition A tree is a connected undirected acyclic (with no cycle) simple graph A collection of trees is called forest.
AVL Trees COL 106 Amit Kumar Shweta Agrawal Slide Courtesy : Douglas Wilhelm Harder, MMath, UWaterloo
Great Theoretical Ideas in Computer Science for Some.
1 Discrete Structures & Algorithms Graphs and Trees: III EECE 320.
CS 312 – Graph Algorithms1 Graph Algorithms Many problems are naturally represented as graphs – Networks, Maps, Possible paths, Resource Flow, etc. Ch.
Applications of graph traversals
Great Theoretical Ideas in Computer Science.
Data Structures & Algorithms Graph Search Richard Newman based on book by R. Sedgewick and slides by S. Sahni.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
Great Theoretical Ideas in Computer Science.
Voronoi Diagrams.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
CSC 2300 Data Structures & Algorithms February 6, 2007 Chapter 4. Trees.
Graph Algorithms Using Depth First Search Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
Advanced Data Structures and Algorithms COSC-600 Lecture presentation-6.
MST Many of the slides are from Prof. Plaisted’s resources at University of North Carolina at Chapel Hill.
A Test for the Consecutive Ones Property 1/39. Outline Consecutive ones property PQ-trees Template operations Complexity Analysis –The most time consuming.
“On an Algorithm of Zemlyachenko for Subtree Isomorphism” Yefim Dinitz, Alon Itai, Michael Rodeh (1998) Presented by: Masha Igra, Merav Bukra.
UNC Chapel Hill Lin/Foskey/Manocha Minimum Spanning Trees Problem: Connect a set of nodes by a network of minimal total length Some applications: –Communication.
Tree A connected graph that contains no simple circuits is called a tree. Because a tree cannot have a simple circuit, a tree cannot contain multiple.
Discussion #32 1/13 Discussion #32 Properties and Applications of Depth-First Search Trees.
Introduction to Planarity Test W. L. Hsu. Plane Graph A plane graph is a graph drawn in the plane in such a way that no two edges intersect A plane graph.
Finding maximal planar subgraphs Wen-Lian Hsu 1/33.
Graphs.
Starting at Binary Trees
Agenda Review: –Planar Graphs Lecture Content:  Concepts of Trees  Spanning Trees  Binary Trees Exercise.
Data Structures and Algorithms in Parallel Computing Lecture 2.
Graphs A graphs is an abstract representation of a set of objects, called vertices or nodes, where some pairs of the objects are connected by links, called.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
Graph theory and networks. Basic definitions  A graph consists of points called vertices (or nodes) and lines called edges (or arcs). Each edge joins.
Topological Sort: Definition
PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting.
Trees Dr. Yasir Ali. A graph is called a tree if, and only if, it is circuit-free and connected. A graph is called a forest if, and only if, it is circuit-free.
Chapter 10: Trees A tree is a connected simple undirected graph with no simple circuits. Properties: There is a unique simple path between any 2 of its.
Properties and Applications of Depth-First Search Trees and Forests
S&H Planarity Test Based on PC-Trees Wen-Lian Hsu.
PC-Trees vs. PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting.
Algorithms for hard problems Parameterized complexity Bounded tree width approaches Juris Viksna, 2015.
Trees By JJ Shepherd. Introduction Last time we discussed searching and sorting in a more efficient way Divide and Conquer – Binary Search – Merge Sort.
Trees CSIT 402 Data Structures II 1. 2 Why Do We Need Trees? Lists, Stacks, and Queues are linear relationships Information often contains hierarchical.
5. Biconnected Components of A Graph If one city’s airport is closed by bad weather, can you still fly between any other pair of cities? If one computer.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
PC-Trees & PQ-Trees. 2 Table of contents Review of PQ-trees –Template operations Introducing PC-trees The PC-tree algorithm –Terminal nodes –Splitting.
Algorithms and Networks
Great Theoretical Ideas In Computer Science
CSCE 210 Data Structures and Algorithms
Characteristics of Planar Graphs
Discrete Mathematicsq
GRAPHS Lecture 16 CS2110 Fall 2017.
Conventions Red edges: traversed tree edges White edges: back edges
12. Graphs and Trees 2 Summary
PC trees and Circular One Arrangements
Great Theoretical Ideas in Computer Science
ITEC 2620M Introduction to Data Structures
Algorithms and Complexity
CMSC 341 Lecture 10 B-Trees Based on slides from Dr. Katherine Gibson.
Graph Algorithms Using Depth First Search
Planarity Testing.
Discrete Mathematics for Computer Science
Bart M. P. Jansen June 3rd 2016, Algorithms for Optimization Problems
Lecture 11 Graph Algorithms
Trees.
Minimum Spanning Trees
Presentation transcript:

1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan

2 Outline Planar Graphs  Definition  Some thoughts  Basic Strategy PC Tree Algorithm  Review of PC Trees  The Algorithm  Complexity Analysis

3 Planar Graphs Graphs that can be drawn on a plane, without intersecting edges. Examples:  Borders Between Countries  Trees, Forests  Simple Cycles Counter-Examples: K5K5  K 3,3

4 Basic Non-Planar Graphs

5 Some Thoughts Every Non-Planar Has a K 5 or K 3,3 Subgraph (Kuratowski, 1930) Articulation Vertices – Divide and Conquer. The Problem – Cycles  Everything else is either inside or outside.  Cut-Set Cycle in a Graph– A cycle that breaks the graph’s connectivity.

6 More Thoughts Small Variations on Trees are allowed  Connect one vertex to another.  Connect all leaves to the root. “Minimal” Biconnected Tree  Biconnected: No Articulation Vertices  Root Must Have a Single Child.  Connect Root to a Descendant of its Child.  Connect All Leaves to Ancestors.

7 Existing Solutions Hopcroft & Tarjan – 1974  First Linear Time Solution PQ-Tree related solutions  Early 90’s  Fairly complicated PC-Tree Solution – 1999  Presented here

8 Our Strategy Find a Cut-Set Cycle Replace it With a Simple Place-Holder Recursively Work on the Inside and the Outside of the Graph Put Everything Back Together On Error – Find a Kuratowski Sub- Graph.

9 Some Preprocessing Split by Articulation Vertices DFS Scan the Graph  Reminder: Back-Edges connect vertices with their ancestors. Label the Vertices According to a Post- Order Traversal of the DFS-Tree Keep a List of Back-Vertices, Sorted in Ascending (Post-)Order

10 Data Representation Same building blocks as in PC-Trees. P-nodes represent regular vertices in the graph (store their label) C-nodes represent “place-holders” for cycles  Very intuitive: reserves cyclic order of edges. Each P-node Knows its DFS-Parent, Each Tree-Edge Knows Who’s the Parent

11 Flow of The Algorithm On each step we will work on a single back-vertex, according to their order in the list. Recursion Ends when the list only holds the root.  The root has to be a back-vertex  When it’s the only back-vertex we know how to embed the graph

12 Finding a Cut-Set Cycle Let i be the current back-vertex.  r is i’s son on the path to the back edge. Let T r be the DFS-subtree who’s root is r. We will view T r as a PC-tree  No internal back edges (i is minimal)  Back edges to i will be considered full  Back edges to ancestors of i will be considered empty

13 Full-Partial Labeling X is a Full Vertex When (deg(x)-1) of its Neighbors are Full X is an Empty Vertex When (deg(x)-1) of its Neighbors are Empty X is Partial if it is not Full and not Empty A Terminal Edge Connects Partial Vertices. Algorithm: Start with Full Leaves, and Scan Up the PC-Graph

14 Terminal Path All Terminal Edges Are Connected Claim: If they do not form a Path  The Graph isn’t Planar. (Proved Later) Claim: If we can’t Flip Full and Empty Vertices to Opposite side of the Path  The Graph isn’t Planar. (Proved Later)

15 T r As a PC-Tree

16 The Actual Cut-Set Cycle

17 Pitfall A Vertex can have a degree of 2. It can Full and Empty  Ambiguous. Easily detected:  X’s Full Neighbor is the Only One Left on the Update List.  Deg(X) = 2 In That Case – Only X is a Terminal Node.

18 Complete Labeling Algorithm L  List of Full Leaves While L is not Empty  X = pop(L)  If L is Empty, and X has a neighbor of degree 2  output X as the Only Terminal Node.  For each Neighbor Y of X Increment Y’s counter. If the counter reached deg(Y)-1  Add Y to L.

19 Finding The Terminal Path Climb Up the DFS Tree From All Partial Vertices, in an Interlaced Manner. Trim a Possible Apex. If We End Up with a Path  Output it. If We End Up with a Tree  Non- Planar.

20 Our Strategy - Reminder Find a Cut-Set Cycle Replace it With a Simple Place-Holder Recursively Work on the Inside and the Outside of the Graph Put Everything Back Together On Error – Find a Kuratowski Sub- Graph.

21 Place-Holder For A Cycle

22 Fine Details Resulting Graph has the Same Number of Edges, But One Less Cycle. A Vertex of Degree 2 on the Cycle Becomes an Articulation Vertex  Avoid it by Contracting The Vertex. We Want to Avoid Having Neighboring C Nodes  Contract them as well

23 Fine Details (2) Parent-bits of the edges need to be kept consistent.  Actually not very hard.  The new C-node is a Child of i.  Vertices in the terminal path that lost their parents are “adopted” by the new C-node  Edge contraction is easy to fix.

24 How It Is Done

25 How It Is Done (2)

26 How It Is Done (3)

27 Another Example

28 Another Example (2)

29 Another Example (3)

30 Another Example (4)

31 Our Strategy - Reminder Find a Cut-Set Cycle Replace it With a Simple Place-Holder Recursively Work on the Inside and the Outside of the Graph Put Everything Back Together On Error – Find a Kuratowski Sub- Graph.

32 Recursive Work The Inner Side of the Cycle is Easy  A tree (T r ) where all the leaves, and the root are connected to a single node – i. The Outer Side is Done Recursively  The new graph has fewer back-edges, and thus is simpler.

33 Putting It Together Each Phase Remembers:  Contracted Edges  The C-node it created Connecting Inner and Outer Parts is Easy  The C-node preserves cyclic order.

34 Handling Errors Two Possible Cases:  Terminal edges form a tree.  Terminal path can’t be flipped correctly. Basic Idea  Walk from i down the tree to problematic leaves  Move up through back edges  Down the tree back to i  K 5 or K 3,3

35 Terminal Edges Form a Tree

36 Points to Remember Full Leaves have Back-Edges to i. Empty Leaves have Back-Edges to ancestors of i. Every C-node in the Graph originated from a cycle  Every path through a C-node, represents two paths in the original graph.

37 Paths Through C-Nodes

38 When W is a P-Node

39 When W is a C-Node (1)

40 When W is a C-Node (2)

41 When W is a C-Node (2.1)

42 When W is a C-Node (2.2)

43 A Path that won’t Flip The Problematic Node is a C-Node Has an Empty and a Full Sub-Tree on the Same Side of the Path Terminal Edges Lead to Empty/Full Sub-Trees As Well

44 A Path That Won’t Flip (2)

45 Complexity Analysis Preprocessing  DFS Scan  Post-order scan of the DFS tree Actual Processing  Finding Terminal Path  Splitting Graph, Putting Back Together  Ordering Internal Sub-Tree  Recursive Call

46 Complexity Analysis (2) Preprocessing – Linear Finding Terminal Path  Every Node scanned not on the Terminal Path will be removed from the graph.  Only need to worry about total lengths of terminal paths Splitting and Joining  O(Terminal Path) Sub-Trees  Once for each node.

47 How Long Are The Paths Vertex is on the Terminal Path  Only two are at the edges  Linear cost  Others lose at least one edge (to full subtree)  O(|E|) total amount

48 Some Minor Details Terminal Path Flipping is Easy  P-nodes sorted through the labeling process  Flipping done in O(1) due to cyclic lists. Terminal Path Splitting is Easy  Simply use some pointer tricks

49 Summary Intuitive, Linear Algorithm to a Non- Trivial Problem Data Structure Actually Represents the Problem Domain A Great Way to End A Great Seminar

50 Questions ?

51 Complexity Analysis Use Amortized Complexity  If we work hard in phase i, we make the job easier for the next phases. Potential Function: |G i | – Number of Vertices and Edges in G i |C i | - Number of C-Nodes in G i |P i | - Number of P-Nodes in G i