Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Schnyder’s Method. 2 Motivation Given a planar graph, we want to embed it in a grid We want the grid to be relatively small And we want an efficient.

Similar presentations


Presentation on theme: "1 Schnyder’s Method. 2 Motivation Given a planar graph, we want to embed it in a grid We want the grid to be relatively small And we want an efficient."— Presentation transcript:

1 1 Schnyder’s Method

2 2 Motivation Given a planar graph, we want to embed it in a grid We want the grid to be relatively small And we want an efficient (linear) algorithm to do it  The algorithm we’ve seen last week runs in O(nlogn) time

3 3 Triangular Graph As we’ve seen before, any planar graph can be extended to a triangulation  Note the number of internal triangles in such a graph is 2|V| - 5 (by Euler’s formula) If we find a method to embed a triangulation in a grid, we can use it to embed any planar graph with only linear overhead

4 4 Barycentric Coordinates Imagine weights w 1, w 2, w 3 are placed at the vertices of a triangle  w 1 +w 2 +w 3 = 1 Then (w 1,w 2,w 3 ) are the coordinates of the center of mass

5 5 Barycentric Representation Assignment of barycentric coordinates (v 1,v 2,v 3 ) to a node v of a graph, such that  (v 1,v 2,v 3 ) = (u 1,u 2,u 3 )  v = u  v 1 +v 2 +v 3 = 1  For any (u,v)  E, and for any w  V, there is some i so that w i > u i and w i > v i

6 6 Straight-line Drawing A barycentric representation of a graph gives rise to a straight-line drawing (“Cheating”: sum of coordinates is 7, not 1)

7 7 Crossing-Free Drawing The drawing imposed by the barycentric representation is crossing free Given two edges (u,v) and (x,y), we know that there exist indices so that:  x i > u i, v i  y j > u j, v j  u h > x h, y h  v k > x k, y k

8 8 Crossing-Free Drawing Four indices, three co-ordinates  By the pigeonhole principle, some two indices are equal Assume without loss of generality i = j Then  x i > u i, v i  y i > u i, v i No two points on (x,y) and (u,v) share the same i coordinate  So (x,y) and (u,v) are separated by a line

9 9 Crossing-Free Drawing (0,0,7) (2,1,4) (4,2,1) (1,4,2) (0,0,7) (1,4,2) (2,1,4) (4,2,1)

10 10 Planar coordinates lemma We can choose any three non-colinear points a, b, c on the plane and define new coordinates based on the barycentric representation:  f(v 1,v 2,v 3 ) = av 1 +bv 2 +cv 3 The previous proof still holds so the drawing is crossing-free

11 11 Normal labeling of angles A labeling of the angles of a triangulation is called normal if  The angles of each triangle are labeled 1, 2, 3 in counterclockwise order  At each interior vertex: All three labels appear In counterclockwise order:  An interval of 1’s  An interval of 2’s  An interval of 3’s

12 12 Labeling in a Barycentric Representation Given a triangulation G with a barycentric representation For any internal triangle’s angle  uvw, there is an index i so that v i > u i, w i We’ll give that angle the label i

13 13 Labeling in a Barycentric Representation (0,0,7) (2,1,4) (4,2,1) (1,4,2) 3 2 1 3 2 1

14 14 Labeling in a Barycentric Representation This labeling is normal The other direction is also true:  Any normal labeling of angles can be constructed from some barycentric representation  So, if we have a normal labeling for a triangulation, there exists a straight-line drawing of it This statement will not be proven explicitly, but it will follow from the correctness of Schnyder’s method

15 15 Edge labeling We can turn any normal angle labeling into a labeling of edges Any internal edge (u,v) lies on two triangles: uvw and uvz

16 16 Edge labeling At either u or v, the two angles have distinct labels The other vertex must have the same label for both angles

17 17 Edge labeling Look at the angle labeling at each vertex Label and direct the edge using the vertex with the two identical labels

18 18 Edge labeling - partition Treat the graph created by the previous procedure as three directed graphs  T 1 : The set of all directed edges with the label 1  T 2 : The set of all directed edges with the label 2  T 3 : The set of all directed edges with the label 3

19 19 Edge labeling - partition 3 2 1 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3

20 20 Edge labeling - partition 3 2 1 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 T 1

21 21 Edge labeling - partition 3 2 1 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 T 2

22 22 Edge labeling - partition 3 2 1 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3 T 3

