Grafalgo
Library of useful data structures and algorithms
/Users/jst/src/grafalgo/cpp/include/Mflograph.h
Go to the documentation of this file.
00001 
00009 #ifndef MFLOGRAPH_H
00010 #define MFLOGRAPH_H
00011 
00012 #include "stdinc.h"
00013 #include "Util.h"
00014 #include "Flograph.h"
00015 
00016 namespace grafalgo {
00017 
00022 class Mflograph : public Flograph {
00023 public:         Mflograph(int=3,int=2,int=1,int=2);
00024                 virtual ~Mflograph();
00025 
00026         void    resize(int,int);        
00027         void    resize(int numv) { resize(numv,numv); }
00028         void    expand(int,int);        
00029         void    expand(int numv) { expand(numv,max(numv,m())); }
00030         void    copyFrom(const Mflograph&);
00031 
00032         flow    res(vertex, edge) const;
00033         virtual edge join(vertex,vertex);
00034 
00035         flow    minFlo(edge) const;
00036         void    setMinFlo(edge,flow);
00037         void    randMinFlo(flow,flow);
00038 
00039         string& edge2string(edge, string&) const;
00040         string& toDotString(string&) const;
00041 
00042 protected:
00043         flow    *mflo;                          
00044 
00045         // various helper methods
00046         void    makeSpace(int,int);             
00047         void    freeSpace();            
00048         void    virtual shuffle(int*, int*);
00049         bool    readAdjList(istream&);
00050         string& adjList2string(vertex,string&) const; 
00051 
00052 private:
00053         Mflograph& operator=(const Mflograph&); 
00054 };
00055 
00061 inline flow Mflograph::minFlo(edge e) const { 
00062         assert(1 <= e && e <= m());
00063         return mflo[e];
00064 }
00065 
00072 inline void Mflograph::setMinFlo(edge e, flow c) { 
00073         assert(1 <= e && e <= m());
00074         mflo[e] = min(c,cap(tail(e),e));
00075 }
00076 
00082 inline flow Mflograph::res(vertex v, edge e) const {
00083         assert(1 <= v && v <= n() && 1 <= e && e <= m());
00084         return tail(e) == v ? floInfo[e].cpy - floInfo[e].flo
00085                             : floInfo[e].flo - mflo[e];
00086 }
00087 
00088 } // ends namespace
00089 
00090 #endif
 All Classes Files Functions Variables Typedefs Friends