| [325] | 1 | // -*- c++ -*- | 
|---|
| [921] | 2 | #ifndef LEMON_GRAPH_H | 
|---|
|  | 3 | #define LEMON_GRAPH_H | 
|---|
| [325] | 4 |  | 
|---|
|  | 5 | ///\file | 
|---|
| [651] | 6 | ///\brief Declaration of GraphConcept. | 
|---|
| [325] | 7 |  | 
|---|
| [921] | 8 | #include <lemon/invalid.h> | 
|---|
| [325] | 9 |  | 
|---|
| [921] | 10 | namespace lemon { | 
|---|
| [325] | 11 |  | 
|---|
| [651] | 12 | /// @defgroup empty_graph The GraphConcept class | 
|---|
| [332] | 13 | /// @{ | 
|---|
| [325] | 14 |  | 
|---|
|  | 15 | /// An empty graph class. | 
|---|
|  | 16 |  | 
|---|
|  | 17 | /// This class provides all the common features of a graph structure, | 
|---|
|  | 18 | /// however completely without implementations and real data structures | 
|---|
|  | 19 | /// behind the interface. | 
|---|
|  | 20 | /// All graph algorithms should compile with this class, but it will not | 
|---|
|  | 21 | /// run properly, of course. | 
|---|
|  | 22 | /// | 
|---|
|  | 23 | /// It can be used for checking the interface compatibility, | 
|---|
|  | 24 | /// or it can serve as a skeleton of a new graph structure. | 
|---|
|  | 25 | /// | 
|---|
|  | 26 | /// Also, you will find here the full documentation of a certain graph | 
|---|
|  | 27 | /// feature, the documentation of a real graph imlementation | 
|---|
|  | 28 | /// like @ref ListGraph or | 
|---|
|  | 29 | /// @ref SmartGraph will just refer to this structure. | 
|---|
| [651] | 30 | class GraphConcept | 
|---|
| [325] | 31 | { | 
|---|
|  | 32 | public: | 
|---|
|  | 33 | /// Defalult constructor. | 
|---|
| [651] | 34 | GraphConcept() { } | 
|---|
| [325] | 35 |  | 
|---|
| [651] | 36 | /// \brief Copy consructor. | 
|---|
|  | 37 | /// | 
|---|
|  | 38 | /// \todo It is not clear, what we expect from a copy constructor. | 
|---|
|  | 39 | /// E.g. How to assign the nodes/edges to each other? What about maps? | 
|---|
|  | 40 | GraphConcept(const GraphConcept&) { } | 
|---|
| [325] | 41 |  | 
|---|
| [651] | 42 | /// \brief The base type of the node iterators. | 
|---|
|  | 43 | /// | 
|---|
| [325] | 44 | /// This is the base type of each node iterators, | 
|---|
|  | 45 | /// thus each kind of node iterator will convert to this. | 
|---|
| [651] | 46 | /// Sometimes it is said to be a trivial iterator. | 
|---|
| [325] | 47 | class Node { | 
|---|
|  | 48 | public: | 
|---|
|  | 49 | /// @warning The default constructor sets the iterator | 
|---|
|  | 50 | /// to an undefined value. | 
|---|
| [651] | 51 | Node() { }   //FIXME | 
|---|
| [325] | 52 |  | 
|---|
| [651] | 53 | // /// Copy constructor. | 
|---|
|  | 54 | // Node(const Node&) { } | 
|---|
|  | 55 |  | 
|---|
|  | 56 | /// \brief Invalid constructor \& conversion. | 
|---|
|  | 57 | /// | 
|---|
| [325] | 58 | /// This constructor initializes the iterator to be invalid. | 
|---|
|  | 59 | /// \sa Invalid for more details. | 
|---|
| [651] | 60 | Node(const Invalid&) { } | 
|---|
|  | 61 |  | 
|---|
| [325] | 62 | /// Two iterators are equal if and only if they point to the | 
|---|
|  | 63 | /// same object or both are invalid. | 
|---|
|  | 64 | bool operator==(Node n) const { return true; } | 
|---|
|  | 65 |  | 
|---|
|  | 66 | /// \sa \ref operator==(Node n) | 
|---|
|  | 67 | /// | 
|---|
|  | 68 | bool operator!=(Node n) const { return true; } | 
|---|
|  | 69 |  | 
|---|
|  | 70 | bool operator<(Node n) const { return true; } | 
|---|
|  | 71 | }; | 
|---|
|  | 72 |  | 
|---|
|  | 73 | /// The base type of the edge iterators. | 
|---|
|  | 74 | class Edge { | 
|---|
|  | 75 | public: | 
|---|
|  | 76 | /// @warning The default constructor sets the iterator | 
|---|
|  | 77 | /// to an undefined value. | 
|---|
| [651] | 78 | Edge() { }   //FIXME | 
|---|
|  | 79 |  | 
|---|
|  | 80 | // /// Copy constructor. | 
|---|
|  | 81 | // Edge(const Edge&) { } | 
|---|
|  | 82 |  | 
|---|
| [325] | 83 | /// Initialize the iterator to be invalid | 
|---|
| [651] | 84 | Edge(const Invalid&) { } | 
|---|
| [325] | 85 | /// Two iterators are equal if and only if they point to the | 
|---|
|  | 86 | /// same object or both are invalid. | 
|---|
|  | 87 | bool operator==(Edge n) const { return true; } | 
|---|
|  | 88 | bool operator!=(Edge n) const { return true; } | 
|---|
|  | 89 | bool operator<(Edge n) const { return true; } | 
|---|
|  | 90 | }; | 
|---|
|  | 91 |  | 
|---|
|  | 92 | //  class SymEdgeIt : public Edge {}; | 
|---|
|  | 93 |  | 
|---|
|  | 94 |  | 
|---|
|  | 95 | //  SymEdgeIt &first(SymEdgeIt &, Node) const { return i;} | 
|---|
|  | 96 |  | 
|---|
|  | 97 | //     Node getNext(Node) const {} | 
|---|
|  | 98 | //     InEdgeIt getNext(InEdgeIt) const {} | 
|---|
|  | 99 | //     OutEdgeIt getNext(OutEdgeIt) const {} | 
|---|
|  | 100 | //     //SymEdgeIt getNext(SymEdgeIt) const {} | 
|---|
|  | 101 | //     EdgeIt getNext(EdgeIt) const {} | 
|---|
|  | 102 |  | 
|---|
|  | 103 | //SymEdgeIt &next(SymEdgeIt &) const {} | 
|---|
|  | 104 |  | 
|---|
| [651] | 105 |  | 
|---|
| [986] | 106 | /// Gives back the target node of an edge. | 
|---|
|  | 107 | Node target(const Edge&) const { return INVALID; } | 
|---|
|  | 108 | /// Gives back the source node of an edge. | 
|---|
|  | 109 | Node source(const Edge&) const { return INVALID; } | 
|---|
| [325] | 110 |  | 
|---|
|  | 111 | //   Node aNode(SymEdgeIt) const {} | 
|---|
|  | 112 | //   Node bNode(SymEdgeIt) const {} | 
|---|
|  | 113 |  | 
|---|
| [651] | 114 | /// \brief Checks if a node iterator is valid | 
|---|
|  | 115 | /// | 
|---|
|  | 116 | /// \todo Maybe, it would be better if iterator converted to | 
|---|
|  | 117 | /// bool directly, as Jacint prefers. | 
|---|
|  | 118 | bool valid(const Node&) const { return true; } | 
|---|
|  | 119 | /// \brief Checks if an edge iterator is valid | 
|---|
|  | 120 | /// | 
|---|
|  | 121 | /// \todo Maybe, it would be better if iterator converted to | 
|---|
|  | 122 | /// bool directly, as Jacint prefers. | 
|---|
|  | 123 | bool valid(const Edge&) const { return true; } | 
|---|
| [325] | 124 |  | 
|---|
| [651] | 125 | /// \brief Gives back the \e id of a node. | 
|---|
|  | 126 | /// | 
|---|
|  | 127 | /// \warning Not all graph structures provide this feature. | 
|---|
| [325] | 128 | /// | 
|---|
| [651] | 129 | int id(const Node&) const { return 0; } | 
|---|
|  | 130 | /// \brief Gives back the \e id of an edge. | 
|---|
| [325] | 131 | /// | 
|---|
| [651] | 132 | /// \warning Not all graph structures provide this feature. | 
|---|
|  | 133 | /// | 
|---|
|  | 134 | int id(const Edge&) const { return 0; } | 
|---|
| [325] | 135 |  | 
|---|
|  | 136 | //void setInvalid(Node &) const {}; | 
|---|
|  | 137 | //void setInvalid(Edge &) const {}; | 
|---|
|  | 138 |  | 
|---|
| [651] | 139 | /// \brief Add a new node to the graph. | 
|---|
|  | 140 | /// | 
|---|
| [325] | 141 | /// \return the new node. | 
|---|
| [651] | 142 | Node addNode() { return INVALID; } | 
|---|
|  | 143 | /// \brief Add a new edge to the graph. | 
|---|
| [325] | 144 | /// | 
|---|
| [986] | 145 | /// Add a new edge to the graph with source node \c source | 
|---|
|  | 146 | /// and target node \c target. | 
|---|
| [651] | 147 | /// \return the new edge. | 
|---|
| [986] | 148 | Edge addEdge(const Node& source, const Node& target) { return INVALID; } | 
|---|
| [325] | 149 |  | 
|---|
| [651] | 150 | /// \brief Resets the graph. | 
|---|
|  | 151 | /// | 
|---|
| [325] | 152 | /// This function deletes all edges and nodes of the graph. | 
|---|
|  | 153 | /// It also frees the memory allocated to store them. | 
|---|
| [651] | 154 | /// \todo What happens with the maps? | 
|---|
|  | 155 | void clear() { } | 
|---|
| [325] | 156 |  | 
|---|
| [651] | 157 | /// Read/write/reference map of the nodes to type \c T. | 
|---|
| [325] | 158 |  | 
|---|
| [651] | 159 | /// Read/write/reference map of the nodes to type \c T. | 
|---|
|  | 160 | /// \sa MemoryMapConcept | 
|---|
| [325] | 161 | /// \todo We may need copy constructor | 
|---|
|  | 162 | /// \todo We may need conversion from other nodetype | 
|---|
|  | 163 | /// \todo We may need operator= | 
|---|
|  | 164 | /// \warning Making maps that can handle bool type (NodeMap<bool>) | 
|---|
|  | 165 | /// needs extra attention! | 
|---|
|  | 166 |  | 
|---|
|  | 167 | template<class T> class NodeMap | 
|---|
|  | 168 | { | 
|---|
|  | 169 | public: | 
|---|
| [987] | 170 | typedef T Value; | 
|---|
|  | 171 | typedef Node Key; | 
|---|
| [325] | 172 |  | 
|---|
| [651] | 173 | NodeMap(const GraphConcept& g) { } | 
|---|
|  | 174 | NodeMap(const GraphConcept& g, T t) { } | 
|---|
| [325] | 175 |  | 
|---|
| [651] | 176 | template<typename TT> NodeMap(const NodeMap<TT>& m) { } | 
|---|
| [325] | 177 |  | 
|---|
|  | 178 | /// Sets the value of a node. | 
|---|
|  | 179 |  | 
|---|
|  | 180 | /// Sets the value associated with node \c i to the value \c t. | 
|---|
|  | 181 | /// | 
|---|
|  | 182 | void set(Node i, T t) {} | 
|---|
|  | 183 | /// Gets the value of a node. | 
|---|
|  | 184 | T get(Node i) const {return *(T*)0;}  //FIXME: Is it necessary | 
|---|
|  | 185 | T &operator[](Node i) {return *(T*)0;} | 
|---|
|  | 186 | const T &operator[](Node i) const {return *(T*)0;} | 
|---|
|  | 187 |  | 
|---|
|  | 188 | /// Updates the map if the graph has been changed | 
|---|
|  | 189 |  | 
|---|
|  | 190 | /// \todo Do we need this? | 
|---|
|  | 191 | /// | 
|---|
| [651] | 192 | void update() { } | 
|---|
|  | 193 | //void update(T a) { }   //FIXME: Is it necessary | 
|---|
| [325] | 194 | }; | 
|---|
|  | 195 |  | 
|---|
|  | 196 | ///Read/write/reference map of the edges to type \c T. | 
|---|
|  | 197 |  | 
|---|
| [651] | 198 | /// Read/write/reference map of the edges to type \c T. | 
|---|
|  | 199 | /// It behaves exactly in the same way as \ref NodeMap. | 
|---|
| [325] | 200 | /// \sa NodeMap | 
|---|
| [651] | 201 | /// \sa MemoryMapConcept | 
|---|
| [325] | 202 | /// \todo We may need copy constructor | 
|---|
|  | 203 | /// \todo We may need conversion from other edgetype | 
|---|
|  | 204 | /// \todo We may need operator= | 
|---|
|  | 205 | template<class T> class EdgeMap | 
|---|
|  | 206 | { | 
|---|
|  | 207 | public: | 
|---|
| [987] | 208 | typedef T Value; | 
|---|
|  | 209 | typedef Edge Key; | 
|---|
| [325] | 210 |  | 
|---|
| [651] | 211 | EdgeMap(const GraphConcept& g) {} | 
|---|
|  | 212 | EdgeMap(const GraphConcept& g, T t) {} | 
|---|
| [325] | 213 |  | 
|---|
|  | 214 | void set(Edge i, T t) {} | 
|---|
|  | 215 | T get(Edge i) const {return *(T*)0;} | 
|---|
|  | 216 | T &operator[](Edge i) {return *(T*)0;} | 
|---|
|  | 217 |  | 
|---|
| [651] | 218 | void update() { } | 
|---|
|  | 219 | //void update(T a) { }   //FIXME: Is it necessary | 
|---|
| [325] | 220 | }; | 
|---|
|  | 221 | }; | 
|---|
|  | 222 |  | 
|---|
| [651] | 223 |  | 
|---|
|  | 224 | /// \brief Node-iterable graph concept. | 
|---|
| [325] | 225 | /// | 
|---|
| [651] | 226 | /// A graph class which provides functions to | 
|---|
|  | 227 | /// iterate on its nodes. | 
|---|
|  | 228 | class NodeIterableGraphConcept : virtual public GraphConcept | 
|---|
| [334] | 229 | { | 
|---|
|  | 230 | public: | 
|---|
|  | 231 |  | 
|---|
| [651] | 232 | /// \brief This iterator goes trough the nodes of the graph. | 
|---|
|  | 233 | /// | 
|---|
|  | 234 | /// This iterator goes trough the \e nodes of the graph. | 
|---|
|  | 235 | /// Its usage is quite simple, for example you can count the number | 
|---|
|  | 236 | /// of nodes in graph \c g of type \c Graph as follows. | 
|---|
|  | 237 | /// \code | 
|---|
|  | 238 | /// int count=0; | 
|---|
|  | 239 | /// for(Graph::NodeIt n(g); g.valid(n); g.next(n)) ++count; | 
|---|
|  | 240 | /// \endcode | 
|---|
|  | 241 | class NodeIt : public Node { | 
|---|
|  | 242 | public: | 
|---|
|  | 243 | /// @warning The default constructor sets the iterator. | 
|---|
|  | 244 | /// to an undefined value. | 
|---|
|  | 245 | NodeIt() { } | 
|---|
|  | 246 | // /// Copy constructor | 
|---|
|  | 247 | //NodeIt(const NodeIt& n) { } | 
|---|
|  | 248 | /// Initialize the iterator to be invalid. | 
|---|
|  | 249 | NodeIt(const Invalid&) { } | 
|---|
|  | 250 | /// \brief This constructor sets the iterator to first node. | 
|---|
|  | 251 | /// | 
|---|
|  | 252 | /// This constructor set the iterator to the first | 
|---|
|  | 253 | /// node of the graph \c g. | 
|---|
|  | 254 | /// | 
|---|
|  | 255 | ///@param g the graph | 
|---|
|  | 256 | NodeIt(const GraphConcept& g) { } | 
|---|
|  | 257 | }; | 
|---|
| [334] | 258 |  | 
|---|
| [651] | 259 | /// The first node. | 
|---|
|  | 260 | NodeIt &first(NodeIt &i) const { return i; } | 
|---|
|  | 261 |  | 
|---|
|  | 262 | /// Go to the next node. | 
|---|
|  | 263 | NodeIt &next(NodeIt &i) const { return i; } | 
|---|
|  | 264 | }; | 
|---|
|  | 265 |  | 
|---|
|  | 266 |  | 
|---|
|  | 267 | /// \brief Edge-iterable graph concept. | 
|---|
|  | 268 | /// | 
|---|
|  | 269 | /// A graph class which provides functions to | 
|---|
|  | 270 | /// iterate on its edges. | 
|---|
|  | 271 | class EdgeIterableGraphConcept : virtual public GraphConcept | 
|---|
|  | 272 | { | 
|---|
|  | 273 | public: | 
|---|
|  | 274 |  | 
|---|
|  | 275 | /// \brief This iterator goes trough the edges of the graph. | 
|---|
|  | 276 | /// | 
|---|
|  | 277 | /// This iterator goes trough the \e edges of the graph. | 
|---|
|  | 278 | /// Its usage is quite simple, for example you can count the number | 
|---|
|  | 279 | /// of edges in graph \c g of type \c Graph as follows. | 
|---|
|  | 280 | /// \code | 
|---|
|  | 281 | /// int count=0; | 
|---|
|  | 282 | /// for(Graph::EdgeIt e(g); g.valid(e); g.next(e)) ++count; | 
|---|
|  | 283 | /// \endcode | 
|---|
|  | 284 | class EdgeIt : public Edge { | 
|---|
|  | 285 | public: | 
|---|
|  | 286 | /// @warning The default constructor sets the iterator. | 
|---|
|  | 287 | /// to an undefined value. | 
|---|
|  | 288 | EdgeIt() { } | 
|---|
|  | 289 | // /// Copy constructor | 
|---|
|  | 290 | // EdgeIt(const EdgeIt&) { } | 
|---|
|  | 291 | /// Initialize the iterator to be invalid. | 
|---|
|  | 292 | EdgeIt(const Invalid&) { } | 
|---|
|  | 293 | /// \brief This constructor sets the iterator to first edge. | 
|---|
|  | 294 | /// | 
|---|
|  | 295 | /// This constructor set the iterator to the first | 
|---|
|  | 296 | /// edge of the graph \c g. | 
|---|
|  | 297 | /// | 
|---|
|  | 298 | ///@param g the graph | 
|---|
|  | 299 | EdgeIt(const GraphConcept& g) { } | 
|---|
|  | 300 | }; | 
|---|
|  | 301 |  | 
|---|
|  | 302 | /// The first edge. | 
|---|
|  | 303 | EdgeIt &first(EdgeIt &i) const { return i; } | 
|---|
|  | 304 |  | 
|---|
|  | 305 | /// Go to the next edge. | 
|---|
|  | 306 | EdgeIt &next(EdgeIt &i) const { return i; } | 
|---|
|  | 307 | }; | 
|---|
|  | 308 |  | 
|---|
|  | 309 |  | 
|---|
|  | 310 | /// \brief Out-edge-iterable graph concept. | 
|---|
|  | 311 | /// | 
|---|
|  | 312 | /// A graph class which provides functions to | 
|---|
|  | 313 | /// iterate on out-edges of any node. | 
|---|
|  | 314 | class OutEdgeIterableGraphConcept : virtual public GraphConcept | 
|---|
|  | 315 | { | 
|---|
|  | 316 | public: | 
|---|
|  | 317 |  | 
|---|
|  | 318 | /// \brief This iterator goes trough the outgoing edges of a node. | 
|---|
|  | 319 | /// | 
|---|
| [334] | 320 | /// This iterator goes trough the \e outgoing edges of a certain node | 
|---|
|  | 321 | /// of a graph. | 
|---|
|  | 322 | /// Its usage is quite simple, for example you can count the number | 
|---|
|  | 323 | /// of outgoing edges of a node \c n | 
|---|
| [651] | 324 | /// in graph \c g of type \c Graph as follows. | 
|---|
| [334] | 325 | /// \code | 
|---|
| [651] | 326 | /// int count=0; | 
|---|
|  | 327 | /// for(Graph::OutEdgeIt e(g, n); g.valid(e); g.next(e)) ++count; | 
|---|
| [334] | 328 | /// \endcode | 
|---|
|  | 329 | class OutEdgeIt : public Edge { | 
|---|
|  | 330 | public: | 
|---|
| [651] | 331 | /// @warning The default constructor sets the iterator. | 
|---|
| [334] | 332 | /// to an undefined value. | 
|---|
| [651] | 333 | OutEdgeIt() { } | 
|---|
|  | 334 | /// Initialize the iterator to be invalid. | 
|---|
|  | 335 | OutEdgeIt(const Invalid&) { } | 
|---|
|  | 336 | /// \brief This constructor sets the iterator to first outgoing edge. | 
|---|
|  | 337 | /// | 
|---|
| [334] | 338 | /// This constructor set the iterator to the first outgoing edge of | 
|---|
|  | 339 | /// node | 
|---|
|  | 340 | ///@param n the node | 
|---|
| [651] | 341 | ///@param g the graph | 
|---|
|  | 342 | OutEdgeIt(const GraphConcept& g, const Node& n) { } | 
|---|
| [334] | 343 | }; | 
|---|
| [651] | 344 |  | 
|---|
|  | 345 | /// The first outgoing edge. | 
|---|
|  | 346 | OutEdgeIt &first(OutEdgeIt &i, const Node& n) const { return i; } | 
|---|
|  | 347 |  | 
|---|
|  | 348 | /// Go to the next outgoing edge. | 
|---|
|  | 349 | OutEdgeIt &next(OutEdgeIt &i) const { return i; } | 
|---|
|  | 350 |  | 
|---|
|  | 351 | Node aNode(const OutEdgeIt&) const { return Node(); } | 
|---|
|  | 352 | Node bNode(const OutEdgeIt&) const { return Node(); } | 
|---|
| [334] | 353 | }; | 
|---|
|  | 354 |  | 
|---|
| [651] | 355 |  | 
|---|
|  | 356 | /// \brief In-edge-iterable graph concept. | 
|---|
|  | 357 | /// | 
|---|
|  | 358 | /// A Graph class which provides a function to | 
|---|
| [334] | 359 | /// iterate on in-edges of any node. | 
|---|
| [651] | 360 | class InEdgeIterableGraphConcept : virtual public GraphConcept | 
|---|
| [334] | 361 | { | 
|---|
|  | 362 | public: | 
|---|
|  | 363 |  | 
|---|
| [651] | 364 | /// \brief This iterator goes trough the incoming edges of a node. | 
|---|
|  | 365 | /// | 
|---|
| [334] | 366 | /// This iterator goes trough the \e incoming edges of a certain node | 
|---|
|  | 367 | /// of a graph. | 
|---|
|  | 368 | /// Its usage is quite simple, for example you can count the number | 
|---|
|  | 369 | /// of incoming edges of a node \c n | 
|---|
| [651] | 370 | /// in graph \c g of type \c Graph as follows. | 
|---|
| [334] | 371 | /// \code | 
|---|
| [651] | 372 | /// int count=0; | 
|---|
|  | 373 | /// for(Graph::InEdgeIt e(g, n); g.valid(e); g.next(e)) ++count; | 
|---|
| [334] | 374 | /// \endcode | 
|---|
|  | 375 | class InEdgeIt : public Edge { | 
|---|
|  | 376 | public: | 
|---|
|  | 377 | /// @warning The default constructor sets the iterator | 
|---|
|  | 378 | /// to an undefined value. | 
|---|
| [651] | 379 | InEdgeIt() { } | 
|---|
| [334] | 380 | /// Initialize the iterator to be invalid | 
|---|
| [651] | 381 | InEdgeIt(const Invalid&) { } | 
|---|
|  | 382 | /// \brief This constructor sets the iterator to first incomig edge. | 
|---|
|  | 383 | /// | 
|---|
| [334] | 384 | /// This constructor set the iterator to the first incomig edge of | 
|---|
|  | 385 | /// node | 
|---|
|  | 386 | ///@param n the node | 
|---|
| [651] | 387 | ///@param g the graph | 
|---|
|  | 388 | InEdgeIt(const GraphConcept& g, const Node& n) { } | 
|---|
| [334] | 389 | }; | 
|---|
| [651] | 390 |  | 
|---|
|  | 391 | /// The first incoming edge. | 
|---|
|  | 392 | InEdgeIt &first(InEdgeIt &i, const Node& n) const { return i; } | 
|---|
|  | 393 |  | 
|---|
|  | 394 | /// Go to the next incoming edge. | 
|---|
|  | 395 | InEdgeIt &next(InEdgeIt &i) const { return i; } | 
|---|
|  | 396 |  | 
|---|
|  | 397 | Node aNode(const InEdgeIt&) const { return Node(); } | 
|---|
|  | 398 | Node bNode(const InEdgeIt&) const { return Node(); } | 
|---|
| [334] | 399 | }; | 
|---|
|  | 400 |  | 
|---|
|  | 401 |  | 
|---|
| [826] | 402 | /// \brief Node-erasable graph concept. | 
|---|
| [651] | 403 | /// | 
|---|
|  | 404 | /// A graph class which provides a function to | 
|---|
| [333] | 405 | /// delete any of its nodes. | 
|---|
| [826] | 406 | class NodeErasableGraphConcept : virtual public GraphConcept | 
|---|
| [333] | 407 | { | 
|---|
|  | 408 | public: | 
|---|
|  | 409 | /// Deletes a node. | 
|---|
| [651] | 410 | void erase(const Node& n) { } | 
|---|
| [333] | 411 | }; | 
|---|
|  | 412 |  | 
|---|
| [651] | 413 |  | 
|---|
| [826] | 414 | /// \brief Edge-erasable graph concept. | 
|---|
| [651] | 415 | /// | 
|---|
|  | 416 | /// A graph class which provides a function to delete any | 
|---|
| [333] | 417 | /// of its edges. | 
|---|
| [826] | 418 | class EdgeErasableGraphConcept : virtual public GraphConcept | 
|---|
| [333] | 419 | { | 
|---|
|  | 420 | public: | 
|---|
|  | 421 | /// Deletes a node. | 
|---|
| [651] | 422 | void erase(const Edge& n) { } | 
|---|
| [333] | 423 | }; | 
|---|
|  | 424 |  | 
|---|
| [651] | 425 |  | 
|---|
|  | 426 | /// \brief An empty graph class which provides a function to | 
|---|
|  | 427 | /// get the number of its nodes. | 
|---|
|  | 428 | /// | 
|---|
| [325] | 429 | /// This graph class provides a function for getting the number of its | 
|---|
|  | 430 | /// nodes. | 
|---|
|  | 431 | /// Clearly, for physical graph structures it can be expected to have such a | 
|---|
|  | 432 | /// function. For wrappers or graphs which are given in an implicit way, | 
|---|
|  | 433 | /// the implementation can be circumstantial, that is why this composes a | 
|---|
|  | 434 | /// separate concept. | 
|---|
| [651] | 435 | class NodeCountingGraphConcept : virtual public GraphConcept | 
|---|
| [325] | 436 | { | 
|---|
|  | 437 | public: | 
|---|
|  | 438 | /// Returns the number of nodes. | 
|---|
| [651] | 439 | int nodeNum() const { return 0; } | 
|---|
| [325] | 440 | }; | 
|---|
|  | 441 |  | 
|---|
| [651] | 442 |  | 
|---|
|  | 443 | /// \brief An empty graph class which provides a function to | 
|---|
|  | 444 | /// get the number of its edges. | 
|---|
|  | 445 | /// | 
|---|
| [325] | 446 | /// This graph class provides a function for getting the number of its | 
|---|
|  | 447 | /// edges. | 
|---|
|  | 448 | /// Clearly, for physical graph structures it can be expected to have such a | 
|---|
|  | 449 | /// function. For wrappers or graphs which are given in an implicit way, | 
|---|
|  | 450 | /// the implementation can be circumstantial, that is why this composes a | 
|---|
|  | 451 | /// separate concept. | 
|---|
| [651] | 452 | class EdgeCountingGraphConcept : virtual public GraphConcept | 
|---|
| [325] | 453 | { | 
|---|
|  | 454 | public: | 
|---|
|  | 455 | /// Returns the number of edges. | 
|---|
| [651] | 456 | int edgeNum() const { return 0; } | 
|---|
|  | 457 | }; | 
|---|
|  | 458 |  | 
|---|
| [652] | 459 | class FullFeatureGraphConcept : virtual public NodeIterableGraphConcept, | 
|---|
|  | 460 | virtual public EdgeIterableGraphConcept, | 
|---|
|  | 461 | virtual public OutEdgeIterableGraphConcept, | 
|---|
|  | 462 | virtual public InEdgeIterableGraphConcept, | 
|---|
|  | 463 | virtual public NodeCountingGraphConcept { | 
|---|
| [651] | 464 | public: | 
|---|
|  | 465 | FullFeatureGraphConcept() { } | 
|---|
| [652] | 466 | using EdgeIterableGraphConcept::next; | 
|---|
|  | 467 | using NodeIterableGraphConcept::next; | 
|---|
|  | 468 | using OutEdgeIterableGraphConcept::next; | 
|---|
|  | 469 | using InEdgeIterableGraphConcept::next; | 
|---|
| [325] | 470 | }; | 
|---|
| [332] | 471 |  | 
|---|
|  | 472 | /// @} | 
|---|
| [325] | 473 |  | 
|---|
| [921] | 474 | } //namespace lemon | 
|---|
| [325] | 475 |  | 
|---|
|  | 476 |  | 
|---|
| [332] | 477 |  | 
|---|
| [651] | 478 | // class EmptyBipGraph : public Graph Concept | 
|---|
| [325] | 479 | // { | 
|---|
|  | 480 | //   class ANode {}; | 
|---|
|  | 481 | //   class BNode {}; | 
|---|
|  | 482 |  | 
|---|
|  | 483 | //   ANode &next(ANode &) {} | 
|---|
|  | 484 | //   BNode &next(BNode &) {} | 
|---|
|  | 485 |  | 
|---|
|  | 486 | //   ANode &getFirst(ANode &) const {} | 
|---|
|  | 487 | //   BNode &getFirst(BNode &) const {} | 
|---|
|  | 488 |  | 
|---|
|  | 489 | //   enum NodeClass { A = 0, B = 1 }; | 
|---|
|  | 490 | //   NodeClass getClass(Node n) {} | 
|---|
|  | 491 |  | 
|---|
|  | 492 | // } | 
|---|
|  | 493 |  | 
|---|
| [921] | 494 | #endif // LEMON_GRAPH_H | 
|---|