Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
dr. C. P. J. Koymans
Informatics Institute University of Amsterdam
(version 1.2, 2010/02/23 13:59:54)
Algorithms
1 / 33
Distance vector algorithms A basic triangle Flooding Bellman-Ford Memorizing alternatives Counting to Algorithms based on global or centralized information Shortest Path Tree
Dijkstra Demos
Properties
Algorithms
2 / 33
Outline
1
Distance vector algorithms A basic triangle Flooding Bellman-Ford Memorizing alternatives Counting to Algorithms based on global or centralized information Shortest Path Tree
Dijkstra Demos
Properties
dr. C. P. J. Koymans (UvA) Algorithms Monday, February 22, 2010 3 / 33
A basic triangle
Outline
1
Distance vector algorithms A basic triangle Flooding Bellman-Ford Memorizing alternatives Counting to Algorithms based on global or centralized information Shortest Path Tree
Dijkstra Demos
Properties
dr. C. P. J. Koymans (UvA) Algorithms Monday, February 22, 2010 4 / 33
Distance Vector
Distance to N 0 1 10
Via A A A
Distance to N 0
Via A
Distance Vector
Distance to N 0 1 10
Via A A A
Distance to N 0 1
Via A A
Distance Vector
Distance to N 0 1 10
Via A A A
Distance to N 0 1 2
Via A A B
Flooding
Outline
1
Distance vector algorithms A basic triangle Flooding Bellman-Ford Memorizing alternatives Counting to Algorithms based on global or centralized information Shortest Path Tree
Dijkstra Demos
Properties
dr. C. P. J. Koymans (UvA) Algorithms Monday, February 22, 2010 6 / 33
Flooding
Flooding
Origin A B C D
Distance to N 0 1 2 ?
Via A A A ?
Origin A B C D
Distance to N 0 1 2
Via A A A
Algorithms
7 / 33
Flooding
Flooding
Origin A B C D
Distance to N 0 1 2 ?
Via A A A ?
Origin A B C D
Distance to N 0 1 2 3
Via A A A B or C
Algorithms
7 / 33
Flooding
Flooding
Origin A B C D
Distance to N 0 1 2 ?
Via A A A ?
Origin A B C D
Distance to N 0 1 2 3
Via A A A B or C
The orange messages dont change anything and the algorithm has converged
dr. C. P. J. Koymans (UvA) Algorithms Monday, February 22, 2010 7 / 33
Bellman-Ford
Outline
1
Distance vector algorithms A basic triangle Flooding Bellman-Ford Memorizing alternatives Counting to Algorithms based on global or centralized information Shortest Path Tree
Dijkstra Demos
Properties
dr. C. P. J. Koymans (UvA) Algorithms Monday, February 22, 2010 8 / 33
Bellman-Ford
Undirected graphs
Algorithms
9 / 33
Bellman-Ford
We seek the shortest paths from(to) any node i to(from) node j Dn (i , j ) is the distance from i to j using no more than n steps
Algorithms
10 / 33
Bellman-Ford
Memorizing alternatives
Outline
1
Distance vector algorithms A basic triangle Flooding Bellman-Ford Memorizing alternatives Counting to Algorithms based on global or centralized information Shortest Path Tree
Dijkstra Demos
Properties
dr. C. P. J. Koymans (UvA) Algorithms Monday, February 22, 2010 12 / 33
Memorizing alternatives
Adding memory
You can also keep the information about distance to a certain node via (longer) backup paths In case of failure of best link, fall back to second best link This makes the algorithm dynamic But also introduces some quirks!
Algorithms
13 / 33
Linear case
Origin A B C
Origin A B C
Linear case
Origin A B C
Origin A B C
Linear case
Origin A B C
Origin A B C
Linear case
Origin A B C
Origin A B C
Counting to
Outline
1
Distance vector algorithms A basic triangle Flooding Bellman-Ford Memorizing alternatives Counting to Algorithms based on global or centralized information Shortest Path Tree
Dijkstra Demos
Properties
dr. C. P. J. Koymans (UvA) Algorithms Monday, February 22, 2010 15 / 33
Before A has a chance to tell B that its link to N is down B could have told A that it can reach network N with distance one, letting A start thinking it can (still) reach N (now with distance two.)
Counting to
Counting to solutions
Split horizon
Dont advertise back to advertiser itself B does not report N back to A
Poison reverse
B reports innite distance to N back to A
Algorithms
17 / 33
Still counting to
B and C keep fooling each other about a route to N, because they dont know that the others route is also via the blocked path through A. Split horizon doesnt help, because information is relayed via A.
Outline
1
Distance vector algorithms A basic triangle Flooding Bellman-Ford Memorizing alternatives Counting to Algorithms based on global or centralized information Shortest Path Tree
Dijkstra Demos
Properties
dr. C. P. J. Koymans (UvA) Algorithms Monday, February 22, 2010 19 / 33
Algorithms
20 / 33
Outline
1
Distance vector algorithms A basic triangle Flooding Bellman-Ford Memorizing alternatives Counting to Algorithms based on global or centralized information Shortest Path Tree
Dijkstra Demos
Properties
dr. C. P. J. Koymans (UvA) Algorithms Monday, February 22, 2010 21 / 33
SPT
Algorithms
22 / 33
if i
Algorithms
23 / 33
Let i be the latest addition to P Update tentative distances for nodes j not in P
Dj min{Dj , Di + dij } (relaxation)
Algorithms
24 / 33
Demo Dijkstra
Algorithms
25 / 33
Outline
1
Distance vector algorithms A basic triangle Flooding Bellman-Ford Memorizing alternatives Counting to Algorithms based on global or centralized information Shortest Path Tree
Dijkstra Demos
Properties
dr. C. P. J. Koymans (UvA) Algorithms Monday, February 22, 2010 26 / 33
MST
Algorithms
27 / 33
Prims algorithm
Start constructing a tree < T , B > with an arbitrary node n V and no branches
T B
{n }
Add a new branch b to the tree of minimum distance (weight) connecting T with a new node m outside the tree
T B T {m } B {b }
Kruskals algorithm
Pick a minimal distance (weight) edge e that joins any two fragments < V1 , E1 > and < V2 , E2 > in F
F
Algorithms
29 / 33
Demos
http://www-b2.is.tokushima-u.ac.jp/~ikeda/suuri/main/ index.shtml
http://www-b2.is.tokushima-u.ac.jp/~ikeda/suuri/ dijkstra/Prim.shtml (Prim) http://www-b2.is.tokushima-u.ac.jp/~ikeda/suuri/kruskal/ Kruskal.shtml (Kruskal)
Algorithms
30 / 33
Properties
Outline
1
Distance vector algorithms A basic triangle Flooding Bellman-Ford Memorizing alternatives Counting to Algorithms based on global or centralized information Shortest Path Tree
Dijkstra Demos
Properties
dr. C. P. J. Koymans (UvA) Algorithms Monday, February 22, 2010 31 / 33
Properties
Properties
All algorithms generate spanning trees If there is a unique MST, Kruskal may be parallellised If all distances (weights) are different there is a unique MST Not every MST is automatically a SPT for all nodes
Algorithms
32 / 33
The red tree is the shortest path tree, starting in A. This is denitely not a minimum spanning tree.