You are on page 1of 22

CHAPTER IV: Introduction to Network Models

4. Introduction to Network Models............................................................................................................ 4.1


4.1. Network Definitions ....................................................................................................................... 4.2
4.2. Minimal Spanning Tree Problem ................................................................................................... 4.4
4.3. Shortest Path Problem .................................................................................................................... 4.9
4.3.1. Shortest Path Application Example: Equipment Replacement............................................... 4.9
4.3.2. Dijkstra’s Shortest Path Algorithm........................................................................................4.10
4.3.3. Bellman-Ford Shortest Path Algorithm .................................................................................4.14
4.3.4. Shortest Path Problems in Acyclic Networks ........................................................................4.17
4. Introduction to Network Models

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.

Example 4.1: Bridges of Konigsberg

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

Figure 4.1. Bridges of Konigsberg

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.

Operations Research – September 2018 4.1


B

A D

Figure 4.2. Network representation of Konigsberg problem

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.

4.1. Network Definitions

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

Figure 4.3. Example of a directed network


Operations Research – September 2018 4.2
A network is a graph whose nodes and/or arcs have associated numerical values (typically, costs,
capacities, and/or supplies and demands). However, we often make no distinction between graphs
and networks and we use the terms “graph” and “network” synonymously.

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

Walk Directed Walk

1 3 1 3 5

2 4 4

Path Directed Path

1 3 5 3

2 4 2 4

Cycle Directed Cycle

Figure 4.4. Examples of walks, paths, and cycles from the network in Figure 4.3

A walk is a sequence of nodes and arcs  −  −  −  − ⋯ −  −  −  satisfying the


property that for all 1 ≤  ≤  − 1, either  = ( ,  ) ∈  or  = ( ,  ) ∈ . A directed

Operations Research – September 2018 4.3


walk is an oriented version of a walk in the sense that for any two consecutive nodes  and  on
the walk, ( ,  ) ∈ .

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

Tree Spanning tree

Figure 4.5. Examples of a tree and a spanning tree from the network in Figure 4.3

4.2. Minimal Spanning Tree Problem

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:

Operations Research – September 2018 4.4


 : set of nodes that have been permanently connected at iteration 
̅
 : set of nodes to be connected permanently after iteration 
 : set of arcs in the minimal spanning tree linking the nodes of 

The steps of this procedure are given as follows:

Step 0: Set  = ∅, # = ∅, and #̅ = .


Step 1: Start with any node  in the unconnected set #̅ and set  = {} which renders
̅ =  − {}. Set  = 2.


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.

Example 4.2: Midwest TV Cable Company

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

Figure 4.6. Cable connections for Midwest TV Company

Operations Research – September 2018 4.5


The algorithm starts at node 1 (any other node will do as well), which gives  = {1},

̅ = {2, 3, 4, 5, 6}. The iterations of the algorithm are summarized in Figures 4.7 to 4.11. The thick
arcs in blue provide the candidate links between and ̅ . The thick red arcs represent the
permanent links between the nodes of the connected set , and the dashed red arc represents the
new (permanent) arc added at each iteration.

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

Figure 4.7. Iteration 2 for Midwest TV Company

Operations Research – September 2018 4.6


2 3 miles
6 5
C2
4
1

9
10
1 3 6
5

8
7 5
3

Figure 4.8. Iteration 3 for Midwest TV Company

2 3 miles
C3
6 5
4
1

9
10
1 3 6
5

8
7 5
3

Figure 4.9. Iteration 4 for Midwest TV Company

Operations Research – September 2018 4.7


2 3 miles
C4
6 5
4
1

9
10
1 3 6
5

8
7 5
3

Figure 4.10. Iteration 5 for Midwest TV Company

2 3 miles
C5
6 5
4
1

9
10
1 3 6
5

8
7 5
3

Figure 4.11. Iteration 6 for Midwest TV Company

Operations Research – September 2018 4.8


2 3 miles
5
4
1
Alternate Arcs

1 3 6
5

5
3

Figure 4.12. Minimal spanning tree for Midwest TV Company

4.3. Shortest Path Problem

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.

4.3.1. Shortest Path Application Example: Equipment Replacement

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.

Equipment acquired Replacement cost ($) for given years in operation


at start of year 1 2 3
1 4,000 5,400 9,800
2 4,300 6,200 8,700
3 4,800 7,100 -
4 4,900 - -

Operations Research – September 2018 4.9


The problem can be formulated as a network in which nodes 1 to 5 represent the start of years 1 to
5. Arcs from node 1 (year 1) can reach only nodes 2, 3, and 4 because a car must be in operation
between 1 and 3 years. The arcs from the other nodes can be interpreted similarly. The length of
each arc equals the replacement cost. The solution of the problem is equivalent to finding the
shortest path between nodes 1 and 5.

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

