Grafalgo
Library of useful data structures and algorithms
|
00001 00009 #ifndef WDIGRAPH_H 00010 #define WDIGRAPH_H 00011 00012 #include "Digraph.h" 00013 00014 namespace grafalgo { 00015 00025 class Wdigraph : public Digraph { 00026 public: Wdigraph(int=1,int=1); 00027 ~Wdigraph(); 00028 00029 void resize(int, int); 00030 void resize(int numv) { resize(numv, numv); } 00031 void expand(int, int); 00032 void expand(int numv) { expand(numv, max(numv,m())); } 00033 virtual void copyFrom(const Wdigraph&); 00034 00035 // methods for accessing/changing length 00036 int length(edge) const; 00037 void setLength(edge,int); 00038 00039 // create a string representation 00040 string& edge2string(edge, string&) const; 00041 string& toDotString(string&) const; 00042 00043 void randLength(int, int); 00044 00045 private: 00046 int *len; 00047 00048 void makeSpace(int,int); 00049 void freeSpace(); 00050 bool readAdjList(istream&); 00051 string& adjList2string(vertex,string&) const; 00052 00053 Wdigraph& operator=(const Wdigraph&); 00054 }; 00055 00060 inline int Wdigraph::length(edge e) const { 00061 assert(0 <= e && e <= maxEdge); return len[e]; 00062 } 00063 00068 inline void Wdigraph::setLength(edge e, int lng) { 00069 assert(0 <= e && e <= maxEdge); len[e] = lng; 00070 } 00071 00072 } // ends namespace 00073 00074 #endif