Discrete Mathematics Graphs H. Turgut Uyar Ay seg ul Gen cata - - PowerPoint PPT Presentation

discrete mathematics
SMART_READER_LITE
LIVE PREVIEW

Discrete Mathematics Graphs H. Turgut Uyar Ay seg ul Gen cata - - PowerPoint PPT Presentation

Discrete Mathematics Graphs H. Turgut Uyar Ay seg ul Gen cata Yayml Emre Harmanc 2001-2016 License 2001-2016 T. Uyar, A. Yayml, E. Harmanc c You are free to: Share copy and redistribute the material in any


slide-1
SLIDE 1

Discrete Mathematics

Graphs

  • H. Turgut Uyar

Ay¸ seg¨ ul Gen¸ cata Yayımlı Emre Harmancı 2001-2016

slide-2
SLIDE 2

License

c 2001-2016 T. Uyar, A. Yayımlı, E. Harmancı

You are free to: Share – copy and redistribute the material in any medium or format Adapt – remix, transform, and build upon the material Under the following terms: Attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. NonCommercial – You may not use the material for commercial purposes. ShareAlike – If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.

For more information:

https://creativecommons.org/licenses/by-nc-sa/4.0/

Read the full license:

https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode

slide-3
SLIDE 3

Topics

1 Graphs

Introduction Walks Traversable Graphs Planar Graphs

2 Graph Problems

Connectivity Graph Coloring Shortest Path TSP Searching Graphs

slide-4
SLIDE 4

Topics

1 Graphs

Introduction Walks Traversable Graphs Planar Graphs

2 Graph Problems

Connectivity Graph Coloring Shortest Path TSP Searching Graphs

slide-5
SLIDE 5

Graphs

Definition graph: G = (V , E) V : node (or vertex) set E ⊆ V × V : edge set e = (v1, v2) ∈ E: v1 and v2 are endnodes of e e is incident to v1 and v2 v1 and v2 are adjacent

slide-6
SLIDE 6

Graphs

Definition graph: G = (V , E) V : node (or vertex) set E ⊆ V × V : edge set e = (v1, v2) ∈ E: v1 and v2 are endnodes of e e is incident to v1 and v2 v1 and v2 are adjacent

slide-7
SLIDE 7

Graph Example

V = {a, b, c, d, e, f } E = {(a, b), (a, c), (a, d), (a, e), (a, f ), (b, c), (d, e), (e, f )}

slide-8
SLIDE 8

Directed Graphs

Definition directed graph (digraph): D = (V , A) V : node set A ⊆ V × V : arc set a = (v1, v2) ∈ A: v1: origin node of a v2: terminating node of a

slide-9
SLIDE 9

Directed Graph Example

slide-10
SLIDE 10

Weighted Graphs

weighted graph: labels assigned to edges weight length, distance cost, delay probability . . .

slide-11
SLIDE 11

Multigraphs

parallel edges: edges between same node pair loop: edge starting and ending in same node plain graph: no loops, no parallel edges multigraph: a graph which is not plain

slide-12
SLIDE 12

Multigraph Example

parallel edges: (a, b) loop: (e, e)

slide-13
SLIDE 13

Subgraph

Definition G ′ = (V ′, E ′) is a subgraph of G = (V , E): V ′ ⊆ V ∧ E ′ ⊆ E ∧ ∀(v1, v2) ∈ E ′ [v1, v2 ∈ V ′]

slide-14
SLIDE 14

Incidence Matrix

rows: nodes, columns: edges 1 if edge incident on node, 0 otherwise example e1 e2 e3 e4 e5 e6 e7 e8 v1 1 1 1 1 v2 1 1 v3 1 1 1 1 v4 1 1 1 v5 1 1 1

slide-15
SLIDE 15

Adjacency Matrix

rows: nodes, columns: nodes 1 if nodes are adjacent, 0 otherwise example v1 v2 v3 v4 v5 v1 1 1 1 1 v2 1 1 v3 1 1 1 1 v4 1 1 1 v5 1 1 1

slide-16
SLIDE 16

Adjacency Matrix

multigraph: number of edges between nodes example a b c d a 1 b 2 1 1 c d 1 1

slide-17
SLIDE 17

Adjacency Matrix

weighted graph: weight of edge

slide-18
SLIDE 18

Degree

degree of node: number of incident edges Theorem di: degree of vi |E| =

  • i di

2

slide-19
SLIDE 19

Degree

degree of node: number of incident edges Theorem di: degree of vi |E| =

  • i di

2

slide-20
SLIDE 20

Degree Example

da = 5 db = 2 dc = 2 dd = 2 de = 3 df = 2 16 |E| = 8

slide-21
SLIDE 21

Multigraph Degree Example

da = 6 db = 3 dc = 2 dd = 2 de = 5 df = 2 20 |E| = 10

slide-22
SLIDE 22

Degree in Directed Graphs

in-degree: dv i

  • ut-degree: dv o

node with in-degree 0: source node with out-degree 0: sink

  • v∈V dv i =

v∈V dv o = |A|

slide-23
SLIDE 23

Degree in Directed Graphs

in-degree: dv i

  • ut-degree: dv o

node with in-degree 0: source node with out-degree 0: sink

  • v∈V dv i =

v∈V dv o = |A|

slide-24
SLIDE 24

Degree in Directed Graphs

in-degree: dv i

  • ut-degree: dv o

node with in-degree 0: source node with out-degree 0: sink

  • v∈V dv i =

v∈V dv o = |A|

slide-25
SLIDE 25

Degree

