You are on page 1of 30

Linear Programming

and Game Theory


Network Models
8.4 Network Models

Flow Networks Beth


Directed Graph
Definitions and Constraints
Kirchhoff’s Current Law (KCL)
Incidence Matrix
S-T cuts
Max Flow – Min Cut Theorem
Maximal Flow Sample Problems
Graph Terminology
8.4 Network Models

The Marriage Problem Selma


Matrix vs. Graph
Complete Matching
Hall’s Condition
8.4 Network Models

Spanning Trees and The Greedy Algorithm Will


Shortest Path Problem
Shortest Spanning Tree
Greedy Algorithm
Optimal Assignment Problem
Transportation Problem
Minimum Cost Flow
Dynamic Programming
Bellman Equation
Examples of Network Applications

Vehicular traffic on roads and highways


Water or oil flowing through pipes
Electrical current running through circuitry
Network programming can be used to design road, pipeline,
or circuit systems to optimally direct all such flows.
Flow Networks

A popular problem using flow networks in optimization


theory is called the maximum flow problem.

Graph theory provides us with a nice visual representation


of a flow network: in a directed graph, each edge has a
capacity and receives a flow into a node, f/c.
Goal:
3/3
2 4 Max Flow
3/5 3/5
Source
1 6

2/6 2/2 Sink


3 5
2/5

The goal is to find a feasible flow from a single source to a


single sink that is a maximum.
Definitions and Constraints
We denote flows from node i to node j as fij, where fij > 0,
subject to two constraints:

1. Flow on an edge cannot exceed its capacity: fij ≤ cij.

2. Inflow to a node must equal outflow*, except when it is


a source (more outgoing flow) or a sink (more incoming flow).
That is, no flow accumulation is permitted at any interim node.
The flows fij enter node j from previous nodes i.
The flows fik leave node j to subsequent nodes k.

*According to Kirchhoff’s Current Law (or “conservation law”).


or , for j = 1, 2, …, 6
Maximal Flow Problem 1:

The directed graph represents a 6-node network:

Total flow into the sink cannot exceed 7 (= 6 + 1).


Can this total flow be achieved?
What is the maximal flow from left to right?

Maximizing the return flow from the sink to the source, f61,
(dotted line), maximizes the total flow into the sink.
Incidence Matrix
A is a node-edge incidence matrix. Constraint 2 tells us that Af = 0.
The rows correspond to nodes and the columns correspond to edges,
with +1, -1 for every edge showing a balance in inflows and outflows.
The last column is for the additional return flow from the sink to the
source (dotted line).
1 1 -1 node 1
-1 1 1 2
-1 1 1 3
A=
-1 -1 1 4
-1 -1 1 5
-1 -1 1 6
edge 12 13 24 25 34 35 46 56
Maximal Flow61 Maximize f61 subject to: 1) 0 ≤ fij ≤ cij and 2) Af = 0
Maximal Flow Problem 1:
Return Flow f61 = 6 Goal:
2+3= 5
2/2 Max Flow
2 4 5 /6
Source 2/4 0/5
cut
1 capacity 6
4/5 3/3 2+3+1
1/ 1 Sink
3 5
1/4

1. Flows cannot exceed the capacities. 2. Flow in = Flow out.


fij ≤ cij Arrows cannot be reversed.
SOLUTION:
flow of 2 on path 1-2-4-6-1 + flow 0f 3 on path 1-3-4-6-1 = 2+3
+ flow of 1 on lowest path 1-3-5-6-1 = 5 + 1 = 6!

The key is to find a cut in the network across which all capacities are filled. The
edges going forward across the cut have total capacity
= 2 + 3 + 1 = 6 and no more can get across!
S-T Cuts and Max flow−Min cut Theorem
An s-t cut is a node partition into two sets, S and T, such that
the source is in S and the sink is in T.

The capacity of an s-t cut equals the sum of the


capacity of all edges crossing the cut, from S to T.

The max flow−min cut theorem states that the maximum value
of a flow in a network is equal to the total capacity across the
minimal cut (cut of smallest capacity).

PROOF that max flow = min cut:


Suppose we have maximal flow. It may be possible to send
additional flow from the source to some nodes which are not at
capacity. Those nodes lie in S with the source. The sink must lie in T, or it could
have received more flow! It must be that every edge across the cut is filled, fij =
cij, or extra flow to a node in T would have been feasible.
So, maximal flow fills the cut to capacity and equality is achieved!
Maximal Flow Problem 2:
Return Flow f6 1 = __ ??? Goal:
2 Max Flow
2 4 2
Source 5 1
1 2 3 6
4 4
7 Sink
3 5
2

Total flow into the sink cannot exceed ____ ???


Can this total flow be achieved? YES / NO
Maximal flow from left to right is ____ ???

[HINT: Recall 2 constraints and work backwards!]

If you could increase the capacity of any one pipe, which change would
produce the largest increase in the maximal flow? Name edges using ij.
Edge ____ from ___ to ___ OR Edge ____ from ___ to ___
[HINT: There is more than one possibility!]
Maximal Flow Problem 2:
Return Flow f6 1 = 8 2+3= 5 Goal:
-2 - 1- 2 = - 5 2/2
-2 - 3 = -5
2 4
Max Flow
2/2
Source 5/5 1/1
cut
1 2/2 3/3 capacity 6
2+3+1+2
3/4 3/ 4 6/ 7 Sink
3 5
2/2
3+2= 5 2+1+3= 6
-3 - 2 = -5