23 23 Normal Partition (Realizer) A partition (T 1, T 2, T 3 ) of a triangular graph G is called normal if for any interior vertex v:  In each T i, the outdegree of v  G is exactly 1  The counterclockwise order of the edges at v is: Outgoing in T 1 Incoming in T 3 Outgoing in T 2 Incoming in T 1 Outgoing in T 2 Incoming in T 3

24 24 Normal Partition The edge partition defined previously is normal We know the labeling of angles is normal 11 1 2 2 3 3

25 25 Normal Partition Series of angle labels are in counterclockwise order Transitions between series become outgoing edges, in the correct order 11 1 2 2 3 3 2 1 3

26 26 Normal Partition Edges between angles in the same series become incoming edges Again, the order is determined by the normality of the angle partition 11 1 2 2 3 3 2 1 3 2 3 1 1

27 27 Normal Partition The directed graph we got indeed satisfies the conditions of a normal partition 2 1 3 2 3 1 1

28 28 Edge Contraction Let (x,y) be an edge in G The contracted graph G’ = G\(x,y) is  V(G’) = V(G)\{y}  E(G’) is constructed by removing all edges (v,y) and adding (v,x) instead x y

29 29 Contractible Edge An edge (x,y) is contractible, if x and y have exactly two common neighbors If G is a triangulation and (x,y) is contractible in G, then G\(x,y) is a triangulation x y

30 30 Contractible Edges Lemma Let G be a triangular graph with n > 3 vertices, and w an external vertex Then there exists a contractible edge (w,z) where z is an internal vertex of G Proof by induction  Using “separating triangles”

31 31 Normal labeling of angles Any triangular graph G has a normal labeling of its angles, where each exterior vertex has the same label on its angles Proof by induction on the number of vertices  Base case (n = 3) is trivial 3 1 2

32 32 Normal labeling of angles Suppose we can construct a normal labeling of angles for a triangular graph with n vertices Given a triangular graph with n+1 vertices, we can find (by lemma) a contractible edge (x,y) where x is an exterior vertex  If we contract we’ll get a triangular graph with n vertices  That graph will have a normal labeling

33 33 Normal labeling of angles Let’s assume the angles of the external labels are labeled with 1 Extend the labeling in the following way:  Label all the new angles of the external labels with 1  Label the new angles touching the two neighbor vertices with the same label the old angles touching them had  The rest of the labels are uniquely determined by the conditions of normality

34 34 Normal labeling of angles We get a normal labeling of a graph with n+1 vertices  The external vertex’ angles are still labeled with a single label 1 1 1 2 2 2 3 3 3 1 1 1 2 3 3 2 x y n1n1 n2n2

35 35 Edge partition We can also look at the edge partitions induced by this construction 1 1 1 1 1 2 3 x y n1n1 n2n2

36 36 Recap We’ve shown any triangular graph G has a normal labeling of its angles From which we know we can obtain a normal labeling of edges From which we get T 1, T 2, T 3

37 37 Recap What remains to be shown is:  The T i ’s can be used to generate a barycentric representation We already know a barycentric representation automatically gives us a compact straight-line drawing  The whole process has linear time complexity

38 38 T i are trees Each T i is a directed tree  A spanning tree of the interior vertices of G Each tree is directed towards a different exterior vertex The exterior vertex is called the root of that tree Proof by induction

39 39 T i are trees Base case: n = 4 Each T i is a single edge  A “spanning tree” on one vertex 1 1 2 2 33 2 1 3

40 40 T i are trees A graph with n+1 vertices can be built from a graph with n vertices using the previous construction That construction preserves each T i as a spanning tree 1 1 1 1 1 2 3 x y n1n1 n2n2

41 41 More trees Define T i -1 as the graph obtained from T i by reversing all edges T 1  T 2 -1  T 3 -1 has no directed cycles  Proof similar to the previous one 3 2 1 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3

42 42 i-Path from v The i-Path from v, P i (v), is the path from v to the root of T i  Because they are directed spanning trees, that path always exists  Because T i  T j -1  T k -1 has no directed cycles, for any r, s, P r (v) and P s (v) do not cross If they did at some vertex u ≠ v, there’d be a directed cycle between those two vertices on T r  T s -1

43 43 i-Path from v P 3 (v) P 2 (v) P 1 (v)

44 44 Regions With respect to each vertex v  Given the three paths P i (v) we can define three regions R i (v)  R 1 (v) is a triangulation bounded by P 2 (v) P 3 (v) The edge between the roots of T 2 and T 3

45 45 Regions P 3 (v) P 2 (v) P 1 (v) R 1 (v)R 2 (v) R 3 (v)