Theorem In an undirected graph, there is an even number of nodes which have an odd degree. Proof. ti: number of nodes of degree i 2|E| =

i di = 1t1 + 2t2 + 3t3 + 4t4 + 5t5 + . . .

2|E| − 2t2 − 4t4 − · · · = t1 + t3 + t5 + · · · + 2t3 + 4t5 + . . . 2|E| − 2t2 − 4t4 − · · · − 2t3 − 4t5 − · · · = t1 + t3 + t5 + . . . left-hand side even ⇒ right-hand side even

slide-26
SLIDE 26

Degree

Theorem In an undirected graph, there is an even number of nodes which have an odd degree. Proof. ti: number of nodes of degree i 2|E| =

i di = 1t1 + 2t2 + 3t3 + 4t4 + 5t5 + . . .

2|E| − 2t2 − 4t4 − · · · = t1 + t3 + t5 + · · · + 2t3 + 4t5 + . . . 2|E| − 2t2 − 4t4 − · · · − 2t3 − 4t5 − · · · = t1 + t3 + t5 + . . . left-hand side even ⇒ right-hand side even

slide-27
SLIDE 27

Degree

Theorem In an undirected graph, there is an even number of nodes which have an odd degree. Proof. ti: number of nodes of degree i 2|E| =

i di = 1t1 + 2t2 + 3t3 + 4t4 + 5t5 + . . .

2|E| − 2t2 − 4t4 − · · · = t1 + t3 + t5 + · · · + 2t3 + 4t5 + . . . 2|E| − 2t2 − 4t4 − · · · − 2t3 − 4t5 − · · · = t1 + t3 + t5 + . . . left-hand side even ⇒ right-hand side even

slide-28
SLIDE 28

Degree

Theorem In an undirected graph, there is an even number of nodes which have an odd degree. Proof. ti: number of nodes of degree i 2|E| =

i di = 1t1 + 2t2 + 3t3 + 4t4 + 5t5 + . . .

2|E| − 2t2 − 4t4 − · · · = t1 + t3 + t5 + · · · + 2t3 + 4t5 + . . . 2|E| − 2t2 − 4t4 − · · · − 2t3 − 4t5 − · · · = t1 + t3 + t5 + . . . left-hand side even ⇒ right-hand side even

slide-29
SLIDE 29

Degree

Theorem In an undirected graph, there is an even number of nodes which have an odd degree. Proof. ti: number of nodes of degree i 2|E| =

i di = 1t1 + 2t2 + 3t3 + 4t4 + 5t5 + . . .

2|E| − 2t2 − 4t4 − · · · = t1 + t3 + t5 + · · · + 2t3 + 4t5 + . . . 2|E| − 2t2 − 4t4 − · · · − 2t3 − 4t5 − · · · = t1 + t3 + t5 + . . . left-hand side even ⇒ right-hand side even

slide-30
SLIDE 30

Degree

Theorem In an undirected graph, there is an even number of nodes which have an odd degree. Proof. ti: number of nodes of degree i 2|E| =

i di = 1t1 + 2t2 + 3t3 + 4t4 + 5t5 + . . .

2|E| − 2t2 − 4t4 − · · · = t1 + t3 + t5 + · · · + 2t3 + 4t5 + . . . 2|E| − 2t2 − 4t4 − · · · − 2t3 − 4t5 − · · · = t1 + t3 + t5 + . . . left-hand side even ⇒ right-hand side even

slide-31
SLIDE 31

Isomorphism

Definition G = (V , E) and G ⋆ = (V ⋆, E ⋆) are isomorphic: ∃f : V → V ⋆ [(u, v) ∈ E ⇒ (f (u), f (v)) ∈ E ⋆] ∧ f is bijective G and G ⋆ can be drawn the same way

slide-32
SLIDE 32

Isomorphism

Definition G = (V , E) and G ⋆ = (V ⋆, E ⋆) are isomorphic: ∃f : V → V ⋆ [(u, v) ∈ E ⇒ (f (u), f (v)) ∈ E ⋆] ∧ f is bijective G and G ⋆ can be drawn the same way

slide-33
SLIDE 33

Isomorphism Example

f = (a → d, b → e, c → b, d → c, e → a)

slide-34
SLIDE 34

Isomorphism Example

f = (a → d, b → e, c → b, d → c, e → a)

slide-35
SLIDE 35

Petersen Graph

f = (a → q, b → v, c → u, d → y, e → r, f → w, g → x, h → t, i → z, j → s)

slide-36
SLIDE 36

Homeomorphism

Definition G = (V , E) and G ⋆ = (V ⋆, E ⋆) are homeomorphic: G and G ⋆ isomorphic, except that some edges in E ⋆ are divided with additional nodes

slide-37
SLIDE 37

Homeomorphism Example

slide-38
SLIDE 38

Regular Graphs

regular graph: all nodes have the same degree n-regular: all nodes have degree n examples

slide-39
SLIDE 39

Completely Connected Graphs

G = (V , E) is completely connected: ∀v1, v2 ∈ V (v1, v2) ∈ E every pair of nodes are adjacent Kn: completely connected graph with n nodes

slide-40
SLIDE 40

Completely Connected Graph Examples

K4 K5

slide-41
SLIDE 41

Bipartite Graphs

G = (V , E) is bipartite: V1 ∪ V2 = V , V1 ∩ V2 = ∅ ∀(v1, v2) ∈ E [v1 ∈ V1 ∧ v2 ∈ V2] example complete bipartite: ∀v1 ∈ V1 ∀v2 ∈ V2 (v1, v2) ∈ E Km,n: |V1| = m, |V2| = n

