Computational Geometry Seminar Lecture 1 Drawing Planar Graphs

  • Slides: 85
Download presentation
Computational Geometry Seminar Lecture 1 Drawing Planar Graphs

Computational Geometry Seminar Lecture 1 Drawing Planar Graphs

Graph • Definition: A Simple Undirected Graph G consists of: A finite set of

Graph • Definition: A Simple Undirected Graph G consists of: A finite set of vertices V(G). A set E(G) of sets of 2 vertices, called edges. • Note: From now on we will call this type of graphs by the general name Graph. 2

Degree • Definition: In a graph G, the vertices u, v are adjacent iff

Degree • Definition: In a graph G, the vertices u, v are adjacent iff the edge uv belongs to E(G). • The number of adjacent vertices to a vertex u is called the degree of u, denoted d(u). 3

Subgraph • Definition: A graph H is a subgraph G (written H G) iff

Subgraph • Definition: A graph H is a subgraph G (written H G) iff V(H) V(G) and E(H) E(G). • We say that a graph H is the subgraph of G induced by a set of vertices U V(G) if V(H) = U and E(H) is the set of all the edges of G connecting vertices of U. 4

Paths and Cycles • Definition: A sequence of k distinct vertices, in which every

Paths and Cycles • Definition: A sequence of k distinct vertices, in which every consecutive vertices are adjacent, is called a path of length k-1. • Definition: A path of length k-1 with the addition of an edge from the last vertex to the first vertex of the path is called a cycle of length k. 5

Connectivity • Definition: A maximal set of vertices, for which there exists a path

Connectivity • Definition: A maximal set of vertices, for which there exists a path from every vertex in the set to another, is called a connected component. • A graph composed of only one connected component is called connected. 6

Graphs in the plane • Can represent graphs in the plane by assigning distinct

Graphs in the plane • Can represent graphs in the plane by assigning distinct points to vertices and drawing continuous non-self-intersecting curves (Jordan arcs) between adjacent vertices. K 4 7

Graphs in the plane • But sometimes we want the drawing to be simple

Graphs in the plane • But sometimes we want the drawing to be simple or satisfy other requirements, such as: straight line segments as arcs or avoiding crossing arcs. K 4 Can we always achieve that? 8

Planar Graphs • Definition: A graph that can be represented in the plane so

Planar Graphs • Definition: A graph that can be represented in the plane so that no two arcs meet at a point other than their endpoints is called a Planar graph. • Such representation of a planar graph is called a Plane graph or Planar embedding of the graph. 9

Nonplanar Graphs K 5 and K 3, 3 are not planar K 5 10

Nonplanar Graphs K 5 and K 3, 3 are not planar K 5 10 K 3, 3

K 3, 3 is not planar u 1 v 3 v 2 u 3

K 3, 3 is not planar u 1 v 3 v 2 u 3 v 1 11

Subdivision • A subdivision of a graph is obtained by repeating the operation of

Subdivision • A subdivision of a graph is obtained by repeating the operation of removing an edge and introducing a new vertex connected to the endpoints of the edge removed. 12

Kuratowski’s Theorem • The theorem states that a graph is not planar iff it

Kuratowski’s Theorem • The theorem states that a graph is not planar iff it has a subgraph which is a subdivision of K 5 or K 3, 3. 13

Straight Line Embedding • Deleting any edge from K 5 will result in a

Straight Line Embedding • Deleting any edge from K 5 will result in a planar graph. Moreover this graph can be embedded in the plane by using straight line segments. • Does every planar graph have a straight line embedding? ? ? 14

Faces • Definition: A plane graph divides (with its arcs) the plane into connected

Faces • Definition: A plane graph divides (with its arcs) the plane into connected regions called faces. • Exactly one of these faces is unbounded and is called the exterior face. • We denote the number of faces of a plane graph G by f(G). 15 Exterior Face

Dual Graph • Definition: For a plane graph G we construct G*, the dual

Dual Graph • Definition: For a plane graph G we construct G*, the dual of G as follows. A vertex is placed in each face of G. These are the vertices of G*. For each edge e of G we draw an edge e*, called the dual edge of e, which crosses e (and no other edge of G) and joins the vertices corresponding to the faces, whose boundary consists of e. 16

Euler’s Formula • For a connected plane graph G: v=5 e=7 f=4 17

Euler’s Formula • For a connected plane graph G: v=5 e=7 f=4 17