46 46 Region Inclusion Given interior vertices u, v so that u  R i (v)  R i (u)  R i (v) Follows from the order of edges around each vertex  Note this inclusion is proper P 3 (v) P 2 (v) P 1 (v) R 3 (v) v u R 3 (u) P 2 (u) P 1 (u)

47 47 Triangle Counting For any interior vertex v, define v i as the number of elementary triangles in R i (v) So for each interior vertex we have a triplet of coordinates (v 1,v 2,v 3 )  The total number of interior triangles is 2n-5  So v 1 +v 2 +v 3 = 2n-5 Extend this to exterior nodes  The root of the tree T i will have v i = 2n-5, v j = v k = 0

48 48 Triangle Counting v 1 = 4 v 2 = 1 v 3 = 2 Coordinate triplet: (1,4,2) v 1 1 1 2 2 2 3 33

49 49 Constructing a barycentric representation Define v i = v i / 2n-5 The set of triplets (v 1, v 2, v 3 ) is a barycentric representation of the graph! v 1 +v 2 +v 3 = (v 1 +v 2 +v 3 ) / (2n-5) = 1 The other condition also holds:  Take (x,y)  E, z  V  If z is the root of T i, z i = 2n-5 > x i,y i  Otherwise, for some i, (x,y)  R i (z) R i (x), R i (y)  R i (z) And by definition, x i,y i < z i

50 50 Grid embedding Let us choose three points on the plane:  a = (2n-5, 0)  b = (0, 2n-5)  c = (0,0) We know that if {(v 1,v 2,v 3 )|v  V } is a barycentric representation of G, we’ll get a straight-line drawing by assigning vertices the coordinates av 1 + bv 2 + cv 3 = ((2n-5)v 1, (2n-5)v 2 ) = (v 1,v 2 ) v 1,v 2 are integers between 0 and 2n-5, so this is a drawing on a 2n-5 x 2n-5 grid

51 51 Grid embedding 7 6 5 4 3 2 1 0 01234567

52 52 Vertex counting Instead of counting the number rectangles in each region, we can count vertices  v i is r i (v) : the number of vertices in the region R i (v) except those on the i-Path P i-1 (v) That way, we can get an embedding on a smaller grid: n-1 x n-1 Unfortunately, the coordinates we get are not barycentric  But they are “weak barycentric”

53 53 Weak Barycentric Representation Assignment of coordinates (v 1,v 2,v 3 ) to a node v of a graph, such that  (v 1,v 2,v 3 ) = (u 1,u 2,u 3 )  v = u  v 1 +v 2 +v 3 = 1  For any (u,v)  E, and for any w  V, there is some i so that (w i,w i+1 ) > lex (u i, u i+1 ), (v i, v i+1 ) Same proof as before to show this induces a straight-line drawing

54 54 Vertex Counting R 1 (v) = 5, P 3 (v) = 2, r 1 (v) = 3 R 2 (v) = 3, P 1 (v) = 2, r 2 (v) = 1 R 3 (v) = 4, P 2 (v) = 3, r 3 (v) = 1 Coordinate triplet: (3,1,1) v 1 1 1 2 2 2 3 33

55 55 Algorithm complexity To construct the embedding we need to  Extend the graph to a triangulation A linear algorithm exists  Find the three T i trees The construction shown earlier is linear in the number of edges We know |E| < 3n – 6, so it’s linear in the number of vertices  Count the number of vertices in each region The naïve method is O(n 2 ) A linear algorithm can be shown

56 56 Vertex Counting So how do we count vertices in linear time? We defined v i =|R i (v)| - |P i-1 (v)| We can define t i (v) as the number of nodes in the subtree of T i (v) rooted in v  t i (v) = 1 for roots for T i-1 and T i+1

57 57 Vertex Counting t 1 (v) = 2 t 2 (v) = 1 t 3 (v) = 1 v 1 1 1 2 2 2 3 33

58 58 Vertex Counting If u is in R i (v), then the i-Path P i (u) intersects either P i-1 (v) or P i+1 (v) So there is some x on P i-1 (v)  P i+1 (v) so that u is in the subtree of T i rooted in x P 3 (v) P 2 (v) P 1 (v) R 3 (v) v u P 3 (u) x

59 59 Vertex Counting So if we sum up the subtrees for P i-1 (v)  P i+1 (v) we’ll get : This sum can be computed for all vertices in the graph in a constant number of passes on the trees T i


Download ppt "1 Schnyder’s Method. 2 Motivation Given a planar graph, we want to embed it in a grid We want the grid to be relatively small And we want an efficient."

Similar presentations


Ads by Google