slide-42
SLIDE 42

Complete Bipartite Graph Examples

K2,3 K3,3

slide-43
SLIDE 43

Topics

1 Graphs

Introduction Walks Traversable Graphs Planar Graphs

2 Graph Problems

Connectivity Graph Coloring Shortest Path TSP Searching Graphs

slide-44
SLIDE 44

Walk

walk: sequence of nodes and edges from a starting node (v0) to an ending node (vn) v0

e1

− → v1

e2

− → v2

e3

− → v3 − → · · · − → vn−1

en

− → vn where ei = (vi−1, vi) no need to write the edges if not weighted length: number of edges v0 = vn: closed

slide-45
SLIDE 45

Walk

walk: sequence of nodes and edges from a starting node (v0) to an ending node (vn) v0

e1

− → v1

e2

− → v2

e3

− → v3 − → · · · − → vn−1

en

− → vn where ei = (vi−1, vi) no need to write the edges if not weighted length: number of edges v0 = vn: closed

slide-46
SLIDE 46

Walk Example

c

(c,b)

− − − → b

(b,a)

− − − → a

(a,d)

− − − → d

(d,e)

− − − → e

(e,f )

− − − → f

(f ,a)

− − − → a

(a,b)

− − − → b c → b → a → d → e → f → a → b length: 7

slide-47
SLIDE 47

Trail

trail: edges not repeated circuit: closed trail spanning trail: covers all edges

slide-48
SLIDE 48

Trail Example

c

(c,b)

− − − → b

(b,a)

− − − → a

(a,e)

− − − → e

(e,d)

− − − → d

(d,a)

− − − → a

(a,f )

− − − → f c → a → e → d → a → f

slide-49
SLIDE 49

Path

path: nodes not repeated cycle: closed path spanning path: visits all nodes

slide-50
SLIDE 50

Path Example

c

(c,b)

− − − → b

(b,a)

− − − → a

(a,d)

− − − → d

(d,e)

− − − → e

(e,f )

− − − → f c → b → a → d → e → f

slide-51
SLIDE 51

Connected Graphs

connected: a path between every pair of nodes a disconnected graph can be divided into connected components

slide-52
SLIDE 52

Connected Components Example

disconnected: no path between a and c connected components: a, d, e b, c f

slide-53
SLIDE 53

Distance

distance between vi and vj: length of shortest path between vi and vj diameter of graph: largest distance in graph

slide-54
SLIDE 54

Distance Example

distance between a and e: 2 diameter: 3

slide-55
SLIDE 55

Cut-Points

G − v: delete v and all its incident edges from G v is a cut-point for G: G is connected but G − v is not

slide-56
SLIDE 56

Cut-Point Example

G G − d

slide-57
SLIDE 57

Directed Walks

ignoring directions on arcs: semi-walk, semi-trail, semi-path if between every pair of nodes there is: a semi-path: weakly connected a path from one to the other: unilaterally connected a path: strongly connected

slide-58
SLIDE 58

Directed Graph Examples

weakly unilaterally strongly

slide-59
SLIDE 59

Topics

1 Graphs

Introduction Walks Traversable Graphs Planar Graphs

2 Graph Problems

Connectivity Graph Coloring Shortest Path TSP Searching Graphs

slide-60
SLIDE 60

Bridges of K¨

  • nigsberg

cross each bridge exactly once and return to the starting point

slide-61
SLIDE 61

Graphs

slide-62
SLIDE 62

Traversable Graphs

G is traversable: G contains a spanning trail a node with an odd degree must be either the starting node

  • r the ending node of the trail

all nodes except the starting node and the ending node must have even degrees

slide-63
SLIDE 63

Bridges of K¨

  • nigsberg

all nodes have odd degrees: not traversable

slide-64
SLIDE 64

Traversable Graph Example

a, b, c: even d, e: odd start from d, end at e: d → b → a → c → e → d → c → b → e

slide-65
SLIDE 65

Euler Graphs

Euler graph: contains closed spanning trail G is an Euler graph ⇔ all nodes in G have even degrees

slide-66
SLIDE 66

Euler Graph Examples

Euler not Euler

slide-67
SLIDE 67

Hamilton Graphs

Hamilton graph: contains a closed spanning path

slide-68
SLIDE 68

Hamilton Graph Examples

Hamilton not Hamilton

slide-69
SLIDE 69

Topics

1 Graphs

Introduction Walks Traversable Graphs Planar Graphs

2 Graph Problems

Connectivity Graph Coloring Shortest Path TSP Searching Graphs

slide-70
SLIDE 70

Planar Graphs

Definition G is planar: G can be drawn on a plane without intersecting its edges a map of G: a planar drawing of G

slide-71
SLIDE 71

Planar Graph Example

slide-72
SLIDE 72

Regions

map divides plane into regions degree of region: length of closed trail that surrounds region Theorem dri: degree of region ri |E| =

  • i dri

2

slide-73
SLIDE 73

Regions

map divides plane into regions degree of region: length of closed trail that surrounds region Theorem dri: degree of region ri |E| =

  • i dri

2

slide-74
SLIDE 74

Region Example

dr1 = 3 dr2 = 3 dr3 = 5 dr4 = 4 dr5 = 3 = 18 |E| = 9

slide-75
SLIDE 75

Euler’s Formula

Theorem (Euler’s Formula) G = (V , E): planar, connected graph R: set of regions in a map of G |V | − |E| + |R| = 2

slide-76
SLIDE 76

