Planarity Testing

advertisement
PLANARITY TESTING AND
EMBEDDING
1
By: Seyed Akbar Mostafavi
Fall 2010
OUTLINE
Planar Graphs
 Planarity Testing Theorems






Kuratowski’s Theorem
Demoucron’s Planarity Algorithms
Euler Polyhedron Formula
Nonplanarity of Kuratowski Graphs
Minimum Degree Bound
Definitions of Planarity Testing
 st-numbering Algorithm
 Bush Form and PQ-Tree
 Booth-Lueker Algorithm
 Embedding Algorithms

2
PLANAR GRAPHS
A graph G(V,E) is called planar graph if it can be
drawn on embedded in the plane in such a way that
the edges of the embedding intersect only at the
vertices of G.
 Example: K(4)

3
PLANAR GRAPHS

Nonplanar Graph example: K(3,3)
4
PLANARITY TESTING

Two classical approaches

Theorem of Kuratowski
Characterizes planar graphs in terms of subgraphs they are
forbidden to have
 Based on the notion of homeomorphism
 Series insertion: replacement of an edge (u,v) of G by a pair of
edges (u,z) and (z,v)
 Series deletion: replacement of a pair of edges (u,z) and (z,v) of G
by a single edge (u,v)


Hopcraft and Tarjan Algorithm

determines planarity in linear time and shows how to draw the
graph if it is planar
5
KURATOWSKI’S THEOREM
A graph G(V,E) is planar if and only if G contains no
subgraph homeomorphic to either K(5) or K(3,3)
 Example: Petersen’s Graph

6
CONTRACTION FORM OF KURATOWSKI’S
THEOREM
Contraction: operation of removing an edge (u,v)
from a graph G and identifying the endpoints u and v
(with a single new vertex uv) so that every edge
originally incident with either u and v becomes
incident with uv.
 Graph 𝐺1 (V,E) is said contractible to a graph 𝐺2 (V,E)
if 𝐺2 can be obtained from 𝐺1 by a sequence of
contractions.
 Theorem: A graph G(V,E) is planar if and only if G
contains no subgraph contractible to either K(5) or
K(3,3).

7
DEMOUCRON’S PLANARITY ALGORITHM

Terminology
face of a planar representation: a planar region bounded by
edges and vertices of the representation and containing no
graphical elements in its interior.
 R: a planar representation of a subgraph S of a graph G(V,E)
 We try to extend R to a planar representation of G


Constraints
Each component of G-R, being a connected piece of the graph,
must, in any planar extension of R, be placed within a face of R.
 Further constraint is observed by considering those edges
connecting a component c of G-R to set of vertices W in R.
 All the vertices W in R must lie on the boundary of a single face
in R. Otherwise, c would have to straddle more than one face of
R.

8
TERMINOLOGY (MORE)

A part p of G relative to R is defined as
1)
2)



An edge (u,v) in E(G) – E(R) such that u and v ∈ 𝑉(𝑅) or
A component of G – R together with the edges (called pending
edges) that connect the component to the vertices of R.
Contact vertex of a part p of G relative to R is defined as a
vertex of G – R that is incident with a pending edge of p
A planar representation R of a subgraph S of a planar
graph G is planar extensible to G if R can be extended to a
planar representation of G.
A part p of G relative to R is drawable in a face of R if there
is a planar extension of R to G where p lies in f.
9
DEMOUCRON’S ALGORITHM

1)
2)
3)
4)
Idea: we repeatedly extend a planar representation R of a
subgraph of graph G until either R equals G or the
procedure becomes blocked in which case G is nonplanar.
We start by taking R to be an arbitrary cycle from G
We then partition the remainder of G not yet included in
R into parts of G relative to R and apply drawability
condition.
We identify those faces of R in which p is potentially
drawable, a path q through p, and add q to R by drawing
it through f in a planar matter.
Process is blocked only if we find some part that doesn’t
satisfy the drawability condition for any face in which
case R is not planar extensible to G.
10
DECOUCRON’S ALGORITHM PSEUDO-CODE
Function Draw (G, R)
(* Returns a planar representation of G in R)
Var G: Graph
R: Planar Representation
p: Part
P: set of Part
f: Face
F: Set of Face
Draw: Boolean function
Set Draw to True
Set R to some cycle in G
repeat
Set P to the set of parts of R relative to G
for each p in P do Set F(p) to the set of faces of R
in which p is drawable
if
F(p) is empty for any p
then
Set Draw to False
11
DECOUCRON’S ALGORITHM PSEUDO-CODE
else if
For some part p, F(p) contains only a single face
then
else
Let f be the face in which p is drawable
Let p be any part and let f be a face in F(p)
Let q be a path between a pair of contact vetices of
that contains only edges of p
Set
until
p with R
R to 𝑅 ∪ 𝑞
R = G or not Draw
End_function_Draw
12
EXAMPLE OF CONSTRUCTION OF PATH
13
PLANAR GRAPH THEORY