Euler’s Formula (Proof) • Proof: By induction on f. ü If f(G) = 1

Euler’s Formula (Proof) • Proof: By induction on f. ü If f(G) = 1 then G has no cycles (a tree), thus = v(G) – 1. e(G) ü Assume for f(G) ≥ 2 that theorem is correct for connected plane graphs with fewer than f(G) faces. 18

Euler’s Formula (Proof) ü Delete an edge e that belongs to a cycle in

Euler’s Formula (Proof) ü Delete an edge e that belongs to a cycle in G. For the resulting connected plane graph G-e we get f(G -e) = f(G) – 1. Therefore, using the induction hypothesis on G-e we obtain: v(G) – (e(G) – 1) + (f(G) – 1) = 2. ☺ 19

Euler’s Formula • Note: When dealing with disconnected graphs we can add edges between

Euler’s Formula • Note: When dealing with disconnected graphs we can add edges between connected components without adding more faces, eventually creating a connected graph. Thus, the formula becomes: (C is the number of connected components) 20

Bridges • Definition: An edge which is a boundary to only one face is

Bridges • Definition: An edge which is a boundary to only one face is called a bridge. • Same bridges as in graph theory (edges not contained in cycles). Bridges 21

Sides • Definition: For a face f of G, the number of sides of

Sides • Definition: For a face f of G, the number of sides of f is the number of edges belonging to the boundary of f, where bridges are counted twice. Denoted s(f). 7 5 22

Sides • Every non-bridge is in a boundary of exactly two faces. Therefore: 23

Sides • Every non-bridge is in a boundary of exactly two faces. Therefore: 23

Euler’s Formula • Note: According to Euler’s formula the number of faces is independent

Euler’s Formula • Note: According to Euler’s formula the number of faces is independent of the embedding we choose for the graph. However, the number of sides of the faces is not. 24

Triangulation • Definition: A face f for which s(f) = 3 is called a

Triangulation • Definition: A face f for which s(f) = 3 is called a triangle. If all faces of G are triangles, G is called a Triangulation. Triangle Triangulation 25

Triangulation • Every graph can be extended to a triangulation by the addition of

Triangulation • Every graph can be extended to a triangulation by the addition of new edges between existing vertices. • A triangulation is maximal in the sense that no more edges can be added without violating its planarity. 26

Euler’s Formula • Corollary 1: For a plane graph G with at least 3

Euler’s Formula • Corollary 1: For a plane graph G with at least 3 vertices: e(G) ≤ 3 v(G) – 6 f(G) ≤ 2 v(G) – 4 • The equalities hold iff G is a triangulation. 27

Corollary 1 • Proof: Sufficient to prove for connected plane graphs since otherwise number

Corollary 1 • Proof: Sufficient to prove for connected plane graphs since otherwise number of edges and faces only decreases. ü For every face f of G, s(f) ≥ 3. ü Thus: ü By Euler’s formula we obtain v(G) – e(G) + e(G) ≥ 2 v(G) – f(G) + f(G) ≥ 2 28 ☺

Chromatic Number • Definition: The chromatic number χ(G) of a graph G is the

Chromatic Number • Definition: The chromatic number χ(G) of a graph G is the minimum number of colors required to color the vertices of G so that no adjacent vertices are of the same color. 29

The Four-Color Theorem • According to the four-color-theorem of Appel and Haken the chromatic

The Four-Color Theorem • According to the four-color-theorem of Appel and Haken the chromatic number of a planar graph is at most 4. • This bound cannot be improved. • Proof is quite complicated. We’ll prove a weaker statement deduced from Corollary 1. 30

Corollary 2 • Corollary 2: If G is a planar graph, then χ(G) ≤

Corollary 2 • Corollary 2: If G is a planar graph, then χ(G) ≤ 5. • Proof: By induction on v(G). ü If v(G) ≤ 5, we can assign every vertex a different color. ü Assume that for v(G) ≥ 6 we proved the statement for graphs of size smaller than v(G). 31

Corollary 2 (Proof) ü From Corollary 1: G must have a vertex u with

Corollary 2 (Proof) ü From Corollary 1: G must have a vertex u with d(u) ≤ 5. Otherwise for every vertex u, d(u) ≥ 6. Thus: In contradiction to corollary 1. 32

Corollary 2 (Proof) ü If d(u) ≤ 4 then color the rest of the