Euler’s Formula Example

|V | = 6, |E| = 9, |R| = 5

slide-77
SLIDE 77

Planar Graph Theorems

Theorem G = (V , E): connected, planar graph where |V | ≥ 3 |E| ≤ 3|V | − 6 Proof. sum of region degrees: 2|E| degree of a region ≥ 3 ⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 2

3|E|

|V | − |E| + |R| = 2 ⇒ |V | − |E| + 2

3|E| ≥ 2 ⇒ |V | − 1 3|E| ≥ 2

⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6

slide-78
SLIDE 78

Planar Graph Theorems

Theorem G = (V , E): connected, planar graph where |V | ≥ 3 |E| ≤ 3|V | − 6 Proof. sum of region degrees: 2|E| degree of a region ≥ 3 ⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 2

3|E|

|V | − |E| + |R| = 2 ⇒ |V | − |E| + 2

3|E| ≥ 2 ⇒ |V | − 1 3|E| ≥ 2

⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6

slide-79
SLIDE 79

Planar Graph Theorems

Theorem G = (V , E): connected, planar graph where |V | ≥ 3 |E| ≤ 3|V | − 6 Proof. sum of region degrees: 2|E| degree of a region ≥ 3 ⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 2

3|E|

|V | − |E| + |R| = 2 ⇒ |V | − |E| + 2

3|E| ≥ 2 ⇒ |V | − 1 3|E| ≥ 2

⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6

slide-80
SLIDE 80

Planar Graph Theorems

Theorem G = (V , E): connected, planar graph where |V | ≥ 3 |E| ≤ 3|V | − 6 Proof. sum of region degrees: 2|E| degree of a region ≥ 3 ⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 2

3|E|

|V | − |E| + |R| = 2 ⇒ |V | − |E| + 2

3|E| ≥ 2 ⇒ |V | − 1 3|E| ≥ 2

⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6

slide-81
SLIDE 81

Planar Graph Theorems

Theorem G = (V , E): connected, planar graph where |V | ≥ 3 |E| ≤ 3|V | − 6 Proof. sum of region degrees: 2|E| degree of a region ≥ 3 ⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 2

3|E|

|V | − |E| + |R| = 2 ⇒ |V | − |E| + 2

3|E| ≥ 2 ⇒ |V | − 1 3|E| ≥ 2

⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6

slide-82
SLIDE 82

Planar Graph Theorems

Theorem G = (V , E): connected, planar graph where |V | ≥ 3 |E| ≤ 3|V | − 6 Proof. sum of region degrees: 2|E| degree of a region ≥ 3 ⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 2

3|E|

|V | − |E| + |R| = 2 ⇒ |V | − |E| + 2

3|E| ≥ 2 ⇒ |V | − 1 3|E| ≥ 2

⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6

slide-83
SLIDE 83

Planar Graph Theorems

Theorem G = (V , E): connected, planar graph where |V | ≥ 3 |E| ≤ 3|V | − 6 Proof. sum of region degrees: 2|E| degree of a region ≥ 3 ⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 2

3|E|

|V | − |E| + |R| = 2 ⇒ |V | − |E| + 2

3|E| ≥ 2 ⇒ |V | − 1 3|E| ≥ 2

⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6

slide-84
SLIDE 84

Planar Graph Theorems

Theorem G = (V , E): connected, planar graph where |V | ≥ 3 |E| ≤ 3|V | − 6 Proof. sum of region degrees: 2|E| degree of a region ≥ 3 ⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 2

3|E|

|V | − |E| + |R| = 2 ⇒ |V | − |E| + 2

3|E| ≥ 2 ⇒ |V | − 1 3|E| ≥ 2

⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6

slide-85
SLIDE 85

Planar Graph Theorems

Theorem G = (V , E): connected, planar graph where |V | ≥ 3 |E| ≤ 3|V | − 6 Proof. sum of region degrees: 2|E| degree of a region ≥ 3 ⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 2

3|E|

|V | − |E| + |R| = 2 ⇒ |V | − |E| + 2

3|E| ≥ 2 ⇒ |V | − 1 3|E| ≥ 2

⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6

slide-86
SLIDE 86

Planar Graph Theorems

Theorem G = (V , E): connected, planar graph where |V | ≥ 3 |E| ≤ 3|V | − 6 Proof. sum of region degrees: 2|E| degree of a region ≥ 3 ⇒ 2|E| ≥ 3|R| ⇒ |R| ≤ 2

3|E|

|V | − |E| + |R| = 2 ⇒ |V | − |E| + 2

3|E| ≥ 2 ⇒ |V | − 1 3|E| ≥ 2

⇒ 3|V | − |E| ≥ 6 ⇒ |E| ≤ 3|V | − 6

slide-87
SLIDE 87

Planar Graph Theorems

Theorem G = (V , E): connected, planar graph where |V | ≥ 3: ∃v ∈ V [dv ≤ 5] Proof. assume: ∀v ∈ V [dv ≥ 6] ⇒ 2|E| ≥ 6|V | ⇒ |E| ≥ 3|V | ⇒ |E| > 3|V | − 6

slide-88
SLIDE 88

Planar Graph Theorems

Theorem G = (V , E): connected, planar graph where |V | ≥ 3: ∃v ∈ V [dv ≤ 5] Proof. assume: ∀v ∈ V [dv ≥ 6] ⇒ 2|E| ≥ 6|V | ⇒ |E| ≥ 3|V | ⇒ |E| > 3|V | − 6

slide-89
SLIDE 89

Planar Graph Theorems

