Presentation is loading. Please wait.

Presentation is loading. Please wait.

Divide and Conquer. Subject Series-Parallel Digraphs Planarity testing.

Similar presentations

Presentation on theme: "Divide and Conquer. Subject Series-Parallel Digraphs Planarity testing."— Presentation transcript:

1 Divide and Conquer

2 Subject Series-Parallel Digraphs Planarity testing

3 Series-Parallel Digraphs

4 Graph with a source and sink nodes Source and sink are called poles Defined recursively Base case: An edge with source and sink vertices sourcesink

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 G 1 and G 2 where T 1 and T 2 are their parse trees so T has P-node root with children T 1 and T 2 P T1T1 T2T2

10 Decomposition trees G is a series composition of G 1 and G 2 where T 1 and T 2 are their parse trees so T has S-node root with children T 1 and T 2 S T1T1 T2T2

11 Decomposition trees If a node has the same type as his parent it 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 u 1 … u k 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(n 2 ) drawing area

17 Δ-SP-Draw Upward embedding of SP-digraph Drawing inside a bounding triangle Δ(Γ) 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 Δ(Γ) 2.Top = Sink = t Left = nothing Bottom = Source = s 3.If (s, u) exist then between slopes –π/2 and –π/4 there’s nothing but s 4.If (v, t) exist then between slopes π/2 and π/4 there’s nothing but t t s v u

19 Δ-SP-Draw

20 Δ-SP-Draw – base If G is a single edge Draw it as a vertical edge with length 2 Bounding triangle Δ(Γ) will have width 1 G t s

21 Δ-SP-Draw – series If G is a series composition of G1 and G2 Recursively draw Γ1 and Γ2 Translate Γ2 so G2’s sink is on G1’s source Extend bounding triangle Δ(Γ) accordingly G1 G2

22 If G is a parallel composition of G1 and G2 Recursively draw Γ1 and Γ2 Translate Γ2 to the “prescribed-region” of G2 (right of the dashes) Extend bounding triangle Δ(Γ) accordingly Move sources and sinks to upper and lower corners of Δ(Γ) Δ-SP-Draw – parallel G1 G2

23 “prescribed-region” (v, t) and (s, u) are rightmost edges on G1 λv and λu are rays parallel to G1’s bounding triangle G2 will be translated to anywhere on the right of λv, λu and κ. G1 G2 v u κ t s λvλv λuλu

24 Lemma 3.3 Let u and v be neighbors of the source so (s, u) is left of (s, v) Let λu and λv be rays of slope -π/4 from u and v If invariant 3 holds then λu is below λv s uv λuλu λvλv

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

26 Therefore Proving Invariants 3 and 4 guarantee that s and t can be moved as described in the algorithm without creating crossings. Invariant 2 states that left corner of Δ(Γ) is always empty, so G2’s left corner can be on 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 vertices the length of the base is 2n. So the area needed is O(n 2 )

28 Calculating distances We’ll describe Γ by: b = length of the base b‘ = vertical distance to λu b‘’ = vertical distance to λv v u κ t s λvλv λuλu b’ b’’ b

29 Parallel distances To describe parallel combinations we’ll use: Δx = horizontal distance from Δ(Γ1) to Δ(Γ2) Δy = vertical distance from bottom ray of Δ(Γ1) to left corner of Δ(Γ2) Δ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(n 2 ) The algorithm runs in O(n) and needs O(n) space end of Series-Parallel Digraphs

32 Planarity Testing

33 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 C: if 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 separatingnonseparating

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 separating cycle C’ consisting of subpath of C and a 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 v without any attachments. Since P is connected there is a path π in P between u and v. Let C’ be the cycle obtained from C by replacing γ with π. Now γ is a piece on G with respect to C’ Let e be an edge on P not π. 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. C’ C γ π e

40 Interlacement Each piece can be drawn either entirely inside or outside of the cycle Interlacing pieces are ones that can’t 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 – can’t reside on the same side of C C P1 P3 P2 P4 P1P3 P2P4

42 Interlacement to planarity If G is planar graph then its interlacement graph must be bipartite C P1 P3 P2 P4 P1 P3 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 1.Find pieces of G 2.For each piece P that is not a path test planarity by recursion 3.Compute interlacement graph of the pieces 4.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 of G 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 replacing part of C with a path in P Since P’ is biconnected and C’ is separating – test planarity recursively Takes O(E(P’)) P2

48 Computing interlacement graph For each 2 pieces P, Q P, Q’s attachments are numbered along C If attachments are not continuous in region for each piece then P, Q are interlaced 1 3 2 1 3 2 4

49 Computing interlacement graph Checking one piece vs. all others takes O(n) All vs. all takes O(n 2 ) Interlacement graph has O(n) vertices and O(n 2 ) edges Checking if it’s bipartite takes O(n 2 )

50 Overall runtime Each recursive invocation takes O(n 2 ) Each recursion is associated with at least one edge of G There are O(n) edges Runtime is O(n 3 )

Download ppt "Divide and Conquer. Subject Series-Parallel Digraphs Planarity testing."

Similar presentations

Ads by Google