







































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








































nska [email protected]
CS3510 A, Fall 2005 – p. 1/
Problem:
given a set of computers and a maintenance cost associated with every potential link, build a communicationnetwork which is connected and has the cheapest cost.
CS3510 A, Fall 2005 – p. 2/
Problem:
given a set of computers and a maintenance cost associated with every potential link, build a communicationnetwork which is connected and has the cheapest cost.^34 B
1 4 4
2
4 6
5 C^
E F
A
D Observation:
the optimal set of edges cannot contain a cycle.
CS3510 A, Fall 2005 – p. 2/
Problem:
given a set of computers and a maintenance cost associated with every potential link, build a communicationnetwork which is connected and has the cheapest cost.^34 B
1 4 4
2
4 6
5 C^
E F
A
D Observation:
the optimal set of edges cannot contain a cycle.Thus, the solution must be connected and acyclic -
TREE
CS3510 A, Fall 2005 – p. 2/
INPUT: an undirected, connected graph
with edge weights
w(e)
OUTPUT: a tree
)^ spanning all the vertices of
G^ and
minimizing weight
∑ ′ e∈E w(e)
(^34) B 1 4 4
2
4 6
5 C^
E F
A
D MST cost in the example above is 16.
CS3510 A, Fall 2005 – p. 3/
INPUT: an undirected, connected graph
with edge weights
w(e)
OUTPUT: a tree
)^ spanning all the vertices of
G^ and
minimizing weight
∑ ′ e∈E w(e)
(^34) B 1 4 4
2
4 6
5 C^
E F
A
D MST cost in the example above is 16.
CS3510 A, Fall 2005 – p. 3/
INPUT: an undirected, connected graph
with edge weights
w(e)
OUTPUT: a tree
)^ spanning all the vertices of
G^ and
minimizing weight
∑ ′ e∈E w(e)
(^34) B 1 4 4
2
4 6
5 C^
E F
A
D MST cost in the example above is 16. Is it unique?
CS3510 A, Fall 2005 – p. 3/
Algorithms?
CS3510 A, Fall 2005 – p. 4/
Algorithms? "Greed ... is good. Greed is right. Greed works." Kruskal’s greedy algorithm: build a spanning tree by successively adding edges inorder of increasing weights and in such a way that they donot form a cycle with those edges already chosen.
CS3510 A, Fall 2005 – p. 4/
Algorithms? "Greed ... is good. Greed is right. Greed works." Kruskal’s greedy algorithm: build a spanning tree by successively adding edges inorder of increasing weights and in such a way that they donot form a cycle with those edges already chosen. See example on the board.
CS3510 A, Fall 2005 – p. 4/
We will proof a more general property first:
CS3510 A, Fall 2005 – p. 5/
Cut property:
Let^ X
be part of some minimum spanning tree
of^ G^
).^ Pick any set of nodes
V^ such that there is no
edge in
X^ which connects a node in
S^ to one in
S.^ If^ e
is the
minimum-weight edge between
S^ and
S,^ then
e}^ is also
part of some MST.
CS3510 A, Fall 2005 – p. 5/
Proof:
Assume
e /∈^ T.^ Then
e}^ contains a cycle
Now
C^ contains another edge
′^ eacross the cut
e e’ S^
V^ ^ S
CS3510 A, Fall 2005 – p. 6/
Proof:
Assume
e /∈^ T.^ Then
e}^ contains a cycle
Now
C^ contains another edge
′^ eacross the cut
e e’ S^
V^ ^ S
Consider
e} − {
′′e}.It is a tree with
′ w(T ) =^ w
w(e)
−^ w
′(e)^ ≤ w(T
),^ because
w(e)
≤^ w
′(e).^ Since
T^ is MST, so is
CS3510 A, Fall 2005 – p. 6/