Theorem G = (V , E): connected, planar graph where |V | ≥ 3: ∃v ∈ V [dv ≤ 5] Proof. assume: ∀v ∈ V [dv ≥ 6] ⇒ 2|E| ≥ 6|V | ⇒ |E| ≥ 3|V | ⇒ |E| > 3|V | − 6

slide-90
SLIDE 90

Planar Graph Theorems

Theorem G = (V , E): connected, planar graph where |V | ≥ 3: ∃v ∈ V [dv ≤ 5] Proof. assume: ∀v ∈ V [dv ≥ 6] ⇒ 2|E| ≥ 6|V | ⇒ |E| ≥ 3|V | ⇒ |E| > 3|V | − 6

slide-91
SLIDE 91

Planar Graph Theorems

Theorem G = (V , E): connected, planar graph where |V | ≥ 3: ∃v ∈ V [dv ≤ 5] Proof. assume: ∀v ∈ V [dv ≥ 6] ⇒ 2|E| ≥ 6|V | ⇒ |E| ≥ 3|V | ⇒ |E| > 3|V | − 6

slide-92
SLIDE 92

Nonplanar Graphs

Theorem K5 is not planar. Proof. |V | = 5 3|V | − 6 = 3 · 5 − 6 = 9 |E| ≤ 9 should hold but |E| = 10

slide-93
SLIDE 93

Nonplanar Graphs

Theorem K5 is not planar. Proof. |V | = 5 3|V | − 6 = 3 · 5 − 6 = 9 |E| ≤ 9 should hold but |E| = 10

slide-94
SLIDE 94

Nonplanar Graphs

Theorem K5 is not planar. Proof. |V | = 5 3|V | − 6 = 3 · 5 − 6 = 9 |E| ≤ 9 should hold but |E| = 10

slide-95
SLIDE 95

Nonplanar Graphs

Theorem K5 is not planar. Proof. |V | = 5 3|V | − 6 = 3 · 5 − 6 = 9 |E| ≤ 9 should hold but |E| = 10

slide-96
SLIDE 96

Nonplanar Graphs

Theorem K5 is not planar. Proof. |V | = 5 3|V | − 6 = 3 · 5 − 6 = 9 |E| ≤ 9 should hold but |E| = 10

slide-97
SLIDE 97

Nonplanar Graphs

Theorem K3,3 is not planar. Proof. |V | = 6, |E| = 9 if planar then |R| = 5 degree of a region ≥ 4 ⇒

r∈R dr ≥ 20

|E| ≥ 10 should hold but |E| = 9

slide-98
SLIDE 98

Nonplanar Graphs

Theorem K3,3 is not planar. Proof. |V | = 6, |E| = 9 if planar then |R| = 5 degree of a region ≥ 4 ⇒

r∈R dr ≥ 20

|E| ≥ 10 should hold but |E| = 9

slide-99
SLIDE 99

Nonplanar Graphs

Theorem K3,3 is not planar. Proof. |V | = 6, |E| = 9 if planar then |R| = 5 degree of a region ≥ 4 ⇒

r∈R dr ≥ 20

|E| ≥ 10 should hold but |E| = 9

slide-100
SLIDE 100

Nonplanar Graphs

Theorem K3,3 is not planar. Proof. |V | = 6, |E| = 9 if planar then |R| = 5 degree of a region ≥ 4 ⇒

r∈R dr ≥ 20

|E| ≥ 10 should hold but |E| = 9

slide-101
SLIDE 101

Nonplanar Graphs

Theorem K3,3 is not planar. Proof. |V | = 6, |E| = 9 if planar then |R| = 5 degree of a region ≥ 4 ⇒

r∈R dr ≥ 20

|E| ≥ 10 should hold but |E| = 9

slide-102
SLIDE 102

Nonplanar Graphs

Theorem K3,3 is not planar. Proof. |V | = 6, |E| = 9 if planar then |R| = 5 degree of a region ≥ 4 ⇒

r∈R dr ≥ 20

|E| ≥ 10 should hold but |E| = 9

slide-103
SLIDE 103

Kuratowski’s Theorem

Theorem G contains a subgraph homeomorphic to K5 or K3,3. ⇔ G is not planar.

slide-104
SLIDE 104

Platonic Solids

regular polyhedron: a 3-dimensional solid where faces are identical regular polygons projection of a regular polyhedron onto the plane: a planar graph corners: nodes sides: edges faces: regions

slide-105
SLIDE 105

Platonic Solid Example

slide-106
SLIDE 106

Platonic Solids

|V |: number of corners (nodes) |E|: number of sides (edges) |R|: number of faces (regions) n: number of faces meeting at a corner (node degree) m: number of sides of a face (region degree) m, n ≥ 3 2|E| = n · |V | 2|E| = m · |R|

slide-107
SLIDE 107

Platonic Solids

|V |: number of corners (nodes) |E|: number of sides (edges) |R|: number of faces (regions) n: number of faces meeting at a corner (node degree) m: number of sides of a face (region degree) m, n ≥ 3 2|E| = n · |V | 2|E| = m · |R|

slide-108
SLIDE 108

Platonic Solids

from Euler’s formula: 2 = |V |−|E|+|R| = 2|E| n −|E|+2|E| m = |E| 2m − mn + 2n mn

  • > 0

|E|, m, n > 0: 2m − mn + 2n > 0 ⇒ mn − 2m − 2n < 0 ⇒ mn − 2m − 2n + 4 < 4 ⇒ (m − 2)(n − 2) < 4

  • nly 5 solutions
slide-109
SLIDE 109

