# HG changeset patch # User alpar # Date 1094415107 0 # Node ID bc0c74eeb15136c56fbcaed837997f29c343634b # Parent 48638058e1883dbc63d041c8181d1066de71c5cd - Changes in doc - setGraph(...) finally removed from Dijkstra, Bfs and Dfs. diff -r 48638058e188 -r bc0c74eeb151 src/hugo/bfs.h --- a/src/hugo/bfs.h Sun Sep 05 20:06:08 2004 +0000 +++ b/src/hugo/bfs.h Sun Sep 05 20:11:47 2004 +0000 @@ -34,9 +34,13 @@ public: ///The type of the underlying graph. typedef GR Graph; + ///. typedef typename Graph::Node Node; + ///. typedef typename Graph::NodeIt NodeIt; + ///. typedef typename Graph::Edge Edge; + ///. typedef typename Graph::OutEdgeIt OutEdgeIt; ///\brief The type of the map that stores the last @@ -49,15 +53,22 @@ typedef typename Graph::template NodeMap DistMap; private: + /// Pointer to the underlying graph. const Graph *G; + ///Pointer to the map of predecessors edges. PredMap *predecessor; + ///Indicates if \ref predecessor is locally allocated (\c true) or not. bool local_predecessor; + ///Pointer to the map of predecessors nodes. PredNodeMap *pred_node; + ///Indicates if \ref pred_node is locally allocated (\c true) or not. bool local_pred_node; + ///Pointer to the map of distances. DistMap *distance; + ///Indicates if \ref distance is locally allocated (\c true) or not. bool local_distance; - //The source node of the last execution. + ///The source node of the last execution. Node source; @@ -79,6 +90,9 @@ } public : + ///Constructor. + + ///\param _G the graph the algorithm will run on. Bfs(const Graph& _G) : G(&_G), predecessor(NULL), local_predecessor(false), @@ -86,6 +100,7 @@ distance(NULL), local_distance(false) { } + ///Destructor. ~Bfs() { if(local_predecessor) delete predecessor; @@ -93,17 +108,6 @@ if(local_distance) delete distance; } - ///Sets the graph the algorithm will run on. - - ///Sets the graph the algorithm will run on. - ///\return (*this) - ///\bug What about maps? - ///\todo It may be unnecessary - Bfs &setGraph(const Graph &_G) - { - G = &_G; - return *this; - } ///Sets the map storing the predecessor edges. ///Sets the map storing the predecessor edges. @@ -249,7 +253,7 @@ ///Checks if a node is reachable from the root. ///Returns \c true if \c v is reachable from the root. - ///\warning The root node is reported to be reached! + ///\note The root node is reported to be reached! /// ///\pre \ref run() must be called before using this function. /// diff -r 48638058e188 -r bc0c74eeb151 src/hugo/dfs.h --- a/src/hugo/dfs.h Sun Sep 05 20:06:08 2004 +0000 +++ b/src/hugo/dfs.h Sun Sep 05 20:11:47 2004 +0000 @@ -33,9 +33,13 @@ public: ///The type of the underlying graph. typedef GR Graph; + /// . typedef typename Graph::Node Node; + /// . typedef typename Graph::NodeIt NodeIt; + /// . typedef typename Graph::Edge Edge; + /// . typedef typename Graph::OutEdgeIt OutEdgeIt; ///\brief The type of the map that stores the last @@ -48,15 +52,22 @@ typedef typename Graph::template NodeMap DistMap; private: + /// Pointer to the underlying graph. const Graph *G; + ///Pointer to the map of predecessors edges. PredMap *predecessor; + ///Indicates if \ref predecessor is locally allocated (\c true) or not. bool local_predecessor; + ///Pointer to the map of predecessors nodes. PredNodeMap *pred_node; + ///Indicates if \ref pred_node is locally allocated (\c true) or not. bool local_pred_node; + ///Pointer to the map of distances. DistMap *distance; + ///Indicates if \ref distance is locally allocated (\c true) or not. bool local_distance; - //The source node of the last execution. + ///The source node of the last execution. Node source; @@ -78,6 +89,9 @@ } public : + ///Constructor. + + ///\param _G the graph the algorithm will run on. Dfs(const Graph& _G) : G(&_G), predecessor(NULL), local_predecessor(false), @@ -85,6 +99,7 @@ distance(NULL), local_distance(false) { } + ///Destructor. ~Dfs() { if(local_predecessor) delete predecessor; @@ -92,17 +107,6 @@ if(local_distance) delete distance; } - ///Sets the graph the algorithm will run on. - - ///Sets the graph the algorithm will run on. - ///\return (*this) - ///\bug What about maps? - ///\todo It may be unnecessary - Dfs &setGraph(const Graph &_G) - { - G = &_G; - return *this; - } ///Sets the map storing the predecessor edges. ///Sets the map storing the predecessor edges. @@ -253,7 +257,7 @@ ///Checks if a node is reachable from the root. ///Returns \c true if \c v is reachable from the root. - ///\warning The root node is reported to be reached! + ///\note The root node is reported to be reached! /// ///\pre \ref run() must be called before using this function. /// diff -r 48638058e188 -r bc0c74eeb151 src/hugo/dijkstra.h --- a/src/hugo/dijkstra.h Sun Sep 05 20:06:08 2004 +0000 +++ b/src/hugo/dijkstra.h Sun Sep 05 20:11:47 2004 +0000 @@ -55,9 +55,13 @@ public: ///The type of the underlying graph. typedef GR Graph; + ///. typedef typename Graph::Node Node; + ///. typedef typename Graph::NodeIt NodeIt; + ///. typedef typename Graph::Edge Edge; + ///. typedef typename Graph::OutEdgeIt OutEdgeIt; ///The type of the length of the edges. @@ -74,17 +78,24 @@ typedef typename Graph::template NodeMap DistMap; private: + /// Pointer to the underlying graph. const Graph *G; + /// Pointer to the length map const LM *length; - // bool local_length; + ///Pointer to the map of predecessors edges. PredMap *predecessor; + ///Indicates if \ref predecessor is locally allocated (\c true) or not. bool local_predecessor; + ///Pointer to the map of predecessors nodes. PredNodeMap *pred_node; + ///Indicates if \ref pred_node is locally allocated (\c true) or not. bool local_pred_node; + ///Pointer to the map of distances. DistMap *distance; + ///Indicates if \ref distance is locally allocated (\c true) or not. bool local_distance; - //The source node of the last execution. + ///The source node of the last execution. Node source; ///Initializes the maps. @@ -93,10 +104,6 @@ ///\todo Better memory allocation (instead of new). void init_maps() { -// if(!length) { -// local_length = true; -// length = new LM(G); -// } if(!predecessor) { local_predecessor = true; predecessor = new PredMap(*G); @@ -112,7 +119,10 @@ } public : + ///Constructor. + ///\param _G the graph the algorithm will run on. + ///\param _length the length map used by the algorithm. Dijkstra(const Graph& _G, const LM& _length) : G(&_G), length(&_length), predecessor(NULL), local_predecessor(false), @@ -120,35 +130,20 @@ distance(NULL), local_distance(false) { } + ///Destructor. ~Dijkstra() { - // if(local_length) delete length; if(local_predecessor) delete predecessor; if(local_pred_node) delete pred_node; if(local_distance) delete distance; } - ///Sets the graph the algorithm will run on. - - ///Sets the graph the algorithm will run on. - ///\return (*this) - ///\bug What about maps? - ///\todo It may be unnecessary - Dijkstra &setGraph(const Graph &_G) - { - G = &_G; - return *this; - } ///Sets the length map. ///Sets the length map. ///\return (*this) Dijkstra &setLengthMap(const LM &m) { -// if(local_length) { -// delete length; -// local_length=false; -// } length = &m; return *this; } @@ -317,7 +312,7 @@ ///Checks if a node is reachable from the root. ///Returns \c true if \c v is reachable from the root. - ///\warning the root node is reported to be reached! + ///\note The root node is reported to be reached! ///\pre \ref run() must be called before using this function. /// bool reached(Node v) { return v==source || (*predecessor)[v]!=INVALID; }