0% found this document useful (0 votes)
23 views22 pages

Greedy Algorithms

This document describes a greedy algorithm for solving the Tree Vertex Splitting Problem (TVSP). The TVSP aims to determine the minimum number of vertices that need to be split in a weighted directed tree in order to ensure the total path delay does not exceed a given tolerance level. The greedy algorithm works by computing the maximum delay from each vertex to leaves in its subtree, and splitting any vertex where this delay plus the weight of the parent edge would exceed the tolerance level. The algorithm proceeds from leaves to the root. A proof is provided that this greedy approach outputs a minimum cardinality split set.

Uploaded by

f20210467
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views22 pages

Greedy Algorithms

This document describes a greedy algorithm for solving the Tree Vertex Splitting Problem (TVSP). The TVSP aims to determine the minimum number of vertices that need to be split in a weighted directed tree in order to ensure the total path delay does not exceed a given tolerance level. The greedy algorithm works by computing the maximum delay from each vertex to leaves in its subtree, and splitting any vertex where this delay plus the weight of the parent edge would exceed the tolerance level. The algorithm proceeds from leaves to the root. A proof is provided that this greedy approach outputs a minimum cardinality split set.

Uploaded by

f20210467
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

GREEDY ALGORITHMS

Tree Vertex Splitting Problem(TVSP)


• Consider a Directed and weighted binary tree
• Consider a network of power line transmission
• The transmission of power from one node to the other
results in some loss, such as drop in voltage
• Each edge is labeled with the loss that occurs (edge weight)
• Network may not be able to tolerate losses beyond a certain
level
• You can place boosters in the nodes to account for the losses
• Definition: Given a network and a loss tolerance level, the
TVSP is to determine an optimal placement of boosters.
In graph terminology
• Let T = (V,E,w) be a weighted directed tree
• V is the set of vertices
• E is the set of edges
• w is the weight function for the edges
• w(i,j) is the weight of the edge <i, j> ε E
• We say that w(i,j) is undefined if there is no edge between i and j.
• A vertex with in-degree zero is called a source vertex
• A vertex with out-degree zero is called a sink vertex
• For any path P in tree T, its delay d(P) is defined to be the sum of
the weights (w(i,j) ) of that path.
• Delay of tree, d(T) is the maximum of all the path delays.
Splitting vertex
• Splitting vertices to create forest
• Let T/X be the forest that results when each vertex
u in X is split into two nodes ui and uo such that all
the edges <u,j> є E (<j, u> є E) are replaced by edges
of the form <uo; j> є E (<j, ui > є E).
• Outbound edges from u now leave from uo
• Inbound edges to u now enter at ui
• Split node is the booster station
Example

1 1

2 3 2 3i

4 5 6 4
3o

5 6
The Problem Statement
• The Tree Vertex Splitting Problem is to identify a
set X  V of minimum cardinality for which

d (T / X )  

• Where δ is the specified tolerance limit.


• Note: TVSP has a solution only if the maximum
edge weight is less than equal to δ .
Feasible Solution
• Feasible Solution: Any subset X of V if d (T / X )  
• Trivial Way:
– Find all the subsets of V.
– For each subset compute d(T/X).
– Select X with minimum cardinality.
– How many subsets?
A greedy approach
• For each node u є V, compute that maximum
delay d(u) from u to any other node in its
subtree.
• If u has a parent v such that d(u) + w(u,v) > δ,
then the node u gets split and d(ui) is set to
zero.
• Computation proceeds from the leaves toward
the root.
Example
1
4 2

2 3
1 3
2

4 5 6
2 3
1 4

7 9 10
8
Example
1
4 2

2 3
1 3
2

4 5 6
2 3
1 4

7 9 10
8

Let δ = 5.
For each leaf node 5, 7,8, 9, 10 delay is 0.
Computing Delay
• Let C(u) be the children of u.
• Then d(u) is given by

d (u )  max d (v)  w(u , v)


vC ( u )
Example
1
4 2

2 3
1 3
2

4 5 6
2 3
1 4

7 9 10
8

d(4) = 4
Since d(4) + w(2,4) = 6 > δ=5, Node 4 has to be split.
Example (after splitting node 4)
1
4 2

2 3
1 3
2

4o 4i 5 6
2 3
1 4

7 9 10
8
Example (after splitting node 4)
1
4 2

2 3
1 3
2

4o 4i 5 6
2 3
1 4

7 9 10
8

d(4) = 0
d(2) = 2
Since d(2) + w(1,2) = 6 > δ=5, Node 2 has to be split.
Example (after splitting node 2)
1
4 2

2i 2o 3
1 3
2
4o 4i 5 6
2 3
1 4

7 9 10
8
Example (after splitting node 2)
1
4 2

2i 2o 3
1 3
2
4o 4i 5 6
2 3
1 4

7 9 10
8

d(6) = 3
Since d(6) + w(3,6) = 6 > δ=5, Node 6 has to be split.
Example (after splitting node 6)
1
4 2

2i 2o 3
1 3
2
6i
4o 4i 5
1 4 6o
2 3
7 8
9 10
Example (after splitting node 6)
1
4 2

2i 2o 3
1 3
2
6i
4o 4i 5
1 4 6o
2 3
7 8
9 10

d(3) = 3
d(1) = 5
No further split is required.
Algorithm
TVS(T, δ)
//Determine and output the nodes to be split
//w() is the weighting function for the edges
{
If ( T ≠ 0) then
{
d[T] = 0;
For each child v of T do
{
TVS(v, δ);
d[T] = max{d[T], d[v] + w(T,v)};
}
If((T is not the root) and
(d[T] + w(parent(T),T) > δ)) then
{
Write(T); d[T] = 0;
}
}
}
• Theorem: Algorithm TVS outputs a minimum cardinality set U such
that d(T/U) ≤δ on any tree T, provided no edge of T has weight > δ.
• Proof:
• Base case. If the tree has only one node, the theorem is true.
• Induction hypothesis. Assume that the theorem is true for all
trees of size n.
• Induction step. Consider a tree T of size n + 1
• – Let U be the set of nodes split by TVS.
• – Let W be a minimum cardinality set such that d(T/W) ≤δ
• – We need to show that |U| ≤ |W|
• – If |U|= 0, the above is indeed true
• Otherwise
• Let x be the first vertex split by TVS
• Let Tx be the subtree rooted at x.
• Let T’ = T - Tx + x (Delete Tx from T except for x)
• W has to have at least one node, y, from Tx
• Let W’ = W – {y}.
• If there exists W* such that |W*| < |W’| and d(T’/W*) ≤δ, then since
d(T/(W*+{x})) ≤δ, W is not minimum cardinality split set for T.
• Thus W’ has to be minimum cardinality split set such that d(T’/W’) ≤δ.
• If TVS is run on tree T’, the set of split nodes output is U – {x}
• – Since T’ has ≤ n nodes, U – {x} is a minimum cardinality set split for T’.
• – This means that |W’| ≥ |U| -1, or |W| ≥ |U|
Reference
• E Horowitz, S Sahni, S. Rajsekaran,
Fundamental of Computer Algorithms , 2nd Ed,
University Press.
• http://www.cis.upenn.edu/~matuszek/cit594-
2005/Lectures/36-greedy.ppt
• http://www.cs.umsl.edu/~sanjiv/classes/
cs5130/lectures/gm.pdf

You might also like