Corollary 2 (Proof) ü If d(u) ≤ 4 then color the rest of the graph G-u with 5 colors using the induction, and then color u with a color different from its neighbors. 33

Corollary 2 (Proof) ü If u has 5 neighbors wi (1≤ i ≤ 5):

Corollary 2 (Proof) ü If u has 5 neighbors wi (1≤ i ≤ 5): Since G is planar it does not contain K 5 as a subgraph. Thus, assume WLOG that w 1 and w 2 are not adjacent. Merge Let G’ be the graph obtained from G-u by merging w 1 and w 2 to w’, which is adjacent to neighbors of w 1 or w 2. 34

Corollary 2 (Proof) G’ is a planar graph, hence we apply the induction to

Corollary 2 (Proof) G’ is a planar graph, hence we apply the induction to obtain a 5 -coloring of G’. If we use the same coloring on G-u, where w 1 and w 2 are assigned the color of w’, the neighbors of u are colored in at most 4 colors. Therefore, we can assign a color for u different from its neighbors. ☺ 35

Straight Line Drawing • We will now prove that every planar graph has and

Straight Line Drawing • We will now prove that every planar graph has and embedding with straight line segments, called the straight-line embedding. K 4 36

Straight Line Drawing • Let us start off with the following lemma: • Lemma

Straight Line Drawing • Let us start off with the following lemma: • Lemma 1: Let G be a plane graph whose exterior face is bounded by a cycle u 1, … , uk. Then exists up (p ≠ 1, k) not adjacent to any uj other than up-1 and up+1. u 1 u 2 u 3 u 5 37 u 4

Lemma 1 (Proof) • Proof: If no two non-consecutive vertices in the exterior boundary

Lemma 1 (Proof) • Proof: If no two non-consecutive vertices in the exterior boundary are adjacent, then the lemma is trivial. Otherwise: ü Pick two non-consecutive adjacent vertices ui, uj (j > i+1) for which j-i is minimal. u 1 u 2 u 3 i=1 j=3 u 5 38 u 4

Lemma 1 (Proof) ü ui+1 cannot be adjacent to u 1, …, ui-1, …,

Lemma 1 (Proof) ü ui+1 cannot be adjacent to u 1, …, ui-1, …, uj+1 , …, uk by planarity. u 1 u 2 u 3 i=1 j=3 crossing u 5 u 4 ü ui+1 cannot be adjacent to any ui, …, uj other than ui and ui+2 because of minimality of j-i. ☺ 39

Canonical Construction of Triangulations • Let G be a triangulation with an exterior face

Canonical Construction of Triangulations • Let G be a triangulation with an exterior face uvw and a labelling u 1 = u, u 2 = v, u 3, …, un = w of the vertices of G. Denote by Gk the subgraph of G induced by u 1, …, uk and by Ck the exterior boundary of Gk. 40

Canonical Construction of Triangulations • There exists a labelling such that for every 4

Canonical Construction of Triangulations • There exists a labelling such that for every 4 ≤ k ≤ n: I. Gk-1 is internally triangulated. II. The edge uv is in Ck-1. III. uk is in the exterior face of Gk-1 the neighbors of uk in V(Gk-1) are consecutive on Ck-1. • This kind of labelling is called a canonical labelling. 41

Canonical Construction of Triangulations (Proof) • Proof: We define un, un-1, …, u 3

Canonical Construction of Triangulations (Proof) • Proof: We define un, un-1, …, u 3 by reverse induction. ü For un = w: w u 42 v

Canonical Construction of Triangulations (Proof) ü For 4 ≤ k ≤ n: Assume we

Canonical Construction of Triangulations (Proof) ü For 4 ≤ k ≤ n: Assume we defined un, …, uk correctly. Applying Lemma 1 to Gk-1, the subgraph induced by the remaining vertices, we know that there is a vertex on Ck-1, other than u and v, that is only adjacent to its preceding and subsequent vertices on Ck-1. Let uk-1 be that vertex. Proof of I. -III. is the same as with un. ☺ 43

Canonical Labelling (Example) w u 44 v

Canonical Labelling (Example) w u 44 v

Canonical Labelling (Example) w= u 7 u= u 1 45 u 2=v

Canonical Labelling (Example) w= u 7 u= u 1 45 u 2=v

Canonical Labelling (Example) u 6 u= u 1 46 u 2=v

