Beruflich Dokumente
Kultur Dokumente
24
23
6
5
16
11
14
10
21
18
5
8
11
w(T) = 50
Applications
Cluster analysis.
delete long edges leaves connected components
finding clusters of quasars and Seyfert galaxies
analyzing fungal spore spatial patterns
Objective.
Indirect applications.
max bottleneck paths
describing arrangements of nuclei in skin cells for cancer research
learning salient features for real-time face verification
modeling locality of particle interactions in turbulent fluid flow
reducing data storage in sequencing amino acids in a protein
(1 pij )
(i, j)T
(1 pij )
log(1 pij )
(i, j)T
Prims Algorithm
Prims Algorithm
1
2
6
5
4
1-2
1-6
6-5
5-4
2
1
1
2
6
5
4
3
1-2
1-6
6-5
5-4
4-3
2
1
5
8
7
5
C
B
I
G
T*
A
7
Vertex Nearest
A
E
B
C
D
E
E
F
G
H
C
I
E
Dist
15
9
23
11
8
Running time.
Vertex Nearest
C
B
I
G
F
A
A
B
C
D
E
F
G
H
I
E
D
D
Dist
15
4
6
O(V) time.
O(V2) overall.
10
Q PQinit()
for each vertex v in graph G
key(v)
pred(v) nil
PQinsert(v, Q)
key(s) 0
while (!PQisempty(Q))
v = PQdelmin(Q)
for each edge v-w s.t. w is in Q
if key(w) > c(v,w)
PQdeckey(w, c(v,w), Q)
pred(w) v
PQisempty():
V vertices.
PQdelmin():
V vertices.
PQdeckey():
E edges.
Priority Queues
11
Operation
Array
insert
log N
delete-min
log N
log N
decrease-key
log N
is-empty
Prim
V2
E log V
E + V log V
12
Kruskals Algorithm
Classic Prim:
O(V2).
1
6
Bottom line.
Initialize F = .
5
8
8
7
Case 1: {5, 8}
Case 2: {5, 6}
13
14
UFinit(G->V);
for (i = k = 0; i < E && k < G->V-1; i++) {
v = a[i].v;
w = a[i].w;
// if edge a[i] doesnt create a cycle, add to tree
if (!UFfind(v, w)) {
UFunion(v, w);
mst[k++] = a[i];
}
}
}
15
16
UFinit():
V singleton sets.
UFfind():
17
O(E log V)
O(E log*V).
Fredman-Tarjan (1987).
Gabow-Galil-Spencer-Tarjan (1986).
Chazelle (2000).
O(E).
Holy grail.
Worth noting.
O(E) randomized.
Karger-Klein-Tarjan (1995).
O(E) verification.
Dixon-Rauch-Tarjan (1992).
19
18