4000 4300 4800 4900


1 2 3 4 5

6200

8700

Figure 4.13. Equipment replacement problem as a shortest path model

4.3.2. Dijkstra’s Shortest Path Algorithm

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

Operations Research – September 2018 4.10


arbitrarily), makes it permanent, and updates the distance labels of immediately succeeding
temporary nodes. The algorithm terminates when it has designated all nodes as permanent.

Define:

S : set of permanently labeled nodes


,̅ : set of temporarily labeled nodes
*() : distance label of node 
-.*( ) : immediate predecessor of node  in the path that yields the distance label *()
/01 : length of arc (, %)

The steps of the Dijkstra’s algorithm are as follows:

Step 0: Set , = ∅, ,̅ = , *()) = 0, -.*()) = 0 and *( ) = ∞ for each node  ∈ .


Step k: Select the temporary node  ∈ ,̅ having the minimum temporary level.
Set , = , + {} and ,̅ = ,̅ − {}.
For each node % that can be reached from node , provided that % is not permanently
labeled, determine if *(%) > *( ) + /01 :
if *(%) > *( ) + /01 , set * (%) = *() + /01 and -.* (%) = .
If all the nodes are permanently labeled, stop. Otherwise, repeat step .

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

Figure 4.14. Network example for Dijkstra’s shortest path algorithm

Operations Research – September 2018 4.11


Iteration 0. Set , = ∅, ,̅ = , *(1) = 0, -.*(1) = 0 and *( ) = ∞ for each node  ∈ .
Iteration 1. Set , = , + {1} and ,̅ = ,̅ − {1}. Nodes 2 and 3 can be reached from (the last
permanently labeled) node 1. Thus, the list of nodes having finite distance labels (temporary and
permanent) becomes:
Node Label Predecessor Status
1 * (1) = 0 -.*(1) = 0 Permanent
2 *(2) = 100 -.*(2) = 1 Temporary
3 *(3) = 30 -.*(3) = 1 Temporary

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

Operations Research – September 2018 4.12


2. However, node 3 is permanent and cannot be relabeled. The new list of labels remains the same
as in iteration 3 except that the label at node 2 is now permanent. That is:

Node Label Predecessor Status


1 *(1) = 0 -.*(1) = 0 Permanent
2 *(2) = 55 -.*(2) = 4 Permanent
3 *(3) = 30 -.*(3) = 1 Permanent
4 *(4) = 40 -.*(4) = 3 Permanent
5 *(5) = 90 -.*(5) = 3 Temporary

Iteration 5. The only temporarily labeled node is node 5. Thus, , = , + {5} and ,̅ = ,̅ − {5}.
The final list is then:

Node Label Predecessor Status


1 *(1) = 0 -.*(1) = 0 Permanent
2 *(2) = 55 -.*(2) = 4 Permanent
3 *(3) = 30 -.*(3) = 1 Permanent
4 *(4) = 40 -.*(4) = 3 Permanent
5 *(5) = 90 -.*(5) = 3 Permanent

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

Figure 4.15. Shortest paths for the problem of Example 4.3

Operations Research – September 2018 4.13


4.3.3. Bellman-Ford Shortest Path Algorithm

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:

*(%) ≤ *( ) + /01 for all (, %) ∈ 

d( i )
i cij d( j )
j

Figure 4.16. Optimality conditions of Bellman-Ford algorithm

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.

Operations Research – September 2018 4.14


Let  be the number of nodes in the network. Bellman-Ford algorithm determines the shortest path
distances by performing at most  − 1 passes through the arc list if there are no negative cycles in
the network. If there is at least one negative cycle, the algorithm will perform more than  − 1
passes. It will keep decreasing distance labels indefinitely and will never terminate. Therefore, if the
algorithm examines an arc more than  − 1 times, we stop the algorithm and we conclude that the
network contains a negative cycle.

3
-2 5
-2
2
-1 4
5
4 6 1

1 3
6

Figure 4.17. Network example with a negative cycle

Step 0: Set  = 0, *()) = 0, -.*()) = 0 and *() = ∞ for each node  ∈ .


Step k: For each node % ≠ ) and for each immediate predecessor node  of node %, determine
if *(%) > *( ) + /01 :
If * (%) > * ( ) + /01 , set *(%) = * ( ) + /01 and -.*(%) = .
If improvement is obtained, set  =  + 1.
If no improvement is obtained or if  >  − 1, stop. Otherwise, repeat step .
If  >  − 1, then there is negative cycle in the graph.

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

Figure 4.18. Network example for Bellman-Ford shortest path algorithm

Operations Research – September 2018 4.15