Platonic Solids

from Euler’s formula: 2 = |V |−|E|+|R| = 2|E| n −|E|+2|E| m = |E| 2m − mn + 2n mn

  • > 0

|E|, m, n > 0: 2m − mn + 2n > 0 ⇒ mn − 2m − 2n < 0 ⇒ mn − 2m − 2n + 4 < 4 ⇒ (m − 2)(n − 2) < 4

  • nly 5 solutions
slide-110
SLIDE 110

Platonic Solids

from Euler’s formula: 2 = |V |−|E|+|R| = 2|E| n −|E|+2|E| m = |E| 2m − mn + 2n mn

  • > 0

|E|, m, n > 0: 2m − mn + 2n > 0 ⇒ mn − 2m − 2n < 0 ⇒ mn − 2m − 2n + 4 < 4 ⇒ (m − 2)(n − 2) < 4

  • nly 5 solutions
slide-111
SLIDE 111

Platonic Solids

from Euler’s formula: 2 = |V |−|E|+|R| = 2|E| n −|E|+2|E| m = |E| 2m − mn + 2n mn

  • > 0

|E|, m, n > 0: 2m − mn + 2n > 0 ⇒ mn − 2m − 2n < 0 ⇒ mn − 2m − 2n + 4 < 4 ⇒ (m − 2)(n − 2) < 4

  • nly 5 solutions
slide-112
SLIDE 112

Platonic Solids

from Euler’s formula: 2 = |V |−|E|+|R| = 2|E| n −|E|+2|E| m = |E| 2m − mn + 2n mn

  • > 0

|E|, m, n > 0: 2m − mn + 2n > 0 ⇒ mn − 2m − 2n < 0 ⇒ mn − 2m − 2n + 4 < 4 ⇒ (m − 2)(n − 2) < 4

  • nly 5 solutions
slide-113
SLIDE 113

Tetrahedron

m = 3, n = 3

slide-114
SLIDE 114

Hexahedron

m = 4, n = 3

slide-115
SLIDE 115

Octahedron

m = 3, n = 4

slide-116
SLIDE 116

Dodecahedron

m = 5, n = 3

slide-117
SLIDE 117

Icosahedron

m = 3, n = 5

slide-118
SLIDE 118

Topics

1 Graphs

Introduction Walks Traversable Graphs Planar Graphs

2 Graph Problems

Connectivity Graph Coloring Shortest Path TSP Searching Graphs

slide-119
SLIDE 119

Connectivity Matrix

A: adjacency matrix of G = (V , E) Ak

ij: number of walks of length k between vi and vj

maximum distance between two nodes: |V | − 1 connectivity matrix: C = A1 + A2 + A3 + · · · + A|V |−1 connected: all elements of C are non-zero

slide-120
SLIDE 120

Connectivity Matrix

A: adjacency matrix of G = (V , E) Ak

ij: number of walks of length k between vi and vj

maximum distance between two nodes: |V | − 1 connectivity matrix: C = A1 + A2 + A3 + · · · + A|V |−1 connected: all elements of C are non-zero

slide-121
SLIDE 121

Warshall’s Algorithm

very expensive to compute the connectivity matrix easier to find whether there is a walk between two nodes rather than finding the number of walks for each node: from all nodes which can reach the current node (rows that contain 1 in current column) to all nodes which can be reached from the current node (columns that contain 1 in current row)

slide-122
SLIDE 122

Warshall’s Algorithm

very expensive to compute the connectivity matrix easier to find whether there is a walk between two nodes rather than finding the number of walks for each node: from all nodes which can reach the current node (rows that contain 1 in current column) to all nodes which can be reached from the current node (columns that contain 1 in current row)

slide-123
SLIDE 123

Warshall’s Algorithm Example

a b c d a 1 b 1 c 1 d 1 1

slide-124
SLIDE 124

Warshall’s Algorithm Example

a b c d a 1 b 1 c 1 d 1 1 1

slide-125
SLIDE 125

Warshall’s Algorithm Example

a b c d a 1 b 1 c 1 d 1 1 1

slide-126
SLIDE 126

Warshall’s Algorithm Example

a b c d a 1 b 1 c 1 d 1 1 1 1

slide-127
SLIDE 127

Warshall’s Algorithm Example

a b c d a 1 b 1 c 1 1 1 1 d 1 1 1 1

slide-128
SLIDE 128

Topics

1 Graphs

Introduction Walks Traversable Graphs Planar Graphs

2 Graph Problems

Connectivity Graph Coloring Shortest Path TSP Searching Graphs

slide-129
SLIDE 129

Graph Coloring

G = (V , E), C: set of colors proper coloring of G: find an f : V → C, such that ∀(vi, vj) ∈ E [f (vi) = f (vj)] chromatic number of G: χ(G) minimum |C| finding χ(G) is a very difficult problem χ(Kn) = n

slide-130
SLIDE 130

Graph Coloring

G = (V , E), C: set of colors proper coloring of G: find an f : V → C, such that ∀(vi, vj) ∈ E [f (vi) = f (vj)] chromatic number of G: χ(G) minimum |C| finding χ(G) is a very difficult problem χ(Kn) = n

slide-131
SLIDE 131

Graph Coloring

G = (V , E), C: set of colors proper coloring of G: find an f : V → C, such that ∀(vi, vj) ∈ E [f (vi) = f (vj)] chromatic number of G: χ(G) minimum |C| finding χ(G) is a very difficult problem χ(Kn) = n

slide-132
SLIDE 132

Chromatic Number Example

Herschel graph: χ(G) = 2

