Professional Documents
Culture Documents
A multitude of operations research situations can be modeled and solved as networks that are nodes
connected by branches. The following example illustrates how network representations may
facilitate problem solving.
The Prussian city of Konigsberg (now Kalingrad in Russia) was founded in 1254 on the banks of
river Pergel with seven bridges connecting its four sections (labeled A, B, C, and D) as shown in
Figure 4.1. A problem circulating among the inhabitants of the city was to find out if a walk that
starts at some section and returns to the starting section could be made with each bridge being
crossed exactly once. No limits were set on the number of times any of the four sections could be
visited.
A D
This situation can be represented as a network in which each of the four sections (A, B, C, and D) is
a node and each bridge is an arc joining applicable nodes, as shown in Figure 4.2.
A D
In the mid-eighteenth century, the famed mathematician Leonhard Euler developed a special “path
construction” argument to prove that it was impossible to make such a trip. The desired round trip is
impossible, because there are four nodes and each is associated with an odd number of arcs, which
does not allow distinct entrance and exit (and hence distinct use of the bridges) to each section of
the city.
This example demonstrates how the solution of the problem is facilitated by using network
representation. In the general solution, such a walk, called an Eulerian tour, exists if the network is
connected (that is, if there is a path from each node to each other node) and if all nodes have an
even number of arcs.
A graph consists of a set of nodes linked by arcs. The notation for describing a graph is
= (, ), where is the set of nodes and is the set of arcs. As an illustration, the graph in
Figure 4.3 is described as
= {1, 2, 3, 4, 5}
= {(1, 2), (1, 3), (2, 3), (2, 5), (3, 4), (3, 5), (4, 2), (4, 5)}
1 3 5
2 4
Associated with each network is a flow (e.g., oil products flow in a pipeline, an automobile traffic
flows in highways). In general, the flow in a network is limited by the capacity of its arcs, which
may be finite or infinite.
An arc is said to be directed or oriented if it allows positive flow in one direction and zero flow in
the opposite direction. A network that has only directed arcs is called a directed network.
Similarly, if the network has only undirected arcs, it is said to be an undirected network.
1 3 5 1 3
2 4 2 4
1 3 1 3 5
2 4 4
1 3 5 3
2 4 2 4
Figure 4.4. Examples of walks, paths, and cycles from the network in Figure 4.3
A path is a walk in which no node and no arc is repeated. A directed path is a directed walk in
which no node and no arc is repeated.
A path forms a cycle or a loop if it connects a node to itself. In a directed network, a cycle is either
a directed or an undirected cycle, depending on whether the path involved is a directed or an
undirected path.
A connected network is such that every two distinct nodes are linked by at least one path. The
network in Figure 4.3 is connected. A tree is a connected network comprised of a subset of all the
nodes and that contains no cycles. A spanning tree is a tree that links all the nodes of the network.
Figure 4.5 provides examples of a tree and a spanning tree from the network in Figure 4.3.
1 3 1 3 5
2 4 2 4
Figure 4.5. Examples of a tree and a spanning tree from the network in Figure 4.3
The minimal spanning tree problem deals with linking the nodes of an undirected network using the
shortest total length of connecting arcs. The arcs are needed to be chosen in a way that the resulting
network forms a spanning tree. A typical application occurs in the construction of paved roads that
link several rural towns. The road between two towns may pass through one or more other towns.
The most economical design of the road system calls for minimizing the total length of paved roads,
a result that is achieved by implementing a minimal spanning tree algorithm.
In the following, we study a simple algorithm for the minimal spanning tree problem, known as
Prim’s algorithm. Let = {1, 2, … , } be the set of nodes of the network and define:
Step k: ̅
Select a node j in the unconnected set that yields the shortest arc to a node in the
connected set , say arc ($, %). Link % permanently to
̅ .
and remove it from
That is, set = + {%} and ̅ =
̅ − {%}. Let = + {($, %)}. If the set of
unconnected nodes ̅ is empty, stop. Otherwise set = + 1 and repeat the step.
Midwest TV Cable Company is in the process of providing cable service to six new housing
development areas. Figure 4.6 depicts possible TV linkages among the six areas. The cable miles
are shown on each arc. The company wants to determine the most economical cable network.
2 3 miles
6 5
4
1
9
10
1 3 6
5
8
7 5
3
The solution is given by the minimal spanning tree shown in Figure 4.12. The resulting minimum
cable miles needed to provide the desired cable service are 1 + 3 + 4 + 3 + 5 = 16 miles.
2 3 miles
6 5
4
1
C1
9
10
1 3 6
5
8
7 5
3
9
10
1 3 6
5
8
7 5
3
2 3 miles
C3
6 5
4
1
9
10
1 3 6
5
8
7 5
3
9
10
1 3 6
5
8
7 5
3
2 3 miles
C5
6 5
4
1
9
10
1 3 6
5
8
7 5
3
1 3 6
5
5
3
The shortest path problem determines the shortest path between a source and a destination in a
transportation network. Other situations can be represented by the same model as illustrated by the
following example.
RentCar is developing a replacement policy for its newly acquired car fleet for a 4-year planning
horizon. At the start of each year a decision is made as to whether a car should be kept in operation
or replaced. A car must be in service a minimum of 1 year and a maximum of 3 years. The
following table provides the replacement costs as a function of the year a car is acquired and the
number of years in operation.
Figure 4.13 shows the resulting network. The shortest path can be found as 1 – 3 – 5. The solution
means that a car acquired at the start of year 1 (node 1) must be replaced after 2 years at the start of
year 3 (node 3). The replacement car will then be kept in service until the end of year 4. The total
cost of this replacement policy is $12,500 (= $5,400 + $7,100).
9800
5400 7100
6200
8700
Dijkstra’s algorithm is designed to determine the shortest paths from a given source node ) to every
other node in a network with nonnegative arc lengths. Dijkstra’s algorithm maintains a distance
label * ( ) with each node , which is an upper bound on the shortest path length to node . At any
intermediate step, the algorithm divides the nodes into two groups: those which it designates as
permanently labeled (or permanent) and those it designates as temporarily labeled (or temporary).
The distance label of any permanent node represents the shortest distance from the source ) to that
node. For any temporary node, the distance label is an upper bound on the shortest path distance to
that node. The basic idea of the algorithm is to fan out from node ) and permanently label nodes in
the order of their distances from node ).
Initially, we give node ) a temporary label of zero, and all the other nodes a temporary label ∞. At
each iteration, the algorithm selects a node with the minimum temporary label (breaking ties
Define:
Example 4.3: The network in Figure 4.14 gives the permissible routes and their lengths in miles
between city 1 (node 1) and four other cities (nodes 2 to 5). Determine the shortest routes between
city 1 and each of the remaining four cities.
2 15
4
20 50
100
10
30 60
1 3 5
Iteration 2. Between the two temporarily labeled nodes having finite labels, node 3 yields the
smallest distance label. Thus, the status of node 3 is changed to permanent. That is, , = , + {3} and
,̅ = ,̅ − {3}. Nodes 4 and 5 can be reached from node 3 and the list of nodes having finite labels
becomes:
Node Label Predecessor Status
1 *(1) = 0 -.*(1) = 0 Permanent
2 *(2) = 100 -.*(2) = 1 Temporary
3 *(3) = 30 -.*(3) = 1 Permanent
4 *(4) = 40 -.*(4) = 3 Temporary
5 *(5) = 90 -.*(5) = 3 Temporary
Iteration 3. The temporarily labeled node having the smallest distance label is node 4. Thus,
, = , + {4} and ,̅ = ,̅ − {4}. Nodes 2 and 5 can be reached from node 4. Node 2’s temporary label
100 obtained in iteration 1 is changed to 55 to indicate that a shorter path has been found through
node 4. Note also that node 5 has two alternative labels with the same distance 90. The list of nodes
is updated as:
Node Label Predecessor Status
1 *(1) = 0 -.*(1) = 0 Permanent
2 5(6) = 77 89:5(6) = ; Temporary
3 *(3) = 30 -.*(3) = 1 Permanent
4 *(4) = 40 -.*(4) = 3 Permanent
5 *(5) = 90 -.*(5) = 3 Temporary
Iteration 4. Between the temporarily labeled nodes having finite labels, node 2 yields the
smallest distance label. Thus, , = , + {2} and ,̅ = ,̅ − {2}. Only node 3 can be reached from node
Iteration 5. The only temporarily labeled node is node 5. Thus, , = , + {5} and ,̅ = ,̅ − {5}.
The final list is then:
The shortest route between node 1 and any other node in the network is determined by starting at
the desired destination node and backtracking through the nodes using the information given by
-.*( ) for each node . The obtained shortest paths of this problem are shown by thick arcs in
Figure 4.15.
2 15
4
20 50
100
10
30 60
1 3 5
Bellman-Ford algorithm determines the shortest paths from a given source node ) to every other
node in a network having arbitrary arc lengths. The algorithm maintains a distance label *() with
each node ∈ . At intermediate stages of computation, the distance label * ( ) is an upper bound
on the shortest path distance from the source node ) to node , and at the termination it is the
shortest path distance. Bellman-Ford algorithm determines the shortest paths in a given network
based on the following optimality conditions:
Optimality Conditions: If the distance labels are the shortest path distances, then they must
satisfy the following conditions:
d( i )
i cij d( j )
j
These inequalities state that for every arc (, %) in the network, the length of the shortest path to
node % is no greater than the length of the shortest path to node plus the length of the arc (, %). If
not, some arc (, %) must satisfy the condition *(%) > *() + /01 . In this case, we could improve the
length of the shortest path to node % by passing through node , thereby contradicting the optimality
of distance labels *(%).
Bellman-Ford algorithm is a general procedure for successively updating the distance labels until
they satisfy the sated optimality conditions. The algorithm can be implemented by first arranging all
the arcs in in some specified (possibly arbitrary) order. We then make passes through . In each
pass, we scan arcs in , one by one, and check the condition *(%) > *() + /01 . If the arc satisfies
this condition, we update * (%) = * ( ) + /01 . We stop when no distance label changes during an
entire pass.
3
-2 5
-2
2
-1 4
5
4 6 1
1 3
6
Example 4.4: We want to determine the shortest path distances between node 1 and each of the
remaining nodes of the network in Figure 4.18.
3
2 4
4
4
9 -4 1 6
1 -
2
6 4
3 5
Iteration 1. By examining the arcs in the following order, the distance labels of the nodes are
updated as follows:
Then, = 1.
Then, = 2.
3
2 4
4
4
9 -4 1 6
1 -
2
6 4
3 5
A network is called acyclic if it contains no directed cycle. We can always number (or rank) nodes
of an acyclic network so that ( ) < (%) for each (, %) ∈ . That is, a node having the
rank () = has all its predecessors in ranks − 1, − 2, … , 0. This ranking of nodes is
called a topological ordering.
Starting by = 0, this ranking is obtained by attributing a node to the rank if all the immediate
predecessors of that node are already attributed to ranks − 1, − 2, … , 0. When there are no more
nodes that can be attributed to rank , we increase by 1 and continue this procedure until all the
nodes are attributed to a rank. Note that, if all the nodes of a network can not be attributed to a rank
using this procedure, then the network must contain a directed cycle.
5
2 4
2
11
3 15 12
- 6
1
15 4
9
3 5
Using the described procedure, the node ranks are obtained as follows:
If we visualize each rank as a vertical line and place the nodes with the same rank to the
corresponding vertical line, we can see more clearly that each node having the rank ( ) =
has all its predecessors in ranks − 1, − 2, … , 0 and so there is no directed cycle in the network.
11 15
- 2
12
3
1 -
6
15
4
3 5
9
The shortest path distances from a given source node ) having the rank ()) = 0 to every other
node of an acyclic network can be determined using a simplified version of the Bellman-Ford
algorithm. In fact, in the case of an acyclic network, we can obtain the shortest path distances at the
end of the first pass if we examine the nodes in the increasing order of their ranks. Let F() be the
set of immediate predecessors of node and GHI be the maximum rank number of the network.
The simplified version of the Bellman-Ford algorithm is described as follows:
11 15
[0, 0] - 2
12
3
1 -
6
15
4
3 5
9
11 15
[0, 0] - 2
12
3
1 -
6
15
4
3 5
9
[14, 2]
11 15
[0, 0] - 2
12
3
1 -
6
15
4
3 5
9
[14, 2] [23, 3]
11 15
[0, 0] - 2
12 [18, 4]
3
1 -
6
15
4
3 5
9
[14, 2] [23, 3]
REFERENCES
Ahuja, R.K., Magnanti, T.L, and J.B. Orlin, 1993. Network Flows: Theory, Algorithms, and Applications,
Prentice Hall.
Taha, H.A., 2007. Operations Research, An Introduction, eight edition, Pearson Prentice Hall.