Divide and Conquer - PowerPoint PPT Presentation

About This Presentation
Title:

Divide and Conquer

Description:

Planarity testing. Series-Parallel Digraphs. Series-Parallel Digraphs ... there's nothing but s. If (v, t) exist then. between slopes p/2 and p/4. there's ... – PowerPoint PPT presentation

Number of Views:67
Avg rating:3.0/5.0
Slides: 51
Provided by: eran2
Category:

less

Transcript and Presenter's Notes

Title: Divide and Conquer


1
Divide and Conquer
2
Subject
  • Series-Parallel Digraphs
  • Planarity testing

3
Series-Parallel Digraphs
4
Series-Parallel Digraphs
  • Graph with a source and sink nodes
  • Source and sink are called poles
  • Defined recursively
  • Base caseAn edge with source and sink vertices

source
sink
5
Series composition of digraphs
  • Identifying the sink of one and the source of the
    other as one vertex

6
Parallel composition of digraphs
  • Identifying as one vertex both their sources
  • Identifying as one vertex both their sinks

7
Decomposition trees
  • Associating SP digraphs with Parse Trees
  • Binary trees
  • S-nodes, P-nodes and Q-nodes
  • Defined recursively

8
Decomposition trees
  • G is a single edge so T is a single Q-node

Q
9
Decomposition trees
  • G is a parallel composition of G1 and G2where T1
    and T2 are their parse treesso T has P-node root
    with children T1 and T2

P
T1
T2
10
Decomposition trees
  • G is a series composition of G1 and G2where T1
    and T2 are their parse treesso T has S-node root
    with children T1 and T2

S
T1
T2
11
Decomposition trees
  • If a node has the same type as his parentit will
    be the right child
  • T is unique for G
  • If G has n nodes then T has O(n) nodes
  • T can be created in O(n) time so will be assumed
    to be part of the input

12
Components
  • Let C be a maximal path same node type on T
  • Let u1 uk children of C not on C
  • Component is the part of G associated with a
    subsequence ui .. uj where 1 i j k
  • Component is closed when C is of S-nodes
  • Otherwise it is open

13
Closed component
14
Open component
15
Not a component
16
Right-pushed embedding
  • (u, v) is transitive in G if there is another
    path from u to v
  • Drawing transitive edge (u, v) on the right of
    all components with u and v poles
  • O(n2) drawing area

17
?-SP-Draw
  • Upward embedding of SP-digraph
  • Drawing inside a bounding triangle ?(G) which is
    isosceles (???? ??????) and right-handed
  • Series one above the other
  • Parallel one to the right of the other

18
?-SP-Draw invariants
  1. Inside an isosceles right-angled triangle ?(G)
  2. Top Sink tLeft nothingBottom Source
    s
  3. If (s, u) exist then between slopes p/2 and
    p/4theres nothing but s
  4. If (v, t) exist thenbetween slopes p/2 and
    p/4theres nothing but t

t
v
u
s
19
?-SP-Draw
20
?-SP-Draw base
  • If G is a single edge
  • Draw it as a vertical edge with length 2
  • Bounding triangle ?(G) will have width 1

t
G
s
21
?-SP-Draw series
  • If G is a series composition of G1 and G2
  • Recursively draw G1 and G2
  • Translate G2 so G2s sink is on G1s source
  • Extend bounding triangle ?(G) accordingly

G1
G2
22
?-SP-Draw parallel
  • If G is a parallel composition of G1 and G2
  • Recursively draw G1 and G2
  • Translate G2 to the prescribed-region of
    G2(right of the dashes)
  • Extend bounding triangle ?(G)accordingly
  • Move sources and sinks toupper and lower corners
    of ?(G)

G2
G1
23
prescribed-region
  • (v, t) and (s, u) are rightmostedges on G1
  • ?v and ?u are rays parallelto G1s bounding
    triangle
  • G2 will be translated toanywhere on the right
    of ?v, ?u and ?.

?
?v
t
v
G2
u
G1
s
?u
24
Lemma 3.3
  • Let u and v be neighbors of the sourceso (s, u)
    is left of (s, v)
  • Let ?u and ?v be rays of slope -p/4from u and v
  • If invariant 3 holdsthen ?u is below ?v

u
v
?v
s
?u
25
Lemma 3.3 outcome
  • If G2 is placed to the right of G1 and above
    ?uwhere (s, u) is the rightmost edge of s on G1
  • Then no vertex of G2 is in the wedge limited by
    the p/4 ray from the neighbors of s
  • Hence if invariant 3 is held onG1 and G2 it is
    also held on G
  • Symmetrically invariant 4 can be proved

u
s
26
Therefore
  • Proving Invariants 3 and 4 guarantee thats and t
    can be moved as described in the algorithm
    without creating crossings.
  • Invariant 2 states that left cornerof ?(G) is
    always empty,so G2s left corner can beon the
    base of G1.

27
Area of the triangle
  • So the base of resulting triangle is equals the
    sum of bases of both triangles.
  • For a graph with n verticesthe length of the
    base is 2n.
  • So the area needed is O(n2)

28
Calculating distances
  • Well describe G by
  • b length of the base
  • b vertical distance to ?u
  • b vertical distance to ?v

