Grafalgo
Library of useful data structures and algorithms
/Users/jst/src/grafalgo/cpp/include/Wflograph.h
Go to the documentation of this file.
00001 
00009 #ifndef WFLOGRAPH_H
00010 #define WFLOGRAPH_H
00011 
00012 #include "stdinc.h"
00013 #include "Util.h"
00014 #include "Flograph.h"
00015 
00016 namespace grafalgo {
00017 
00018 typedef int floCost;
00019 
00025 class Wflograph : public Flograph {
00026 public:         Wflograph(int=3,int=2,int=1,int=2);
00027                 Wflograph(const Wflograph&);
00028                 virtual ~Wflograph();
00029 
00030         void    resize(int,int);        
00031         void    resize(int numv) { resize(numv,numv); }
00032         void    expand(int,int);        
00033         void    expand(int numv) { expand(numv,max(numv,m())); }
00034         void    copyFrom(const Wflograph&);
00035 
00036         virtual edge join(vertex,vertex);
00037 
00038         floCost cost(vertex,edge) const;
00039         void    setCost(edge,floCost);
00040         void    randCost(floCost,floCost);
00041 
00042         string& edge2string(edge, string&) const;
00043         string& toDotString(string&) const;
00044 
00045 protected:
00046         floCost *cst;                           
00047 
00048         // various helper methods
00049         void    makeSpace(int,int);             
00050         void    freeSpace();            
00051         void    virtual shuffle(int*, int*);
00052         bool    readAdjList(istream&);
00053         string& adjList2string(vertex,string&) const; 
00054 
00055 private:
00056         Wflograph& operator=(const Wflograph&); 
00057 };
00058 
00064 inline flow Wflograph::cost(vertex v, edge e) const { 
00065         assert(1 <= v && v <= n() && 1 <= e && e <= m());
00066         return tail(e) == v ? cst[e] : -cst[e];
00067 }
00068 
00073 inline void Wflograph::setCost(edge e, floCost c) { 
00074         assert(1 <= e && e <= m());
00075         cst[e] = c;
00076 }
00077 
00078 } // ends namespace
00079 
00080 #endif
 All Classes Files Functions Variables Typedefs Friends