COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
10/03/06 13:46:39 (18 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2973
Message:

Some rearrangement of concepts and extenders
BpUGraph concepts and concept check test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/concept/graph_components.h

    r2181 r2231  
    219219        /// be convertible to the represented undirected edge.
    220220        UEdge(const Edge&) {}
     221        /// \brief Assign edge to undirected edge.
     222        ///
     223        /// Besides the core graph item functionality each edge should
     224        /// be convertible to the represented undirected edge.
     225        UEdge& operator=(const Edge&) { return *this; }
    221226      };
    222227
     
    291296    };
    292297
    293     /// \brief An empty iterable base graph class.
     298    /// \brief An empty base bipartite undirected graph class.
    294299    /// 
    295     /// This class provides beside the core graph features
    296     /// core iterable interface for the graph structure.
    297     /// Most of the base graphs should be conform to this concept.
    298     template <typename _Base = BaseGraphComponent>
    299     class BaseIterableGraphComponent : public _Base {
    300     public:
    301 
    302       typedef _Base Base;
    303       typedef typename Base::Node Node;
    304       typedef typename Base::Edge Edge;
    305 
    306       /// \brief Gives back the first node in the iterating order.
    307       ///     
    308       /// Gives back the first node in the iterating order.
    309       ///     
    310       void first(Node&) const {}
    311 
    312       /// \brief Gives back the next node in the iterating order.
    313       ///
    314       /// Gives back the next node in the iterating order.
    315       ///     
    316       void next(Node&) const {}
    317 
    318       /// \brief Gives back the first edge in the iterating order.
    319       ///
    320       /// Gives back the first edge in the iterating order.
    321       ///     
    322       void first(Edge&) const {}
    323 
    324       /// \brief Gives back the next edge in the iterating order.
    325       ///
    326       /// Gives back the next edge in the iterating order.
    327       ///     
    328       void next(Edge&) const {}
    329 
    330 
    331       /// \brief Gives back the first of the edges point to the given
    332       /// node.
    333       ///
    334       /// Gives back the first of the edges point to the given node.
    335       ///     
    336       void firstIn(Edge&, const Node&) const {}
    337 
    338       /// \brief Gives back the next of the edges points to the given
    339       /// node.
    340       ///
    341       /// Gives back the next of the edges points to the given node.
    342       ///
    343       void nextIn(Edge&) const {}
    344 
    345       /// \brief Gives back the first of the edges start from the
    346       /// given node.
    347       ///     
    348       /// Gives back the first of the edges start from the given node.
    349       ///     
    350       void firstOut(Edge&, const Node&) const {}
    351 
    352       /// \brief Gives back the next of the edges start from the given
    353       /// node.
    354       ///
    355       /// Gives back the next of the edges start from the given node.
    356       ///     
    357       void nextOut(Edge&) const {}
    358 
    359 
     300    /// This class provides the minimal set of features needed for an
     301    /// bipartite undirected graph structure. All bipartite undirected
     302    /// graph concepts have to be conform to this base graph. It just
     303    /// provides types for nodes, A-nodes, B-nodes, edges and
     304    /// undirected edges and functions to get the source and the
     305    /// target of the edges and undirected edges, conversion from
     306    /// edges to undirected edges and function to get both direction
     307    /// of the undirected edges.
     308    class BaseBpUGraphComponent : public BaseUGraphComponent {
     309    public:
     310      typedef BaseUGraphComponent::Node Node;
     311      typedef BaseUGraphComponent::Edge Edge;
     312      typedef BaseUGraphComponent::UEdge UEdge;
     313
     314      /// \brief Helper class for A-nodes.
     315      ///
     316      /// This class is just a helper class for A-nodes, it is not
     317      /// suggested to use it directly. It can be converted easily to
     318      /// node and vice versa. The usage of this class is limited
     319      /// to use just as template parameters for special map types.
     320      class ANode : public Node {
     321      public:
     322        typedef Node Parent;
     323
     324        /// \brief Default constructor.
     325        ///     
     326        /// \warning The default constructor is not required to set
     327        /// the item to some well-defined value. So you should consider it
     328        /// as uninitialized.
     329        ANode() {}
     330        /// \brief Copy constructor.
     331        ///
     332        /// Copy constructor.
     333        ///
     334        ANode(const ANode &) : Parent() {}
     335        /// \brief Invalid constructor \& conversion.
     336        ///
     337        /// This constructor initializes the item to be invalid.
     338        /// \sa Invalid for more details.
     339        ANode(Invalid) {}
     340        /// \brief Converter from node to A-node.
     341        ///
     342        /// Besides the core graph item functionality each node should
     343        /// be convertible to the represented A-node if it is it possible.
     344        ANode(const Node&) {}
     345        /// \brief Assign node to A-node.
     346        ///
     347        /// Besides the core graph item functionality each node should
     348        /// be convertible to the represented A-node if it is it possible.
     349        ANode& operator=(const Node&) { return *this; }
     350      };
     351
     352      /// \brief Helper class for B-nodes.
     353      ///
     354      /// This class is just a helper class for B-nodes, it is not
     355      /// suggested to use it directly. It can be converted easily to
     356      /// node and vice versa. The usage of this class is limited
     357      /// to use just as template parameters for special map types.
     358      class BNode : public Node {
     359      public:
     360        typedef Node Parent;
     361
     362        /// \brief Default constructor.
     363        ///     
     364        /// \warning The default constructor is not required to set
     365        /// the item to some well-defined value. So you should consider it
     366        /// as uninitialized.
     367        BNode() {}
     368        /// \brief Copy constructor.
     369        ///
     370        /// Copy constructor.
     371        ///
     372        BNode(const BNode &) : Parent() {}
     373        /// \brief Invalid constructor \& conversion.
     374        ///
     375        /// This constructor initializes the item to be invalid.
     376        /// \sa Invalid for more details.
     377        BNode(Invalid) {}
     378        /// \brief Converter from node to B-node.
     379        ///
     380        /// Besides the core graph item functionality each node should
     381        /// be convertible to the represented B-node if it is it possible.
     382        BNode(const Node&) {}
     383        /// \brief Assign node to B-node.
     384        ///
     385        /// Besides the core graph item functionality each node should
     386        /// be convertible to the represented B-node if it is it possible.
     387        BNode& operator=(const Node&) { return *this; }
     388      };
     389     
     390      /// \brief Gives back %true when the node is A-node.
     391      ///
     392      /// Gives back %true when the node is A-node.
     393      bool aNode(const Node&) const { return false; }
     394
     395      /// \brief Gives back %true when the node is B-node.
     396      ///
     397      /// Gives back %true when the node is B-node.
     398      bool bNode(const Node&) const { return false; }
     399
     400      /// \brief Gives back the A-node of the undirected edge.
     401      ///
     402      /// Gives back the A-node of the undirected edge.
     403      Node aNode(const UEdge&) const { return INVALID; }
     404
     405      /// \brief Gives back the B-node of the undirected edge.
     406      ///
     407      /// Gives back the B-node of the undirected edge.
     408      Node bNode(const UEdge&) const { return INVALID; }
     409     
    360410      template <typename _Graph>
    361411      struct Constraints {
     412        typedef typename _Graph::Node Node;
     413        typedef typename _Graph::ANode ANode;
     414        typedef typename _Graph::BNode BNode;
     415        typedef typename _Graph::Edge Edge;
     416        typedef typename _Graph::UEdge UEdge;
    362417     
    363418        void constraints() {
    364           checkConcept< BaseGraphComponent, _Graph >();
    365           typename _Graph::Node node(INVALID);     
    366           typename _Graph::Edge edge(INVALID);
     419          checkConcept<BaseUGraphComponent, _Graph>();
     420          checkConcept<GraphItem<'a'>, ANode>();
     421          checkConcept<GraphItem<'b'>, BNode>();
    367422          {
    368             graph.first(node);
    369             graph.next(node);
    370           }
    371           {
    372             graph.first(edge);
    373             graph.next(edge);
    374           }
    375           {
    376             graph.firstIn(edge, node);
    377             graph.nextIn(edge);
    378           }
    379           {
    380             graph.firstOut(edge, node);
    381             graph.nextOut(edge);
    382           }
    383         }
    384 
     423            Node n;
     424            UEdge ue(INVALID);
     425            bool b;
     426            n = graph.aNode(ue);
     427            n = graph.bNode(ue);
     428            b = graph.aNode(n);
     429            b = graph.bNode(n);
     430            ANode an;
     431            an = n; n = an;
     432            BNode bn;
     433            bn = n; n = bn;           
     434            ignore_unused_variable_warning(b);
     435          }     
     436        }
     437     
    385438        const _Graph& graph;
    386439      };
    387     };
    388 
    389     /// \brief An empty iterable base undirected graph class.
    390     /// 
    391     /// This class provides beside the core undirceted graph features
    392     /// core iterable interface for the undirected graph structure.
    393     /// Most of the base undirected graphs should be conform to this
    394     /// concept.
    395     template <typename _Base = BaseUGraphComponent>
    396     class BaseIterableUGraphComponent
    397       : public BaseIterableGraphComponent<_Base> {
    398     public:
    399 
    400       typedef _Base Base;
    401       typedef typename Base::UEdge UEdge;
    402       typedef typename Base::Node Node;
    403 
    404       using BaseIterableGraphComponent<_Base>::first;
    405       using BaseIterableGraphComponent<_Base>::next;
    406 
    407       /// \brief Gives back the first undirected edge in the iterating
    408       /// order.
    409       ///
    410       /// Gives back the first undirected edge in the iterating order.
    411       ///     
    412       void first(UEdge&) const {}
    413 
    414       /// \brief Gives back the next undirected edge in the iterating
    415       /// order.
    416       ///
    417       /// Gives back the next undirected edge in the iterating order.
    418       ///     
    419       void next(UEdge&) const {}
    420 
    421 
    422       /// \brief Gives back the first of the undirected edges from the
    423       /// given node.
    424       ///
    425       /// Gives back the first of the undirected edges from the given
    426       /// node. The bool parameter gives back that direction which
    427       /// gives a good direction of the uedge so the source of the
    428       /// directed edge is the given node.
    429       void firstInc(UEdge&, bool&, const Node&) const {}
    430 
    431       /// \brief Gives back the next of the undirected edges from the
    432       /// given node.
    433       ///
    434       /// Gives back the next of the undirected edges from the given
    435       /// node. The bool parameter should be used as the \c firstInc()
    436       /// use it.
    437       void nextInc(UEdge&, bool&) const {}
    438 
    439       template <typename _Graph>
    440       struct Constraints {
    441      
    442         void constraints() {
    443           checkConcept<Base, _Graph >();
    444           checkConcept<BaseIterableGraphComponent<Base>, _Graph>();
    445           typename _Graph::Node node(INVALID);
    446           typename _Graph::UEdge uedge(INVALID);
    447           bool dir;
    448           {
    449             graph.first(uedge);
    450             graph.next(uedge);
    451           }
    452           {
    453             graph.firstInc(uedge, dir, node);
    454             graph.nextInc(uedge, dir);
    455           }
    456         }
    457 
    458         const _Graph& graph;
    459       };
     440
    460441    };
    461442
     
    518499
    519500        void constraints() {
    520           checkConcept< BaseGraphComponent, _Graph >();
     501          checkConcept<Base, _Graph >();
    521502          typename _Graph::Node node;
    522503          int nid = graph.id(node);
     
    591572    };
    592573
    593     /// \brief An empty extendable base graph class.
    594     ///
    595     /// This class provides beside the core graph features
    596     /// core graph extend interface for the graph structure.
    597     /// The most of the base graphs should be conform to this concept.
    598     template <typename _Base = BaseGraphComponent>
    599     class BaseExtendableGraphComponent : public _Base {
    600     public:
    601 
    602       typedef typename _Base::Node Node;
    603       typedef typename _Base::Edge Edge;
    604 
    605       /// \brief Adds a new node to the graph.
    606       ///
    607       /// Adds a new node to the graph.
    608       ///
    609       Node addNode() {
    610         return INVALID;
    611       }
    612    
    613       /// \brief Adds a new edge connects the given two nodes.
    614       ///
    615       /// Adds a new edge connects the the given two nodes.
    616       Edge addEdge(const Node&, const Node&) {
    617         return INVALID;
    618       }
    619 
    620       template <typename _Graph>
    621       struct Constraints {
    622         void constraints() {
    623           typename _Graph::Node node_a, node_b;
    624           node_a = graph.addNode();
    625           node_b = graph.addNode();
    626           typename _Graph::Edge edge;
    627           edge = graph.addEdge(node_a, node_b);
    628         }
    629 
    630         _Graph& graph;
    631       };
    632     };
    633 
    634     /// \brief An empty extendable base undirected graph class.
    635     ///
    636     /// This class provides beside the core undirected graph features
    637     /// core undircted graph extend interface for the graph structure.
    638     /// The most of the base graphs should be conform to this concept.
    639     template <typename _Base = BaseUGraphComponent>
    640     class BaseExtendableUGraphComponent : public _Base {
    641     public:
    642 
    643       typedef typename _Base::Node Node;
    644       typedef typename _Base::UEdge UEdge;
    645 
    646       /// \brief Adds a new node to the graph.
    647       ///
    648       /// Adds a new node to the graph.
    649       ///
    650       Node addNode() {
    651         return INVALID;
    652       }
    653    
    654       /// \brief Adds a new edge connects the given two nodes.
    655       ///
    656       /// Adds a new edge connects the the given two nodes.
    657       UEdge addEdge(const Node&, const Node&) {
    658         return INVALID;
    659       }
    660 
    661       template <typename _Graph>
    662       struct Constraints {
    663         void constraints() {
    664           typename _Graph::Node node_a, node_b;
    665           node_a = graph.addNode();
    666           node_b = graph.addNode();
    667           typename _Graph::UEdge uedge;
    668           uedge = graph.addUEdge(node_a, node_b);
    669         }
    670 
    671         _Graph& graph;
    672       };
    673     };
    674 
    675     /// \brief An empty erasable base graph class.
     574    /// \brief An empty idable base bipartite undirected graph class.
    676575    /// 
    677     /// This class provides beside the core graph features
    678     /// core erase functions for the graph structure.
    679     /// The most of the base graphs should be conform to this concept.
    680     template <typename _Base = BaseGraphComponent>
    681     class BaseErasableGraphComponent : public _Base {
     576    /// This class provides beside the core bipartite undirected graph
     577    /// features core id functions for the bipartite undirected graph
     578    /// structure.  The most of the base undirected graphs should be
     579    /// conform to this concept.
     580    template <typename _Base = BaseBpUGraphComponent>
     581    class IDableBpUGraphComponent : public IDableUGraphComponent<_Base> {
    682582    public:
    683583
    684584      typedef _Base Base;
    685585      typedef typename Base::Node Node;
    686       typedef typename Base::Edge Edge;
    687 
    688       /// \brief Erase a node from the graph.
    689       ///
    690       /// Erase a node from the graph. This function should not
    691       /// erase edges connecting to the Node.
    692       void erase(const Node&) {}   
    693 
    694       /// \brief Erase an edge from the graph.
    695       ///
    696       /// Erase an edge from the graph.
    697       ///
    698       void erase(const Edge&) {}
     586
     587      using IDableUGraphComponent<_Base>::id;
     588
     589      /// \brief Gives back an unique integer id for the ANode.
     590      ///
     591      /// Gives back an unique integer id for the ANode.
     592      ///
     593      int aNodeId(const Node&) const { return -1;}
     594
     595      /// \brief Gives back the undirected edge by the unique id.
     596      ///
     597      /// Gives back the undirected edge by the unique id.  If the
     598      /// graph does not contain edge with the given id then the
     599      /// result of the function is undetermined.
     600      Node nodeFromANodeId(int) const { return INVALID;}
     601
     602      /// \brief Gives back an integer greater or equal to the maximum
     603      /// ANode id.
     604      ///
     605      /// Gives back an integer greater or equal to the maximum ANode
     606      /// id.
     607      int maxANodeId() const { return -1;}
     608
     609      /// \brief Gives back an unique integer id for the BNode.
     610      ///
     611      /// Gives back an unique integer id for the BNode.
     612      ///
     613      int bNodeId(const Node&) const { return -1;}
     614
     615      /// \brief Gives back the undirected edge by the unique id.
     616      ///
     617      /// Gives back the undirected edge by the unique id.  If the
     618      /// graph does not contain edge with the given id then the
     619      /// result of the function is undetermined.
     620      Node nodeFromBNodeId(int) const { return INVALID;}
     621
     622      /// \brief Gives back an integer greater or equal to the maximum
     623      /// BNode id.
     624      ///
     625      /// Gives back an integer greater or equal to the maximum BNode
     626      /// id.
     627      int maxBNodeId() const { return -1;}
    699628
    700629      template <typename _Graph>
    701630      struct Constraints {
    702         void constraints() {
    703           typename _Graph::Node node;
    704           graph.erase(node);
    705           typename _Graph::Edge edge;
    706           graph.erase(edge);
    707         }
    708 
    709         _Graph& graph;
    710       };
    711     };
    712 
    713     /// \brief An empty erasable base undirected graph class.
    714     /// 
    715     /// This class provides beside the core undirected graph features
    716     /// core erase functions for the undirceted graph structure.
    717     template <typename _Base = BaseUGraphComponent>
    718     class BaseErasableUGraphComponent : public _Base {
    719     public:
    720 
    721       typedef _Base Base;
    722       typedef typename Base::Node Node;
    723       typedef typename Base::UEdge UEdge;
    724 
    725       /// \brief Erase a node from the graph.
    726       ///
    727       /// Erase a node from the graph. This function should not
    728       /// erase edges connecting to the Node.
    729       void erase(const Node&) {}   
    730 
    731       /// \brief Erase an edge from the graph.
    732       ///
    733       /// Erase an edge from the graph.
    734       ///
    735       void erase(const UEdge&) {}
    736 
    737       template <typename _Graph>
    738       struct Constraints {
    739         void constraints() {
    740           typename _Graph::Node node;
    741           graph.erase(node);
    742           typename _Graph::Edge edge;
    743           graph.erase(edge);
    744         }
    745 
    746         _Graph& graph;
    747       };
    748     };
    749 
    750     /// \brief An empty clearable base graph class.
    751     ///
    752     /// This class provides beside the core graph features
    753     /// core clear functions for the graph structure.
    754     /// The most of the base graphs should be conform to this concept.
    755     template <typename _Base = BaseGraphComponent>
    756     class BaseClearableGraphComponent : public _Base {
    757     public:
    758 
    759       /// \brief Erase all the nodes and edges from the graph.
    760       ///
    761       /// Erase all the nodes and edges from the graph.
    762       ///
    763       void clear() {}   
    764 
    765       template <typename _Graph>
    766       struct Constraints {
    767         void constraints() {
    768           graph.clear();
    769         }
    770 
    771         _Graph graph;
    772       };
    773     };
    774 
    775     /// \brief An empty clearable base undirected graph class.
    776     ///
    777     /// This class provides beside the core undirected graph features
    778     /// core clear functions for the undirected graph structure.
    779     /// The most of the base graphs should be conform to this concept.
    780     template <typename _Base = BaseUGraphComponent>
    781     class BaseClearableUGraphComponent : public _Base {
    782     public:
    783 
    784       /// \brief Erase all the nodes and undirected edges from the graph.
    785       ///
    786       /// Erase all the nodes and undirected edges from the graph.
    787       ///
    788       void clear() {}   
    789 
    790       template <typename _Graph>
    791       struct Constraints {
    792         void constraints() {
    793           graph.clear();
    794         }
    795 
    796         _Graph graph;
    797       };
    798     };
    799 
     631
     632        void constraints() {
     633          checkConcept<Base, _Graph >();
     634          checkConcept<IDableGraphComponent<Base>, _Graph >();
     635          typename _Graph::Node node(INVALID);
     636          int id;
     637          id = graph.aNodeId(node);
     638          id = graph.bNodeId(node);
     639          node = graph.nodeFromANodeId(id);
     640          node = graph.nodeFromBNodeId(id);
     641          id = graph.maxANodeId();
     642          id = graph.maxBNodeId();
     643        }
     644
     645        const _Graph& graph;
     646      };
     647    };
    800648
    801649    /// \brief Skeleton class for graph NodeIt and EdgeIt
     
    948796    /// This class provides beside the core graph features
    949797    /// iterator based iterable interface for the graph structure.
    950     /// This concept is part of the GraphConcept.
     798    /// This concept is part of the Graph concept.
    951799    template <typename _Base = BaseGraphComponent>
    952800    class IterableGraphComponent : public _Base {
     
    960808      typedef IterableGraphComponent Graph;
    961809
     810      /// \name Base iteration
     811      ///
     812      /// This interface provides functions for iteration on graph items
     813      ///
     814      /// @{ 
     815
     816      /// \brief Gives back the first node in the iterating order.
     817      ///     
     818      /// Gives back the first node in the iterating order.
     819      ///     
     820      void first(Node&) const {}
     821
     822      /// \brief Gives back the next node in the iterating order.
     823      ///
     824      /// Gives back the next node in the iterating order.
     825      ///     
     826      void next(Node&) const {}
     827
     828      /// \brief Gives back the first edge in the iterating order.
     829      ///
     830      /// Gives back the first edge in the iterating order.
     831      ///     
     832      void first(Edge&) const {}
     833
     834      /// \brief Gives back the next edge in the iterating order.
     835      ///
     836      /// Gives back the next edge in the iterating order.
     837      ///     
     838      void next(Edge&) const {}
     839
     840
     841      /// \brief Gives back the first of the edges point to the given
     842      /// node.
     843      ///
     844      /// Gives back the first of the edges point to the given node.
     845      ///     
     846      void firstIn(Edge&, const Node&) const {}
     847
     848      /// \brief Gives back the next of the edges points to the given
     849      /// node.
     850      ///
     851      /// Gives back the next of the edges points to the given node.
     852      ///
     853      void nextIn(Edge&) const {}
     854
     855      /// \brief Gives back the first of the edges start from the
     856      /// given node.
     857      ///     
     858      /// Gives back the first of the edges start from the given node.
     859      ///     
     860      void firstOut(Edge&, const Node&) const {}
     861
     862      /// \brief Gives back the next of the edges start from the given
     863      /// node.
     864      ///
     865      /// Gives back the next of the edges start from the given node.
     866      ///     
     867      void nextOut(Edge&) const {}
     868
     869      /// @}
     870
     871      /// \name Class based iteration
     872      ///
     873      /// This interface provides functions for iteration on graph items
     874      ///
     875      /// @{
    962876
    963877      /// \brief This iterator goes through each node.
     
    1009923      Node runningNode(const OutEdgeIt&) const { return INVALID; }
    1010924
    1011       /// \brief The opposite node on the given edge.
    1012       ///
    1013       /// Gives back the opposite on the given edge.
    1014       /// \todo It should not be here.
    1015       Node oppositeNode(const Node&, const Edge&) const { return INVALID; }
    1016 
    1017    
     925      /// @}
     926
    1018927      template <typename _Graph>
    1019928      struct Constraints {
    1020929        void constraints() {
    1021930          checkConcept<Base, _Graph>();
    1022          
    1023           checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
    1024             typename _Graph::EdgeIt >();
    1025           checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
    1026             typename _Graph::NodeIt >();
    1027           checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
    1028             typename _Graph::Node, 'i'>, typename _Graph::InEdgeIt>();
    1029           checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
    1030             typename _Graph::Node, 'o'>, typename _Graph::OutEdgeIt>();
    1031 
    1032           typename _Graph::Node n;
    1033           typename _Graph::InEdgeIt ieit(INVALID);
    1034           typename _Graph::OutEdgeIt oeit(INVALID);
    1035           n = graph.baseNode(ieit);
    1036           n = graph.runningNode(ieit);
    1037           n = graph.baseNode(oeit);
    1038           n = graph.runningNode(oeit);
    1039           ignore_unused_variable_warning(n);
     931
     932          {
     933            typename _Graph::Node node(INVALID);     
     934            typename _Graph::Edge edge(INVALID);
     935            {
     936              graph.first(node);
     937              graph.next(node);
     938            }
     939            {
     940              graph.first(edge);
     941              graph.next(edge);
     942            }
     943            {
     944              graph.firstIn(edge, node);
     945              graph.nextIn(edge);
     946            }
     947            {
     948              graph.firstOut(edge, node);
     949              graph.nextOut(edge);
     950            }
     951          }           
     952
     953          {
     954            checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
     955              typename _Graph::EdgeIt >();
     956            checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
     957              typename _Graph::NodeIt >();
     958            checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
     959              typename _Graph::Node, 'i'>, typename _Graph::InEdgeIt>();
     960            checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
     961              typename _Graph::Node, 'o'>, typename _Graph::OutEdgeIt>();
     962
     963            typename _Graph::Node n;
     964            typename _Graph::InEdgeIt ieit(INVALID);
     965            typename _Graph::OutEdgeIt oeit(INVALID);
     966            n = graph.baseNode(ieit);
     967            n = graph.runningNode(ieit);
     968            n = graph.baseNode(oeit);
     969            n = graph.runningNode(oeit);
     970            ignore_unused_variable_warning(n);
     971          }
    1040972        }
    1041973       
     
    1049981    /// This class provides beside the core graph features iterator
    1050982    /// based iterable interface for the undirected graph structure.
    1051     /// This concept is part of the GraphConcept.
     983    /// This concept is part of the UGraph concept.
    1052984    template <typename _Base = BaseUGraphComponent>
    1053985    class IterableUGraphComponent : public IterableGraphComponent<_Base> {
     
    1061993   
    1062994      typedef IterableUGraphComponent Graph;
     995
     996      /// \name Base iteration
     997      ///
     998      /// This interface provides functions for iteration on graph items
     999      /// @{ 
     1000
     1001      using IterableGraphComponent<_Base>::first;
     1002      using IterableGraphComponent<_Base>::next;
     1003
     1004      /// \brief Gives back the first undirected edge in the iterating
     1005      /// order.
     1006      ///
     1007      /// Gives back the first undirected edge in the iterating order.
     1008      ///     
     1009      void first(UEdge&) const {}
     1010
     1011      /// \brief Gives back the next undirected edge in the iterating
     1012      /// order.
     1013      ///
     1014      /// Gives back the next undirected edge in the iterating order.
     1015      ///     
     1016      void next(UEdge&) const {}
     1017
     1018
     1019      /// \brief Gives back the first of the undirected edges from the
     1020      /// given node.
     1021      ///
     1022      /// Gives back the first of the undirected edges from the given
     1023      /// node. The bool parameter gives back that direction which
     1024      /// gives a good direction of the uedge so the source of the
     1025      /// directed edge is the given node.
     1026      void firstInc(UEdge&, bool&, const Node&) const {}
     1027
     1028      /// \brief Gives back the next of the undirected edges from the
     1029      /// given node.
     1030      ///
     1031      /// Gives back the next of the undirected edges from the given
     1032      /// node. The bool parameter should be used as the \c firstInc()
     1033      /// use it.
     1034      void nextInc(UEdge&, bool&) const {}
     1035
    10631036      using IterableGraphComponent<_Base>::baseNode;
    10641037      using IterableGraphComponent<_Base>::runningNode;
    10651038
     1039      /// @}
     1040
     1041      /// \name Class based iteration
     1042      ///
     1043      /// This interface provides functions for iteration on graph items
     1044      ///
     1045      /// @{
    10661046
    10671047      /// \brief This iterator goes through each node.
     
    10851065      Node runningNode(const IncEdgeIt&) const { return INVALID; }
    10861066
     1067      /// @}
     1068
    10871069      template <typename _Graph>
    10881070      struct Constraints {
    10891071        void constraints() {
    1090           checkConcept<Base, _Graph>();
    10911072          checkConcept<IterableGraphComponent<Base>, _Graph>();
    1092          
    1093           checkConcept<GraphItemIt<_Graph, typename _Graph::UEdge>,
    1094             typename _Graph::UEdgeIt >();
    1095           checkConcept<GraphIncIt<_Graph, typename _Graph::UEdge,
    1096             typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
    1097 
    1098           typename _Graph::Node n;
    1099           typename _Graph::IncEdgeIt ueit(INVALID);
    1100           n = graph.baseNode(ueit);
    1101           n = graph.runningNode(ueit);
     1073
     1074          {
     1075            typename _Graph::Node node(INVALID);
     1076            typename _Graph::UEdge uedge(INVALID);
     1077            bool dir;
     1078            {
     1079              graph.first(uedge);
     1080              graph.next(uedge);
     1081            }
     1082            {
     1083              graph.firstInc(uedge, dir, node);
     1084              graph.nextInc(uedge, dir);
     1085            }
     1086           
     1087          }     
     1088 
     1089          {
     1090            checkConcept<GraphItemIt<_Graph, typename _Graph::UEdge>,
     1091              typename _Graph::UEdgeIt >();
     1092            checkConcept<GraphIncIt<_Graph, typename _Graph::UEdge,
     1093              typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
     1094           
     1095            typename _Graph::Node n;
     1096            typename _Graph::IncEdgeIt ueit(INVALID);
     1097            n = graph.baseNode(ueit);
     1098            n = graph.runningNode(ueit);
     1099          }
     1100        }
     1101       
     1102        const _Graph& graph;
     1103       
     1104      };
     1105    };
     1106
     1107    /// \brief An empty iterable bipartite undirected graph class.
     1108    ///
     1109    /// This class provides beside the core graph features iterator
     1110    /// based iterable interface for the bipartite undirected graph
     1111    /// structure. This concept is part of the BpUGraph concept.
     1112    template <typename _Base = BaseUGraphComponent>
     1113    class IterableBpUGraphComponent : public IterableUGraphComponent<_Base> {
     1114    public:
     1115
     1116      typedef _Base Base;
     1117      typedef typename Base::Node Node;
     1118      typedef typename Base::UEdge UEdge;
     1119   
     1120      typedef IterableBpUGraphComponent Graph;
     1121
     1122      /// \name Base iteration
     1123      ///
     1124      /// This interface provides functions for iteration on graph items
     1125      /// @{ 
     1126
     1127      using IterableUGraphComponent<_Base>::first;
     1128      using IterableUGraphComponent<_Base>::next;
     1129
     1130      /// \brief Gives back the first A-node in the iterating order.
     1131      ///
     1132      /// Gives back the first undirected A-node in the iterating
     1133      /// order.
     1134      ///     
     1135      void firstANode(Node&) const {}
     1136
     1137      /// \brief Gives back the next A-node in the iterating order.
     1138      ///
     1139      /// Gives back the next A-node in the iterating order.
     1140      ///     
     1141      void nextANode(Node&) const {}
     1142
     1143      /// \brief Gives back the first B-node in the iterating order.
     1144      ///
     1145      /// Gives back the first undirected B-node in the iterating
     1146      /// order.
     1147      ///     
     1148      void firstBNode(Node&) const {}
     1149
     1150      /// \brief Gives back the next B-node in the iterating order.
     1151      ///
     1152      /// Gives back the next B-node in the iterating order.
     1153      ///     
     1154      void nextBNode(Node&) const {}
     1155
     1156
     1157      /// \brief Gives back the first of the undirected edges start
     1158      /// from the given A-node.
     1159      ///     
     1160      /// Gives back the first of the undirected edges start from the
     1161      /// given A-node.
     1162      void firstFromANode(UEdge&, const Node&) const {}
     1163
     1164      /// \brief Gives back the next of the undirected edges start
     1165      /// from the given A-node.
     1166      ///     
     1167      /// Gives back the next of the undirected edges start from the
     1168      /// given A-node.
     1169      void nextFromANode(UEdge&) const {}
     1170
     1171      /// \brief Gives back the first of the undirected edges start
     1172      /// from the given B-node.
     1173      ///     
     1174      /// Gives back the first of the undirected edges start from the
     1175      /// given B-node.
     1176      void firstFromBNode(UEdge&, const Node&) const {}
     1177
     1178      /// \brief Gives back the next of the undirected edges start
     1179      /// from the given B-node.
     1180      ///     
     1181      /// Gives back the next of the undirected edges start from the
     1182      /// given B-node.
     1183      void nextFromBNode(UEdge&) const {}
     1184
     1185
     1186      /// @}
     1187
     1188      /// \name Class based iteration
     1189      ///
     1190      /// This interface provides functions for iteration on graph items
     1191      ///
     1192      /// @{
     1193
     1194      /// \brief This iterator goes through each A-node.
     1195      ///
     1196      /// This iterator goes through each A-node.
     1197      typedef GraphItemIt<Graph, Node> ANodeIt;
     1198
     1199      /// \brief This iterator goes through each B-node.
     1200      ///
     1201      /// This iterator goes through each B-node.
     1202      typedef GraphItemIt<Graph, Node> BNodeIt;
     1203
     1204      /// @}
     1205
     1206      template <typename _Graph>
     1207      struct Constraints {
     1208        void constraints() {
     1209          checkConcept<IterableUGraphComponent<Base>, _Graph>();
     1210
     1211          {
     1212            typename _Graph::Node node(INVALID);
     1213            typename _Graph::UEdge uedge(INVALID);
     1214            graph.firstANode(node);
     1215            graph.nextANode(node);
     1216            graph.firstBNode(node);
     1217            graph.nextBNode(node);
     1218
     1219            graph.firstFromANode(uedge, node);
     1220            graph.nextFromANode(uedge);
     1221            graph.firstFromBNode(uedge, node);
     1222            graph.nextFromBNode(uedge);
     1223          }
     1224          {
     1225            checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
     1226              typename _Graph::ANodeIt >();
     1227            checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
     1228              typename _Graph::BNodeIt >();
     1229          }
     1230
    11021231        }
    11031232       
     
    11951324      struct Constraints {
    11961325        void constraints() {
    1197           checkConcept<Base, _Graph>();
    1198           checkConcept<AlterableGraphComponent, _Graph>();
     1326          checkConcept<AlterableGraphComponent<Base>, _Graph>();
    11991327          typename _Graph::UEdgeNotifier& uen
    12001328            = graph.getNotifier(typename _Graph::UEdge());
    12011329          ignore_unused_variable_warning(uen);
     1330        }
     1331       
     1332        const _Graph& graph;
     1333       
     1334      };
     1335     
     1336    };
     1337
     1338    /// \brief An empty alteration notifier bipartite undirected graph
     1339    /// class.
     1340    /// 
     1341    /// This class provides beside the core graph features alteration
     1342    /// notifier interface for the graph structure.  This implements
     1343    /// an observer-notifier pattern for each graph item. More
     1344    /// obsevers can be registered into the notifier and whenever an
     1345    /// alteration occured in the graph all the observers will
     1346    /// notified about it.
     1347    template <typename _Base = BaseUGraphComponent>
     1348    class AlterableBpUGraphComponent : public AlterableUGraphComponent<_Base> {
     1349    public:
     1350
     1351      typedef _Base Base;
     1352      typedef typename Base::ANode ANode;
     1353      typedef typename Base::BNode BNode;
     1354
     1355
     1356      /// The A-node observer registry.
     1357      typedef AlterationNotifier<AlterableBpUGraphComponent, ANode>
     1358      ANodeNotifier;
     1359
     1360      /// The B-node observer registry.
     1361      typedef AlterationNotifier<AlterableBpUGraphComponent, BNode>
     1362      BNodeNotifier;
     1363     
     1364      /// \brief Gives back the A-node alteration notifier.
     1365      ///
     1366      /// Gives back the A-node alteration notifier.
     1367      ANodeNotifier& getNotifier(ANode) const {
     1368        return ANodeNotifier();
     1369      }
     1370
     1371      /// \brief Gives back the B-node alteration notifier.
     1372      ///
     1373      /// Gives back the B-node alteration notifier.
     1374      BNodeNotifier& getNotifier(BNode) const {
     1375        return BNodeNotifier();
     1376      }
     1377
     1378      template <typename _Graph>
     1379      struct Constraints {
     1380        void constraints() {
     1381          checkConcept<AlterableUGraphComponent<Base>, _Graph>();
     1382          typename _Graph::ANodeNotifier& ann
     1383            = graph.getNotifier(typename _Graph::ANode());
     1384          typename _Graph::BNodeNotifier& bnn
     1385            = graph.getNotifier(typename _Graph::BNode());
     1386          ignore_unused_variable_warning(ann);
     1387          ignore_unused_variable_warning(bnn);
    12021388        }
    12031389       
     
    14161602    };
    14171603
    1418     /// \brief An empty mappable base graph class.
     1604    /// \brief An empty mappable base bipartite undirected graph class.
    14191605    ///
    14201606    /// This class provides beside the core graph features
     
    14791665
    14801666        void constraints() {
    1481           checkConcept<Base, _Graph>();
    14821667          checkConcept<MappableGraphComponent<Base>, _Graph>();
    14831668
     
    15011686    };
    15021687
     1688    /// \brief An empty mappable base bipartite undirected graph
     1689    /// class.
     1690    ///
     1691    /// This class provides beside the core graph features
     1692    /// map interface for the graph structure.
     1693    /// This concept is part of the BpUGraph concept.
     1694    template <typename _Base = BaseBpUGraphComponent>
     1695    class MappableBpUGraphComponent : public MappableUGraphComponent<_Base>  {
     1696    public:
     1697
     1698      typedef _Base Base;
     1699      typedef typename Base::Node Node;
     1700
     1701      typedef MappableBpUGraphComponent Graph;
     1702
     1703      /// \brief ReadWrite map of the A-nodes.
     1704      ///
     1705      /// ReadWrite map of the A-nodes.
     1706      ///
     1707      template <typename _Value>
     1708      class ANodeMap : public GraphMap<Graph, Node, _Value> { 
     1709      public:
     1710        typedef GraphMap<MappableBpUGraphComponent, Node, _Value> Parent;
     1711
     1712        /// \brief Construct a new map.
     1713        ///
     1714        /// Construct a new map for the graph.
     1715        /// \todo call the right parent class constructor
     1716        explicit ANodeMap(const MappableBpUGraphComponent& graph)
     1717          : Parent(graph) {}
     1718
     1719        /// \brief Construct a new map with default value.
     1720        ///
     1721        /// Construct a new map for the graph and initalise the values.
     1722        ANodeMap(const MappableBpUGraphComponent& graph, const _Value& value)
     1723          : Parent(graph, value) {}
     1724
     1725        /// \brief Copy constructor.
     1726        ///
     1727        /// Copy Constructor.
     1728        ANodeMap(const ANodeMap& nm) : Parent(nm) {}
     1729
     1730        /// \brief Assign operator.
     1731        ///
     1732        /// Assign operator.
     1733        template <typename CMap>
     1734        ANodeMap& operator=(const CMap&) {
     1735          checkConcept<ReadMap<Node, _Value>, CMap>();
     1736          return *this;
     1737        }
     1738
     1739      };
     1740
     1741      /// \brief ReadWrite map of the B-nodes.
     1742      ///
     1743      /// ReadWrite map of the A-nodes.
     1744      ///
     1745      template <typename _Value>
     1746      class BNodeMap : public GraphMap<Graph, Node, _Value> { 
     1747      public:
     1748        typedef GraphMap<MappableBpUGraphComponent, Node, _Value> Parent;
     1749
     1750        /// \brief Construct a new map.
     1751        ///
     1752        /// Construct a new map for the graph.
     1753        /// \todo call the right parent class constructor
     1754        explicit BNodeMap(const MappableBpUGraphComponent& graph)
     1755          : Parent(graph) {}
     1756
     1757        /// \brief Construct a new map with default value.
     1758        ///
     1759        /// Construct a new map for the graph and initalise the values.
     1760        BNodeMap(const MappableBpUGraphComponent& graph, const _Value& value)
     1761          : Parent(graph, value) {}
     1762
     1763        /// \brief Copy constructor.
     1764        ///
     1765        /// Copy Constructor.
     1766        BNodeMap(const BNodeMap& nm) : Parent(nm) {}
     1767
     1768        /// \brief Assign operator.
     1769        ///
     1770        /// Assign operator.
     1771        template <typename CMap>
     1772        BNodeMap& operator=(const CMap&) {
     1773          checkConcept<ReadMap<Node, _Value>, CMap>();
     1774          return *this;
     1775        }
     1776
     1777      };
     1778
     1779
     1780      template <typename _Graph>
     1781      struct Constraints {
     1782
     1783        struct Dummy {
     1784          int value;
     1785          Dummy() : value(0) {}
     1786          Dummy(int _v) : value(_v) {}
     1787        };
     1788
     1789        void constraints() {
     1790          checkConcept<MappableUGraphComponent<Base>, _Graph>();
     1791
     1792          { // int map test
     1793            typedef typename _Graph::template ANodeMap<int> IntANodeMap;
     1794            checkConcept<GraphMap<_Graph, typename _Graph::ANode, int>,
     1795              IntANodeMap >();
     1796          } { // bool map test
     1797            typedef typename _Graph::template ANodeMap<bool> BoolANodeMap;
     1798            checkConcept<GraphMap<_Graph, typename _Graph::ANode, bool>,
     1799              BoolANodeMap >();
     1800          } { // Dummy map test
     1801            typedef typename _Graph::template ANodeMap<Dummy> DummyANodeMap;
     1802            checkConcept<GraphMap<_Graph, typename _Graph::ANode, Dummy>,
     1803              DummyANodeMap >();
     1804          }
     1805        }
     1806
     1807        _Graph& graph;
     1808      };
     1809    };
     1810
    15031811
    15041812    /// \brief An empty extendable graph class.
     
    15111819    class ExtendableGraphComponent : public _Base {
    15121820    public:
     1821      typedef _Base Base;
    15131822
    15141823      typedef typename _Base::Node Node;
     
    15331842      struct Constraints {
    15341843        void constraints() {
     1844          checkConcept<Base, _Graph>();
    15351845          typename _Graph::Node node_a, node_b;
    15361846          node_a = graph.addNode();
     
    15551865    public:
    15561866
     1867      typedef _Base Base;
    15571868      typedef typename _Base::Node Node;
    15581869      typedef typename _Base::UEdge UEdge;
     
    15761887      struct Constraints {
    15771888        void constraints() {
     1889          checkConcept<Base, _Graph>();
    15781890          typename _Graph::Node node_a, node_b;
    15791891          node_a = graph.addNode();
     
    15841896
    15851897        _Graph& graph;
     1898      };
     1899    };
     1900
     1901    /// \brief An empty extendable base undirected graph class.
     1902    ///
     1903    /// This class provides beside the core bipartite undirected graph
     1904    /// features core undircted graph extend interface for the graph
     1905    /// structure.  The main difference between the base and this
     1906    /// interface is that the graph alterations should handled already
     1907    /// on this level.
     1908    template <typename _Base = BaseBpUGraphComponent>
     1909    class ExtendableBpUGraphComponent
     1910      : public ExtendableUGraphComponent<_Base> {
     1911
     1912      typedef _Base Base;
     1913
     1914      template <typename _Graph>
     1915      struct Constraints {
     1916        void constraints() {
     1917          checkConcept<ExtendableUGraphComponent<Base>, _Graph>();
     1918        }
    15861919      };
    15871920    };
     
    16161949      struct Constraints {
    16171950        void constraints() {
     1951          checkConcept<Base, _Graph>();
    16181952          typename _Graph::Node node;
    16191953          graph.erase(node);
     
    16551989      struct Constraints {
    16561990        void constraints() {
     1991          checkConcept<Base, _Graph>();
    16571992          typename _Graph::Node node;
    16581993          graph.erase(node);
     
    16621997
    16631998        _Graph& graph;
     1999      };
     2000    };
     2001
     2002    /// \brief An empty erasable base bipartite undirected graph class.
     2003    /// 
     2004    /// This class provides beside the core bipartite undirected graph
     2005    /// features core erase functions for the undirceted graph
     2006    /// structure. The main difference between the base and this
     2007    /// interface is that the graph alterations should handled already
     2008    /// on this level.
     2009    template <typename _Base = BaseBpUGraphComponent>
     2010    class ErasableBpUGraphComponent : public ErasableUGraphComponent<_Base> {
     2011    public:
     2012
     2013      typedef _Base Base;
     2014
     2015      template <typename _Graph>
     2016      struct Constraints {
     2017        void constraints() {
     2018          checkConcept<ErasableUGraphComponent<Base>, _Graph>();
     2019        }
    16642020      };
    16652021    };
     
    16752031    public:
    16762032
     2033      typedef _Base Base;
     2034
    16772035      /// \brief Erase all nodes and edges from the graph.
    16782036      ///
     
    16842042      struct Constraints {
    16852043        void constraints() {
     2044          checkConcept<Base, _Graph>();
    16862045          graph.clear();
    16872046        }
     
    16982057    /// the graph alterations should handled already on this level.
    16992058    template <typename _Base = BaseUGraphComponent>
    1700     class ClearableUGraphComponent : public _Base {
    1701     public:
    1702 
    1703       /// \brief Erase all nodes and undirected edges from the graph.
    1704       ///
    1705       /// Erase all nodes and undirected edges from the graph.
    1706       ///
    1707       void clear() {}   
     2059    class ClearableUGraphComponent : public ClearableUGraphComponent<_Base> {
     2060    public:
     2061
     2062      typedef _Base Base;
    17082063
    17092064      template <typename _Graph>
    17102065      struct Constraints {
    17112066        void constraints() {
    1712           graph.clear();
     2067          checkConcept<ClearableUGraphComponent<Base>, _Graph>();
    17132068        }
    17142069
     
    17172072    };
    17182073
     2074    /// \brief An empty clearable base bipartite undirected graph
     2075    /// class.
     2076    ///
     2077    /// This class provides beside the core bipartite undirected graph
     2078    /// features core clear functions for the undirected graph
     2079    /// structure. The main difference between the base and this
     2080    /// interface is that the graph alterations should handled already
     2081    /// on this level.
     2082    template <typename _Base = BaseUGraphComponent>
     2083    class ClearableBpUGraphComponent
     2084      : public ClearableBpUGraphComponent<_Base> {
     2085    public:
     2086
     2087      typedef _Base Base;
     2088
     2089      template <typename _Graph>
     2090      struct Constraints {
     2091        void constraints() {
     2092          checkConcept<ClearableBpUGraphComponent<Base>, _Graph>();
     2093        }
     2094
     2095      };
     2096
     2097    };
     2098
    17192099  }
    17202100
Note: See TracChangeset for help on using the changeset viewer.