Theorem (Euler Polyhedron Formula). Let G(V,E)
be a connected planar graph and |F| denote the
number of faces in a planar embedding of G. Then
𝐹 + 𝑉 = 𝐸 +2
 Proof:
induction on the number of edge
14
PLANAR GRAPH THEORY (CONT’)

Theorem (Linear bound on |E|). If G(V, E) is a planar graph, then
𝐸 ≤3 𝑉 −6

Proof: We let |𝐹𝑖 | denote the number of edges bounding the 𝑖 𝑡ℎ face of
some planar representation of G. Each face must contains at least 3
bounding edges. Therefore,
|𝐹|
|𝐹𝑖 | ≥ 3|𝐹|
𝑖=1

Since each edge borders exactly two faces, the summation counts each
edges twice. Therefore,
|𝐹|
|𝐹𝑖 | = 2|𝐸|
𝑖=1

Combining these results and using the Euler Polyhedron Formula, we
obtain
𝐸 ≤3 𝑉 −6
15
PLANAR GRAPH THEORY (CONT’)



Theorem (Nonplanarity of Kuratowski Graphs). The
graphs K(3,3) and K(5) are nonplanar.
Proof. Nonplanarity of K(5) follows by contradiction from
the Linear Bound Theorem. For K(3,3), we argue as
follows.
By Euler’s Theorem, |F| = |E| - |V| + 2 = 5. However, since
every cycle in K(3,3) has at least four edges, similar to
proof of Linear Bound Theorem, we would have
|𝐹|
|𝐹𝑖 | ≥ 4|𝐹|
𝑖=1

whence emulating the Linear Bound proof, we could
conclude that |𝐸|(= 9) ≥ 2|𝐹| so that 𝐹 ≤ 4, contrary to
the previous lower bound of 5.
16
PLANAR GRAPH THEORY (CONT’)
Minimum Degree Bound. If G(V,E) is a planar
graph, min(𝐺) ≤ 5.
 Proof (by contradiction). Suppose that the minimum
degree of G is at least 6. then

|𝐹|
𝑑𝑒𝑔(𝑣𝑖 ) ≥ 6|𝐹|
𝑖=1

Since the sum of the degrees is always 2|E|, it follows
that |E| is at least 3|V|, contrary to the Linear Bound
Theorem.
17
VERTEX ADDITION ALGORITHM
Vertex Addition Algorithm is based on s-t
numbering, that assigns an index to each vertex.
 Graph is represented by a set of n lists, called
“adjacency lists” Adj(v)
 The adjacency list of a vertex contains all its
neighbors
 An embedding of a graph determines the order of the
neighbors embedded around a vertex.
 A graph is planar if and only if all the 2-connected
components are planar [Har72].
 Corollary 1.1: 𝑚 ≤ 3𝑛; otherwise the graph is
nonplanar

From: Planar Graphs
18
DEFINITION OF S-T NUMBERING

An st-numbering is numbering 1, . . . , n of the
vertices of a graph such that
Vertices “1” and “n” are adjacent
 Every other vertex j is adjacent to two vertices i and k such
that 𝑖 ≤ 𝑗 ≤ 𝑘

Vertex “1” is the source s and vertex “n” the sink t
 Every 2-connected graph G has an st-numbering, and
an algorithm given by Even and Tarjan finds an stnumbering in linear time.

19
DEPTH-FIRST SEARCH
Start with arbitrary edge (t, s)
 Compute for each vertex its depth-first number
DFN(v), its parent FATH(v) and its lowpoint LOW(v)