Canonical Labelling (Example) u 6 u= u 1 46 u 2=v

Canonical Labelling (Example) u 5 u= u 1 47 u 2=v

Canonical Labelling (Example) u 5 u= u 1 47 u 2=v

Canonical Labelling (Example) u 4 u= u 1 48 u 2=v

Canonical Labelling (Example) u 4 u= u 1 48 u 2=v

Canonical Labelling (Example) u 3 u= u 1 49 u 2=v

Canonical Labelling (Example) u 3 u= u 1 49 u 2=v

Straight Line Drawing • Corollary 3: Every planar graph has a straight line embedding

Straight Line Drawing • Corollary 3: Every planar graph has a straight line embedding in the plane. • Proof: It is sufficient to show that the statement is true for any maximal planar graph, i. e. a graph that can be represented as a triangulation. 50

Corollary 3 (Proof) ü Let G be a triangulation with the canonical labelling u

Corollary 3 (Proof) ü Let G be a triangulation with the canonical labelling u 1 = u, u 2 = v, u 3, …, un = w as described earlier. We will determine the positions p(uk) = (x(uk), y(uk)) of the vertices by induction on k. 51

Corollary 3 (Proof) ü Set p(u 1) = (0, 0) , p(u 2) =

Corollary 3 (Proof) ü Set p(u 1) = (0, 0) , p(u 2) = (2, 0) , p(u 3) = (1, 1). ü For k ≥ 4 assume that p(u 1), …, p(uk-1) have already been defined s. t. , by connecting the images of adjacent vertices with segments, we obtain a straight line embedding of Gk-1, whose exterior face is bounded by the segments corresponding to the edges of Ck-1. 52

Corollary 3 (Proof) Let v 1 = u, v 2, …, vm = v

Corollary 3 (Proof) Let v 1 = u, v 2, …, vm = v denote the vertices of Ck-1 listed in the order they appear on the cycle. Suppose further that: (1) x(v 1) < x(v 2) < … < x(vm) y(vi) > 0 for 1 < i < m 53

Corollary 3 (Proof) ü By condition III. of the canonical labelling, uk is connected

Corollary 3 (Proof) ü By condition III. of the canonical labelling, uk is connected to a series of consecutive vertices of Ck-1, vq, …, vr (1 ≤ q < r ≤ m). Choose x(uk) s. t. x(vq) < x(uk) < x(vr). Now choose y(uk) > 0 large enough. The new position p(uk) meets all the requirements (including the assumption (1)). ☺ 54

Straight Line Drawing (Example) The starting graph 55

Straight Line Drawing (Example) The starting graph 55

Straight Line Drawing (Example) Making the triangulation 56

Straight Line Drawing (Example) Making the triangulation 56

Straight Line Drawing (Example) w= u 6 u 5 u= u 1 u 3

Straight Line Drawing (Example) w= u 6 u 5 u= u 1 u 3 u 4 v= u 2 Canonical labelling 57

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4 v= u 2 u= u 1 x 0 Setting p(u 1) p(u 2) p(u 3) 58 1 2

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4 v 2 v= u 2 u= u 1 0 59 v 3 v 1 1 2 x

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4 v 2 v 3 v= u 2 u= u 1 0 60 v 4 v 1 1 2 x

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4 v 2 v 3 v 4 v= u 2 u= u 1 0 61 v 5 v 1 1 2 x

Straight Line Drawing (Example) Delete added edges 62

Straight Line Drawing (Example) Delete added edges 62

Straight Line Drawing (Example) 63

Straight Line Drawing (Example) 63

Straight Line Drawing • Note: By using this method we can also establish the

Straight Line Drawing • Note: By using this method we can also establish the existence of straight line embedding of other representations. For example, straight line embeddings of the following representation, found by Rosenstiehl and Tarjan. 64

Straight Line Drawing • Corollary 4: The vertices and edges of any planar graph

Straight Line Drawing • Corollary 4: The vertices and edges of any planar graph can be represented by horizontal and vertical segments, respectively, s. t. : I. Segments don’t have interior points in common. II. Horizontal segments connected by a vertical segment represent adjacent vertices. 65

Corollary 4 (Proof) • Proof: As earlier it is sufficient to establish the statement

