Professional Documents
Culture Documents
Branch and Bound1
Branch and Bound1
}
}
Rabin Karp
Network Flow
Ford Fulkerson
Edmonds Karp
inputs
C[n x n] : Capacity Matrix
E[n x n] : Adjacency Matrix
s : source
t : sink
output
f : maximum flow
Edmonds-Karp:
f=0 // Flow is initially 0
F = [n x n] // residual capacity array
while true:
m, P = Breadth-First-Search(C, E, s, t, F)
if m = 0:
break
f=f+m
v=t
while v != s:
u = P[v]
F[u, v] = F[u, v] - m //This is reducing the residual capacity of the au
gmenting path
F[v, u] = F[v, u] + m //This is increasing the residual capacity of the
reverse edges
v=u
return f
Geometric Algorithms
Graham’s Scan : O(n log n)
Approximation Algorithm
Travelling Salesman :O(N^3)
Algorithm: Traveling-Salesman-Problem
C ({1}, 1) = 0
for s = 2 to n do
for all subsets S Є {1, 2, 3, … , n} of size s and containing 1
C (S, 1) = ∞
for all j Є S and j ≠ 1
C (S, j) = min {C (S – {j}, i) + d(i, j) for i Є S and i ≠ j}
Return minj C ({1, 2, 3, …, n}, j) + d(j, i)