Download We apply the shortest augmenting path algorithm for our

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

CAN bus wikipedia , lookup

Airborne Networking wikipedia , lookup

List of wireless community networks by region wikipedia , lookup

Kademlia wikipedia , lookup

IEEE 802.1aq wikipedia , lookup

Routing in delay-tolerant networking wikipedia , lookup

Dijkstra's algorithm wikipedia , lookup

Transcript
Maximum Flow Problem (Ford and Fulkerson, 1956)
In this problem we find the maximum flow possible in a directed connected network with
arc capacities. There is unlimited quantity available in the given source and we wish to
maximize the quantity that can be sent to the sink (destination) through the capacitated
arcs. Let there be n nodes and m arcs in the network. The formulation of the maximum flow
problem is given by
Maximize f
Subject to
βˆ‘ 𝑋𝑆𝑗 = 𝑓
𝑗
βˆ’ βˆ‘ 𝑋𝑖𝑗 + βˆ‘ π‘‹π‘—π‘˜ = 0 βˆ€π‘— β‰  𝑆, 𝑇
𝑗
π‘˜
βˆ‘ 𝑋𝑗𝑇 = 𝑓
𝑗
𝑋𝑖𝑗 ≀ π‘ˆπ‘–π‘—
Xij, f β‰₯ 0.
The problem is a Linear Programming problem and can be solved using the Simplex
algorithm.
It is possible to reduce the number of variables and constraints by substituting for f. This can
be used when we solve the maximum flow problem as an LP. This problem usually is solved
using flow augmenting path algorithms whose optimality is based on the dual of the given
formulation. Hence the given formulation is always used.
The above formulation is called node-arc formulation. There is also a path-arc formulation
where the flows on all possible paths are defined. In this formulation, X j is the flow in path j.
The capacity constraints on the arcs limit the flow. This formulation requires that we
enumerate all possible paths, which is β€œdifficult” as the problem size increases.
Illustration 7.10
Consider a network with 6 nodes and 10 arcs given in Figure 7.5. The arc capacities are given
in brackets: 1-2 (20), 1-3 (60), 2-3 (50), 2-4 (30), 2-5 (10), 3-4 (35), 3-6 (10), 4-5 (30), 4-6 (25)
and 5-6 (50). Find the maximum flow between nodes 1 and 6? Solve using the node arc and
path arc formulations?
10
2
5
50
30
20
30
50
4
1
60
35
25
6
10
3
Figure 7.5 – Network for the maximum flow problem
The node-arc formulation for the given instance is to Maximize f
Subject to
X12 + X13 = f
-X12 + X23 + X24 + X25 = 0
-X13 -X23 + X34 + X36 = 0
-X24 -X34 + X45 + X46 = 0
X36 + X46 + X56 = f
X12 ≀ 20
X13 ≀ 60
X23 ≀ 50
X24 ≀ 30
X25 ≀ 10
X34 ≀ 35
X36 ≀ 10
X45 ≀ 30
X46 ≀ 25
X56 ≀ 50
Xij β‰₯ 0.
The optimum solution to the above LP is given by X12 = 20, X13 = 45, X24 = 20, X34 = 35, X36 =
10, X45 = 30, X46 = 25, X56 = 30 and f = 65. The maximum slow possible is 65 units. Arcs 1-2, 34, 3-6, 4-5, and 4-6 are full and have been used to maximum capacity. Other arcs have
unfilled or remaining capacity. It is to be noted that Xij and f need not be restricted to
integer and hence the given problem is a LP.
We first enumerate all the paths in the given network. These are 1-2-3-4-5-6, 1-2-3-4-6, 1-23-6, 1-2-4-5-6, 1-2-5-6, 1-2-4-6, 1-3-4-5-6, 1-3-4-6, 1-3-6. There are nine paths and we
denote the flow in path j as Xj. The objective is to
Maximize X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8 + X9
Subject to
X1 + X2 + X3 + X4 + X5 + X6 ≀ 20
X7 + X8 + X9 ≀ 60
X1 + X2 + X3 ≀ 50
X4 + X6 ≀ 30
X5 ≀ 10
X1 + X2 +X7 + X8 ≀ 35
X3 + X9 ≀ 10
X1 + X4 + X7 ≀ 30
X2 + X6 + X8 ≀ 25
X1 + X4 + X5 X7 ≀ 50
Xj β‰₯ 0.
The objective function maximizes the total flow which is the sum of the flows in each path.
There are as many constraints as the number of arcs and the constraints ensure that arc
capacities are not violated.
The optimum solution is given by X8 = 15, X7 = 20, X9 = 10, X6 = 10 and X5 = 10 with total flow
= 65.
Algorithms considering flows in various paths
The path arc formulation requires that we enumerate all the paths and include as many
variables as the number of paths. We consider an algorithm where we progressively
consider each path and allot the maximum possible flow to the path which is the minimum
of the available capacities in the arcs. This algorithm is called the flow augmenting path
algorithm. We also consider diverting the flows so as to permit additional flow when a new
path is introduced.
The flow augmenting path algorithm when implemented by considering the paths in the non
decreasing order of arcs in them is called the Shortest augmenting path algorithm (Ahuja et
al, 1993). This algorithm is optimum and also does not require us to divert the flow when
new paths are considered. We explain all the algorithms using an example.
Illustration 7. 11
Consider a network with 6 nodes and 10 arcs given in Figure 7.5. The arc capacities are given
in brackets: 1-2 (20), 1-3 (60), 2-3 (50), 2-4 (30), 2-5 (10), 3-4 (35), 3-6 (10), 4-5 (30), 4-6 (25)
and 5-6 (50). Find the maximum flow between nodes 1 and 6? Solve using the flow
augmenting path algorithm and the shortest augmenting path algorithm?
The nine paths that we listed are 1-2-3-4-5-6, 1-2-3-4-6, 1-2-3-6, 1-2-4-5-6, 1-2-5-6, 1-2-4-6,
1-3-4-5-6, 1-3-4-6, 1-3-6.
1. We consider the path 1-2-3-4-5-6. The maximum possible flow in this path is 20,
which is the capacity of arc 1-2. We allow a flow of 20 and update the flow in the
arcs. 1-2 (20), 2-3 (20), 3-4 (20), 4-5 (20), 5-6 (20) and f = 20.
2. We cannot increase the flow using paths 2 to 6 because they involve the arc 1-2
whose capacity is fully used.
3. We consider the path 1-3-4-5-6. The available capacities are 1-3 (60), 3-4 (15), 4-5
(10), 5-6 (30). We increase the flow by 10 and f = 30. The flows in the various arcs are
1-2 (20), 2-3 (20), 3-4 (30), 4-5 (30), 5-6 (30), 1-3 (10).
4. We consider the path 1-3-4-6. The available capacities are 1-3 (50), 3-4 (5), 4-6 (25).
The maximum possible flow is 5 which is the minimum of the capacities. We increase
the flow b y 5 and f = 35. The updated arc flows are 1-2 (20), 2-3 (20), 3-4 (35), 4-5
(30), 5-6 (30), 1-3 (15), 4-6 (5).
5. We consider the path 1-3-6. The available capacities are 1-3 (45) and 3-6 (10). The
maximum possible increase is 10 and f = 45. The updates arc flows are 1-2 (20), 2-3
(20), 3-4 (35), 4-5 (30), 5-6 (30), 1-3 (25), 4-6 (5), 3-5 (15)
6. We have exhausted all the paths and the maximum flow possible at this point is 45.
We observe that the maximum flow using the flow augmenting path algorithm is 45 at the
moment while the optimum is 65. We now have to divert flows in existing paths and
effectively consider additional paths (which we could not consider earlier).
1. We consider the path 1-3-2-5-6. This appears as an invalid path because the network
does not contain an arc 3-2. We allow this as a valid path when there is existing flow
from 2-3 and there are arc capacities in the other arcs. The available capacities in the
arcs are 1-3 (35), 3-2 (20), which is the flow of 20 from 2-3, 2-5 (10), 5-6 (20). The
additional flow is 10 which is the minimum of the possible flows and f = 55. We
update the flows in the arcs by adding 10 to all arcs. The updated flows in the arcs
are 1-2 (20), 2-3 (10), 3-4 (35), 4-5 (30), 5-6 (40), 1-3 (35), 4-6 (5), 3-5 (15), 2-5 (10).
We observe that the flow in 2-3 has reduced because we have added 10 in the
opposite direction (3-2) which is the same as subtracting 10 from the existing flow.
This was possible because we considered the opposite arc 3-2 only when the actual
arc 2-3 has a positive flow. We also observe that in the process we have effectively
considered the path 1-2-5-6 (which we could not consider earlier) by diverting flow
using 1-3-2-5-6.
2. We next consider the path 1-3-2-4-6. This also has an arc 3-2 because the actual arc
2-3 has a positive flow. The available capacities are 1-3 (25), 3-2 (10 – which is the
flow in 2-3), 2-4 (30), 4-6 (25). The minimum possible addition is 10 and f = 65. The
updated flows are 1-2 (20), 3-4 (35), 4-5 (30), 5-6 (40), 1-3 (45), 4-6 (15), 3-5 (15), 2-5
(10), 2-4 (10). Now there is no flow in 2-3 (since a flow of 10 has been subtracted).
3. We now observe that we cannot divert any more flow and conclude that we have
reached the optimum.
The flow augmenting path algorithm is optimal when we also consider diverting existing
flows to accommodate further paths and flows.
We apply the shortest augmenting path algorithm for our example. The nine paths are
arranged in increasing (or non decreasing) order of the number of arcs in the path. The
order is 1-3-6, 1-2-3-6, 1-2-4-6, 1-2-5-6, 1-3-4-6, 1-2-3-4-6, 1-2-4-5-6, 1-3-4-5-6, 1-2-3-4-5-6.
1. Consider 1-3-6. The available capacities are 1-3 (60) and 3-6 (10). The maximum flow
possible is 10 and f = 10. We update the flows as 1-3 (10) and 3-6 (10).
2. We cannot use 1-2-3-6 since the capacity of 3-6 is used fully. Consider 1-2-4-6. The
available capacities are 1-2 (20), 2-4 (30), 4-6 (25). The flow can be increased by 20
and f = 30. The updated flows are 1-3 (10), 1-2 (20), 2-4 (20), 4-6 (20) and 3-6 (10).
3. We cannot use 1-2-5-6 because the capacity of 1-2 is used fully. Consider 1-3-4-6.
The available capacities are 1-3 (50), 3-4 (35) and 4-6 (5). The maximum flow
permissible is 5 and f = 35. The updated flows are 1-3 (15), 1-2 (20), 2-4 (20), 4-6
(25), 3-6 (10), 3-4 (5).
4. We cannot use 1-2-3-4-6 because the capacities of 1-2 and 4-6 are used fully. We
cannot use 1-2-4-5-6 because the capacity of 1-2 is used fully.
5. We consider 1-3-4-5-6. The available capacities are 1-3 (45), 3-4 (30), 4-5 (30), 5-6
(50). The maximum permissible flow is 30 and f = 65. The updated flows are 1-3 (45),
1-2 (20), 2-4 (20), 4-6 (25), 3-6 (10), 3-4 (35), 4-5 (30), 5-6 (30).
6. We cannot increase the flow by considering 1-2-3-4-5-6 because capacity of 1-2 is
utilized fully. The algorithm terminates giving a maximum flow of 65.
The shortest augmenting path algorithm gives the optimum solution. There is no need to
consider paths with negative arcs that divert flows. The flow augmenting path algorithm
effectively used the same paths that the shortest augmenting path algorithm used when we
considered diverting the flows. Because we considered path that diverted flows, we
considered more paths while applying the flow augmenting path algorithm.
Maximum flows and Minimum cuts (Ford and Fulkerson 1962)
A cut or cut set is a set of arcs which when removed from the network, permits no flow from
the source and the sink. It also divides the nodes into two sets where the source and sink
are in different sets and each of the remaining nodes is in one of the sets. For example, the
arcs that leave the source node represent a cut set that has the source in one set and all
other vertices in the other set. The capacity of the arcs in the cut set gives an upper bound
(or upper estimate) of the maximum flow possible. An important theorem that relates the
maximum flow and the cut set is the max-flow min – cut theorem that states that the
maximum flow is equal to the capacity of the minimum cut set (Ford and Fulkerson, 1962).
Illustration 7. 12
Consider the network with 6 nodes and 10 arcs given in Figure 7.5. The arc capacities are
given in brackets: 1-2 (20), 1-3 (60), 2-3 (50), 2-4 (30), 2-5 (10), 3-4 (35), 3-6 (10), 4-5 (30), 46 (25) and 5-6 (50). Find the minimal cut set from the optimum solution given by 1-3 (45), 12 (20), 2-4 (20), 4-6 (25), 3-6 (10), 3-4 (35), 4-5 (30), 5-6 (30).
From the optimum solution we observe that arcs 1-2, 3-4 and 3-6 with capacities 20, 35 and
10 are consumed fully and removing them gives the total capacity of 65 and separated the
network into two parts with no flow possible. The arcs 1-2, 3-4 and 3-6 form the minimum
cut set that divide the nodes into two sets {1,3} and {2, 4, 5, 6}.
Minimum cost flow problem (Ahuja et al, 1993)
In the minimum cost flow problem or transhipment problem, we minimize the total cost of
transporting a single item from multiple sources to multiple destinations. This is similar to
the transportation problem but with two differences. In this problem some nodes act as
source nodes, some nodes act as destination nodes and some act as intermediate nodes (or
transit points). In the transportation problem a given node can be only a source or
destination. In the minimum cost flow problem, items can be also transported from one
source node to another and from one destination node to another. Arcs exist amongst the
source nodes and amongst the destination nodes. The transportation problem is bipartite
and there are no arcs between source nodes or destination nodes.
The formulation of the minimum cost flow problem is as follows:
Let Xij be the quantity transported between nodes i and j. Let Cij be the unit transportion
cost between nodes i and j. Let bj be the supply at node j (demand is shown as negative
supply and transit as zero supply). The objective is to
Minimize βˆ‘π‘›π‘–=1 βˆ‘π‘›π‘—=1 𝐢𝑖𝑗 𝑋𝑖𝑗
Subject to
βˆ‘ 𝑋𝑖𝑗 βˆ’ βˆ‘ π‘‹π‘—π‘˜ = 𝑏𝑗
𝑖
Xij β‰₯ 0.
π‘˜
There can be capacity constraints of the form Xij ≀ uij. In this case the problem is called the
capacitated minimum cost flow problem. This problem can also be modelled as a
transportation problem with each node becoming a potential source as well as destination.
Solving this as a transportation problem is advantageous when we use special algorithms for
the transportation problem. Otherwise the LP formulation can be used.
Illustration 7.13
Consider the network with 6 nodes and 10 arcs given in Figure 7.6. The node supplies are b1
= 60, b2 = 50, b3 = b5 = 0, b4 = -30 and b6 = -80. The network is given below where the unit
transportation costs are shown as arc weights. The arc capacities are given in brackets: 1-2
(40), 1-3 (60), 2-3 (50), 2-4 (40), 2-5 (10), 3-4 (55), 3-6 (10), 4-5 (30), 4-6 (50) and 5-6 (50).
b=50
b=0
9
2
6
10
5
b=-30 4
7
1
b=60 6
5
5
3
6
6
b=-80
14
3
b=0
Figure 7.6 – Network for minimum cost flow problem
The formulation is to Minimize 10X12 + 6X13 + 5X23 + 6X24 + 9X25 + 7X34 + 14X36 + 3X45 + 6X46 +
5X56
Subject to
X12 + X13 = 60
-X12 + X23 + X24 + X25 = 50
-X13 – X23 + X34 + X36 = 0
-X24 – X34 + X45 + X46 = -30
-X25 – X45 + X56 = 0
-X36 - X46 - X56 = -80
Xij β‰₯ 0.
The optimum solution to this LP is given by X13 = 60, X24 = 50, X34 = 60, X46 = 80 with Z =
1560.
We include the arc capacities in the form of constraints X12 ≀ 40; X13 ≀ 60; X23 ≀ 50; X24 ≀ 40;
X25 ≀ 10; X34 ≀ 55; X36 ≀ 10; X45 ≀ 30; X46 ≀ 50; X56 ≀ 50. The optimum solution is X13 = 60, X24 =
40, X25 = 10, X34 = 50, X36 = 10, X45 = 10, X46 = 50, X56 = 20 with Z = 1610. The capacitated
problem understandably has a higher cost.
Circulatory flow problem (Bazaara et al, 1990)
In this problem, the flow in each arc is constrained by a lower bound as well as an upper
bound. The network is such that there is circulatory flow. We wish to minimize the total cost
associate with the circulatory flow. The formulation is the same as that of the minimum cost
flow problem except that the demand and supply are zero at all nodes and there is an
additional lower bound on the flow.
We use the same notation for the minimum cost flow problem. The formulation is to
Minimize βˆ‘π‘›π‘–=1 βˆ‘π‘›π‘—=1 𝐢𝑖𝑗 𝑋𝑖𝑗
Subject to
βˆ‘ 𝑋𝑖𝑗 βˆ’ βˆ‘ π‘‹π‘—π‘˜ = 0
𝑖
π‘˜
uij β‰₯ Xij β‰₯ lij
Illustration 7.14
Consider the network with 5 nodes and 8 arcs given in Figure 7.7. The values of Cij, lij and uij
for the arcs are given in brackets: 1-2 (4, 1, 8), 3-1(5, 1, 10), 2-3 (6, 3, 12), 2-4 (3, 0, 3), 2-5 (2,
0, 10), 4-3 (7, 1, 6), 5-3 (8, 2, 12), 4-5 (10, 2, 9).
2,0,10
2
4,1,
6,3,12
1
3,0,3
7,1,6
5,1,10
3
4
10,2,9
5
8,2,12
Figure 7.7 – Network for circulatory flow problem
The formulation of the circulatory flow problem is to Minimize 4X 12 + 6X23 + 3X24 + 2X25 +
5X31 + 7X43 + 10X45 + 8X53
subject to
X12 - X31 = 0
-X12 + X23 + X24 + X25 = 0
-X23 - X43 - X53 + X31 = 0
-X24 + X43 + X45 = 0
-X25 - X45 + X53 = 0
X12 ≀ 8; X23 ≀ 12; X24 ≀ 3; X25 ≀ 10; X31 ≀ 10; X43 ≀ 6; X45 ≀ 9; X53 ≀ 12; X12 β‰₯ 1; X23 β‰₯ 3; X24 β‰₯ 0;
X25 β‰₯ 0; X31 β‰₯ 1; X43 β‰₯ 1; X45 β‰₯ 2; X53 β‰₯ 2.
The optimum solution to the LP is given by X12 = 6, X23 = 3, X24 = 3, X31 = 6, X43 = 1, X45 = 2and
X53 = 2 with Z = 124.
Multi commodity Flows (Hu, 1963)
The multi commodity flow problem addresses the flow of different types of commodities on
a given network. We assume that there are K different commodities. Let Cijk represent the
unit cost of transporting commodity k in arc i-j. Let uijk be the capacity of arc i-j for
commodity k. Let blk be the supply of commodity k in node l. The demands are shown as
negative supplies. Let Uij be the maximum capacity of arc i-j for all commodities put
together. The problem is to
𝑛
𝑛
Minimize βˆ‘πΎ
π‘˜=1 βˆ‘π‘–=1 βˆ‘π‘—=1 πΆπ‘–π‘—π‘˜ π‘‹π‘–π‘—π‘˜
Subject to
βˆ‘ π‘‹π‘–π‘™π‘˜ βˆ’ βˆ‘ π‘‹π‘™π‘—π‘˜ = π‘π‘™π‘˜
𝑖
𝑗
π‘‹π‘–π‘—π‘˜ ≀ π‘’π‘–π‘—π‘˜
βˆ‘ π‘‹π‘–π‘—π‘˜ ≀ π‘ˆπ‘—π‘˜
π‘˜
Xijk β‰₯ 0.
The above formulation is an LP formulation.
Illustration 7. 15
Consider the network with 5 nodes and 8 arcs given in Figure 7.8. There are two
commodities. The values of Cij1, Cij2, uij1, uij2 and Uij for the arcs i-j are shown in the figure.
The five values are given in brackets for arc i-j as follows: 1-2 (5,3,4,2,4), 1-3 (7,5,3,6,5), 2-3
(6,1,3,2,6), 2-4 (3,8,3,2,4), 2-5 (6,4,5,3,6), 3-4 (2,4,4,3,3) 3-5 (3,5,4,4,5) and 4-5 (1,1,5,1,6).
Six units of commodity 1 is available in node 1 and the demands are 3 and 3 in nodes 4 and
5. Four units of commodity 2 is available in node 2and one unit in node 1 and the demands
are 1 and 4 in nodes 3 and 5. Solve the multi commodity flow formulation?
b2=4
2
6,4,5,3,6
5,3,4,2,4
6,1,3,2,6
b1=6
b2=1
1
7,5,3,6,5
3,8,3,2,4
4
2,4,4,3,3
3
1,1,5,3,6
b1=-3
b1=-3
5 b2=-4
3,5,4,4,5
b2=-1
Figure 7.8 – Network for multi commodity flow problem
Let Xij1 and Xij2 represent the flow of the two commodities in arc i-j. There are 16 variables.
The multi commodity flow formulation is to Minimize 5X121 + 3X122 + 7X131 + 5X132 + 6X231 +
X232 + 3X241 + 8X242 + 6X251 + 4X252 + 2X341 + 4X342 + 3X351 + 5X352 + X451 + X452
Subject to
X121 + X131 = 6
-X121 + X231 + X241 + X251 = 0
-X131 – X231 + X341 + X351 = 0
-X241 – X341 + X451 = -3
-X25 – X35 – X45 = -3
X122 + X132 = 1
-X122 + X232 + X242 + X252 = 4
-X132 – X232 + X342 + X352 = -1
-X242 – X342 + X452 = 0
-X252 – X352 – X452 = -4
X121 ≀ 4; X122 ≀ 2: X131 ≀ 3; X132 ≀ 6; X231 ≀ 3; X232 ≀ 2; X241 ≀ 3; X242 ≀ 2; X251 ≀ 5; X252 ≀ 3; X341 ≀
4; X342 ≀ 3; X351 ≀ 4; X352 ≀ 4; X451 ≀ 5; X452 ≀ 3
X121 + X122 ≀ 4; X131 + X132 ≀ 5; X231 + X232 ≀ 6; X241 + X242 ≀ 3; X251 + X252 ≀ 6; X341 + X342 ≀ 3;
X351 + X352 ≀ 5; X451 + X452 ≀ 6
Xijk β‰₯ 0.
The optimum solution to the LP is given by X121 = 3, X122 = 1, X131 = 3, X232 = 2, X241 = 3, X252 =
3, X351 = 3, X352 = 1 with cost = 76. This solution is given in Figure 7.9
b2=4
2
X121 = 3, X122 = 1
b1=6
b2=1
1
X131 = 3
X241 = 3
, X232 = 2
X252 = 3
4
5
b1=-3
b2=-4
b1=-3
3
X351 = 3, X352 = 1
b2=-1
Figure 7.9 – Solution to multi commodity flow problem
Minimum Spanning Trees (MST)
Consider a network with n nodes and m arcs. We assume that the network is connected,
which means that it is possible to go from every node to every other node on the network
by traversing across arcs. Arc j has a weight Cj. Any network that has n nodes and exactly n-1
arcs and is connected is called a tree.
Given a network with n nodes and m arcs (m > n) such that it is connected, it is possible to
create a sub network (whose node set and arc sets are ≀ that of the given network and from
the given network) that is connected and has all the n nodes and exactly n-1 arcs. Such a
tree is called a spanning tree of the given network. The spanning tree with minimum sum of
arc weights is called the minimum spanning tree.
The binary integer programming formulation of the minimum spanning tree problem is a
follows:
Let Xj = 1 if arc is in the MST; = 0 otherwise. Let V be the set of nodes. The objective is to
Minimize βˆ‘π‘š
𝑗 𝐢𝑗 𝑋𝑗 subject to
π‘š
βˆ‘ 𝑋𝑗 = 𝑛 βˆ’ 1
𝑗
βˆ‘ 𝑋𝑗 ≀ |𝑆| βˆ’ 1
βˆ€π‘† βŠ†π‘‰
π‘—βˆˆ(𝑆,𝑆 β€² )
Xj = 0, 1
The formulation has a large number of constraints as we will see in the example. This
happens because we have to evaluate all the subsets of the node set V.
Illustration 7.16
Consider the network given in Figure 7.10 with 5 nodes and eight arcs. The arc weights are
given in the network. Find the length of the minimum spanning tree using the formulation?
2
4
6
5
5
1
8
5
3
4
10
5
3
Figure 7.10 – Network for Illustration 7.16
The mathematical programming formulation is as follows: Let Xj = 1 if arc j is in the MST; = 0
otherwise. We have to label the arcs. This is done as follows: Arc 1-2 is denoted by variable
X1; 1-3 by X2, 2-3 by X3, 2-4 by X4, 2-5 by X5, 3-4 by X6, 3-5 by X7 and 4-5 by X8.
Minimize 4X1 + 5X2 + 5X3 + 5X4 + 6X5 + 8X6 + 3X7 + 10X8
Subject to
X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8 = 4
X1 ≀ 1; X2 ≀ 1; X3 ≀ 1; X4 ≀ 1; X5 ≀ 1; X6 ≀ 1; X7 ≀ 1; X8 ≀ 1;
X1 + X2 + X3 ≀ 2; X1 + X4 ≀ 2; X1 + X5 ≀ 2; X2 + X6 ≀ 2; X2 + X7 ≀ 2; X3 + X4 + X6 ≀ 2; X3 + X7 ≀ 2; X4 +
X8 ≀ 2; X6 + X7 + X8 ≀ 2
X1 + X2 + X3 + X4 + X6 ≀ 3; X1 + X2 + X3 + X5 ≀ 3, X1 + X4 + X5 + X8 ≀ 3; X2 + X6 + X7 + X8 ≀ 3; X3 + X4
+ X5 + X6 + X7 + X8 ≀ 3
Xj = 0,1
The second set of constraints are written considering the node sets {1,2}, {1,3}, {2,3}, {2,4},
{2,5}, {3,4}, {3,5}, {4,5}, {1,2,3}, {1,2,4}, {1,2,5}, {1,3,4}, {1,3,5}, {1,4,5}, {2,3,4}, {2,3,5}, {2,4,5},
{3,4,5}, {1,2,3,4}, {1,2,3,5}, {1,2,4,5}, {1,3,4,5} and {2,3,4,5}. The node set {1, 4, 5} gives us
only one arc X8 and there is already a constraint X8 ≀ 1 for the node set {4,5}. The constraint
X8 ≀ 2 for the node set {1,4,5} is left out.
The optimum solution to the formulation is given by X1 = X3 = X4 = X7 = 1 with distance = 17.
It is also observed that the LP relaxation where all Xj β‰₯ 0 also gives us the same solution with
Xj taking values zero or 1.
Algorithms to find the MST
The MST formulation is interesting because it has a large number of constraints. If there are
n nodes, we have 𝑛2𝐢 + 𝑛3𝐢 + … + π‘›βˆ’1𝑛𝐢 + 1 constraints. In spite of this large number of
constraints (that increase exponentially with n) the LP relaxation gives solutions with binary
values. Two very popular algorithms exist that find the MST. These are the Prim’s algorithm
and Kruskal’s algorithm:
Prim’s algorithm (Prim, 1957)
1. Find the arc k-l with the smallest weight. Arc i-j is in the MST. Create node set S1 =
{k, l} and node set S2 = {rest of the nodes}
2. For every node i in S1 and every node j in S2 find the arc i-j such that dij is minimum.
Add node j to S1 and delete j from S2.
3. Repeat step 2 such that S2 = { } or when exactly n-1 arcs have been considered. These
arcs form the MST.
Kruskal’s algorithm (Kruskal, 1956)
1. Sort the arcs according to increasing (non decreasing) order of weights.
2. The first arc k-l is in the MST. Create set S1 = {k,l}.
3. Consider the next arc k-l in the sorted list.
4. If inclusion of arc k-l will create a cycle, go to Step 3.
5. If one of the nodes is in S1 add the other node to S1. If both are not in S1 add both to
S1. Include the arc into the MST. If both nodes are in S1 go to step 3.
6. Repeat steps 3 to 5 till exactly n-1 arcs have been added. These arcs form the MST.
Illustration 7.17
Consider the network given in Figure 7.10 with 5 nodes and eight arcs. The arc weights are
given in the network. Find the length of the minimum spanning tree using Prim’s and
Kruskal’s algorithms?
Prim’s algorithm: Arc 3-5 has minimum weight. S1 = {3, 5} and S2 = {1,2,4}. Consider d13, d23,
d34, d25, d45. The minimum distance is for 1-3 (also for 2-3 but we consider one of them) . S1
= {1, 3, 5} and S2 = {2, 4}. Consider d12, d23, d25, d24, d34, d45. The minimum distance is for 1-2.
S1 = {1, 2, 3, 5} and S2 = {4}. Consider d24, d34 and d45. The minimum is d24. Now S1 = {1, 2, 3,
4, 5}. The algorithm terminates with arcs 3-5, 1-3, 1-2 and 2-4 in the MST. The reader may
observe that 3-5, 1-2, 2-3 and 2-4 is also an MST with length = 17.
Kruskal’s algorithm: The sorted list is 3-5, 1-2, 1-3, 2-3, 2-4, 2-5, 3-4, 4-5. Consider 3-5. S1 =
{3, 5}. Consider 1-2 and update S1 = {1, 2, 3, 5}. 1-3 is considered and added because it does
not create a cycle. 2-3 is not considered because adding this arc would create a cycle 1-2-31. 2-4 is added and we have added 4 arcs. The MST has arcs 3-5, 1-2, 1-3 and 2-4 with length
= 17.
Degree constrained MST (Narula and Ho, 1980)
A degree constrained MST places a restriction on the number of arcs incident from a vertex.
There is an additional constraint restricting the number of arcs in the minimum spanning
tree from every vertex to be lesser than or equal to a given constant. This is of the form
βˆ‘ 𝑋𝑗 ≀ 𝐾 for all nodes.
The formulation can be solved as a binary IP to get the optimum solution. The LP relaxation
may result in fractional values for the variables in some instances. The reader may observe
that the minimum cost (distance) travelling salesman path problem between a given start
node and a given end node can be modelled as a degree constrained minimum spanning
tree where the start and end nodes have a degree of 1 and every other node has a degree of
2.
Illustration 7.18
Consider the network given in Figure 7.11 with 5 nodes and eight arcs. The arc weights are
given in the network. Solve the degree constrained MST problem where the degree of each
vertex is not more than 2?
2
4
6
5
5
1
8
5
3
4
3
Figure 7.11 – Network for Illustration 7.18
10
5
It is customary to first solve the MST using Prim’s or Kruskal’s algorithm. The solution
obtained using Kruskal’s algorithm has arcs 3-5, 1-2, 2-3 and 2-4 in the MST with length = 17.
In the Xj notation, we observe that X1, X3, X4 and X7 are in the solution. The degree of each
vertex represents the number of arcs in the spanning tree that are incident to the vertex.
We compute d(1) = 1; d(2) = 3, d(3) = 2, d(4) = 1 and d(5) = 1. This solution violates the
restriction because node 2 has degree of 3. We add the following constraints
X1 + X2 ≀ 2; X1 + X3 + X4 + X5 ≀ 2; X3 + X6 + X7 ≀ 2; X4 + X5 + X6 ≀ 2 and X5 + X7 + X8 ≀ 2.
The optimum solution is X1 = X2 = X4 = X7 = 1 with length = 17. This satisfies the degree
constraints. This solution is the other optimum solution to the MST (which also satisfies the
degree constraint). If we were to solve the shortest distance between 1 and 5 passing
through every other node once and only once the path is 1-2-3-4-5 with length = 17.