COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/lemon/skeletons/graph.h @ 938:70e2886211d5

Last change on this file since 938:70e2886211d5 was 938:70e2886211d5, checked in by Alpar Juttner, 19 years ago

Many of ckeckCompileXYZ()'s are now in the corresponding skeleton headers.
(Tests for Symmetric Graphs are still to be moved)

File size: 20.4 KB
RevLine 
[906]1/* -*- C++ -*-
[921]2 * src/lemon/skeletons/graph.h - Part of LEMON, a generic C++ optimization library
[906]3 *
4 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Combinatorial Optimization Research Group, EGRES).
6 *
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
10 *
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
13 * purpose.
14 *
15 */
16
[921]17#ifndef LEMON_SKELETON_GRAPH_H
18#define LEMON_SKELETON_GRAPH_H
[52]19
[794]20///\ingroup skeletons
[242]21///\file
[880]22///\brief Declaration of Graph.
[242]23
[921]24#include <lemon/invalid.h>
25#include <lemon/skeletons/maps.h>
[145]26
[921]27namespace lemon {
[732]28  namespace skeleton {
29   
[794]30    /// \addtogroup skeletons
31    /// @{
[163]32
[732]33    /// An empty static graph class.
34 
35    /// This class provides all the common features of a graph structure,
36    /// however completely without implementations and real data structures
37    /// behind the interface.
38    /// All graph algorithms should compile with this class, but it will not
39    /// run properly, of course.
40    ///
41    /// It can be used for checking the interface compatibility,
42    /// or it can serve as a skeleton of a new graph structure.
43    ///
44    /// Also, you will find here the full documentation of a certain graph
45    /// feature, the documentation of a real graph imlementation
46    /// like @ref ListGraph or
47    /// @ref SmartGraph will just refer to this structure.
[938]48    ///
49    /// \todo A pages describing the concept of concept description would
50    /// be nice.
[880]51    class StaticGraph
[732]52    {
53    public:
54      /// Defalult constructor.
[801]55
56      /// Defalult constructor.
57      ///
[880]58      StaticGraph() { }
[732]59      ///Copy consructor.
[163]60
[801]61//       ///\todo It is not clear, what we expect from a copy constructor.
62//       ///E.g. How to assign the nodes/edges to each other? What about maps?
[880]63//       StaticGraph(const StaticGraph& g) { }
[732]64
[774]65      /// The base type of node iterators,
66      /// or in other words, the trivial node iterator.
[732]67
[774]68      /// This is the base type of each node iterator,
69      /// thus each kind of node iterator converts to this.
[801]70      /// More precisely each kind of node iterator should be inherited
[774]71      /// from the trivial node iterator.
[732]72      class Node {
73      public:
[801]74        /// Default constructor
75
[732]76        /// @warning The default constructor sets the iterator
77        /// to an undefined value.
[774]78        Node() { }
79        /// Copy constructor.
[801]80
81        /// Copy constructor.
82        ///
[774]83        Node(const Node&) { }
[801]84
[732]85        /// Invalid constructor \& conversion.
86
87        /// This constructor initializes the iterator to be invalid.
88        /// \sa Invalid for more details.
[774]89        Node(Invalid) { }
[801]90        /// Equality operator
91
[732]92        /// Two iterators are equal if and only if they point to the
93        /// same object or both are invalid.
94        bool operator==(Node) const { return true; }
95
[801]96        /// Inequality operator
97       
[911]98        /// \sa operator==(Node n)
[732]99        ///
100        bool operator!=(Node) const { return true; }
101
[801]102        ///Comparison operator.
103
104        ///This is a strict ordering between the nodes.
105        ///
106        ///This ordering can be different from the order in which NodeIt
107        ///goes through the nodes.
108        ///\todo Possibly we don't need it.
[732]109        bool operator<(Node) const { return true; }
110      };
111   
112      /// This iterator goes through each node.
113
114      /// This iterator goes through each node.
115      /// Its usage is quite simple, for example you can count the number
[774]116      /// of nodes in graph \c g of type \c Graph like this:
[732]117      /// \code
[774]118      /// int count=0;
[801]119      /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
[732]120      /// \endcode
121      class NodeIt : public Node {
122      public:
[801]123        /// Default constructor
124
[732]125        /// @warning The default constructor sets the iterator
126        /// to an undefined value.
[774]127        NodeIt() { }
128        /// Copy constructor.
[801]129       
130        /// Copy constructor.
131        ///
[774]132        NodeIt(const NodeIt&) { }
[732]133        /// Invalid constructor \& conversion.
134
[774]135        /// Initialize the iterator to be invalid.
[732]136        /// \sa Invalid for more details.
[774]137        NodeIt(Invalid) { }
[801]138        /// Sets the iterator to the first node.
139
[774]140        /// Sets the iterator to the first node of \c g.
[801]141        ///
[880]142        NodeIt(const StaticGraph& g) { }
[801]143        /// Node -> NodeIt conversion.
144
[774]145        /// Sets the iterator to the node of \c g pointed by the trivial
[801]146        /// iterator n.
147        /// This feature necessitates that each time we
148        /// iterate the edge-set, the iteration order is the same.
[880]149        NodeIt(const StaticGraph& g, const Node& n) { }
[801]150        /// Next node.
151
[774]152        /// Assign the iterator to the next node.
[801]153        ///
[774]154        NodeIt& operator++() { return *this; }
[732]155      };
156   
157   
158      /// The base type of the edge iterators.
[801]159
160      /// The base type of the edge iterators.
161      ///
[732]162      class Edge {
163      public:
[801]164        /// Default constructor
165
[732]166        /// @warning The default constructor sets the iterator
167        /// to an undefined value.
[774]168        Edge() { }
169        /// Copy constructor.
[801]170
171        /// Copy constructor.
172        ///
[774]173        Edge(const Edge&) { }
174        /// Initialize the iterator to be invalid.
[801]175
176        /// Initialize the iterator to be invalid.
177        ///
[774]178        Edge(Invalid) { }
[801]179        /// Equality operator
180
[732]181        /// Two iterators are equal if and only if they point to the
182        /// same object or both are invalid.
183        bool operator==(Edge) const { return true; }
[801]184        /// Inequality operator
185
[911]186        /// \sa operator==(Node n)
[801]187        ///
[732]188        bool operator!=(Edge) const { return true; }
[801]189        ///Comparison operator.
190
191        ///This is a strict ordering between the nodes.
192        ///
193        ///This ordering can be different from the order in which NodeIt
194        ///goes through the nodes.
195        ///\todo Possibly we don't need it.
196        bool operator<(Edge) const { return true; }
[732]197      };
198   
199      /// This iterator goes trough the outgoing edges of a node.
200
201      /// This iterator goes trough the \e outgoing edges of a certain node
202      /// of a graph.
203      /// Its usage is quite simple, for example you can count the number
204      /// of outgoing edges of a node \c n
[774]205      /// in graph \c g of type \c Graph as follows.
[732]206      /// \code
[774]207      /// int count=0;
[801]208      /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
[732]209      /// \endcode
210   
211      class OutEdgeIt : public Edge {
212      public:
[801]213        /// Default constructor
214
[732]215        /// @warning The default constructor sets the iterator
216        /// to an undefined value.
[774]217        OutEdgeIt() { }
218        /// Copy constructor.
[801]219
220        /// Copy constructor.
221        ///
[774]222        OutEdgeIt(const OutEdgeIt&) { }
223        /// Initialize the iterator to be invalid.
[801]224
225        /// Initialize the iterator to be invalid.
226        ///
[774]227        OutEdgeIt(Invalid) { }
[732]228        /// This constructor sets the iterator to first outgoing edge.
229   
230        /// This constructor set the iterator to the first outgoing edge of
231        /// node
232        ///@param n the node
[774]233        ///@param g the graph
[880]234        OutEdgeIt(const StaticGraph& g, const Node& n) { }
[801]235        /// Edge -> OutEdgeIt conversion
236
[774]237        /// Sets the iterator to the value of the trivial iterator \c e.
238        /// This feature necessitates that each time we
239        /// iterate the edge-set, the iteration order is the same.
[880]240        OutEdgeIt(const StaticGraph& g, const Edge& e) { }
[801]241        ///Next outgoing edge
242       
243        /// Assign the iterator to the next
244        /// outgoing edge of the corresponding node.
[774]245        OutEdgeIt& operator++() { return *this; }
[732]246      };
247
248      /// This iterator goes trough the incoming edges of a node.
249
250      /// This iterator goes trough the \e incoming edges of a certain node
251      /// of a graph.
252      /// Its usage is quite simple, for example you can count the number
253      /// of outgoing edges of a node \c n
[774]254      /// in graph \c g of type \c Graph as follows.
[732]255      /// \code
[774]256      /// int count=0;
[801]257      /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
[732]258      /// \endcode
259
260      class InEdgeIt : public Edge {
261      public:
[801]262        /// Default constructor
263
[732]264        /// @warning The default constructor sets the iterator
265        /// to an undefined value.
[774]266        InEdgeIt() { }
267        /// Copy constructor.
[801]268
269        /// Copy constructor.
270        ///
[774]271        InEdgeIt(const InEdgeIt&) { }
272        /// Initialize the iterator to be invalid.
[801]273
274        /// Initialize the iterator to be invalid.
275        ///
[774]276        InEdgeIt(Invalid) { }
[801]277        /// This constructor sets the iterator to first incoming edge.
278   
279        /// This constructor set the iterator to the first incoming edge of
280        /// node
281        ///@param n the node
282        ///@param g the graph
[880]283        InEdgeIt(const StaticGraph& g, const Node& n) { }
[801]284        /// Edge -> InEdgeIt conversion
285
286        /// Sets the iterator to the value of the trivial iterator \c e.
287        /// This feature necessitates that each time we
288        /// iterate the edge-set, the iteration order is the same.
[880]289        InEdgeIt(const StaticGraph& g, const Edge& n) { }
[801]290        /// Next incoming edge
291
[774]292        /// Assign the iterator to the next inedge of the corresponding node.
[801]293        ///
[774]294        InEdgeIt& operator++() { return *this; }
[732]295      };
296      /// This iterator goes through each edge.
297
298      /// This iterator goes through each edge of a graph.
299      /// Its usage is quite simple, for example you can count the number
[774]300      /// of edges in a graph \c g of type \c Graph as follows:
[732]301      /// \code
[774]302      /// int count=0;
[801]303      /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
[732]304      /// \endcode
305      class EdgeIt : public Edge {
306      public:
[801]307        /// Default constructor
308
[732]309        /// @warning The default constructor sets the iterator
310        /// to an undefined value.
[774]311        EdgeIt() { }
312        /// Copy constructor.
[801]313
314        /// Copy constructor.
315        ///
[774]316        EdgeIt(const EdgeIt&) { }
317        /// Initialize the iterator to be invalid.
[801]318
319        /// Initialize the iterator to be invalid.
320        ///
[774]321        EdgeIt(Invalid) { }
[801]322        /// This constructor sets the iterator to first edge.
323   
324        /// This constructor set the iterator to the first edge of
325        /// node
326        ///@param g the graph
[880]327        EdgeIt(const StaticGraph& g) { }
[801]328        /// Edge -> EdgeIt conversion
329
330        /// Sets the iterator to the value of the trivial iterator \c e.
331        /// This feature necessitates that each time we
332        /// iterate the edge-set, the iteration order is the same.
[880]333        EdgeIt(const StaticGraph&, const Edge&) { }
[801]334        ///Next edge
335       
336        /// Assign the iterator to the next
337        /// edge of the corresponding node.
[774]338        EdgeIt& operator++() { return *this; }
[732]339      };
340
341      /// First node of the graph.
342
343      /// \retval i the first node.
344      /// \return the first node.
345      ///
[774]346      NodeIt& first(NodeIt& i) const { return i; }
[732]347
348      /// The first incoming edge.
[801]349
350      /// The first incoming edge.
351      ///
[774]352      InEdgeIt& first(InEdgeIt &i, Node) const { return i; }
[732]353      /// The first outgoing edge.
[801]354
355      /// The first outgoing edge.
356      ///
[774]357      OutEdgeIt& first(OutEdgeIt& i, Node) const { return i; }
[732]358      /// The first edge of the Graph.
[801]359
360      /// The first edge of the Graph.
361      ///
[774]362      EdgeIt& first(EdgeIt& i) const { return i; }
[732]363
[801]364      ///Gives back the head node of an edge.
[732]365
366      ///Gives back the head node of an edge.
[801]367      ///
[732]368      Node head(Edge) const { return INVALID; }
369      ///Gives back the tail node of an edge.
[801]370
371      ///Gives back the tail node of an edge.
372      ///
[732]373      Node tail(Edge) const { return INVALID; }
[163]374 
[732]375      ///Gives back the \e id of a node.
[182]376
[732]377      ///\warning Not all graph structures provide this feature.
378      ///
[801]379      ///\todo Should each graph provide \c id?
[774]380      int id(const Node&) const { return 0; }
[732]381      ///Gives back the \e id of an edge.
[182]382
[732]383      ///\warning Not all graph structures provide this feature.
[182]384      ///
[801]385      ///\todo Should each graph provide \c id?
[774]386      int id(const Edge&) const { return 0; }
[182]387
[911]388      ///\e
[801]389     
[880]390      ///\todo Should it be in the concept?
[801]391      ///
[774]392      int nodeNum() const { return 0; }
[911]393      ///\e
[880]394
395      ///\todo Should it be in the concept?
[801]396      ///
[774]397      int edgeNum() const { return 0; }
[732]398
399
400      ///Reference map of the nodes to type \c T.
401
[880]402      /// \ingroup skeletons
[732]403      ///Reference map of the nodes to type \c T.
[880]404      /// \sa Reference
[732]405      /// \warning Making maps that can handle bool type (NodeMap<bool>)
[801]406      /// needs some extra attention!
[880]407      template<class T> class NodeMap : public ReferenceMap< Node, T >
[732]408      {
409      public:
410
[911]411        ///\e
[880]412        NodeMap(const StaticGraph&) { }
[911]413        ///\e
[880]414        NodeMap(const StaticGraph&, T) { }
[732]415
416        ///Copy constructor
[774]417        template<typename TT> NodeMap(const NodeMap<TT>&) { }
[732]418        ///Assignment operator
[774]419        template<typename TT> NodeMap& operator=(const NodeMap<TT>&)
420        { return *this; }
[732]421      };
422
423      ///Reference map of the edges to type \c T.
424
[880]425      /// \ingroup skeletons
[732]426      ///Reference map of the edges to type \c T.
[880]427      /// \sa Reference
[732]428      /// \warning Making maps that can handle bool type (EdgeMap<bool>)
[801]429      /// needs some extra attention!
[732]430      template<class T> class EdgeMap
431        : public ReferenceMap<Edge,T>
432      {
433      public:
434
[911]435        ///\e
[880]436        EdgeMap(const StaticGraph&) { }
[911]437        ///\e
[880]438        EdgeMap(const StaticGraph&, T) { }
[147]439   
[732]440        ///Copy constructor
[774]441        template<typename TT> EdgeMap(const EdgeMap<TT>&) { }
[732]442        ///Assignment operator
[774]443        template<typename TT> EdgeMap &operator=(const EdgeMap<TT>&)
444        { return *this; }
[732]445      };
[163]446    };
447
[938]448    struct DummyType {
449      int value;
450      DummyType() {}
451      DummyType(int p) : value(p) {}
452      DummyType& operator=(int p) { value = p; return *this;}
453    };
454   
455    ///\brief Checks whether \c G meets the
456    ///\ref lemon::skeleton::StaticGraph "StaticGraph" concept
457    template<class Graph> void checkCompileStaticGraph(Graph &G)
458    {
459      typedef typename Graph::Node Node;
460      typedef typename Graph::NodeIt NodeIt;
461      typedef typename Graph::Edge Edge;
462      typedef typename Graph::EdgeIt EdgeIt;
463      typedef typename Graph::InEdgeIt InEdgeIt;
464      typedef typename Graph::OutEdgeIt OutEdgeIt;
465 
466      {
467        Node i; Node j(i); Node k(INVALID);
468        i=j;
469        bool b; b=true;
470        b=(i==INVALID); b=(i!=INVALID);
471        b=(i==j); b=(i!=j); b=(i<j);
472      }
473      {
474        NodeIt i; NodeIt j(i); NodeIt k(INVALID); NodeIt l(G);
475        i=j;
476        j=G.first(i);
477        j=++i;
478        bool b; b=true;
479        b=(i==INVALID); b=(i!=INVALID);
480        Node n(i);
481        n=i;
482        b=(i==j); b=(i!=j); b=(i<j);
483        //Node ->NodeIt conversion
484        NodeIt ni(G,n);
485      }
486      {
487        Edge i; Edge j(i); Edge k(INVALID);
488        i=j;
489        bool b; b=true;
490        b=(i==INVALID); b=(i!=INVALID);
491        b=(i==j); b=(i!=j); b=(i<j);
492      }
493      {
494        EdgeIt i; EdgeIt j(i); EdgeIt k(INVALID); EdgeIt l(G);
495        i=j;
496        j=G.first(i);
497        j=++i;
498        bool b; b=true;
499        b=(i==INVALID); b=(i!=INVALID);
500        Edge e(i);
501        e=i;
502        b=(i==j); b=(i!=j); b=(i<j);
503        //Edge ->EdgeIt conversion
504        EdgeIt ei(G,e);
505      }
506      {
507        Node n;
508        InEdgeIt i; InEdgeIt j(i); InEdgeIt k(INVALID); InEdgeIt l(G,n);
509        i=j;
510        j=G.first(i,n);
511        j=++i;
512        bool b; b=true;
513        b=(i==INVALID); b=(i!=INVALID);
514        Edge e(i);
515        e=i;
516        b=(i==j); b=(i!=j); b=(i<j);
517        //Edge ->InEdgeIt conversion
518        InEdgeIt ei(G,e);
519      }
520      {
521        Node n;
522        OutEdgeIt i; OutEdgeIt j(i); OutEdgeIt k(INVALID); OutEdgeIt l(G,n);
523        i=j;
524        j=G.first(i,n);
525        j=++i;
526        bool b; b=true;
527        b=(i==INVALID); b=(i!=INVALID);
528        Edge e(i);
529        e=i;
530        b=(i==j); b=(i!=j); b=(i<j);
531        //Edge ->OutEdgeIt conversion
532        OutEdgeIt ei(G,e);
533      }
534      {
535        Node n,m;
536        n=m=INVALID;
537        Edge e;
538        e=INVALID;
539        n=G.tail(e);
540        n=G.head(e);
541      }
542      // id tests
543      { Node n; int i=G.id(n); i=i; }
544      { Edge e; int i=G.id(e); i=i; }
545      //NodeMap tests
546      {
547        Node k;
548        typename Graph::template NodeMap<int> m(G);
549        //Const map
550        typename Graph::template NodeMap<int> const &cm = m;
551        //Inicialize with default value
552        typename Graph::template NodeMap<int> mdef(G,12);
553        //Copy
554        typename Graph::template NodeMap<int> mm(cm);
555        //Copy from another type
556        typename Graph::template NodeMap<double> dm(cm);
557        //Copy to more complex type
558        typename Graph::template NodeMap<DummyType> em(cm);
559        int v;
560        v=m[k]; m[k]=v; m.set(k,v);
561        v=cm[k];
562   
563        m=cm; 
564        dm=cm; //Copy from another type 
565        em=cm; //Copy to more complex type
566        {
567          //Check the typedef's
568          typename Graph::template NodeMap<int>::ValueType val;
569          val=1;
570          typename Graph::template NodeMap<int>::KeyType key;
571          key = typename Graph::NodeIt(G);
572        }
573      } 
574      { //bool NodeMap
575        Node k;
576        typename Graph::template NodeMap<bool> m(G);
577        typename Graph::template NodeMap<bool> const &cm = m;  //Const map
578        //Inicialize with default value
579        typename Graph::template NodeMap<bool> mdef(G,12);
580        typename Graph::template NodeMap<bool> mm(cm);   //Copy
581        typename Graph::template NodeMap<int> dm(cm); //Copy from another type
582        bool v;
583        v=m[k]; m[k]=v; m.set(k,v);
584        v=cm[k];
585   
586        m=cm; 
587        dm=cm; //Copy from another type
588        m=dm; //Copy to another type
[186]589
[938]590        {
591          //Check the typedef's
592          typename Graph::template NodeMap<bool>::ValueType val;
593          val=true;
594          typename Graph::template NodeMap<bool>::KeyType key;
595          key= typename Graph::NodeIt(G);
596        }
597      }
598      //EdgeMap tests
599      {
600        Edge k;
601        typename Graph::template EdgeMap<int> m(G);
602        typename Graph::template EdgeMap<int> const &cm = m;  //Const map
603        //Inicialize with default value
604        typename Graph::template EdgeMap<int> mdef(G,12);
605        typename Graph::template EdgeMap<int> mm(cm);   //Copy
606        typename Graph::template EdgeMap<double> dm(cm);//Copy from another type
607        int v;
608        v=m[k]; m[k]=v; m.set(k,v);
609        v=cm[k];
610   
611        m=cm; 
612        dm=cm; //Copy from another type
613        {
614          //Check the typedef's
615          typename Graph::template EdgeMap<int>::ValueType val;
616          val=1;
617          typename Graph::template EdgeMap<int>::KeyType key;
618          key= typename Graph::EdgeIt(G);
619        }
620      } 
621      { //bool EdgeMap
622        Edge k;
623        typename Graph::template EdgeMap<bool> m(G);
624        typename Graph::template EdgeMap<bool> const &cm = m;  //Const map
625        //Inicialize with default value
626        typename Graph::template EdgeMap<bool> mdef(G,12);
627        typename Graph::template EdgeMap<bool> mm(cm);   //Copy
628        typename Graph::template EdgeMap<int> dm(cm); //Copy from another type
629        bool v;
630        v=m[k]; m[k]=v; m.set(k,v);
631        v=cm[k];
632   
633        m=cm; 
634        dm=cm; //Copy from another type
635        m=dm; //Copy to another type
636        {
637          //Check the typedef's
638          typename Graph::template EdgeMap<bool>::ValueType val;
639          val=true;
640          typename Graph::template EdgeMap<bool>::KeyType key;
641          key= typename Graph::EdgeIt(G);
642        }
643      }
644    }
645   
[801]646    /// An empty non-static graph class.
[938]647   
[880]648    /// This class provides everything that \ref StaticGraph
[732]649    /// with additional functionality which enables to build a
650    /// graph from scratch.
[880]651    class ExtendableGraph : public StaticGraph
[732]652    {
[163]653    public:
[732]654      /// Defalult constructor.
[801]655
656      /// Defalult constructor.
657      ///
[880]658      ExtendableGraph() { }
[732]659      ///Add a new node to the graph.
660
661      /// \return the new node.
662      ///
[774]663      Node addNode() { return INVALID; }
[732]664      ///Add a new edge to the graph.
665
[880]666      ///Add a new edge to the graph with tail node \c t
667      ///and head node \c h.
[732]668      ///\return the new edge.
[880]669      Edge addEdge(Node h, Node t) { return INVALID; }
[732]670   
671      /// Resets the graph.
672
673      /// This function deletes all edges and nodes of the graph.
674      /// It also frees the memory allocated to store them.
[880]675      /// \todo It might belong to \ref ErasableGraph.
[774]676      void clear() { }
[163]677    };
678
[938]679   
680    ///\brief Checks whether \c G meets the
681    ///\ref lemon::skeleton::ExtendableGraph "ExtendableGraph" concept
682    template<class Graph> void checkCompileExtendableGraph(Graph &G)
683    {
684      checkCompileStaticGraph(G);
685
686      typedef typename Graph::Node Node;
687      typedef typename Graph::NodeIt NodeIt;
688      typedef typename Graph::Edge Edge;
689      typedef typename Graph::EdgeIt EdgeIt;
690      typedef typename Graph::InEdgeIt InEdgeIt;
691      typedef typename Graph::OutEdgeIt OutEdgeIt;
692 
693      Node n,m;
694      n=G.addNode();
695      m=G.addNode();
696      Edge e;
697      e=G.addEdge(n,m);
698 
699      //  G.clear();
700    }
701
702
[826]703    /// An empty erasable graph class.
[52]704 
[880]705    /// This class is an extension of \ref ExtendableGraph. It also makes it
[732]706    /// possible to erase edges or nodes.
[880]707    class ErasableGraph : public ExtendableGraph
[163]708    {
709    public:
[801]710      /// Defalult constructor.
711
712      /// Defalult constructor.
713      ///
[880]714      ErasableGraph() { }
[732]715      /// Deletes a node.
[801]716
717      /// Deletes node \c n node.
718      ///
[774]719      void erase(Node n) { }
[732]720      /// Deletes an edge.
[801]721
722      /// Deletes edge \c e edge.
723      ///
[774]724      void erase(Edge e) { }
[163]725    };
[938]726   
727    template<class Graph> void checkCompileGraphEraseEdge(Graph &G)
728    {
729      typename Graph::Edge e;
730      G.erase(e);
731    }
[163]732
[938]733    template<class Graph> void checkCompileGraphEraseNode(Graph &G)
734    {
735      typename Graph::Node n;
736      G.erase(n);
737    }
738
739    ///\brief Checks whether \c G meets the
740    ///\ref lemon::skeleton::EresableGraph "EresableGraph" concept
741    template<class Graph> void checkCompileErasableGraph(Graph &G)
742    {
743      checkCompileExtendableGraph(G);
744      checkCompileGraphEraseNode(G);
745      checkCompileGraphEraseEdge(G);
746    }
747
748    ///Checks whether a graph has findEdge() member function.
749   
750    ///\todo findEdge() might be a global function.
751    ///
752    template<class Graph> void checkCompileGraphFindEdge(Graph &G)
753    {
754      typedef typename Graph::NodeIt Node;
755      typedef typename Graph::NodeIt NodeIt;
756
757      G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G)));
758      G.findEdge(Node(),Node(),G.findEdge(Node(),Node())); 
759    }
760 
[732]761    // @}
[801]762  } //namespace skeleton 
[921]763} //namespace lemon
[52]764
[145]765
766
[921]767#endif // LEMON_SKELETON_GRAPH_H
Note: See TracBrowser for help on using the repository browser.