Professional Documents
Culture Documents
Graphs: WIC3001/WRES2109 Dr. Saaidal Razalli Bin Azzuhri
Graphs: WIC3001/WRES2109 Dr. Saaidal Razalli Bin Azzuhri
WIC3001/WRES2109
Dr. Saaidal Razalli Bin Azzuhri
© 2019 McGraw-Hill Education. All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of
Shortest-Path Problems
Planar Graphs
Graph Coloring
Weighted Graphs
Graphs that have a number assigned to
each edge are called weighted graphs. BOS
CHI NY
SF DEN
ATL
LA
MIA
Weighted Graphs
MILES
BOS
2534
1855 722 NY
CHI
SF DEN 908
957
349
ATL
LA 595
MIA
Weighted Graphs
FARES
BOS
$129
$39
$99 $59 NY
CHI
SF DEN
$89
$39
ATL
LA
MIA
Weighted Graphs
FLIGHT
TIMES
BOS
4:05
0:50
2:55 NY
CHI 1:50
SF DEN 2:10
2:20
1:15
ATL
LA
MIA
Weighted Graphs
b 5 d 5 f
4 7
4 3 1
a 2 z
3 4
c 5 e 5 g
Theorems
Dijkstra’s algorithm finds the length of a shortest
path between two vertices in a connected simple
undirected weighted graph G=(V,E).
The Traveling Salesman Problem
30 80
Home
FEMA - Traveling Salesman
• Solution approaches
– Enumeration of all possible cycles.
• This results in (m-1)! cycles to enumerate for a graph with m
nodes.
• Only small problems can be solved with this approach.
FEMA – full enumeration
Possible cycles
Cycle Total Cost
For this problem 1. H-O1-O2-O3-O4-H 210
we have
Minimum
2. H-O1-O2-O4-O3-H 195
(5-1)! / 2 = 12 3. H-O1-O3-O2-O3-H 240
cycles. 4. H-O1-O3-O4-O2-H 200
Symmetrical 5. H-O1-O4-O2-O3-H 225
problems
6. H-O1-O4-O3-O2-H 200
need to
7. H-O2-O3-O1-O4-H 265
enumerate only
(m-1)! / 2 cycles. 8. H-O2-O1-O3-O4-H 235
9. H-O2-O4-O1-O3-H 250
10. H-O2-O1-O4-O3-H 220
11. H-O3-O1-O2-O4-H 260
12. H-O3-O1-O2-O4-H 260
FEMA – optimal solution
2 40
3
25 50 35
40
1 50 4
45 65
30 80
Home
The Traveling Salesman Problem
K4
Planar Graphs
Representation examples: Q3
Planar Graphs
Representation examples: K3,3 is Nonplanar
v1 v2 v3 v1 v5 v1 v5
R21
R2 R1
R1 R22
v3
v4 v5 v6 v4 v2 v4 v2
Planar Graphs
Theorem : Euler's planar graph theorem
For a connected planar graph or multigraph:
v–e+r=2
number
number number of regions
of vertices of edges
Planar Graphs
Example of Euler’s theorem
v=4,e=6,r=4, v-e+r=2
R3
Planar Graphs
Proof of Euler’s formula: By Induction
Base Case: for G1 , e1 = 1, v1 = 2 and r1= 1
v
u
R1
an+1
bn+1
Planar Graphs
Case 2:
an+1
R
bn+1
Planar Graphs
Corollary 1: Let G = (V, E) be a connected simple planar graph with e edges and
v vertices where v ≥ 3, then e ≤ 3v – 6
Proof: A connected planar simple graph drawn in the plane divides the plane into
regions, say r of them. The degree of each region is at least three. (Because the
graphs discussed here are simple graphs, no multiple edges that could produce
regions of degree two, or loops that could produce regions of degree one, are
permitted.) In particular, note that the degree of the unbounded region is at least
three because there are at least three vertices in the graph..
Degree of region: In a planar embedding of a connected graph, the number of
edges bordering region is called the degree of the region, counting bridges, if any,
twice.
an+1
R
bn+1
Region Degree
R Degree of R = 3
Degree of R = ?
R
Planar Graphs
Planar Graphs
Solution:
The graph K5 has five vertices and 10 edges. However, the inequality e
≤ 3v − 6 is not satisfied for this graph because e = 10 and 3v − 6 = 9.
Therefore, K5 is not planar.
Planar Graphs
Corollary 2: Let G = (V, E) be a connected simple planar graph then
G has a vertex degree that does not exceed 5
Proof: If G has one or two vertices the result is true
If G has 3 or more vertices then by Corollary 1, e ≤ 3v – 6
2e ≤ 6v – 12
If the degree of every vertex were at least 6:
by Handshaking theorem: 2e = Sum (deg(v))
2e ≥ 6v. But this contradicts the inequality 2e ≤ 6v – 12
There must be at least one vertex with degree no greater than 5
Planar Graphs
Corollary 3: Let G = (V, E) be a connected simple planar graph with
v vertices ( v ≥ 3) , e edges, and no circuits of length 3 then e ≤ 2v
-4
u v u w v
Solution: These three graphs are homeomorphic because all three can be obtained from
G1 by elementary subdivisions. G1 can be obtained from itself by an empty sequence of
elementary subdivisions. To obtain G2 from G1 we can use this sequence of elementary
subdivisions:
(i ) remove the edge {a, c}, add the vertex f , and add the edges {a, f } and {f, c};
(ii ) remove the edge {b, c}, add the vertex g, and add the edges {b, g} and {g, c}; and
(iii ) remove the edge {b, g}, add the vertex h, and add the edges {g, h} and {b, h}.
Kuratowski Theorem
A graph is nonplanar if and only if it contains a
subgraph homeomorphic to K3,3 or K5.
44
Chapter 10.8
Graph Coloring
B
B G A
C D
A F C
D E
E
b
b
c
a d f g a c e
e d
Graph Coloring
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.
The chromatic number of a graph is the least
number of colors needed for a coloring of the
graph.
What is the chromatic number of a bipartite
graph?
The Four Color Theorem
The chromatic number of a planar graph is no
greater than four.
It was originally posed as a conjecture in the 1850s.
It was finally proved by two American mathematicians
Kenneth Apple and Wolfgang Haken in 1976.
This is the first mathematical theorem
that has been proven with help of computers.
They showed that if the theorem is false, there must be a counterexample
of one of approximately 2000 types.
They used computers to show that none of these counterexamples exists.
Example
• What is the chromatic number of the graph
shown below?
The chromatic number
must be at least 3 since
b e
a, b, and c must be
a d g
assigned different colors.
So Let’s try 3 colors first.
c f
3 colors work, so the
chromatic number of this
graph is 3.
Example
What is the chromatic number for each of
the following graphs?
White
White Yellow
Green Yellow
Yellow White
Solution: