Download presentation
Presentation is loading. Please wait.
1
Drawing a Planar Graph on a Grid
2
Last Week Any planar graph has a Straight-line drawing
But it might take a lot of space -what’s a straight line drawing, the algorithm in one picture. -space might increase exponentially with the number of vertices added. Same picture. -a practical reason :if we’d like to present the graph on a computer screen. In that case some dots might bunch together and become indistinguishable
3
Grid Grid point – a point with integer coordinates
m by n grid – the set of grid points (x, y) with 0 ≤ x ≤ m 0 ≤ y ≤ n Map each vertex in the graph to a grid point Goal - minimize the size of the needed grid Minimize the grid size – for ANY planar graph of (n) vertices.
4
Theorem Any planar graph with n vertices has a straight- line embedding on the 2n-4 by n-2 grid. n = 6 : n - 2 You can use the “edges of the grid” as well. 2n - 4
5
Proof G triangulation Exterior face of G – u v w
{v1 = u, v2 = v, v3, ... , vn = w} canonical labeling of the vertices of G Gk – the sub-graph of G induced by {v1, v2, ... , vk} v7 = w Suffice to prove for triangulations (complete the graph to a triangulation then omit the added edges from the drawing). Canonical labeling was achieved “in reverse” by in each iteration choosing a vertex from the exterior that had only 2 neighbors on the exterior face (starting with w). v1 = u v2 = v v3 v6 v5 v4 G6: G:
6
Each graph Gk can be embedded on the 2k-4 by k-2 Grid
By induction on k, show that Gk can be embedded on the 2k-4 by k-2 grid (k ≥ 3) : k = 3: f3(v3)= (1, 1) 2k – 4 = 2 K – 2 = 1 2 by 1 grid Induction base. Note the notation fk() which marks the embedding of Gk in the grid. f3(v1)= (0, 0) f3(v2)= (2, 0)
7
Induction Hypothesis Assume we already found fk-1(vi) = (xk-1(vi), yk-1(vi)) (1 ≤ i ≤ k-1), (4 ≤ k) Where fk-1(v1) = (0, 0), fk-1(v2) = (2k – 6, 0) Exterior face monotonic in x (cyclic order) The segments fk-1(ui) , fk-1(ui+1) all have slopes +1 or -1 note that (2k-6) and not (2k-4) – left 2 spare grid points. if the vertices of the exterior face of Gk-1 are numbered u1=u, ..., um = v (in cyclic order) - Demonstrate. Slopes + or – 1. implies that for every ui, uj drawing a line with slope -1 through ui, and one with slope +1 through uj will intersect at a grid point = p(ui, uj). (Since it Implies that the Manhattan Distance (texiCab geometry, Minkowski Menger introduced the name. differs from Euclidean geometry only by the distance function, Constraints of city streets) between each fk-1(ui) , fk-1(uj) on the exterior face of Gk-1 is even – cause each block “traveled” either adds the same to x as to y, or adds to one and subtracts the same from the other.), so p(ui, uj) is a grid point. K = 7, k-1 = 6: 2k – 4 = 10 K – 2 = 5 10 by 5 grid u3 u5 u4 u2 u5 u1 u6 fk-1(v1)= (0, 0) fk-1(v2)= (2k – 6, 0)
8
Show for k We’d like to define fk(vk) (draw vk)
{up, up+1, ... , uq} the neighbors of vk in Gk Good Candidate – P(up, uq) We might have a problem... vk’s neighbors in Gk are {u3, u4, u5} P(u3, u5) u3 u5 u4 u2 Why is P(up, uq) on the 2k-4 by k-2 grid? Horizontally – Clear that the intersection is inside the grid. Vertically – the highest possible point will be achieved if vk’s neighbors are u1, uk-1. then we’ll get a isosceles (SHVE SHOKAIM) triangle with slopes +1, -1 for it’s sides which means the x coordinate is (2k-4)/2 (the middle), which means the y coordinate is as well (2k-4)/2 = k-2. u1 u6 f6(v1)= (0, 0) f6(v2)= (8, 0)
9
Problem Assume vk’s neighbors in Gk are {u2, u3, u4, u5}
How do we connect vk to u2 with a straight line? P(u2, u5) u3 u5 Add the candidate vk in p(u2, u5) and connect it to its neighbors u4 u2 u1 u6 f6(v1)= (0, 0) f6(v2)= (8, 0)
10
Modify the previous embedding
Modify fk-1 first Move fk-1(ui) where p+1 ≤ i ≤ q-1 one unit to the right Move fk-1(uj) where q ≤ j ≤ m two units to the right vk’s neighbors in Gk : {u2, u3, u4, u5} P(u2, u5) If there’s no such problem, no need to modify fk-1. We can shift up to two units because until now we only used a (2k – 6) by k-2 grid. u4 u3 u6 u5 u2 u1 f6(v1)= (0, 0) f6(v2)= (8, 0)
11
Another Problem What about the interior vertices?
Insert v8 with neighbors {u2, u3, u4, u5} in G8: v7 = u3 u5 u4 v6 = u3 The u1, ..., um ordering changes whenever k changes, so in the next step we won’t know what to do with interior vertices. v4 = u2 v5 = u4 v1 = u1 v2 = u5 u6
12
Define a New Order Define a total order “‹” on {v1, v2, ... , vn} recursively: v1 ‹ v3 ‹ v2 Assume the order has already been defined for {v1, v2, ... , vk-1} Insert vk just before up+1 {up, up+1, ... , uq} the neighbors of vk in Gk U1, U2, ..., Um – the cyclic order. Total order will include all of the vertices, and allow us to decide what to do with the internal vertices. f3(v3)= (1, 1) f3(v1)= (0, 0) f3(v2)= (2, 0)
13
v7 ‹ v6 (u3) ‹ ... Example In our example: ... ‹ v4 (u2) ‹
v7’s Neighbors in G7 = {u2, u3, u4, u5} v7 u5 v6 = u3 v4 = u2 v5 = u4 v1 = u1 v2 = u6 We already knew u3 will move one unit, u4, u5 will move 2 units. But now we already know what to do with the internal vertices. (Intentionally the new vertex is first drawn to the right of the first internal vertex. v7 ‹ ... ‹ v4 (u2) ‹ v6 (u3) ‹ ...
14
Solution continued Now modifing fk-1 will be defined as
Move fk-1(ui) where up+1 ‹ = ui ‹ uq-1 one unit to the right Move fk-1(uj) where uq ‹ = uj ‹ = um two units to the right Insert v8 with neighbors {u2, u3, u4, u5} in G8: We already knew u3 will move one unit, u4, u5 will move 2 units. But now we already know what to do with the internal vertices. (Intentionally the new vertex is first drawn to the right of the first internal vertex. v7 = u3 u4 v6 v4 = u2 v5 v2 = u5 v1 = u1 ... ‹ v4 ‹ v7 ‹ v6 ‹ ...
15
Prove fk is a Straight Line Embedding
Assume that fk-1 is a straight line embedding of Gk-1 fk-1(vi)= (xk-1(vi), yk-1(vi)) α1, α2, ... ,αm ≥ 0 For any 1 ≤ i ≤ k-1 , 1 ≤ j ≤ m: x(vi) = xk-1(vi) + α1 + α αj if uj ‹ = vi ‹ uj+1 y(vi) = yk-1(vi) Then f ’ k-1 = (x, y) is also a straight line embedding of Gk-1 What did we do that doesn’t necessarily preserves the straight line embedding? Modify f(k-1). We’ll prove it doesn’t matter by proving something stronger – not just for moving ½ units, but a1+a2+...+aj units.
16
v1 ‹ v4 ‹ v3 ‹ v2 Induction Base k = 4: α1, α2, α3, α4
x(v1) = xk-1(v1) + α1 , since u1 ‹ = v1 ‹ u2 x(v4) = xk-1(v4) + α1 + α2 , since u1 ‹ = v4 ‹ u2 ,u2 ‹ = v4 ‹ u3 x(v3) = xk-1(v3) + α1 + α2 + α3 x(v2) = xk-1(v2) + α1 + α2 + α3 + α4 v4 = u2 Explain the order (we began with v1 < v3 < v2, then inserted v4 right after his “first’ neighbor). It is clear to see that moving everything right, then moving everything but V1 right, then moving everything but V1, V4 (and so on) doesn’t create crossing edges. v3 v1 = u1 v2 = u3
17
Show For Gk u1, ... , up, vk, uq, ... , um – the exterior face of Gk
Fix α(u1), α(u2), ... , α(up), α(vk), α(uq), ... , α(um) Take Gk-1, and α1 = α(u1), ... , αp = α(up), αp+1 = α(vk) + 1, αp+2 = 0, ... , αq = α(uq) + 1, αq+1 = α(uq+1), ... , αm = α(um) Apply the induction hypothesis – the restriction of f ’k to Gk-1 is a straight line embedding. Also vk’s edges don’t create any crossing We assume it’s been proved for Gk-1. The fixed a’s can be any non-negative set of numbers. (since it’s the addition of a1,..., ap+2, up+2 will also move by 1 unit. The same way, uq-1 till um will all move 2 units) F’k we defined maps (up+1,...um) to the same set that fk does, and we defined fk so that vk won’t create crossing edges.
18
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.