slide-133
SLIDE 133

Graph Coloring Solution

pick a node and assign a color assign same color to all nodes with no conflict pick an uncolored node and assign a second color assign same color to all uncolored nodes with no conflict pick an uncolored node and assign a third color . . .

slide-134
SLIDE 134

Heuristic Solutions

heuristic solution: based on intuition greedy solution: doesn’t look ahead doesn’t produce optimal results

slide-135
SLIDE 135

Graph Coloring Example

a company produces chemical compounds some compounds cannot be stored together such compounds must be placed in separate storage areas store compounds using minimum number of storage areas

slide-136
SLIDE 136

Graph Coloring Example

a company produces chemical compounds some compounds cannot be stored together such compounds must be placed in separate storage areas store compounds using minimum number of storage areas

slide-137
SLIDE 137

Graph Coloring Example

every compound is a node two compounds that cannot be stored together are adjacent

slide-138
SLIDE 138

Graph Coloring Example

slide-139
SLIDE 139

Graph Coloring Example

slide-140
SLIDE 140

Graph Coloring Example

slide-141
SLIDE 141

Graph Coloring Example

slide-142
SLIDE 142

Graph Coloring Example: Sudoku

every cell is a node cells of the same row are adjacent cells of the same column are adjacent cells of the same 3 × 3 block are adjacent every number is a color problem: properly color a graph that is partially colored

slide-143
SLIDE 143

Graph Coloring Example: Sudoku

every cell is a node cells of the same row are adjacent cells of the same column are adjacent cells of the same 3 × 3 block are adjacent every number is a color problem: properly color a graph that is partially colored

slide-144
SLIDE 144

Region Coloring

coloring a map by assigning different colors to adjacent regions Theorem (Four Color Theorem) The regions in a map can be colored using four colors.

slide-145
SLIDE 145

Topics

1 Graphs

Introduction Walks Traversable Graphs Planar Graphs

2 Graph Problems

Connectivity Graph Coloring Shortest Path TSP Searching Graphs

slide-146
SLIDE 146

Shortest Path

finding shortest paths from a starting node to all other nodes: Dijkstra’s algorithm

slide-147
SLIDE 147

Dijkstra’s Algorithm Example

starting node: c a (∞, −) b (∞, −) c (0, −) f (∞, −) g (∞, −) h (∞, −)

slide-148
SLIDE 148

Dijkstra’s Algorithm Example

from c: base distance=0 c → f : 6, 6 < ∞ c → h : 11, 11 < ∞ a (∞, −) b (∞, −) c (0, −) √ f (6, cf ) g (∞, −) h (11, ch) closest node: f

slide-149
SLIDE 149

Dijkstra’s Algorithm Example

from c: base distance=0 c → f : 6, 6 < ∞ c → h : 11, 11 < ∞ a (∞, −) b (∞, −) c (0, −) √ f (6, cf ) g (∞, −) h (11, ch) closest node: f

slide-150
SLIDE 150

Dijkstra’s Algorithm Example

from c: base distance=0 c → f : 6, 6 < ∞ c → h : 11, 11 < ∞ a (∞, −) b (∞, −) c (0, −) √ f (6, cf ) g (∞, −) h (11, ch) closest node: f

slide-151
SLIDE 151

Dijkstra’s Algorithm Example

from f : base distance=6 f → a : 6 + 11, 17 < ∞ f → g : 6 + 9, 15 < ∞ f → h : 6 + 4, 10 < 11 a (17, cfa) b (∞, −) c (0, −) √ f (6, cf ) √ g (15, cfg) h (10, cfh) closest node: h

slide-152
SLIDE 152

Dijkstra’s Algorithm Example

from f : base distance=6 f → a : 6 + 11, 17 < ∞ f → g : 6 + 9, 15 < ∞ f → h : 6 + 4, 10 < 11 a (17, cfa) b (∞, −) c (0, −) √ f (6, cf ) √ g (15, cfg) h (10, cfh) closest node: h

slide-153
SLIDE 153

Dijkstra’s Algorithm Example

from f : base distance=6 f → a : 6 + 11, 17 < ∞ f → g : 6 + 9, 15 < ∞ f → h : 6 + 4, 10 < 11 a (17, cfa) b (∞, −) c (0, −) √ f (6, cf ) √ g (15, cfg) h (10, cfh) closest node: h

slide-154
SLIDE 154

Dijkstra’s Algorithm Example

from h: base distance=10 h → a : 10 + 11, 21 ≮ 17 h → g : 10 + 4, 14 < 15 a (17, cfa) b (∞, −) c (0, −) √ f (6, cf ) √ g (14, cfhg) h (10, cfh) √ closest node: g

slide-155
SLIDE 155

Dijkstra’s Algorithm Example

from h: base distance=10 h → a : 10 + 11, 21 ≮ 17 h → g : 10 + 4, 14 < 15 a (17, cfa) b (∞, −) c (0, −) √ f (6, cf ) √ g (14, cfhg) h (10, cfh) √ closest node: g

slide-156
SLIDE 156

Dijkstra’s Algorithm Example

from h: base distance=10 h → a : 10 + 11, 21 ≮ 17 h → g : 10 + 4, 14 < 15 a (17, cfa) b (∞, −) c (0, −) √ f (6, cf ) √ g (14, cfhg) h (10, cfh) √ closest node: g

slide-157
SLIDE 157

Dijkstra’s Algorithm Example

from g: base distance=14 g → a : 14 + 17, 31 ≮ 17 a (17, cfa) b (∞, −) c (0, −) √ f (6, cf ) √ g (14, cfhg) √ h (10, cfh) √ closest node: a