Corollary 4 (Proof) • Proof: As earlier it is sufficient to establish the statement for triangulations. ü Let G be a triangulation with the canonical labelling u 1 = u, u 2 = v, u 3, …, un = w. To every uk we will assign a segment s(uk) whose endpoints are (xk, k) and (x'k, k). 66

Corollary 4 (Proof) ü Set x 1=0, x'1=2, x 2=2, x'2=4, x 3=1, x'3=3.

Corollary 4 (Proof) ü Set x 1=0, x'1=2, x 2=2, x'2=4, x 3=1, x'3=3. x 0 2 4 ü For k ≥ 4 assume that s(u 1), …, s(uk-1) have already been defined s. t. , the subgraph Gk-1 has a representation satisfying conditions I. and II. 67

Corollary 4 (Proof) ü We define the upper envelope of s(u 1), …, s(uk-1)

Corollary 4 (Proof) ü We define the upper envelope of s(u 1), …, s(uk-1) as the set of points for which no other point is directly above them. Denote this by UEk-1. 68

Corollary 4 (Proof) ü Let v 1 = u, v 2, …, vm =

Corollary 4 (Proof) ü Let v 1 = u, v 2, …, vm = v denote the vertices of Ck-1 listed in the order they appear on the cycle. Suppose further that UEk-1 consists of portions of s(v 1), …, s(vm), in this order (from left to right). s(v 2) s(v 3) s(v 4) s(v 1) 69

Corollary 4 (Proof) ü By condition III. of the canonical labelling, uk is connected

Corollary 4 (Proof) ü By condition III. of the canonical labelling, uk is connected to a series of consecutive vertices of Ck-1, vq, …, vr (1 ≤ q < r ≤ m). Choose xk to be some point of s(vq) which belongs to UEk-1 and choose x'k to be some point which belongs to UEk-1. The resulting representation of Gk meets the requirements. ☺ 70

Straight Line Drawing (Example) w= u 6 u 5 u= u 1 u 3

Straight Line Drawing (Example) w= u 6 u 5 u= u 1 u 3 u 4 v= u 2 Canonical labelling 71

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4 v= u 2 u= u 1 x 0 Setting s(u 1) s(u 2) s(u 3) 72 2 4

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4 s(v 2) s(v 3) v= u 2 u= u 1 s(v 1) x 0 73 2 4

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4 s(v 2) s(v 4) v= u 2 u= u 1 s(v 1) x 0 74 s(v 3) 2 4

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4

Straight Line Drawing (Example) Left: u 3 w= u 6 u 5 u 4 s(v 2) s(v 3) s(v 4) s(v 5) v= u 2 u= u 1 s(v 1) x 0 75 2 4

Straight Line Drawing (Example) Delete added edges 76

Straight Line Drawing (Example) Delete added edges 76

Straight Line Drawing (Example) 77

Straight Line Drawing (Example) 77

3 D Implementations • So far we’ve seen embeddings of graphs in 2 D

3 D Implementations • So far we’ve seen embeddings of graphs in 2 D (on the plane). • We will now see how to embed planar graphs in 3 D. • We will also get to know new shapes which allow use to draw graphs which are not planar. 78

The Sphere • Every planar graph can be embedded on the sphere. • Likewise,

The Sphere • Every planar graph can be embedded on the sphere. • Likewise, every embedding on the sphere can be transformed to an embedding on the plane. 79

The Sphere • To transform an embedding on the sphere to an embedding on

The Sphere • To transform an embedding on the sphere to an embedding on the plane: • We choose a face and puncture a hole in it. Then stretch the face using the hole until we get a flat surface. That face will be the exterior face. • This procedure is reversible. 80

Handle • Definition: A handle is a tube joining two holes cut in a

Handle • Definition: A handle is a tube joining two holes cut in a surface. 81

Genus • Definition: The genus of a surface obtained by adding handles to a

Genus • Definition: The genus of a surface obtained by adding handles to a sphere is the number of spheres added. 82

Genus 0: Sphere Genus 2: Double-Torus 83 Genus 1: Torus Genus 3: Pretzel

Genus 0: Sphere Genus 2: Double-Torus 83 Genus 1: Torus Genus 3: Pretzel

Graphs • The genus of a graph is the minimum γ such that the

Graphs • The genus of a graph is the minimum γ such that the graph can be embedded on a surface of genus γ. • As stated planar graphs can be embedded on the sphere. Therefore, they are of genus 0. 84

Graphs • K 5 and K 3, 3 are of genus 1. 85

Graphs • K 5 and K 3, 3 are of genus 1. 85