SOLUTION:
flow of 2 on path 1-2-4-6-1
+ flow 0f 2 on path 1-2-3-5-6-1 + flow of 1 on path 1-2-5-6-1
+ flow 0f 3 on path 1-3-4-5-6-1 = 2 + 2 + 1 + 3 = 8!
If you could increase the capacity of any one pipe, which change
would produce the largest increase in the maximal flow?
35 from 2 to 3 OR 45 from 3 to 4 OR 46 from 2 to 3
Graph Terminology
 Directed graph (or digraph) − a graph with directional
arrows as its edges (or sides). Each edge connects two
adjacent nodes (or vertices, or endpoints).
 In-degree and out-degree refer to the number of edges
entering and leaving a vertex, respectively.
 The degree of a vertex equals the sum of its in- and out-
degrees.
 Source − a node with 0 in-degree .
 Sink − a node with 0 out-degree.
 Cut − a partition of the nodes into two subsets.
 Cut-set of the cut contains edges whose nodes are in
different sets of the partition.
Edges are said to be crossing the cut if they are in its cut-set.
The Marriage Problem
Compatibility Matrix Graph

jth column
ith row
women men

1 0 0 0
1 1 1 0
A=
0 0 0 1
0 0 0 1
Two marriages on the left, three (maximum) on
the right. The third is created by adding two new
marriages and one divorce (backward flow).
1

1 1-1
1 1
M2 1
1 1
1
1
s t s t
cut
capacity
1 3
1 1 1

1 1
Complete Matching - set of four 1’s in the
matrix; they would come from 4 different rows
and 4 different columns

1 0 0 0
0 1 0 0
A=
0 0 1 0
0 0 0 1
For Complete Matching, there is no specific
order as long as there are a set of four 1’s in the
matrix and they would come from 4 different
rows and 4 different columns

0 1 0 0
0 0 0 1
A=
0 0 1 0
1 0 0 0
Whenever there is a subset of k women who
among them like fewer than k men, a complete
matching is impossible.

1 0 0 0
1 1 1 0
0 0 0 1
0 0 0 1
The general rule for an n x n matrix is that a p by q
block of zeros prevents a matching if p + q > n.
Hall’s condition
If every set of p women does like at least p
men, a complete matching is possible.
1 1

1 1 1
1 1
1 1 1
1
1
s 1 1 t s 1 t
1 1
1

1 1 1
1

1 1

Each woman must like at least one man, each two women
must between them like at least two men, and so on, to p=n.
A complete matching is possible if and only if
Hall’s condition holds
Proof:
Let the capacities be n on all edges across the middle. The capacities out of
the source and into the sink are still 1.
If the maximal flow is n, all those edges are filled and the flow produces n
marriages.
When the maximal flow is below n, some cut must be responsible. That cut
will have capacity below n , so no middle edges cross it.
n
Suppose p = 2 remaining women 1 1
and r = 1 man left 1 1
Capacity is n – p + r = 4 – 2 + 1 = 3 n
which is below n = 4 s t
cut
exactly when p > r, 2 > 1 capacity
Thus, Hall’s condition fails. 3
1 1
Recall: Hall’s condition - If every set of p
women does like at least p men, a
complete matching is possible n
Spanning Trees and the Greedy
Algorithm

Shortest Path Problem : fundamental network


model; edges have lengths instead of capacities

Shortest Spanning Tree : a set of n – 1 edges


connecting all the nodes of a network; used for
minimizing cost
Spanning Trees and the Greedy
Algorithm
A spanning tree connects
the nodes without loops.
1 8
One possible algorithm: s
Start from any node s and 7 5
repeat the following step –
Add the shortest edge that 2 3
connects the current tree
to a new node. 8 4
The edge lengths would
come in order 1, 2, 7, 4, 3, 6.
The total length is 23. 9 6
Spanning Trees and the Greedy
Algorithm
A spanning tree connects
the nodes without loops.
1 8
A second algorithm: s
Accept edges in increasing 7 5
order of length, rejecting
edges that complete a 2 3
loop.
The edge lengths would
8 4
come in order 1, 2, 3, 4, 6, 7.
The total length is again
23. 9 6
Spanning Trees and the Greedy
Algorithm

Notice the edges chosen were the same in both


algorithms. While this does not always happen, the
total length will always be the same.

The spanning tree problem is exceptional, because it


can be solved in one pass. It is being solved much like
back substitution, with no false steps.

The second approach is called the greedy algorithm.


Spanning Trees and the Greedy
Algorithm
Apply algorithms 1 and 2 to
find a shortest spanning
tree for the network. 2
4, 2 (up), 1, 2 (top), 2 = 11 5 1 2
1, 2 (top), 2, 2 (up), 4 = 11 2 3
4 4 7
2
Further Network Models

Optimal assignment problem : aij measures the value of


applicant i in job j. Assign jobs to maximize the total
value. (If all aij are 0 or 1, this is the marriage problem.)

Transportation problem : Given supplies at n points and


demands at n markets, choose shipments xij from
suppliers to markets that minimize the total cost ∑Cijxij.
(If all supplies and demands are 1, this is the optimal
assignment problem – sending one person to each job.)
Further Network Models

Minimum cost flow : Now the routes have capacities cij as


well as costs Cij, mixing the maximal flow problem with
the transportation problem. What is the cheapest flow,
subject to capacity constraints?

Dynamic programming : If a path from source to sink is


optimal, then each part of the path must be optimal. The
solution is built backwards from the sink, with a
multistage decision process. At each stage, the distance
to the sink is the minimum of a new distance plus an old
distance.
Bellman equation : x-t distance = minimum over y of (x-y +
y-t distances).
References

Strang, Gilbert. Linear Algebra and Its Applications.


4th ed. Belmont, CA: Thomson, Brooks/Cole, 2006.
Print.

You might also like