1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.
-
Upload
dustin-andrews -
Category
Documents
-
view
215 -
download
0
Transcript of 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.
![Page 1: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/1.jpg)
1
PQ Trees, PC Trees, and Planar Graphs
Hsu & McConnell
Presented by Roi Barkan
![Page 2: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/2.jpg)
2
Outline
Planar Graphs Definition Some thoughts Basic Strategy
PC Tree Algorithm Review of PC Trees The Algorithm Complexity Analysis
![Page 3: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/3.jpg)
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
K3,3
![Page 4: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/4.jpg)
4
Basic Non-Planar Graphs
![Page 5: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/5.jpg)
5
Some Thoughts
Every Non-Planar Has a K5 or K3,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.
![Page 6: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/6.jpg)
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.
![Page 7: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/7.jpg)
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
![Page 8: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/8.jpg)
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.
![Page 9: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/9.jpg)
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
![Page 10: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/10.jpg)
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
![Page 11: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/11.jpg)
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
![Page 12: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/12.jpg)
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 Tr be the DFS-subtree who’s root is r.
We will view Tr 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
![Page 13: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/13.jpg)
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
![Page 14: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/14.jpg)
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)
![Page 15: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/15.jpg)
15
Tr As a PC-Tree
![Page 16: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/16.jpg)
16
The Actual Cut-Set Cycle
![Page 17: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/17.jpg)
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.
![Page 18: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/18.jpg)
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.
![Page 19: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/19.jpg)
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.
![Page 20: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/20.jpg)
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.
![Page 21: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/21.jpg)
21
Place-Holder For A Cycle
![Page 22: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/22.jpg)
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
![Page 23: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/23.jpg)
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.
![Page 24: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/24.jpg)
24
How It Is Done
![Page 25: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/25.jpg)
25
How It Is Done (2)
![Page 26: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/26.jpg)
26
How It Is Done (3)
![Page 27: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/27.jpg)
27
Another Example
![Page 28: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/28.jpg)
28
Another Example (2)
![Page 29: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/29.jpg)
29
Another Example (3)
![Page 30: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/30.jpg)
30
Another Example (4)
![Page 31: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/31.jpg)
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.
![Page 32: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/32.jpg)
32
Recursive Work
The Inner Side of the Cycle is Easy A tree (Tr) 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.
![Page 33: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/33.jpg)
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.
![Page 34: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/34.jpg)
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 K5 or K3,3
![Page 35: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/35.jpg)
35
Terminal Edges Form a Tree
![Page 36: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/36.jpg)
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.
![Page 37: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/37.jpg)
37
Paths Through C-Nodes
![Page 38: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/38.jpg)
38
When W is a P-Node
![Page 39: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/39.jpg)
39
When W is a C-Node (1)
![Page 40: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/40.jpg)
40
When W is a C-Node (2)
![Page 41: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/41.jpg)
41
When W is a C-Node (2.1)
![Page 42: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/42.jpg)
42
When W is a C-Node (2.2)
![Page 43: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/43.jpg)
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
![Page 44: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/44.jpg)
44
A Path That Won’t Flip (2)
![Page 45: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/45.jpg)
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
![Page 46: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/46.jpg)
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.
![Page 47: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/47.jpg)
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
![Page 48: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/48.jpg)
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
![Page 49: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/49.jpg)
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
![Page 50: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/50.jpg)
50
Questions ?
![Page 51: 1 PQ Trees, PC Trees, and Planar Graphs Hsu & McConnell Presented by Roi Barkan.](https://reader036.fdocuments.in/reader036/viewer/2022062516/56649dc75503460f94abbd37/html5/thumbnails/51.jpg)
51
Complexity Analysis
Use Amortized Complexity If we work hard in phase i, we make the job
easier for the next phases. Potential Function:
|Gi| – Number of Vertices and Edges in Gi
|Ci| - Number of C-Nodes in Gi
|Pi| - Number of P-Nodes in Gi
, 2 deg 1i
i ix P
M i G C x