Optimization On Graphs
Optimization On Graphs
Definition
2
Example: social network
3
Example: geographical network
Given a map, determine the minimum number
of colors required to color the different regions
so that adjacent ones have different colors
4
Simple and multiple graphs
• Simple: (at most) one edge between two vertices
5
• Multiple Graphs: more edges between two vertices
6
Directed Graphs (asymmetric)
• G = (V,A) V= n A= m
• Vertices V = v1 , … , vn
• Arcs A = a1 , … , am
ak = (vi , vj ) (vj , vi ) ordered pairs
vi tail, vj head
a1
v1 v2
V = v1 , v2 , v3 , v4
a4 a6 a5 a2 A = a1 , a2 , a3 , a4 , a5 , a6
= ... (v1 ,v4),..., (v4 ,v1)
v4 v3
a3
7
Weighted graphs
Weighted Graph (directed/undirected) :
each edge (arc) is associated with a
weight (cost, length, ...)
5
vj vk
v1 v2 v3 v1 v2 v3
9
Star and degree for undirected graphs
• Star of v (v) = vj :(v , vj ) E
v1 v2 (v2) = v1 , v3
d(v2) = 2
(v3) = v1 , v2 , v4
v4 v3
d(v3) = 3
10
Star and degree for directed graphs
• Forward star of v +(v) = vj :(v,vj )A
• Backward star of v -(v) = vj :(vj ,v)A
• external degree of v d+(v) = + (v)
• internal degree of v d-(v) = - (v)
v1 v2 +(v3) = v4
-(v3) = v1 , v2
d+(v3) = 1
v4 v3 d-(v3) = 2
11
Complete graph
G is complete if vi,vj V, (vi ,vj )E
(with/without loops)
12
Cut for undirected graphs
Given S V, cut associated with S:
(S) = (vi , vj ): S vi , vj = 1
v5
S = v1 , v4 , v5
v1 v3
13
Cut for directed graphs
Given SV, directed cut associated with S
+(S) = (vi , vj ) : vi S, vj S
-(S) = (vi , vj ) : vi S, vj S
+(S) -(V \ S)
Internal Arcs (S) = (vi,vj ): viS, vjS
v4 v2 S = v1 , v4 (S) = (v1 , v4 )
+(S) = (v4 ,v2)
v1 v3 -(S) = (v3 ,v4), (v3 ,v1)
14
Path and Cycles
Path:
sequence of consecutive edges (arcs) with no
vertex repetitions
vj1 vj2 vj3 vj4 vj5
15
Acyclic and connected graphs
16
Tree and Spanning Tree
• A tree is an undirected graph that is connected and does not
contain cycles.
• A tree is an undirected graph that is connected and has n-1
edges.
• For any two distinct vertices u and v of a tree, there exists a
unique path from u to v.
31 12
22 6
v4 v3
9
0 1 1 1 10 31 22
0 0 1 0 12
aij = cij =
0 0 0 1 9
1 0 0 0 6
19
Data structures for graphs
Sparse Graphs (m n2)
It is better to store only the exisiting arcs.
Forward star method:
10
v1 v2 c' = 10 31 15 12 9 6
15
31 12
6 u' = 2 3 1 3 4 1
v4 v3
9
p' = 1 3 5 6 7
Data structures for graphs
Sparse Graphs (m n2)
Forward star method for weighted graphs uses:
• vector p(n+1) of pointers: p1=1, pn+1 =m+1
22