Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

graph.h

Go to the documentation of this file.
00001 /* -*- C++ -*-
00002  * lemon/concept/graph.h - Part of LEMON, a generic C++ optimization library
00003  *
00004  * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
00005  * (Egervary Research Group on Combinatorial Optimization, EGRES).
00006  *
00007  * Permission to use, modify and distribute this software is granted
00008  * provided that this copyright notice appears in all copies. For
00009  * precise terms see the accompanying LICENSE file.
00010  *
00011  * This software is provided "AS IS" with no warranty of any kind,
00012  * express or implied, and with no claim as to its suitability for any
00013  * purpose.
00014  *
00015  */
00016 
00017 #ifndef LEMON_CONCEPT_GRAPH_H
00018 #define LEMON_CONCEPT_GRAPH_H
00019 
00023 
00024 #include <lemon/invalid.h>
00025 #include <lemon/utility.h>
00026 #include <lemon/concept/maps.h>
00027 #include <lemon/concept_check.h>
00028 #include <lemon/concept/graph_component.h>
00029 
00030 namespace lemon {
00031   namespace concept {
00032 
00033     
00034     /**************** The full-featured graph concepts ****************/
00035 
00036 
00040     class _StaticGraph 
00041       :  virtual public BaseGraphComponent,
00042          public IterableGraphComponent, public MappableGraphComponent {
00043     public:
00045 
00048       typedef False UndirTag;
00049       
00050       typedef BaseGraphComponent::Node Node;
00051       typedef BaseGraphComponent::Edge Edge;
00052 
00053       template <typename _Graph>
00054       struct Constraints {
00055         void constraints() {
00056           checkConcept<IterableGraphComponent, _Graph>();
00057           checkConcept<MappableGraphComponent, _Graph>();
00058         }
00059       };
00060     };
00061 
00065     class _ExtendableGraph 
00066       :  virtual public BaseGraphComponent, public _StaticGraph,
00067          public ExtendableGraphComponent, public ClearableGraphComponent {
00068     public:
00069       typedef BaseGraphComponent::Node Node;
00070       typedef BaseGraphComponent::Edge Edge;
00071 
00072       template <typename _Graph>
00073       struct Constraints {
00074         void constraints() {
00075           checkConcept<_StaticGraph, _Graph >();
00076           checkConcept<ExtendableGraphComponent, _Graph >();
00077           checkConcept<ClearableGraphComponent, _Graph >();
00078         }
00079       };
00080     };
00081 
00085     class _ErasableGraph 
00086       :  virtual public BaseGraphComponent, public _ExtendableGraph,
00087          public ErasableGraphComponent {
00088     public:
00089       typedef BaseGraphComponent::Node Node;
00090       typedef BaseGraphComponent::Edge Edge;
00091 
00092       template <typename _Graph>
00093       struct Constraints {
00094         void constraints() {
00095           checkConcept<_ExtendableGraph, _Graph >();
00096           checkConcept<ErasableGraphComponent, _Graph >();
00097         }
00098       };
00099     };
00100 
00103 
00105   
00122     class StaticGraph
00123     {
00124     public:
00126 
00129       typedef False UndirTag;
00130 
00132 
00135       StaticGraph() { }
00137 
00138 //       ///\todo It is not clear, what we expect from a copy constructor.
00139 //       ///E.g. How to assign the nodes/edges to each other? What about maps?
00140 //       StaticGraph(const StaticGraph& g) { }
00141 
00144 
00149       class Node {
00150       public:
00152 
00155         Node() { }
00157 
00160         Node(const Node&) { }
00161 
00163 
00166         Node(Invalid) { }
00168 
00171         bool operator==(Node) const { return true; }
00172 
00174         
00177         bool operator!=(Node) const { return true; }
00178 
00180         
00189         bool operator<(Node) const { return false; }
00190 
00191       };
00192     
00194 
00202       class NodeIt : public Node {
00203       public:
00205 
00208         NodeIt() { }
00210         
00213         NodeIt(const NodeIt& n) : Node(n) { }
00215 
00218         NodeIt(Invalid) { }
00220 
00223         NodeIt(const StaticGraph&) { }
00225 
00230         NodeIt(const StaticGraph&, const Node&) { }
00232 
00235         NodeIt& operator++() { return *this; }
00236       };
00237     
00238     
00240 
00243       class Edge {
00244       public:
00246 
00249         Edge() { }
00251 
00254         Edge(const Edge&) { }
00256 
00259         Edge(Invalid) { }
00261 
00264         bool operator==(Edge) const { return true; }
00266 
00269         bool operator!=(Edge) const { return true; }
00270 
00272         
00281         bool operator<(Edge) const { return false; }
00282       };
00283     
00285 
00295     
00296       class OutEdgeIt : public Edge {
00297       public:
00299 
00302         OutEdgeIt() { }
00304 
00307         OutEdgeIt(const OutEdgeIt& e) : Edge(e) { }
00309 
00312         OutEdgeIt(Invalid) { }
00314     
00317         OutEdgeIt(const StaticGraph&, const Node&) { }
00319 
00323         OutEdgeIt(const StaticGraph&, const Edge&) { }
00325         
00328         OutEdgeIt& operator++() { return *this; }
00329       };
00330 
00332 
00342 
00343       class InEdgeIt : public Edge {
00344       public:
00346 
00349         InEdgeIt() { }
00351 
00354         InEdgeIt(const InEdgeIt& e) : Edge(e) { }
00356 
00359         InEdgeIt(Invalid) { }
00361     
00364         InEdgeIt(const StaticGraph&, const Node&) { }
00366 
00370         InEdgeIt(const StaticGraph&, const Edge&) { }
00372 
00375         InEdgeIt& operator++() { return *this; }
00376       };
00378 
00386       class EdgeIt : public Edge {
00387       public:
00389 
00392         EdgeIt() { }
00394 
00397         EdgeIt(const EdgeIt& e) : Edge(e) { }
00399 
00402         EdgeIt(Invalid) { }
00404     
00407         EdgeIt(const StaticGraph& g) { ignore_unused_variable_warning(g); }
00409 
00413         EdgeIt(const StaticGraph&, const Edge&) { } 
00415         
00417         EdgeIt& operator++() { return *this; }
00418       };
00420 
00423       Node target(Edge) const { return INVALID; }
00425 
00428       Node source(Edge) const { return INVALID; }
00429 
00430 //       /// Gives back the first Node in the iterating order.
00431       
00432 //       /// Gives back the first Node in the iterating order.
00433 //       ///     
00434       void first(Node&) const {}
00435 
00436 //       /// Gives back the next Node in the iterating order.
00437       
00438 //       /// Gives back the next Node in the iterating order.
00439 //       ///     
00440       void next(Node&) const {}
00441 
00442 //       /// Gives back the first Edge in the iterating order.
00443       
00444 //       /// Gives back the first Edge in the iterating order.
00445 //       ///     
00446       void first(Edge&) const {}
00447 //       /// Gives back the next Edge in the iterating order.
00448       
00449 //       /// Gives back the next Edge in the iterating order.
00450 //       ///     
00451       void next(Edge&) const {}
00452 
00453 
00454 //       /// Gives back the first of the Edges point to the given Node.
00455       
00456 //       /// Gives back the first of the Edges point to the given Node.
00457 //       ///     
00458       void firstIn(Edge&, const Node&) const {}
00459 
00460 //       /// Gives back the next of the Edges points to the given Node.
00461 
00462 
00463 //       /// Gives back the next of the Edges points to the given Node.
00464 //       ///
00465       void nextIn(Edge&) const {}
00466 
00467 //       /// Gives back the first of the Edges start from the given Node.
00468       
00469 //       /// Gives back the first of the Edges start from the given Node.
00470 //       ///     
00471       void firstOut(Edge&, const Node&) const {}
00472 
00473 //       /// Gives back the next of the Edges start from the given Node.
00474       
00475 //       /// Gives back the next of the Edges start from the given Node.
00476 //       ///     
00477       void nextOut(Edge&) const {}
00478 
00483       Node baseNode(const InEdgeIt&) const { return INVALID; }
00484 
00489       Node runningNode(const InEdgeIt&) const { return INVALID; }
00490 
00495       Node baseNode(const OutEdgeIt&) const { return INVALID; }
00496 
00501       Node runningNode(const OutEdgeIt&) const { return INVALID; }
00502 
00506       Node oppositeNode(const Node&, const Edge&) const { return INVALID; }
00507 
00515       template<class T> 
00516       class NodeMap : public ReadWriteMap< Node, T >
00517       {
00518       public:
00519 
00521         NodeMap(const StaticGraph&) { }
00523         NodeMap(const StaticGraph&, T) { }
00524 
00526         NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
00528         NodeMap& operator=(const NodeMap&) { return *this; }
00529         // \todo fix this concept
00530       };
00531 
00539       template<class T> 
00540       class EdgeMap : public ReadWriteMap<Edge,T>
00541       {
00542       public:
00543 
00545         EdgeMap(const StaticGraph&) { }
00547         EdgeMap(const StaticGraph&, T) { }
00549         EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { }
00551         EdgeMap& operator=(const EdgeMap&) { return *this; }
00552         // \todo fix this concept    
00553       };
00554 
00555       template <typename _Graph>
00556       struct Constraints : public _StaticGraph::Constraints<_Graph> {};
00557 
00558     };
00559 
00561     
00564     class ExtendableGraph : public StaticGraph
00565     {
00566     public:
00568 
00571       ExtendableGraph() { }
00573 
00576       Node addNode() { return INVALID; }
00578 
00582       Edge addEdge(Node, Node) { return INVALID; }
00583     
00585 
00589       void clear() { }
00590 
00591       template <typename _Graph>
00592       struct Constraints : public _ExtendableGraph::Constraints<_Graph> {};
00593 
00594     };
00595 
00597   
00600     class ErasableGraph : public ExtendableGraph
00601     {
00602     public:
00604 
00607       ErasableGraph() { }
00609 
00612       void erase(Node) { }
00614 
00617       void erase(Edge) { }
00618 
00619       template <typename _Graph>
00620       struct Constraints : public _ErasableGraph::Constraints<_Graph> {};
00621 
00622     };
00623     
00624     // @}
00625   } //namespace concept  
00626 } //namespace lemon
00627 
00628 
00629 
00630 #endif // LEMON_CONCEPT_GRAPH_H

Generated on Sat Aug 27 14:14:50 2005 for LEMON by  doxygen 1.4.4