?
b
?v
t
v
b
u
s
?u
b
29
Parallel distances
  • To describe parallel combinations well use
  • ?x horizontal distance from?(G1) to ?(G2)
  • ?y vertical distance frombottom ray of ?(G1)
    toleft corner of ?(G2)

?x
?y
30
?-SP-label
  • input decomposition tree T of G
  • output labeling b, b, b for each subtree of
    T
  • if root Q-node then
  • b(T) b(T) b(T) 2
  • else?-SP-label of T1 and T2 (the subtrees)
  • if root S-node then
  • b(T) b(T1) b(T2)
  • b(T) b(T1)
  • b(T) b(T2)
  • else root P-node then
  • b(T) b(T1) b(T2)2?x
  • if T2 is Q-node (transitive edge) then
  • b(T) b(T) b(T)
  • else
  • b(T) b(T1) 2?x ?y b(T2)
  • b(T) b(T2) ?y

31
?-SP-label
  • ?x can be 0
  • ?y can be b(T1)
  • The area needed is O(n2)
  • The algorithm runs in O(n)and needs O(n) space
  • end of Series-Parallel Digraphs

32
Planarity Testing
33
Planarity Testing
  • Graph is planar if E 3V - 6 (Euler formula)
  • Graph is planar iff all its connected components
    are planar
  • Graph is planar iff all its biconnected
    (connected by 2 edges per vertex) components are
    planar
  • Preprocessing into connected and biconnected
    components the problem is restricted to
    biconnected graphs

34
Partitioning into Pieces
  • Let a biconnected graph G contain a cycle C
  • Classify each edge of G not on Cif 2 edges have
    a path between them with no vertex of C, they
    have the same class.
  • Subgraph induced by edges in a class is called a
    piece of G.

35
Partitioning into Pieces
36
Attachments
  • Vertices of piece P which are also on cycle C are
    called attachments
  • Since G is biconnected each piece has at least 2
    attachments
  • Cycle C induce a circular ordering on the
    attachments of P

37
Separating cycle
  • Cycle C is separating if it has at least 2 pieces
  • If is has one or no pieces it is nonseparating

separating
nonseparating
38
Lemma 3.4
  • Let G be a biconnected graph
  • Let C be a nonseparating cycle of G
  • Let P be a piece on C
  • If P is not a path then G has a separatingcycle
    C consisting of subpath of C anda path of P

39
Lemma 3.4 proof
  • Let u and v be 2 attachments of P that are
    consecutive in the circular ordering.
  • Let ? be a subpath of C between u and vwithout
    any attachments.
  • Since P is connected there is a path p in P
    between u and v.
  • Let C be the cycle obtained from Cby replacing
    ? with p.
  • Now ? is a piece on G with respect to C
  • Let e be an edge on P not p.
  • e exist Because P is not a path.
  • So there is a piece of C other than ? which
    contains e.
  • Thus C is a separating cycle in G.

p
?
e
C
C
40
Interlacement
  • Each piece can be drawn either entirelyinside or
    outside of the cycle
  • Interlacing pieces are ones that cant be drawn
    on the same side of C without crossing

Interlacing pieces
41
Interlacement graph
  • Vertices are pieces on G with cycle C
  • Edges are pairs of pieces that interlace cant
    reside on the same side of C

P3
P2
P1
C
P1
P3
P4
P2
P4
42
Interlacement to planarity
  • If G is planar graph then its interlacement graph
    must be bipartite

P3
P2
P1
P1
C
P3
P4
P2
P4
43
Theorem 3.8
  • A biconnected graph G with cycle C is planar iff
  • For each piece P, adding P to C is planar
  • The interlacement graph of pieces of G with cycle
    C is bipartite

44
Planarity testing
  • 0. Count edges and check Euler's formula
  • Find pieces of G
  • For each piece P that is not a pathtest
    planarity by recursion
  • Compute interlacement graph of the pieces
  • Test if the interlacement graph is bipartite

45
Preliminaries
  • The algorithm receives a biconnected graph G
  • G has n vertices and at most 3n-6 edges
  • Also received is a separating cycle C
  • Returns whether G is planar or not

46
Finding pieces
  • Finding the pieces of G with respect to C by
    computing the connected components ofG without
    C.
  • Takes O(n)

47
Testing piece P planarity
  • For each piece P that is not a path
  • Let P be graph of adding P to C
  • Let C be cycle in P by replacingpart of C with
    a path in P
  • Since P is biconnectedand C is separating
    test planarity recursively
  • Takes O(E(P))

P2
48
Computing interlacement graph
  • For each 2 pieces P, Q
  • P, Qs attachments are numbered along C
  • If attachments are not continuous in region for
    each piece then P, Q are interlaced

1
1
4
2
2
3
3
49
Computing interlacement graph
  • Checking one piece vs. all others takes O(n)
  • All vs. all takes O(n2)
  • Interlacement graph has O(n) vertices and O(n2)
    edges
  • Checking if its bipartite takes O(n2)

50
Overall runtime
  • Each recursive invocation takes O(n2)
  • Each recursion is associated with at least one
    edge of G
  • There are O(n) edges
  • Runtime is O(n3)
Write a Comment
User Comments (0)
About PowerShow.com