Solutions to Homework 6
Debasish Das
EECS Department, Northwestern University
[email protected]
1
Problem 5.24
We want to find light spanning trees with certain special properties. Given is one example of light spanning
tree.
Input: Undirected graph G = (V,E); edge weights
w
e
; subset of vertices U
⊂
V
Output: The lightest spanning tree in which the nodes of U are leaves (there might be other leaves in this
tree as well)
Consider the minimum spanning tree T = (V,
ˆ
E
) of G and the leaves of the tree T as L(T). Three possible
situations are feasible
U
⊆
L
(
T
)
U
=
U
1
∪
U
2
where
U
1
⊆
L
(
T
)
U
2
⊆
V

L
(
T
)
Note that when
U
satisfies Equation 1, the algorithm we are seeking is same as Kruskal’s algorithm. Define
a graph
˜
G
=(
V

U
,
{
(
u, v
) :
u, v
∈
V

U
∧
(
u, v
)
∈
E
}
).
Lemma 1
If there is no minimum spanning tree of the graph
˜
G
, then lightest spanning tree with
U
vertices
as leaves is not feasible
Proof:
Consider that no spanning tree for the graph
˜
G
exists. Without any loss of generality assume that
there are two trees in the spanning tree forest for the graph
˜
G
. The lightest spanning tree of
G
must be a
tree. Therefore some node
u
∈
U
must connect the two tress in the spanning tree forest of the graph
˜
G
. But
then
u
is no longer a leaf node which is a contradiction.
Property 1
Minimum spanning tree obtained on the graph
˜
G
is the lightest spanning tree if we greedily
select and add edges such that all vertices
U
are leaves
Proof:
The minimum spanning tree
˜
T
is well defined on the graph
˜
G
. Consider each node
u
∈
U
. We
greedily select an edge (
u, v
) :
v
∈
˜
T
and add the edge (
u, v
) to
˜
T
. Note that the edge (
u, v
) we greedily
chose,
v
∈
˜
T
. If
v /
∈
˜
T
then
v
∈
U
. But we cannot choose such an edge because to form a spanning tree
either of
u
or
v
must be connected to
˜
T
but connecting one of them (suppose
u
) to
˜
T
will no longer keep
u
as leaf. Cost of the new tree is
cost
(
˜
T
) +
w
(
u,v
)
. Since
cost
(
˜
T
) is optimal and we cannot select any edge
other than (
u, v
) (because of the constraint on
U
vertices as leaves), cost of the new tree is lightest (cannot
be decreased any further).
Based on Lemma 1 and Property 1 we present the following algorithm
procedure lightestspanningtree(G,w,U)
Input:
Graph G = (V,E); edges weights
w
e
;
U
⊂
V
Output:
Lightest spanning tree if exists
Construct graph
˜
G
= (
˜
V ,
˜
E
)
:
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
˜
V
=
V

U
˜
E
=
{
(
u, v
) :
u, v
∈
V

U
∧
(
u, v
)
∈
E
}
Apply Kruskal to get MST(
˜
G
) =
˜
T
:
if
˜
T
does not exist:
lightest spanning tree infeasibile
Construct edge set
¯
E
:
∀
(
u, v
)
∈
¯
E
:
u
∈
U
∧
v /
∈
U
for each
u
∈
U
:
makeset(u) sort the edges
¯
E
by
w
e
for all edges u,v
∈
E, in increasing order of weight:
if find(u)
=
find(v):
add edge u,v to
˜
T
union(u,v)
return
˜
T
Complexity analysis: Other than construction of edge set
¯
E
, rest of the complexity analysis is analogous
to Kruskal’s algorithm which runs in O(

E

log

V

) time. We construct a set
U
. For each edge
e
= (
u, v
)
if
find
(
u
) =
find
(
v
) then we keep that edge in
¯
E
. Therefore this takes O(

E

log

U

) time. Hence total
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '09
 Graph Theory, Kruskal's algorithm, Spanning tree, lightest spanning tree

Click to edit the document details