slide-158
SLIDE 158

Dijkstra’s Algorithm Example

from g: base distance=14 g → a : 14 + 17, 31 ≮ 17 a (17, cfa) b (∞, −) c (0, −) √ f (6, cf ) √ g (14, cfhg) √ h (10, cfh) √ closest node: a

slide-159
SLIDE 159

Dijkstra’s Algorithm Example

from g: base distance=14 g → a : 14 + 17, 31 ≮ 17 a (17, cfa) b (∞, −) c (0, −) √ f (6, cf ) √ g (14, cfhg) √ h (10, cfh) √ closest node: a

slide-160
SLIDE 160

Dijkstra’s Algorithm Example

from a: base distance=17 a → b : 17 + 5, 22 < ∞ a (17, cfa) √ b (22, cfab) c (0, −) √ f (6, cf ) √ g (14, cfhg) √ h (10, cfh) √ last node: b

slide-161
SLIDE 161

Dijkstra’s Algorithm Example

from a: base distance=17 a → b : 17 + 5, 22 < ∞ a (17, cfa) √ b (22, cfab) c (0, −) √ f (6, cf ) √ g (14, cfhg) √ h (10, cfh) √ last node: b

slide-162
SLIDE 162

Dijkstra’s Algorithm Example

from a: base distance=17 a → b : 17 + 5, 22 < ∞ a (17, cfa) √ b (22, cfab) c (0, −) √ f (6, cf ) √ g (14, cfhg) √ h (10, cfh) √ last node: b

slide-163
SLIDE 163

Topics

1 Graphs

Introduction Walks Traversable Graphs Planar Graphs

2 Graph Problems

Connectivity Graph Coloring Shortest Path TSP Searching Graphs

slide-164
SLIDE 164

Traveling Salesperson Problem

start from a home town visit every city exactly once return to the home town minimum total distance find Hamiltonian cycle very difficult problem

slide-165
SLIDE 165

Traveling Salesperson Problem

start from a home town visit every city exactly once return to the home town minimum total distance find Hamiltonian cycle very difficult problem

slide-166
SLIDE 166

TSP Solution

heuristic: nearest-neighbor

slide-167
SLIDE 167

Topics

1 Graphs

Introduction Walks Traversable Graphs Planar Graphs

2 Graph Problems

Connectivity Graph Coloring Shortest Path TSP Searching Graphs

slide-168
SLIDE 168

Searching Graphs

searching nodes of graph G = (V , E) starting from node v1 depth-first breadth-first

slide-169
SLIDE 169

Depth-First Search

1 v ← v1, T = ∅, D = {v1} 2 find smallest i in 2 ≤ i ≤ |V | such that (v, vi) ∈ E and vi /

∈ D

if no such i: go to step 3 if found: T = T ∪ {(v, vi)}, D = D ∪ {vi}, v ← vi, go to step 2

3 if v = v1: result is T 4 if v = v1: v ← backtrack(v), go to step 2

slide-170
SLIDE 170

Depth-First Search

1 v ← v1, T = ∅, D = {v1} 2 find smallest i in 2 ≤ i ≤ |V | such that (v, vi) ∈ E and vi /

∈ D

if no such i: go to step 3 if found: T = T ∪ {(v, vi)}, D = D ∪ {vi}, v ← vi, go to step 2

3 if v = v1: result is T 4 if v = v1: v ← backtrack(v), go to step 2

slide-171
SLIDE 171

Depth-First Search

1 v ← v1, T = ∅, D = {v1} 2 find smallest i in 2 ≤ i ≤ |V | such that (v, vi) ∈ E and vi /

∈ D

if no such i: go to step 3 if found: T = T ∪ {(v, vi)}, D = D ∪ {vi}, v ← vi, go to step 2

3 if v = v1: result is T 4 if v = v1: v ← backtrack(v), go to step 2

slide-172
SLIDE 172

Depth-First Search

1 v ← v1, T = ∅, D = {v1} 2 find smallest i in 2 ≤ i ≤ |V | such that (v, vi) ∈ E and vi /

∈ D

if no such i: go to step 3 if found: T = T ∪ {(v, vi)}, D = D ∪ {vi}, v ← vi, go to step 2

3 if v = v1: result is T 4 if v = v1: v ← backtrack(v), go to step 2

slide-173
SLIDE 173

Breadth-First Search

1 T = ∅, D = {v1}, Q = (v1) 2 if Q empty: result is T 3 if Q not empty: v ← front(Q), Q ← Q − v

for 2 ≤ i ≤ |V | check edges (v, vi) ∈ E:

if vi / ∈ D : Q = Q + vi, T = T ∪ {(v, vi)}, D = D ∪ {vi} go to step 3

slide-174
SLIDE 174

Breadth-First Search

1 T = ∅, D = {v1}, Q = (v1) 2 if Q empty: result is T 3 if Q not empty: v ← front(Q), Q ← Q − v

for 2 ≤ i ≤ |V | check edges (v, vi) ∈ E:

if vi / ∈ D : Q = Q + vi, T = T ∪ {(v, vi)}, D = D ∪ {vi} go to step 3

slide-175
SLIDE 175

References

Required Reading: Grimaldi Chapter 11: An Introduction to Graph Theory Chapter 7: Relations: The Second Time Around

7.2. Computer Recognition: Zero-One Matrices and Directed Graphs

Chapter 13: Optimization and Matching

13.1. Dijkstra’s Shortest Path Algorithm