This preview shows pages 1–16. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: ' n "i . hmgto Unnemts mSt Lows Engineering Minimum Cost Network Flows
and Shortest Paths for Graphs
with Negative Edge Lengths Jon Turner
Computer Science & Engineering
Washington University www.ar1.wustl.edu/~jst E Washington University in St. Louis Minimum Cost Flows cap,cost
\‘ 6,1 Engineering  Max flow can be generalized by adding edge costs >> costs are skew symmetric; cost(v,w)=cost(w,v) >> for flow f, cost'(f)=>:,r(\,/W)>Ocost(v,w)f(v,w)=2V1W cost(v,w)f(v,w)/2 >> cost of path is defined as sum of edge costs and residual graph is
defined as before; cost(v,w) in R is same as in G >> A flow f has minimum cost if there is no flow 9 with g=f that
has lower cost than f >> mincost, maxflow problem: seek min cost flow with max value IGeneral strategies for finding minimum cost flows
>>cost reduction — add flow to negative cost cycles in R
>>min cost augmentation  add flow to min cost augmenting paths 2 $Msh1ngton UanCFSIthStlDUIS Engineering BreadthFirst Scanning .Variant of scanning & labelling method; at each step, select vertex that least recently became labeled
procedure breadthFirst(graph G=(V,E), vertex 3,
mapping p:vertex—>vertex);
vertex v; list queue;
for VEV=> dist(v):=oc; p(v):=nu; rof;
dist(s):=0; queue:=[s]; // contains all label/ed vertices
do queue g =>
v := queue(1); queue := queue[2..];
for [v,w] E out(v) =>
if dist(v)+length(v,w)<dist(w) =>
p(w):=v; dist(w):=dist(v)+length(v,w); f_ if wEuneue => queue:=queue & [w]; fi;
I; rof;
_od; E Washington University in St. Louis Engineering Analysis of BreadthFirst Scanning  Divide execution into passes >>pass 0 ends after vertex 5 is scanned for the first time. >>passj ends after every vertex on queue at end of pass j—1
has been scanned >> the time for each pass is O(m) ITheorem 7.7. If no negative cycle is reachable from s,
the breadthfirst algorithm runs in O(mn) time stopping
after at most pass n—l; otherwise it never halts Proof. Show by induction on k that if there is a shortest path from s to v with k edges, then dist(v) will equal the length of
this path by the end of pass k—l Basis: k=1. After pass 0, dist(w)=/ength(s,w), for every
edge [s,w] $Wash1ngton UanCFSIthStlDUIS Engineering Induction: assume that after pass k—1, for every vertex v
with a shortest path from s with k edges, dist(v) is the
length of this path >> let w be any vertex that has a shortest path from s with k+1
edges and let v be its predecessor on this path >> since dist(v) is length of a shortest path from s to v, dist(v)
+length(v,w) is length of a shortest path from s to w >> when dist(v) receives this value, v is placed on the queue >> since this happens before end of pass k—1, v will be removed
from queue before end of pass k >> when v is removed from queue, dist(w) is set to dist(v)+/ength
(v,w) and w is placed on queue >> hence dist(w) equals the length of a shortest path from s by
the end of pass k I ITheorem 7.7 implies Theorem 7.2 :1, Mshmgton UniversuymStioms Engineering Review Questions 1. Draw a flow graph with at least 8 vertices and 12 edges. Assign a positive capacity
and cost to each edge. Add flow along three augmenting paths from the source to
the sink (you may choose any augmenting paths). Compute the total cost of your
flow. Does the residual graph for your flow contain any negative cycles? If so
identify one. If not, what does that tell you about your flow? . Draw a directed graph with at least five vertices and eight edges. Assign lengths to
all the edges, including a few negative lengths. Be careful not to introduce any
negative length cycles. Now, use the breadthfirst scanning algorithm to find a
shortest path tree from vertex a. Are there any vertices that are placed on the queue more than once? If so, name at least one.
. In your example from question 2, how many passes are completed during the execution of the algorithm (using the definition of pass given on the top of page 4).
List the vertices on the queue at the start of each pass. $Mshmgton UanCFSIthStlDUIS Engineering Making BreadthFirst Algorithm Robust .To ensure that breadthfirst algorithm always halts, count passes
procedure breadthFirst(digraph G=(V,E), vertex 3,
mapping p:vertex—>vertex);
integer pass; vertex v, last; list queue; for vEV=> dist(v):=oc p(v):=nul; rof;
dist(s):=0; queue:=[s]; pass:= 0; /ast:=s;
do queue :2 =>
v := queue(1); queue := queue[2..];
for [v,w] E out(v) => rof;
if V: last and queue :2 [ ] =>
pass := pass + 1; last := queue(queue) fi;
Clif pass = n => there is a negative cycle fi;
0 ;
end; $Msh1ngton UniverSItymStLouis Engineering .Lemma 7.6. If queue is nonempty at end of pass n—1,
pk(v)=v for some vertex v and positive integer k, and
by Lemma 7.5, corresponding cycle in G is negative. Proof. Define pass(v) to be the largest integerj such that v
was scanned during passj Note that if pass(v) is defined and positive then p(v) and
pass(p(v)) are defined and pass(v)spass(p(v))+1 Suppose we run the method until a vertex w is scanned in
pass n Since pass(w)=n, can follow parent pointers back from w Since pass(s)=0, and the pass values decrease by at most
one at each step we must eventually repeat some vertex I E Washington University in St. Louis Engineering Finding Negative Length Cycles I Run breadthfirst algorithm
from every vertex >> otherwise risk missing a cycle IOr, run breadthfirst on modified
graph
>> add new vertex with zero length edge to all others
>> run breadthfirst scanning from new vertex >> if still running after n passes, follow parent pointers from
each vertex to find cycles >> 0(n2) time to find cycle, so 0(mn) overall uCan get same effect by changing initialization
>> set initial distances to zero and put all vertices on queue , —
E Washington University in St. Louis Cost Reduction Method Engineering I Theorem 8.11. A flow f has min cost if and only if its
residual graph R, has no negative cost cycle Proof. If R, contains a negative cost cycle, we can reduce cost of f
without changing its value by pushing ﬂow around the cycle If fdoes not have min cost and f* is min cost flow with same value
as f, then f*—f is flow on R, with zero value and negative cost By flow conservation, f*f can be partitioned into sum of flows on
cycles; at least one of these cycles must have negative cost I ITO find a max flow of min cost >> find any max flow then repeat following step as long as possible
0 Cost reduction step: find negative cost cycle in R; push as much
flow as possible around cycle
>> for integer capacities, takes SmCy cost reduction steps, where c
is max edge capacity and y is the max edge cost; each step can be done in 0(mn) time, using breadthfirst scanning algorithm
for shortest paths In —
Engineering Minimum Cost Augmentation l Theorem 8.12. If fis a min cost flow and p is a min
cost augmenting path for f, then flow obtained by
augmenting along p is a min cost flow E Washington University in St. Louis Proof. If new flow is not min cost, then its residual graph has a negative cycle c; let H be subgraph formed from edges in c plus
edges in p (include edges that appear in both, two times) >> H is an Eulerian graph, meaning that it can be decomposed into a
simple path from s to t and a collection of simple cycles; also note that
cost(H)=cost(p)+cost(c)<cost(p) >> Construct H’ from H by removing all edge pairs {(u,v),(v,u)} where
(u,v)Ep and (v,u)€c; H’ is also Eulerian and by skew symmetry has
same cost as H; also, all edges in H’ are also in the residual graph of f,
so any cycles in H’ are non—negative >> Decompose H’ into simple s—t path and a set of cycles; since cycles are
nonnegative, st path has lower cost than p, contradicting the fact that p is a min cost augmenting path for f I II E Washington University in St. Louis Engineering Min—Cost Augmenting Path Algorithm .Find min cost flow using augmenting path algorithm
and selecting min cost paths
>> O((# of steps)(time to find a min cost augmenting path))
>> for integer capacities, number of steps is at most f* >> since residual graphs may have negative cost edges, we must
use an algorithm that can handle negative cost edges >> using breadthfirst scanning, running time is O(mnf*) 1’) E \X/ashington University in St. Louis Example network with spt and distances from s cap,cost 1 —
Engineering Step 2. showing residual graph and spt res cap,cost I? :1, Mshmgton UnwersuymStloms Engineering 2. Let G be a directed graph in which each Exercises 1.The diagram below represents the
residual graph for a flow. The numbers
next to the edges are the edge costs. 15 the flow corresponding to this residual
graph a mincost flow? Why or why not? It is not a min cost flow because the
cycle acdba has a cost of 2. Explain how you can reduce the cost by
6 if all edges in the residual graph have
capacity 3? Since the edges in the residual graph all
have capacity 3, we can push 3 units of
ﬂow around the cycle acdba. This
reduces the cost by 6. edge (u,v) has a length length(u,v)
Describe (in words) an algorithm to
determine if G has k edge disjoint paths
between a given pair of vertices with
total length no larger than a bound B. We can solve this using mincost flows,
by treating the given graph as a ﬂow
graph, with the two vertices as source
and sink. All edges are assigned
capacity 1 and the cost of each edge is
equated to the given edge length. If we do k steps of the mincost
augmenting path algorithm, the set of
augmenting paths will all be edge
disjoint. If the sum of their costs is less
than or equal the bound B, then the
algorithm succeeds. If the algorithm
terminates before ﬁnding k paths, or if
the total length of the paths found is too
large, then the original graph does not
have k edge disjoint paths with the
desired total length. I/I E Washington University in St. Louis 3.The figure below represents an instance
of the minimum cost, maximum flow
problem. What is the cost of the flow that is shown? The cost of the original flow is 46. Show the residual graph corresponding
to this flow (including the edge costs)
and show the minimum cost
augmenting path in the residual graph. —
Engineering ros. mp, Cost Show how the residual graph changes
when the minimum cost augmenting
path is saturated and show the new
minimum cost augmenting path. I: E Washington University in St. Louis 4.Take the original residual graph from
the previous problem and transform the
edge costs to make them non—negative.
Also, show the distances from s using
the transformed costs. —
Engineering Find the shortest augmenting path
using the transformed costs, add flow
to that path and show the new residual
graph with the new transformed edge
costs and new distance values. Identify
the shortest augmenting path in this
residual graph. IK ...
View
Full
Document
This note was uploaded on 03/08/2012 for the course CSE 542 taught by Professor Jonturner during the Spring '12 term at Washington State University .
 Spring '12
 JonTurner

Click to edit the document details