diff -r d9fac1497298 -r 1ce1b4cd8dd5 src/work/klao/path.h --- a/src/work/klao/path.h Tue Apr 27 08:19:39 2004 +0000 +++ b/src/work/klao/path.h Tue Apr 27 08:31:00 2004 +0000 @@ -1,10 +1,8 @@ // -*- c++ -*- // -/** - * - * Class for representing paths in graphs. - * - */ +///ingroup datas +///\file +///\brief Class for representing paths in graphs. #ifndef HUGO_PATH_H #define HUGO_PATH_H @@ -17,6 +15,18 @@ namespace hugo { + /// \addtogroup datas + /// @{ + + ///A container for directed paths + + ///\param Graph The graph type in which the path is. + /// + ///In a sense, the path can be treated as a graph, for is has \c NodeIt + ///and \c EdgeIt with the same usage. These types converts to the \c Node + ///and \c Edge of the original graph. + ///\todo How to clear a path? + ///\todo Clarify the consistency checks to do. template class DirPath { public: @@ -32,13 +42,17 @@ public: + /// Constructor + + /// \param _G The graph in which the path is. + /// DirPath(const Graph &_G) : gr(&_G) {} /// Subpath defined by two nodes. - /// It is an error if the two edges are not in order! + /// \warning It is an error if the two edges are not in order! DirPath(const DirPath &P, const NodeIt &a, const NodeIt &b); /// Subpath defined by two edges. Contains edges in [a,b) - /// It is an error if the two edges are not in order! + /// \warning It is an error if the two edges are not in order! DirPath(const DirPath &P, const EdgeIt &a, const EdgeIt &b); size_t length() const { return edges.size(); } @@ -128,13 +142,36 @@ }; friend class Builder; + + ///Class to build paths + + ///\ingroup datas + ///This class is used to build new paths. + ///You can push new edges to the front and to the back of the path in + ///arbitrary order the you can commit these changes to the graph. + ///\todo We must clarify when the path will be in "transitional" state. class Builder { DirPath &P; Container d; public: + ///Constructor + + ///\param _P the path you want to build. + /// Builder(DirPath &_P) : P(_P) {} + ///Set the first node of the path. + + ///Set the first node of the path. + ///If the path is empty, this must be call before any call of + ///\ref pushFront() or \ref pushBack() + void setFirst(const GraphNode &) { } + + ///Push a new edge to the front of the path + + ///Push a new edge to the front of the path. + ///\sa setFirst() bool pushFront(const GraphEdge& e) { if( empty() || P.gr->head(e)==from() ) { d.push_back(e); @@ -142,6 +179,10 @@ } return false; } + ///Push a new edge to the back of the path + + ///Push a new edge to the back of the path. + ///\sa setFirst() bool pushBack(const GraphEdge& e) { if( empty() || P.gr->tail(e)==to() ) { P.edges.push_back(e); @@ -150,6 +191,7 @@ return false; } + ///Commit the changes to the path. void commit() { if( !d.empty() ) { P.edges.insert(P.edges.begin(), d.rbegin(), d.rend()); @@ -157,6 +199,11 @@ } } + ///Desctuctor + + ///The desctuctor. + ///It commit also commit the changes. + ///\todo Is this what we want? ~Builder() { commit(); } // FIXME: Hmm, pontosan hogy is kene ezt csinalni? @@ -199,7 +246,6 @@ - /**********************************************************************/ @@ -612,6 +658,7 @@ _last = P.graphNode(b); } + ///@} } // namespace hugo