Professional Documents
Culture Documents
University
c of Waterloo 1 / 20
Shortest Paths
s a Columbia Ave
Albert St
Fisher Rd d
King St
c
Westmount Rd
Erb St
b f g
Victoria St
t
University
c of Waterloo 2 / 20
Shortest Paths
s a Columbia Ave
Albert St
Fisher Rd d
King St
c
Westmount Rd
Erb St
b f g
Victoria St
t
• Goal: Write the problem of finding the shortest route between s and
t as an integer program!
... How?
University
c of Waterloo 3 / 20
Graph Theory 101
• vertices u, w, . . . ∈ V z
(drawn as filled circles)
w t
• edges uw, wz, . . . ∈ E u
University
c of Waterloo 4 / 20
Graphs – Why do we care?
• Modeling circuits
in chip design
• Social networks
Lampman, 2008 [Online Image]. Late Medieval Trade Routes. Wikimedia Commons.
http://commons.wikimedia.org/wiki/File:Late Medieval Trade Routes.jpg
• Trade networks
University
c of Waterloo 5 / 20
The Map of Water Town
s a Columbia Ave
Albert St
Fisher Rd d
King St
c
Westmount Rd
Erb St
b f g
Victoria St
t
University
c of Waterloo 6 / 20
The Map of Water Town
90
80
450
630
900
700
d
590
610
5
250
41
325 c 830 600
325 b g
f
350
0
50
720
700
330
University
c of Waterloo 7 / 20
Paths
s 650 a 830 600
90
80
450
630
900
700
d
590
610
5
250
41
325 c 830 600
325 b g
f
350
0
50
720
700
330
s 650 a
450
d
c(P ) = csa + cad + cdb + cbf + cf g + cgt
= 650 + 490 + 250 + 830 + 600 + 700
250
830 600
= 3520
b f g
700
P= sa, ad, db, bf, fg, gt
University
c of Waterloo 9 / 20
s 650 a 830 600
90
80
450
630
900
700
d
590
610
5
250
41
325 c 830 600
325 b g
350 f
0
50
720
700
330
University
c of Waterloo 10 / 20
Example: Matchings
University
c of Waterloo 11 / 20
WaterTech - Job Assignment
University
c of Waterloo 12 / 20
Matchings
1 1’
5 8
7 8
2 2’
Create a graph with one vertex for 4
each employee and job. 3 1 3’
University
c of Waterloo 13 / 20
Matchings
1 1’
5 8
7 8
2 2’
4
Definition 1
3 3’
A collection M ⊆ E is a matching if no two
edges ij, i0 j 0 ∈ M (ij 6= i0 j 0 ) share an 3
4 4’
endpoint; i.e., {i, j} ∩ {i0 , j 0 } = ∅.
E J
Examples
University
c of Waterloo 14 / 20
Matchings
3
4 4’
e.g., M = {140 , 210 , 320 , 430 }
−→ c(M ) = 19 E J
Definition
A matching M is perfect if every E.g., matching in figure is perfect,
vertex v in the graph is incident to and this one is not!
an edge in M .
University
c of Waterloo 15 / 20
Restating the Assignment Problem
1 1’
Definition 7
5 8
8
A matching M is perfect if every vertex v in 2 2’
the graph is incident to an edge in M . 4
3 1 3’
Note: Perfect matchings correspond to 3
feasible assignments of workers to jobs! 4 4’
University
c of Waterloo 16 / 20
A Little More Notation...
3
4 4’
Definition
E J
Given G = (V, E), M ⊆ E is a perfect
matching iff M ∩ δ(v) contains a single
edge for all v ∈ V .
Examples
University
c of Waterloo 17 / 20
An IP for Perfect Matchings
1 1’
Definition 7
5 8
8
Given G = (V, E), M ⊆ E is a perfect 2 2’
matching iff M ∩ δ(v) contains a single 4
edge for all v ∈ V . 3 1 3’
3
The IP will have a binary variable xe for 4 4’
every edge e ∈ E. Idea: E J
xe = 1 ↔ e ∈ M
Objective:
Constraints: For all v ∈ V , need X
X (ce xe : e ∈ E)
(xe : e ∈ δ(v)) = 1
University
c of Waterloo 18 / 20
An IP for Perfect Matchings
X
min (ce xe : e ∈ E) 2
X 1 5
s.t. (xe : e ∈ δ(v)) = 1 (v ∈ V )
4
x ≥ 0, x integer 1
3
3
12 13 14 23
1 1 1 1 0
2
1 0 0 1 x = 1
s.t.
3 0 1 0 1
4 0 0 1 0
x ≥ 0 integer
University
c of Waterloo 19 / 20
Optimization on Graphs
Recap
• Graphs consist of vertices V and edges E ... and are very useful in
modeling many practical problems.
University
c of Waterloo 20 / 20