5 ///\brief Classes for representing paths in graphs.
7 #ifndef HUGO_SKELETON_PATH_H
8 #define HUGO_SKELETON_PATH_H
10 #include <hugo/invalid.h>
14 /// \addtogroup skeletons
18 //! \brief A skeletom structure for representing directed paths in a graph.
20 //! A skeleton structure for representing directed paths in a graph.
21 //! \param GR The graph type in which the path is.
23 //! In a sense, the path can be treated as a graph, for is has \c NodeIt
24 //! and \c EdgeIt with the same usage. These types converts to the \c Node
25 //! and \c Edge of the original graph.
30 /// Type of the underlying graph.
31 typedef /*typename*/ GR Graph;
32 /// Edge type of the underlying graph.
33 typedef typename Graph::Edge GraphEdge;
34 /// Node type of the underlying graph.
35 typedef typename Graph::Node GraphNode;
39 /// \param _G The graph in which the path is.
41 Path(const Graph &_G) {}
43 /// Length of the path.
44 size_t length() const {return 0;}
45 /// Returns whether the path is empty.
46 bool empty() const { return true;}
48 /// Resets the path to an empty path.
51 /// \brief Starting point of the path.
53 /// Starting point of the path.
54 /// Returns INVALID if the path is empty.
55 GraphNode/*It*/ head() const {return INVALID;}
56 /// \brief End point of the path.
58 /// End point of the path.
59 /// Returns INVALID if the path is empty.
60 GraphNode/*It*/ tail() const {return INVALID;}
62 /// \brief First NodeIt/EdgeIt.
64 /// Initializes node or edge iterator to point to the first
67 It& first(It &i) const { return i=It(*this); }
69 /// \brief The head of an edge.
71 /// Returns node iterator pointing to the head node of the
72 /// given edge iterator.
73 NodeIt head(const EdgeIt& e) const {return INVALID;}
75 /// \brief The tail of an edge.
77 /// Returns node iterator pointing to the tail node of the
78 /// given edge iterator.
79 NodeIt tail(const EdgeIt& e) const {return INVALID;}
82 /* Iterator classes */
85 * \brief Iterator class to iterate on the edges of the paths
88 * This class is used to iterate on the edges of the paths
90 * Of course it converts to Graph::Edge
95 /// Default constructor
97 /// Invalid constructor
99 /// Constructor with starting point
100 EdgeIt(const Path &_p) {}
102 operator GraphEdge () const {}
105 EdgeIt& operator++() {return *this;}
107 /// Comparison operator
108 bool operator==(const EdgeIt& e) const {return true;}
109 /// Comparison operator
110 bool operator!=(const EdgeIt& e) const {return true;}
111 // /// Comparison operator
112 // /// \todo It is not clear what is the "natural" ordering.
113 // bool operator<(const EdgeIt& e) const {}
118 * \brief Iterator class to iterate on the nodes of the paths
121 * This class is used to iterate on the nodes of the paths
123 * Of course it converts to Graph::Node.
128 /// Default constructor
130 /// Invalid constructor
132 /// Constructor with starting point
133 NodeIt(const Path &_p) {}
135 ///Conversion to Graph::Node
136 operator const GraphNode& () const {}
138 NodeIt& operator++() {return *this;}
140 /// Comparison operator
141 bool operator==(const NodeIt& e) const {return true;}
142 /// Comparison operator
143 bool operator!=(const NodeIt& e) const {return true;}
144 // /// Comparison operator
145 // /// \todo It is not clear what is the "natural" ordering.
146 // bool operator<(const NodeIt& e) const {}
150 friend class Builder;
153 * \brief Class to build paths
156 * This class is used to fill a path with edges.
158 * You can push new edges to the front and to the back of the path in
159 * arbitrary order then you should commit these changes to the graph.
161 * While the builder is active (after the first modifying
162 * operation and until the call of \ref commit())
163 * the underlining Path is in a
164 * "transitional" state (operations on it have undefined result).
171 ///\param _P the path you want to fill in.
173 Builder(Path &_P) : P(_P) {}
175 /// Sets the starting node of the path.
177 /// Sets the starting node of the path. Edge added to the path
178 /// afterwards have to be incident to this node.
179 /// You \em must start building an empry path with this functions.
180 /// (And you \em must \em not use it later).
183 void setStartNode(const GraphNode &) {}
185 ///Push a new edge to the front of the path
187 ///Push a new edge to the front of the path.
188 ///If the path is empty, you \em must call \ref setStartNode() before
189 ///the first use of \ref pushFront().
190 void pushFront(const GraphEdge& e) {}
192 ///Push a new edge to the back of the path
194 ///Push a new edge to the back of the path.
195 ///If the path is empty, you \em must call \ref setStartNode() before
196 ///the first use of \ref pushBack().
197 void pushBack(const GraphEdge& e) {}
199 ///Commit the changes to the path.
202 ///Reserve (front) storage for the builder in advance.
204 ///If you know an reasonable upper bound of the number of the edges
205 ///to add to the front of the path,
206 ///using this function you may speed up the building.
207 void reserveFront(size_t r) {}
208 ///Reserve (back) storage for the builder in advance.
210 ///If you know an reasonable upper bound of the number of the edges
211 ///to add to the back of the path,
212 ///using this function you may speed up the building.
213 void reserveBack(size_t r) {}
222 #endif // HUGO_SKELETON_PATH_H