Changeset 801:48638058e188 in lemon-0.x for src/hugo
- Timestamp:
- 09/05/04 22:06:08 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1095
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/hugo/skeletons/graph.h
r794 r801 36 36 public: 37 37 /// Defalult constructor. 38 39 /// Defalult constructor. 40 /// 38 41 StaticGraphSkeleton() { } 39 42 ///Copy consructor. 40 43 41 ///\todo It is not clear, what we expect from a copy constructor.42 ///E.g. How to assign the nodes/edges to each other? What about maps?43 StaticGraphSkeleton(const StaticGraphSkeleton& g) { }44 // ///\todo It is not clear, what we expect from a copy constructor. 45 // ///E.g. How to assign the nodes/edges to each other? What about maps? 46 // StaticGraphSkeleton(const StaticGraphSkeleton& g) { } 44 47 45 48 /// The base type of node iterators, … … 48 51 /// This is the base type of each node iterator, 49 52 /// thus each kind of node iterator converts to this. 50 /// More precisely each kind of node iterator have tobe inherited53 /// More precisely each kind of node iterator should be inherited 51 54 /// from the trivial node iterator. 52 55 class Node { 53 56 public: 57 /// Default constructor 58 54 59 /// @warning The default constructor sets the iterator 55 60 /// to an undefined value. 56 61 Node() { } 57 62 /// Copy constructor. 63 64 /// Copy constructor. 65 /// 58 66 Node(const Node&) { } 67 59 68 /// Invalid constructor \& conversion. 60 69 … … 62 71 /// \sa Invalid for more details. 63 72 Node(Invalid) { } 73 /// Equality operator 74 64 75 /// Two iterators are equal if and only if they point to the 65 76 /// same object or both are invalid. 66 77 bool operator==(Node) const { return true; } 67 78 79 /// Inequality operator 80 68 81 /// \sa \ref operator==(Node n) 69 82 /// 70 83 bool operator!=(Node) const { return true; } 71 84 85 ///Comparison operator. 86 87 ///This is a strict ordering between the nodes. 88 /// 89 ///This ordering can be different from the order in which NodeIt 90 ///goes through the nodes. 91 ///\todo Possibly we don't need it. 72 92 bool operator<(Node) const { return true; } 73 93 }; … … 80 100 /// \code 81 101 /// int count=0; 82 /// for (Graph::NodeIt n(g); g.valid(n); ++n) ++count;102 /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count; 83 103 /// \endcode 84 104 class NodeIt : public Node { 85 105 public: 106 /// Default constructor 107 86 108 /// @warning The default constructor sets the iterator 87 109 /// to an undefined value. 88 110 NodeIt() { } 89 111 /// Copy constructor. 112 113 /// Copy constructor. 114 /// 90 115 NodeIt(const NodeIt&) { } 91 116 /// Invalid constructor \& conversion. … … 94 119 /// \sa Invalid for more details. 95 120 NodeIt(Invalid) { } 121 /// Sets the iterator to the first node. 122 96 123 /// Sets the iterator to the first node of \c g. 124 /// 97 125 NodeIt(const StaticGraphSkeleton& g) { } 126 /// Node -> NodeIt conversion. 127 98 128 /// Sets the iterator to the node of \c g pointed by the trivial 99 /// iterator n. This feature necessitates that each time we 100 /// iterate the node-set, the iteration order is the same. 129 /// iterator n. 130 /// This feature necessitates that each time we 131 /// iterate the edge-set, the iteration order is the same. 101 132 NodeIt(const StaticGraphSkeleton& g, const Node& n) { } 133 /// Next node. 134 102 135 /// Assign the iterator to the next node. 136 /// 103 137 NodeIt& operator++() { return *this; } 104 138 }; … … 106 140 107 141 /// The base type of the edge iterators. 142 143 /// The base type of the edge iterators. 144 /// 108 145 class Edge { 109 146 public: 147 /// Default constructor 148 110 149 /// @warning The default constructor sets the iterator 111 150 /// to an undefined value. 112 151 Edge() { } 113 152 /// Copy constructor. 153 154 /// Copy constructor. 155 /// 114 156 Edge(const Edge&) { } 115 157 /// Initialize the iterator to be invalid. 158 159 /// Initialize the iterator to be invalid. 160 /// 116 161 Edge(Invalid) { } 162 /// Equality operator 163 117 164 /// Two iterators are equal if and only if they point to the 118 165 /// same object or both are invalid. 119 166 bool operator==(Edge) const { return true; } 167 /// Inequality operator 168 169 /// \sa \ref operator==(Node n) 170 /// 120 171 bool operator!=(Edge) const { return true; } 121 bool operator<(Edge) const { return true; } 172 ///Comparison operator. 173 174 ///This is a strict ordering between the nodes. 175 /// 176 ///This ordering can be different from the order in which NodeIt 177 ///goes through the nodes. 178 ///\todo Possibly we don't need it. 179 bool operator<(Edge) const { return true; } 122 180 }; 123 181 … … 131 189 /// \code 132 190 /// int count=0; 133 /// for (Graph::OutEdgeIt e(g, n); g.valid(e); ++e) ++count;191 /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count; 134 192 /// \endcode 135 193 136 194 class OutEdgeIt : public Edge { 137 195 public: 196 /// Default constructor 197 138 198 /// @warning The default constructor sets the iterator 139 199 /// to an undefined value. 140 200 OutEdgeIt() { } 141 201 /// Copy constructor. 202 203 /// Copy constructor. 204 /// 142 205 OutEdgeIt(const OutEdgeIt&) { } 143 206 /// Initialize the iterator to be invalid. 207 208 /// Initialize the iterator to be invalid. 209 /// 144 210 OutEdgeIt(Invalid) { } 145 211 /// This constructor sets the iterator to first outgoing edge. … … 150 216 ///@param g the graph 151 217 OutEdgeIt(const StaticGraphSkeleton& g, const Node& n) { } 218 /// Edge -> OutEdgeIt conversion 219 152 220 /// Sets the iterator to the value of the trivial iterator \c e. 153 221 /// This feature necessitates that each time we 154 222 /// iterate the edge-set, the iteration order is the same. 155 223 OutEdgeIt(const StaticGraphSkeleton& g, const Edge& e) { } 156 /// Assign the iterator to the next outedge of the corresponding node. 224 ///Next outgoing edge 225 226 /// Assign the iterator to the next 227 /// outgoing edge of the corresponding node. 157 228 OutEdgeIt& operator++() { return *this; } 158 229 }; … … 167 238 /// \code 168 239 /// int count=0; 169 /// for(Graph::InEdgeIt e(g, n); g.valid(e); ++) ++count;240 /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count; 170 241 /// \endcode 171 242 172 243 class InEdgeIt : public Edge { 173 244 public: 245 /// Default constructor 246 174 247 /// @warning The default constructor sets the iterator 175 248 /// to an undefined value. 176 249 InEdgeIt() { } 177 250 /// Copy constructor. 251 252 /// Copy constructor. 253 /// 178 254 InEdgeIt(const InEdgeIt&) { } 179 255 /// Initialize the iterator to be invalid. 256 257 /// Initialize the iterator to be invalid. 258 /// 180 259 InEdgeIt(Invalid) { } 181 /// . 182 InEdgeIt(const StaticGraphSkeleton&, const Node&) { } 183 /// . 184 InEdgeIt(const StaticGraphSkeleton&, const Edge&) { } 260 /// This constructor sets the iterator to first incoming edge. 261 262 /// This constructor set the iterator to the first incoming edge of 263 /// node 264 ///@param n the node 265 ///@param g the graph 266 InEdgeIt(const StaticGraphSkeleton& g, const Node& n) { } 267 /// Edge -> InEdgeIt conversion 268 269 /// Sets the iterator to the value of the trivial iterator \c e. 270 /// This feature necessitates that each time we 271 /// iterate the edge-set, the iteration order is the same. 272 InEdgeIt(const StaticGraphSkeleton& g, const Edge& n) { } 273 /// Next incoming edge 274 185 275 /// Assign the iterator to the next inedge of the corresponding node. 276 /// 186 277 InEdgeIt& operator++() { return *this; } 187 278 }; 188 // class SymEdgeIt : public Edge {};189 190 279 /// This iterator goes through each edge. 191 280 … … 195 284 /// \code 196 285 /// int count=0; 197 /// for(Graph::EdgeIt e(g); g.valid(e); ++e) ++count;286 /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count; 198 287 /// \endcode 199 288 class EdgeIt : public Edge { 200 289 public: 290 /// Default constructor 291 201 292 /// @warning The default constructor sets the iterator 202 293 /// to an undefined value. 203 294 EdgeIt() { } 204 295 /// Copy constructor. 296 297 /// Copy constructor. 298 /// 205 299 EdgeIt(const EdgeIt&) { } 206 300 /// Initialize the iterator to be invalid. 301 302 /// Initialize the iterator to be invalid. 303 /// 207 304 EdgeIt(Invalid) { } 208 /// . 209 EdgeIt(const StaticGraphSkeleton&) { } 210 /// . 305 /// This constructor sets the iterator to first edge. 306 307 /// This constructor set the iterator to the first edge of 308 /// node 309 ///@param g the graph 310 EdgeIt(const StaticGraphSkeleton& g) { } 311 /// Edge -> EdgeIt conversion 312 313 /// Sets the iterator to the value of the trivial iterator \c e. 314 /// This feature necessitates that each time we 315 /// iterate the edge-set, the iteration order is the same. 211 316 EdgeIt(const StaticGraphSkeleton&, const Edge&) { } 317 ///Next edge 318 319 /// Assign the iterator to the next 320 /// edge of the corresponding node. 212 321 EdgeIt& operator++() { return *this; } 213 322 }; … … 221 330 222 331 /// The first incoming edge. 332 333 /// The first incoming edge. 334 /// 223 335 InEdgeIt& first(InEdgeIt &i, Node) const { return i; } 224 336 /// The first outgoing edge. 337 338 /// The first outgoing edge. 339 /// 225 340 OutEdgeIt& first(OutEdgeIt& i, Node) const { return i; } 226 // SymEdgeIt& first(SymEdgeIt&, Node) const { return i; }227 341 /// The first edge of the Graph. 342 343 /// The first edge of the Graph. 344 /// 228 345 EdgeIt& first(EdgeIt& i) const { return i; } 229 346 230 // Node getNext(Node) const {}231 // InEdgeIt getNext(InEdgeIt) const {}232 // OutEdgeIt getNext(OutEdgeIt) const {}233 // //SymEdgeIt getNext(SymEdgeIt) const {}234 // EdgeIt getNext(EdgeIt) const {}235 236 /// Go to the next node.237 NodeIt& next(NodeIt& i) const { return i; }238 /// Go to the next incoming edge.239 InEdgeIt& next(InEdgeIt& i) const { return i; }240 /// Go to the next outgoing edge.241 OutEdgeIt& next(OutEdgeIt& i) const { return i; }242 //SymEdgeIt& next(SymEdgeIt&) const { }243 /// Go to the next edge.244 EdgeIt& next(EdgeIt& i) const { return i; }245 246 347 ///Gives back the head node of an edge. 348 349 ///Gives back the head node of an edge. 350 /// 247 351 Node head(Edge) const { return INVALID; } 248 352 ///Gives back the tail node of an edge. 353 354 ///Gives back the tail node of an edge. 355 /// 249 356 Node tail(Edge) const { return INVALID; } 250 357 251 // Node aNode(InEdgeIt) const {}252 // Node aNode(OutEdgeIt) const {}253 // Node aNode(SymEdgeIt) const {}254 255 // Node bNode(InEdgeIt) const {}256 // Node bNode(OutEdgeIt) const {}257 // Node bNode(SymEdgeIt) const {}258 259 /// Checks if a node iterator is valid260 261 ///\todo Maybe, it would be better if iterator converted to262 ///bool directly, as Jacint prefers.263 bool valid(const Node&) const { return true; }264 /// Checks if an edge iterator is valid265 266 ///\todo Maybe, it would be better if iterator converted to267 ///bool directly, as Jacint prefers.268 bool valid(const Edge&) const { return true; }269 270 358 ///Gives back the \e id of a node. 271 359 272 360 ///\warning Not all graph structures provide this feature. 273 361 /// 362 ///\todo Should each graph provide \c id? 274 363 int id(const Node&) const { return 0; } 275 364 ///Gives back the \e id of an edge. … … 277 366 ///\warning Not all graph structures provide this feature. 278 367 /// 368 ///\todo Should each graph provide \c id? 279 369 int id(const Edge&) const { return 0; } 280 370 281 /// Resets the graph. 282 283 /// This function deletes all edges and nodes of the graph. 284 /// It also frees the memory allocated to store them. 285 void clear() { } 286 371 /// . 372 373 ///\todo What is this? 374 /// 287 375 int nodeNum() const { return 0; } 376 /// . 377 ///\todo What is this? 378 /// 288 379 int edgeNum() const { return 0; } 289 380 … … 294 385 /// \sa ReferenceSkeleton 295 386 /// \warning Making maps that can handle bool type (NodeMap<bool>) 296 /// needs extra attention! 297 298 template<class T> class NodeMap 299 : public ReferenceMap< Node, T > 387 /// needs some extra attention! 388 template<class T> class NodeMap: public ReferenceMap< Node, T > 300 389 { 301 390 public: 302 391 392 /// . 303 393 NodeMap(const StaticGraphSkeleton&) { } 394 /// . 304 395 NodeMap(const StaticGraphSkeleton&, T) { } 305 396 … … 316 407 /// \sa ReferenceSkeleton 317 408 /// \warning Making maps that can handle bool type (EdgeMap<bool>) 318 /// needs extra attention!409 /// needs some extra attention! 319 410 template<class T> class EdgeMap 320 411 : public ReferenceMap<Edge,T> 321 412 { 322 413 public: 323 typedef T ValueType; 324 typedef Edge KeyType; 325 414 415 /// . 326 416 EdgeMap(const StaticGraphSkeleton&) { } 417 /// . 327 418 EdgeMap(const StaticGraphSkeleton&, T) { } 328 419 … … 337 428 338 429 339 /// An empty graph class.430 /// An empty non-static graph class. 340 431 341 432 /// This class provides everything that \c StaticGraphSkeleton … … 346 437 public: 347 438 /// Defalult constructor. 439 440 /// Defalult constructor. 441 /// 348 442 GraphSkeleton() { } 349 ///Copy consructor.350 351 ///\todo It is not clear, what we expect from a copy constructor.352 ///E.g. How to assign the nodes/edges to each other? What about maps?353 GraphSkeleton(const GraphSkeleton&) { }354 355 443 ///Add a new node to the graph. 356 444 … … 380 468 { 381 469 public: 470 /// Defalult constructor. 471 472 /// Defalult constructor. 473 /// 474 EraseableGraphSkeleton() { } 382 475 /// Deletes a node. 476 477 /// Deletes node \c n node. 478 /// 383 479 void erase(Node n) { } 384 480 /// Deletes an edge. 481 482 /// Deletes edge \c e edge. 483 /// 385 484 void erase(Edge e) { } 386 387 /// Defalult constructor.388 EraseableGraphSkeleton() { }389 ///Copy consructor.390 EraseableGraphSkeleton(const GraphSkeleton&) { }391 485 }; 392 486 393 487 // @} 394 } //namespace skeleton 395 488 } //namespace skeleton 396 489 } //namespace hugo 397 490 398 491 399 492 400 // class EmptyBipGraph : public Graph Skeleton401 // {402 // class ANode {};403 // class BNode {};404 405 // ANode &next(ANode &) {}406 // BNode &next(BNode &) {}407 408 // ANode &getFirst(ANode &) const {}409 // BNode &getFirst(BNode &) const {}410 411 // enum NodeClass { A = 0, B = 1 };412 // NodeClass getClass(Node n) {}413 414 // }415 416 493 #endif // HUGO_SKELETON_GRAPH_H
Note: See TracChangeset
for help on using the changeset viewer.