Definition( Lowpoint)
LOW(v) = min({v} ∪ {w| there exists a back edge (u,w) such that
u is a descendant of v and w is an
ancestor of v in a DFS tree T})
LOW(v) = min({v} ∪ {LOW(x)|x is a son of v} ∪ {w|(v,w) is a back
edge}
20
DFS ALGORITHM
Procedure DFS(G);
procedure SEARCH(v)
begin
mark v “old”;
DFN(v) := COUNT;
COUNT := COUNT + 1;
LOW(v) := DNF(v);
for each vertex w on Adj(v)
do if w is marked “new”
then begin
add (v,w) to T
FATH(w):=v;
SEARCH(w);
LOW(v) := min{LOW(v) , LOW(w)}
end
else if w is not FATH(v)
then LOW(v) := min {LOW(v), DFN(w)}
end;
21
PARTITION EDGES TO PATHS
Vertices s, t and edge (s, t) are marked “old”
Case 1 There is a “new” back edge (v,w)



Mark (v,w) “old”
Return vw
Case 2 There is a “new” tree edge (v,w)



Let w w1 w2 . . .wk be the path to the lowpoint wk of v
Mark vertices and edges on the path “old”
Return v w w1 w2 . . .wk
Case 3 There is a “new” back edge (w, v)
Let w w1 w2 . . .wk be the path going backward to an old vertex
wk
 Mark vertices and edges on the path “old”
 Return v w w1 w2 . . .wk

Case 4 All edges incident to v are “old”

Return ∅
22
ST-NUMBERING
Special nodes: source s (“1”) and sink t (“n”)
“1” and “n” adjacent
j V-{s,t}:
i, k Adj(j)
8
5
st(i)<st(j)<st(k)
 So 2 must be next to 1
and n-1 must be next to n
1
2

7
3
4
6
23
SOME ST-NUMBERING EXAMPLES
2
1
12
11
4
3
10
9
6
5
8
7
5
4
2
1
3
24
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 an
st-numbering exists.

25
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

26
G
27
G
DFS
28
G
6 DF
N
5
4
3
DFS
2
1
29
DFN
6
G
DFS
LOW
3
5
3
4
1
3
1
2
1
1
1
30
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
31
INITIAL SETUP
The node with DFN 2 is called the ‘source’
 The node with DFN 1 is called the ‘sink’



Stack with source
on top of sink
Source and sink
are “old”
b
a
d
c
e
f
a
c
32
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 onto
the stack
 Mark all as old.

b
a
d
c
e
f
a
b
c
33
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
e
f
b
c
34
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 on
the path onto
the stack
 Mark all as old

b
1
d
c
e
f
b
f
e
d
c
35
NO MATCHES FOR VERTEX B

So the vertex is ready and gets its number
2
1
d
c
e
f
f
e
d
c
36
NO MATCHES FOR VERTEX F

So the vertex is ready and gets its number
2
1
d
c
e
3
e
d
c
37
ET CETERA…
2
1
5
6
38
4
3
EXAMPLE OF S-T NUMBERING
2
3
5
4
1
39
6
BUSH FORM

Let 𝐺𝑘 = (𝑉𝑘 , 𝐸𝑘 ) be the subgraph induced by the
vertices 𝑉𝑘 = {1, . . . , k}
Let 𝐺′𝑘 be the graph formed by adding all edges with
ends in V − 𝑉𝑘 , where the ends of the edges are kept
separate
 These edges are called virtual edges and their ends
virtual vertices


A bush form of 𝐺′𝑘 is an embedding of 𝐺′𝑘 such that
the virtual vertices are on the outer face
40
EXAMPLE OF BUSH FORM
stnumbering
𝐺4
bush form
𝐵4
41
PQ-TREE DATA STRUCTURE
Use PQ-tree to represent bush form 𝐵𝑘
 PQ-tree consists of

P-nodes Represents a cut vertex of 𝐵𝑘 , and its children can
be permuted arbitrarily
Q-nodes Represents a 2-connected component of 𝐵𝑘 , and
its children are only allowed to reverse
leaves Represents a virtual vertex of 𝐵𝑘

PQ-tree represents all the permutations and
reversions possible in a bush form 𝐵𝑘
42
EXAMPLE OF PQ-TREE
bush form
𝐵𝑘
PQ-tree
43
VERTEX ADDITION ALGORITHM
Lemma
If we have a bush form 𝐵𝑘 of a subgraph 𝐺𝑘 of a planar graph G,
then there exists a sequence of permutations and reversions to
make all virtual vertices labeled “k + 1” occupy consecutive
positions




Idea of the algorithm is to test planarity of 𝐺𝑘 +1 by finding these
permutations and reversions
The permutations and reversions can be found by applying 9
transformation rules to the PQ-tree (template matching)
A leaf labeled “k + 1” is pertinent and a pertinent subtree is a
minimal subtree of a PQ-tree containing all the pertinent leaves
A node of a PQ-tree is full if all the leaves of its descendants are
pertinent
44
TEMPLATE MATCHINGS
45
TEMPLATE MATCHINGS
46
TEMPLATE MATCHINGS
47
TEMPLATE MATCHINGS
48
PQ-TREE REDUCTION EXAMPLE
49
50
51
52
53
54
PLANARITY TESTING ALGORITHM
1.
Assign st-numbers to the vertices of G
2.
Construct PQ-tree corresponding to 𝐺′1
Gather pertinent leaves by applying the
template matching
If the reduction fails then G is nonplanar
Replace full nodes of the PQ-tree by a new
P-node
Goto 3
3.
4.
5.
6.
55
EXAMPLE OF VERTEX ADDITION
ALGORITHM
56
EXAMPLE OF VERTEX ADDITION
ALGORITHM
57
EXAMPLE OF VERTEX ADDITION
ALGORITHM
58
EXAMPLE OF VERTEX ADDITION
ALGORITHM
59
EXAMPLE OF VERTEX ADDITION
ALGORITHM
60
EXAMPLE OF VERTEX ADDITION
ALGORITHM
61
EXAMPLE OF VERTEX ADDITION
ALGORITHM
62
EXAMPLE OF VERTEX ADDITION
ALGORITHM
63
EXAMPLE OF VERTEX ADDITION
ALGORITHM
64
Download