Grafalgo
Library of useful data structures and algorithms
/Users/jst/src/grafalgo/cpp/graphAlgorithms/maxFlo/augPath.cpp
Go to the documentation of this file.
00001 
00009 #include "Adt.h"
00010 #include "augPath.h"
00011 
00012 using namespace grafalgo;
00013 
00018 augPath::augPath(Flograph& fg1, int& flow_value) : fg(&fg1) {
00019         pEdge = new edge[fg->n()+1];
00020 }
00021 
00022 augPath::~augPath() { delete [] pEdge; }
00023 
00024 int augPath::augment() {
00025 // Saturate the augmenting path p.
00026         vertex u, v; edge e; flow f;
00027 
00028         // determine residual capacity of path
00029         f = Util::BIGINT32;
00030         u = fg->snk(); e = pEdge[u];
00031         while (u != fg->src()) {
00032                 v = fg->mate(u,e);
00033                 f = min(f,fg->res(v,e));
00034                 u = v; e = pEdge[u];
00035         }
00036         // add flow to saturate path
00037         u = fg->snk(); e = pEdge[u];
00038         while (u != fg->src()) {
00039                 v = fg->mate(u,e);
00040                 fg->addFlow(v,e,f);
00041                 u = v; e = pEdge[u];
00042         }
00043         return f;
00044 }
 All Classes Files Functions Variables Typedefs Friends