Fun and Games with Graphs
CS200 - Graphs 1 8 7 7 S 9 5
5 15
6 8 9
11
Do Dijkstra’s Shortest Paths Algorithm, Source: S
CS200 - Class Overview 2 8 7 7 S 9 5
5 15
6 8 9
11
Do Prim’s Minimum Spanning Tree Algorithm, Source: S
CS200 - Class Overview 3 Bridges of Konigsberg Problem
Euler
Is it possible to travel across every bridge without crossing any bridge more than once?
http://yeskarthi.wordpress.com/2006/07/31/euler-and-the-bridges-of-konigsberg/ CS200 - Graphs 4 Eulerian paths/circuits
n Eulerian path: a path that visits each edge in the graph once n Eulerian circuit: a cycle that visits each edge in the graph once
n Is there a simple criterion that allows us to determine whether a graph has an Eulerian circuit or path?
CS200 - Graphs 5 Example: Does any graph have an Eulerian path?a b
G1
d c e
b a b a e e G2 G3
d d c c
CS200 - Graphs 6 Example: Does any graph have an Eulerian circuit?a b
G1
d c e
b a b a e e G2 G3
d d c c
CS200 - Graphs 7 Example: Does any graph have an Eulerian circuit or path? a b
G1
a b d c g a b c G2 f G3
e d d c
CS200 - Graphs 8 Theorems about Eulerian Paths & Circuits
n Theorem: A connected multigraph has an Eulerian path iff it has exactly zero or two vertices of odd degree.
n Theorem: A connected multigraph, with at least two vertices, has an Eulerian circuit iff each vertex has an even degree.
q Demo: http://www.mathcove.net/petersen/lessons/get- lesson?les=23
CS200 - Graphs 9 Hamiltonian Paths/Circuits n A Hamiltonian path/circuit: path/circuit that visits every vertex exactly once. n Defined for directed and undirected graphs
CS200 - Graphs 10 Circuits (cont.) n Hamiltonian Circuit: path that begins at vertex v, passes through every vertex in the graph exactly once, and ends at v.
q http://www.mathcove.net/petersen/lessons/get- lesson?les=24
CS200 - Graphs 11 Does any graph have a Hamiltonian circuit or a Hamiltonian path?
a b
a b
d c a b
e d c e
d c
CS200 - Graphs 12 Hamiltonian Paths/Circuits
n Is there an efficient way to determine whether a graph has a Hamiltonian circuit?
q NO!
q This problem belongs to a class of problems for which it is believed there is no efficient (polynomial running time) algorithm.
CS200 - Graphs 13 The Traveling Salesman Problem TSP: Given a list of cities and their pairwise distances, find a shortest possible tour that visits each city exactly once.
http://www.tsp.gatech.edu/ 13,509 cities and towns in the US that have more than 500 residents
CS200 - Graphs 14 Using Hamiltonian Circuits n Examine all possible Hamiltonian circuits and select one of minimum total length n With n cities.. q (n-1)! Different Hamiltonian circuits q Ignore the reverse ordered circuits q (n-1)!/2 n With 50 cities n 12,413,915,592,536,072,670,862,289,047,373,3 75,038,521,486,354,677,760,000,000,000 routes
CS200 - Graphs 15 TSP
n How would a approximating algorithm for TSP work?
Local search: construct a solution and then modify it to improve it 71,009 Cities in China CS200 - Graphs 16 Planar Graphs n You are designing a microchip – connections between any two units cannot cross
CS200 - Graphs http://www.dmoma.org17 / Planar Graphs n You are designing a planar microchip – connections between any two units cannot cross n The graph describing the non-planar chip must be planar
http://en.wikipedia.org/wiki/Planar_graph
CS200 - Graphs 18 Are these graphs planar?
CS200 - Graphs 19 Chip Design n You want more than planarity: the lengths of the connections need to be as short as possible (faster, and less heat is generated) n We are now designing 3D chips, less constraint w.r.t. planarity, and shorter distances, but harder to build.
CS200 - Graphs http://www.dmoma.org20 / Graph Coloring n A coloring of a simple graph is the assignment of a color to each vertex of the graph so that no two adjacent vertices are assigned the same color
CS200 - Graphs 21 Map and graph
B
A C D
D B G C F A F E
E G CS200 - Graphs 22 Chromatic number n The least number of colors needed for a coloring of this graph. n The chromatic number of a graph G is denoted by χ(G)
CS200 - Graphs 23 The four color theorem n The chromatic number of a planar graph is no greater than four
n This theorem was proved by a (theorem prover) program!
CS200 - Graphs 24 Example
CS200 - Graphs 25 Example
CS200 - Graphs 26