Iteration 0. Set k = 0, *(1) = 0, -.*(1) = 0 and *() = ∞ for each node  ∈ .

Iteration 1. By examining the arcs in the following order, the distance labels of the nodes are
updated as follows:

Arc Node Label Predecessor


(1, 2) 2 *(2) = 4 -.*(2) = 1
(3, 2) 2 5(6) = ; 89:5(6) = =
(1, 3) 3 *(3) = 6 -.*(3) = 1
(4, 3) 3 5(>) = ? 89:5(>) = =
(2, 4) 4 5(;) = @ 89:5(;) = 6
(3, 5) 5 *(5) = 10 -.*(5) = 3
(4, 5) 5 5(7) = A 89:5(7) = ;
(4, 6) 6 *(6) = 11 -.*(6) = 4
(5, 6) 6 5(?) = =B 89:5(?) = 7

Then,  = 1.

Iteration 2. The distance labels of the nodes are updated as follows:

Arc Node Label Predecessor


(1, 2) 2 *(2) = 4 -.*(2) = 1
(3, 2) 2 *(2) = 4 -.*(2) = 1
(1, 3) 3 *(3) = 6 -.*(3) = 1
(4, 3) 3 5(>) = > 89:5(>) = ;
(2, 4) 4 *(4) = 7 -.*(4) = 2
(3, 5) 5 5(7) = @ 89:5(7) = >
(4, 5) 5 *(5) = 7 -.*(5) = 3
(4, 6) 6 *(6) = 10 -.*(6) = 5
(5, 6) 6 5(?) = D 89:5(?) = 7

Then,  = 2.

Operations Research – September 2018 4.16


Iteration 3. We examine the arcs in the stated order once more, but no improvement is obtained.
We stop the algorithm. At the termination, the distance labels of the nodes are:

Node Label Predecessor


2 *(2) = 4 -.*(2) = 1
3 *(3) = 3 -.*(3) = 4
4 *(4) = 7 -.*(4) = 2
5 *(5) = 7 -.*(5) = 3
6 *(6) = 9 -.*(6) = 5

The obtained shortest paths are given in Figure 4.19.

3
2 4
4
4

9 -4 1 6
1 -

2
6 4
3 5

Figure 4.19. Shortest paths for the problem of Example 4.4

4.3.4. Shortest Path Problems in Acyclic Networks

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.

Operations Research – September 2018 4.17


Example 4.5: Let’s determine the topological ordering of the network in Figure 4.20.

5
2 4
2
11
3 15 12
- 6
1

15 4
9
3 5

Figure 4.20. Network example for topological ordering

Using the described procedure, the node ranks are obtained as follows:

Node Immediate Predecessors Rank


1 – 0
2 1 1
3 1, 2 2
4 2 2
5 2, 3, 4 3
6 4, 5 4

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.

Operations Research – September 2018 4.18


5
2 4

11 15
- 2
12
3
1 -
6
15
4

3 5
9

k=0 k=1 k=2 k=3 k=4

Figure 4.21. Network example for topological ordering

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:

Step 0: Set  = 0, *()) = 0, -.*()) = 0.


Step k: Let  =  + 1. For each node % having the rank  (%) = , set
*(%) = min0∈M(1) N*() + /01 O ,
-.*(%) = argmin0∈M(1) N*() + /01 O .
Stop if  =  GHI . Otherwise, repeat step .

Operations Research – September 2018 4.19


Example 6: The shortest paths of the network given in Figure 4.21 are obtained through the
iterations shown in Figures 4.22 to 4.25.

[11, 1] [5(S), 89:5(S)]


5
2 4

11 15
[0, 0] - 2
12
3
1 -
6
15
4

3 5
9

Figure 4.22. Iteration 1 of the simplified Bellman-Ford algorithm

[11, 1] [16, 2] [5(S), 89:5(S)]


5
2 4

11 15
[0, 0] - 2
12
3
1 -
6
15
4

3 5
9
[14, 2]

Figure 4.23. Iteration 2 of the simplified Bellman-Ford algorithm

Operations Research – September 2018 4.20


[11, 1] [16, 2] [5(S), 89:5(S)]
5
2 4

11 15
[0, 0] - 2
12
3
1 -
6
15
4

3 5
9
[14, 2] [23, 3]

Figure 4.24. Iteration 3 of the simplified Bellman-Ford algorithm

[11, 1] [16, 2] [5(S), 89:5(S)]


5
2 4

11 15
[0, 0] - 2
12 [18, 4]
3
1 -
6
15
4

3 5
9
[14, 2] [23, 3]

Figure 4.25. Iteration 4 of the simplified Bellman-Ford algorithm

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.

Operations Research – September 2018 4.21

You might also like