lemon/concept/graph.h
author athos
Thu, 26 May 2005 15:33:16 +0000
changeset 1438 826bdac3525a
parent 1426 91eb70983697
child 1448 0274acee0e35
permissions -rw-r--r--
Some documentation got revised.
klao@959
     1
/* -*- C++ -*-
ladanyi@1435
     2
 * lemon/concept/graph.h - Part of LEMON, a generic C++ optimization library
klao@959
     3
 *
alpar@1164
     4
 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@1359
     5
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
klao@959
     6
 *
klao@959
     7
 * Permission to use, modify and distribute this software is granted
klao@959
     8
 * provided that this copyright notice appears in all copies. For
klao@959
     9
 * precise terms see the accompanying LICENSE file.
klao@959
    10
 *
klao@959
    11
 * This software is provided "AS IS" with no warranty of any kind,
klao@959
    12
 * express or implied, and with no claim as to its suitability for any
klao@959
    13
 * purpose.
klao@959
    14
 *
klao@959
    15
 */
klao@959
    16
klao@959
    17
#ifndef LEMON_CONCEPT_GRAPH_H
klao@959
    18
#define LEMON_CONCEPT_GRAPH_H
klao@959
    19
klao@1030
    20
///\ingroup graph_concepts
klao@959
    21
///\file
klao@959
    22
///\brief Declaration of Graph.
klao@959
    23
klao@959
    24
#include <lemon/invalid.h>
klao@959
    25
#include <lemon/concept/maps.h>
klao@959
    26
#include <lemon/concept_check.h>
klao@959
    27
#include <lemon/concept/graph_component.h>
klao@959
    28
klao@959
    29
namespace lemon {
klao@959
    30
  namespace concept {
deba@1136
    31
klao@959
    32
    
klao@1030
    33
    /// \addtogroup graph_concepts
klao@959
    34
    /// @{
klao@959
    35
klao@961
    36
    /**************** The full-featured graph concepts ****************/
klao@959
    37
deba@1136
    38
ladanyi@1426
    39
    /// \brief Modular static graph class.
deba@1136
    40
    ///     
deba@1136
    41
    /// It should be the same as the \c StaticGraph class.
deba@1136
    42
    class _StaticGraph 
klao@961
    43
      :  virtual public BaseGraphComponent,
ladanyi@1426
    44
         public IterableGraphComponent, public MappableGraphComponent {
klao@959
    45
    public:
klao@959
    46
      typedef BaseGraphComponent::Node Node;
klao@959
    47
      typedef BaseGraphComponent::Edge Edge;
klao@959
    48
deba@989
    49
      template <typename _Graph>
deba@989
    50
      struct Constraints {
ladanyi@1426
    51
        void constraints() {
ladanyi@1426
    52
          checkConcept<IterableGraphComponent, _Graph>();
ladanyi@1426
    53
          checkConcept<MappableGraphComponent, _Graph>();
ladanyi@1426
    54
        }
deba@989
    55
      };
klao@959
    56
    };
klao@959
    57
ladanyi@1426
    58
    /// \brief Modular extendable graph class.
deba@1136
    59
    ///     
deba@1136
    60
    /// It should be the same as the \c ExtendableGraph class.
deba@1136
    61
    class _ExtendableGraph 
deba@1136
    62
      :  virtual public BaseGraphComponent, public _StaticGraph,
ladanyi@1426
    63
         public ExtendableGraphComponent, public ClearableGraphComponent {
klao@959
    64
    public:
klao@959
    65
      typedef BaseGraphComponent::Node Node;
klao@959
    66
      typedef BaseGraphComponent::Edge Edge;
klao@959
    67
deba@989
    68
      template <typename _Graph>
deba@989
    69
      struct Constraints {
ladanyi@1426
    70
        void constraints() {
ladanyi@1426
    71
          checkConcept<_StaticGraph, _Graph >();
ladanyi@1426
    72
          checkConcept<ExtendableGraphComponent, _Graph >();
ladanyi@1426
    73
          checkConcept<ClearableGraphComponent, _Graph >();
ladanyi@1426
    74
        }
deba@989
    75
      };
klao@959
    76
    };
klao@959
    77
ladanyi@1426
    78
    /// \brief Modular erasable graph class.
deba@1136
    79
    ///     
deba@1136
    80
    /// It should be the same as the \c ErasableGraph class.
deba@1136
    81
    class _ErasableGraph 
deba@1136
    82
      :  virtual public BaseGraphComponent, public _ExtendableGraph,
ladanyi@1426
    83
         public ErasableGraphComponent {
klao@959
    84
    public:
klao@959
    85
      typedef BaseGraphComponent::Node Node;
klao@959
    86
      typedef BaseGraphComponent::Edge Edge;
klao@959
    87
deba@989
    88
      template <typename _Graph>
deba@989
    89
      struct Constraints {
ladanyi@1426
    90
        void constraints() {
ladanyi@1426
    91
          checkConcept<_ExtendableGraph, _Graph >();
ladanyi@1426
    92
          checkConcept<ErasableGraphComponent, _Graph >();
ladanyi@1426
    93
        }
deba@989
    94
      };
klao@959
    95
    };
klao@959
    96
deba@1136
    97
    /// An empty static graph class.
deba@1136
    98
  
deba@1136
    99
    /// This class provides all the common features of a graph structure,
deba@1136
   100
    /// however completely without implementations and real data structures
deba@1136
   101
    /// behind the interface.
deba@1136
   102
    /// All graph algorithms should compile with this class, but it will not
deba@1136
   103
    /// run properly, of course.
deba@1136
   104
    ///
deba@1136
   105
    /// It can be used for checking the interface compatibility,
deba@1136
   106
    /// or it can serve as a skeleton of a new graph structure.
deba@1136
   107
    /// 
deba@1136
   108
    /// Also, you will find here the full documentation of a certain graph
deba@1136
   109
    /// feature, the documentation of a real graph imlementation
deba@1136
   110
    /// like @ref ListGraph or
deba@1136
   111
    /// @ref SmartGraph will just refer to this structure.
deba@1136
   112
    ///
deba@1136
   113
    /// \todo A pages describing the concept of concept description would
deba@1136
   114
    /// be nice.
deba@1136
   115
    class StaticGraph
deba@1136
   116
    {
deba@1136
   117
    public:
deba@1136
   118
      /// Defalult constructor.
deba@1136
   119
deba@1136
   120
      /// Defalult constructor.
deba@1136
   121
      ///
deba@1136
   122
      StaticGraph() { }
deba@1136
   123
      ///Copy consructor.
deba@1136
   124
deba@1136
   125
//       ///\todo It is not clear, what we expect from a copy constructor.
deba@1136
   126
//       ///E.g. How to assign the nodes/edges to each other? What about maps?
deba@1136
   127
//       StaticGraph(const StaticGraph& g) { }
deba@1136
   128
deba@1136
   129
      /// The base type of node iterators, 
deba@1136
   130
      /// or in other words, the trivial node iterator.
deba@1136
   131
deba@1136
   132
      /// This is the base type of each node iterator,
deba@1136
   133
      /// thus each kind of node iterator converts to this.
deba@1136
   134
      /// More precisely each kind of node iterator should be inherited 
deba@1136
   135
      /// from the trivial node iterator.
deba@1136
   136
      class Node {
deba@1136
   137
      public:
ladanyi@1426
   138
        /// Default constructor
deba@1136
   139
ladanyi@1426
   140
        /// @warning The default constructor sets the iterator
ladanyi@1426
   141
        /// to an undefined value.
ladanyi@1426
   142
        Node() { }
ladanyi@1426
   143
        /// Copy constructor.
deba@1136
   144
ladanyi@1426
   145
        /// Copy constructor.
ladanyi@1426
   146
        ///
ladanyi@1426
   147
        Node(const Node&) { }
deba@1136
   148
ladanyi@1426
   149
        /// Invalid constructor \& conversion.
deba@1136
   150
ladanyi@1426
   151
        /// This constructor initializes the iterator to be invalid.
ladanyi@1426
   152
        /// \sa Invalid for more details.
ladanyi@1426
   153
        Node(Invalid) { }
ladanyi@1426
   154
        /// Equality operator
deba@1136
   155
ladanyi@1426
   156
        /// Two iterators are equal if and only if they point to the
ladanyi@1426
   157
        /// same object or both are invalid.
ladanyi@1426
   158
        bool operator==(Node) const { return true; }
deba@1136
   159
ladanyi@1426
   160
        /// Inequality operator
ladanyi@1426
   161
        
ladanyi@1426
   162
        /// \sa operator==(Node n)
ladanyi@1426
   163
        ///
ladanyi@1426
   164
        bool operator!=(Node) const { return true; }
deba@1136
   165
deba@1136
   166
      };
deba@1136
   167
    
deba@1136
   168
      /// This iterator goes through each node.
deba@1136
   169
deba@1136
   170
      /// This iterator goes through each node.
deba@1136
   171
      /// Its usage is quite simple, for example you can count the number
deba@1136
   172
      /// of nodes in graph \c g of type \c Graph like this:
deba@1136
   173
      /// \code
deba@1136
   174
      /// int count=0;
ladanyi@1426
   175
      /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
deba@1136
   176
      /// \endcode
deba@1136
   177
      class NodeIt : public Node {
deba@1136
   178
      public:
ladanyi@1426
   179
        /// Default constructor
deba@1136
   180
ladanyi@1426
   181
        /// @warning The default constructor sets the iterator
ladanyi@1426
   182
        /// to an undefined value.
ladanyi@1426
   183
        NodeIt() { }
ladanyi@1426
   184
        /// Copy constructor.
ladanyi@1426
   185
        
ladanyi@1426
   186
        /// Copy constructor.
ladanyi@1426
   187
        ///
ladanyi@1426
   188
        NodeIt(const NodeIt& n) : Node(n) { }
ladanyi@1426
   189
        /// Invalid constructor \& conversion.
deba@1136
   190
ladanyi@1426
   191
        /// Initialize the iterator to be invalid.
ladanyi@1426
   192
        /// \sa Invalid for more details.
ladanyi@1426
   193
        NodeIt(Invalid) { }
ladanyi@1426
   194
        /// Sets the iterator to the first node.
deba@1136
   195
ladanyi@1426
   196
        /// Sets the iterator to the first node of \c g.
ladanyi@1426
   197
        ///
ladanyi@1426
   198
        NodeIt(const StaticGraph&) { }
ladanyi@1426
   199
        /// Node -> NodeIt conversion.
deba@1136
   200
ladanyi@1426
   201
        /// Sets the iterator to the node of \c g pointed by the trivial 
ladanyi@1426
   202
        /// iterator n.
ladanyi@1426
   203
        /// This feature necessitates that each time we 
ladanyi@1426
   204
        /// iterate the edge-set, the iteration order is the same.
ladanyi@1426
   205
        NodeIt(const StaticGraph& g, const Node& n) { }
ladanyi@1426
   206
        /// Next node.
deba@1136
   207
ladanyi@1426
   208
        /// Assign the iterator to the next node.
ladanyi@1426
   209
        ///
ladanyi@1426
   210
        NodeIt& operator++() { return *this; }
deba@1136
   211
      };
deba@1136
   212
    
deba@1136
   213
    
deba@1136
   214
      /// The base type of the edge iterators.
deba@1136
   215
deba@1136
   216
      /// The base type of the edge iterators.
deba@1136
   217
      ///
deba@1136
   218
      class Edge {
deba@1136
   219
      public:
ladanyi@1426
   220
        /// Default constructor
deba@1136
   221
ladanyi@1426
   222
        /// @warning The default constructor sets the iterator
ladanyi@1426
   223
        /// to an undefined value.
ladanyi@1426
   224
        Edge() { }
ladanyi@1426
   225
        /// Copy constructor.
deba@1136
   226
ladanyi@1426
   227
        /// Copy constructor.
ladanyi@1426
   228
        ///
ladanyi@1426
   229
        Edge(const Edge&) { }
ladanyi@1426
   230
        /// Initialize the iterator to be invalid.
deba@1136
   231
ladanyi@1426
   232
        /// Initialize the iterator to be invalid.
ladanyi@1426
   233
        ///
ladanyi@1426
   234
        Edge(Invalid) { }
ladanyi@1426
   235
        /// Equality operator
deba@1136
   236
ladanyi@1426
   237
        /// Two iterators are equal if and only if they point to the
ladanyi@1426
   238
        /// same object or both are invalid.
ladanyi@1426
   239
        bool operator==(Edge) const { return true; }
ladanyi@1426
   240
        /// Inequality operator
deba@1136
   241
ladanyi@1426
   242
        /// \sa operator==(Node n)
ladanyi@1426
   243
        ///
ladanyi@1426
   244
        bool operator!=(Edge) const { return true; }
deba@1136
   245
      };
deba@1136
   246
    
deba@1136
   247
      /// This iterator goes trough the outgoing edges of a node.
deba@1136
   248
deba@1136
   249
      /// This iterator goes trough the \e outgoing edges of a certain node
deba@1136
   250
      /// of a graph.
deba@1136
   251
      /// Its usage is quite simple, for example you can count the number
deba@1136
   252
      /// of outgoing edges of a node \c n
deba@1136
   253
      /// in graph \c g of type \c Graph as follows.
deba@1136
   254
      /// \code
deba@1136
   255
      /// int count=0;
deba@1136
   256
      /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
deba@1136
   257
      /// \endcode
deba@1136
   258
    
deba@1136
   259
      class OutEdgeIt : public Edge {
deba@1136
   260
      public:
ladanyi@1426
   261
        /// Default constructor
deba@1136
   262
ladanyi@1426
   263
        /// @warning The default constructor sets the iterator
ladanyi@1426
   264
        /// to an undefined value.
ladanyi@1426
   265
        OutEdgeIt() { }
ladanyi@1426
   266
        /// Copy constructor.
deba@1136
   267
ladanyi@1426
   268
        /// Copy constructor.
ladanyi@1426
   269
        ///
ladanyi@1426
   270
        OutEdgeIt(const OutEdgeIt& e) : Edge(e) { }
ladanyi@1426
   271
        /// Initialize the iterator to be invalid.
deba@1136
   272
ladanyi@1426
   273
        /// Initialize the iterator to be invalid.
ladanyi@1426
   274
        ///
ladanyi@1426
   275
        OutEdgeIt(Invalid) { }
ladanyi@1426
   276
        /// This constructor sets the iterator to the first outgoing edge.
deba@1136
   277
    
ladanyi@1426
   278
        /// This constructor sets the iterator to the first outgoing edge of
ladanyi@1426
   279
        /// the node.
ladanyi@1426
   280
        ///@param n the node
ladanyi@1426
   281
        ///@param g the graph
ladanyi@1426
   282
        OutEdgeIt(const StaticGraph&, const Node&) { }
ladanyi@1426
   283
        /// Edge -> OutEdgeIt conversion
deba@1136
   284
ladanyi@1426
   285
        /// Sets the iterator to the value of the trivial iterator \c e.
ladanyi@1426
   286
        /// This feature necessitates that each time we 
ladanyi@1426
   287
        /// iterate the edge-set, the iteration order is the same.
ladanyi@1426
   288
        OutEdgeIt(const StaticGraph& g, const Edge& e) { }
ladanyi@1426
   289
        ///Next outgoing edge
ladanyi@1426
   290
        
ladanyi@1426
   291
        /// Assign the iterator to the next 
ladanyi@1426
   292
        /// outgoing edge of the corresponding node.
ladanyi@1426
   293
        OutEdgeIt& operator++() { return *this; }
deba@1136
   294
      };
deba@1136
   295
deba@1136
   296
      /// This iterator goes trough the incoming edges of a node.
deba@1136
   297
deba@1136
   298
      /// This iterator goes trough the \e incoming edges of a certain node
deba@1136
   299
      /// of a graph.
deba@1136
   300
      /// Its usage is quite simple, for example you can count the number
deba@1136
   301
      /// of outgoing edges of a node \c n
deba@1136
   302
      /// in graph \c g of type \c Graph as follows.
deba@1136
   303
      /// \code
deba@1136
   304
      /// int count=0;
deba@1136
   305
      /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
deba@1136
   306
      /// \endcode
deba@1136
   307
deba@1136
   308
      class InEdgeIt : public Edge {
deba@1136
   309
      public:
ladanyi@1426
   310
        /// Default constructor
deba@1136
   311
ladanyi@1426
   312
        /// @warning The default constructor sets the iterator
ladanyi@1426
   313
        /// to an undefined value.
ladanyi@1426
   314
        InEdgeIt() { }
ladanyi@1426
   315
        /// Copy constructor.
deba@1136
   316
ladanyi@1426
   317
        /// Copy constructor.
ladanyi@1426
   318
        ///
ladanyi@1426
   319
        InEdgeIt(const InEdgeIt& e) : Edge(e) { }
ladanyi@1426
   320
        /// Initialize the iterator to be invalid.
deba@1136
   321
ladanyi@1426
   322
        /// Initialize the iterator to be invalid.
ladanyi@1426
   323
        ///
ladanyi@1426
   324
        InEdgeIt(Invalid) { }
ladanyi@1426
   325
        /// This constructor sets the iterator to first incoming edge.
deba@1136
   326
    
ladanyi@1426
   327
        /// This constructor set the iterator to the first incoming edge of
ladanyi@1426
   328
        /// the node.
ladanyi@1426
   329
        ///@param n the node
ladanyi@1426
   330
        ///@param g the graph
ladanyi@1426
   331
        InEdgeIt(const StaticGraph&, const Node&) { }
ladanyi@1426
   332
        /// Edge -> InEdgeIt conversion
deba@1136
   333
ladanyi@1426
   334
        /// Sets the iterator to the value of the trivial iterator \c e.
ladanyi@1426
   335
        /// This feature necessitates that each time we 
ladanyi@1426
   336
        /// iterate the edge-set, the iteration order is the same.
ladanyi@1426
   337
        InEdgeIt(const StaticGraph&, const Edge&) { }
ladanyi@1426
   338
        /// Next incoming edge
deba@1136
   339
ladanyi@1426
   340
        /// Assign the iterator to the next inedge of the corresponding node.
ladanyi@1426
   341
        ///
ladanyi@1426
   342
        InEdgeIt& operator++() { return *this; }
deba@1136
   343
      };
deba@1136
   344
      /// This iterator goes through each edge.
deba@1136
   345
deba@1136
   346
      /// This iterator goes through each edge of a graph.
deba@1136
   347
      /// Its usage is quite simple, for example you can count the number
deba@1136
   348
      /// of edges in a graph \c g of type \c Graph as follows:
deba@1136
   349
      /// \code
deba@1136
   350
      /// int count=0;
deba@1136
   351
      /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
deba@1136
   352
      /// \endcode
deba@1136
   353
      class EdgeIt : public Edge {
deba@1136
   354
      public:
ladanyi@1426
   355
        /// Default constructor
deba@1136
   356
ladanyi@1426
   357
        /// @warning The default constructor sets the iterator
ladanyi@1426
   358
        /// to an undefined value.
ladanyi@1426
   359
        EdgeIt() { }
ladanyi@1426
   360
        /// Copy constructor.
deba@1136
   361
ladanyi@1426
   362
        /// Copy constructor.
ladanyi@1426
   363
        ///
ladanyi@1426
   364
        EdgeIt(const EdgeIt& e) : Edge(e) { }
ladanyi@1426
   365
        /// Initialize the iterator to be invalid.
deba@1136
   366
ladanyi@1426
   367
        /// Initialize the iterator to be invalid.
ladanyi@1426
   368
        ///
ladanyi@1426
   369
        EdgeIt(Invalid) { }
ladanyi@1426
   370
        /// This constructor sets the iterator to the first edge.
deba@1136
   371
    
ladanyi@1426
   372
        /// This constructor sets the iterator to the first edge of \c g.
ladanyi@1426
   373
        ///@param g the graph
ladanyi@1426
   374
        EdgeIt(const StaticGraph&) { }
ladanyi@1426
   375
        /// Edge -> EdgeIt conversion
deba@1136
   376
ladanyi@1426
   377
        /// Sets the iterator to the value of the trivial iterator \c e.
ladanyi@1426
   378
        /// This feature necessitates that each time we 
ladanyi@1426
   379
        /// iterate the edge-set, the iteration order is the same.
ladanyi@1426
   380
        EdgeIt(const StaticGraph&, const Edge&) { } 
ladanyi@1426
   381
        ///Next edge
ladanyi@1426
   382
        
ladanyi@1426
   383
        /// Assign the iterator to the next edge.
ladanyi@1426
   384
        EdgeIt& operator++() { return *this; }
deba@1136
   385
      };
deba@1136
   386
      ///Gives back the target node of an edge.
deba@1136
   387
deba@1136
   388
      ///Gives back the target node of an edge.
deba@1136
   389
      ///
deba@1136
   390
      Node target(Edge) const { return INVALID; }
deba@1136
   391
      ///Gives back the source node of an edge.
deba@1136
   392
deba@1136
   393
      ///Gives back the source node of an edge.
deba@1136
   394
      ///
deba@1136
   395
      Node source(Edge) const { return INVALID; }
deba@1136
   396
      /// Read write map of the nodes to type \c T.
deba@1136
   397
deba@1136
   398
      /// \ingroup concept
deba@1136
   399
      /// ReadWrite map of the nodes to type \c T.
deba@1136
   400
      /// \sa Reference
deba@1136
   401
      /// \warning Making maps that can handle bool type (NodeMap<bool>)
deba@1136
   402
      /// needs some extra attention!
deba@1136
   403
      template<class T> 
deba@1136
   404
      class NodeMap : public ReadWriteMap< Node, T >
deba@1136
   405
      {
deba@1136
   406
      public:
deba@1136
   407
ladanyi@1426
   408
        ///\e
ladanyi@1426
   409
        NodeMap(const StaticGraph&) { }
ladanyi@1426
   410
        ///\e
ladanyi@1426
   411
        NodeMap(const StaticGraph&, T) { }
deba@1136
   412
ladanyi@1426
   413
        ///Copy constructor
ladanyi@1426
   414
        NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
ladanyi@1426
   415
        ///Assignment operator
ladanyi@1426
   416
        NodeMap& operator=(const NodeMap&) { return *this; }
ladanyi@1426
   417
        // \todo fix this concept
deba@1136
   418
      };
deba@1136
   419
deba@1136
   420
      /// Read write map of the edges to type \c T.
deba@1136
   421
deba@1136
   422
      /// \ingroup concept
deba@1136
   423
      ///Reference map of the edges to type \c T.
deba@1136
   424
      /// \sa Reference
deba@1136
   425
      /// \warning Making maps that can handle bool type (EdgeMap<bool>)
deba@1136
   426
      /// needs some extra attention!
deba@1136
   427
      template<class T> 
deba@1136
   428
      class EdgeMap : public ReadWriteMap<Edge,T>
deba@1136
   429
      {
deba@1136
   430
      public:
deba@1136
   431
ladanyi@1426
   432
        ///\e
ladanyi@1426
   433
        EdgeMap(const StaticGraph&) { }
ladanyi@1426
   434
        ///\e
ladanyi@1426
   435
        EdgeMap(const StaticGraph&, T) { }
ladanyi@1426
   436
        ///Copy constructor
ladanyi@1426
   437
        EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { }
ladanyi@1426
   438
        ///Assignment operator
ladanyi@1426
   439
        EdgeMap& operator=(const EdgeMap&) { return *this; }
ladanyi@1426
   440
        // \todo fix this concept    
deba@1136
   441
      };
deba@1136
   442
deba@1136
   443
      template <typename _Graph>
deba@1136
   444
      struct Constraints : public _StaticGraph::Constraints<_Graph> {};
deba@1136
   445
deba@1136
   446
    };
deba@1136
   447
deba@1136
   448
    /// An empty non-static graph class.
deba@1136
   449
    
ladanyi@1426
   450
    /// This class provides everything that \ref StaticGraph does.
ladanyi@1426
   451
    /// Additionally it enables building graphs from scratch.
deba@1136
   452
    class ExtendableGraph : public StaticGraph
deba@1136
   453
    {
deba@1136
   454
    public:
deba@1136
   455
      /// Defalult constructor.
deba@1136
   456
deba@1136
   457
      /// Defalult constructor.
deba@1136
   458
      ///
deba@1136
   459
      ExtendableGraph() { }
deba@1136
   460
      ///Add a new node to the graph.
deba@1136
   461
deba@1136
   462
      /// \return the new node.
deba@1136
   463
      ///
deba@1136
   464
      Node addNode() { return INVALID; }
deba@1136
   465
      ///Add a new edge to the graph.
deba@1136
   466
deba@1136
   467
      ///Add a new edge to the graph with source node \c s
deba@1136
   468
      ///and target node \c t.
deba@1136
   469
      ///\return the new edge.
alpar@1367
   470
      Edge addEdge(Node, Node) { return INVALID; }
deba@1136
   471
    
deba@1136
   472
      /// Resets the graph.
deba@1136
   473
deba@1136
   474
      /// This function deletes all edges and nodes of the graph.
deba@1136
   475
      /// It also frees the memory allocated to store them.
deba@1136
   476
      /// \todo It might belong to \ref ErasableGraph.
deba@1136
   477
      void clear() { }
deba@1136
   478
deba@1136
   479
      template <typename _Graph>
deba@1136
   480
      struct Constraints : public _ExtendableGraph::Constraints<_Graph> {};
deba@1136
   481
deba@1136
   482
    };
deba@1136
   483
deba@1136
   484
    /// An empty erasable graph class.
deba@1136
   485
  
ladanyi@1426
   486
    /// This class is an extension of \ref ExtendableGraph. It makes it
deba@1136
   487
    /// possible to erase edges or nodes.
deba@1136
   488
    class ErasableGraph : public ExtendableGraph
deba@1136
   489
    {
deba@1136
   490
    public:
deba@1136
   491
      /// Defalult constructor.
deba@1136
   492
deba@1136
   493
      /// Defalult constructor.
deba@1136
   494
      ///
deba@1136
   495
      ErasableGraph() { }
deba@1136
   496
      /// Deletes a node.
deba@1136
   497
deba@1136
   498
      /// Deletes node \c n node.
deba@1136
   499
      ///
alpar@1367
   500
      void erase(Node) { }
deba@1136
   501
      /// Deletes an edge.
deba@1136
   502
deba@1136
   503
      /// Deletes edge \c e edge.
deba@1136
   504
      ///
alpar@1367
   505
      void erase(Edge) { }
deba@1136
   506
deba@1136
   507
      template <typename _Graph>
deba@1136
   508
      struct Constraints : public _ErasableGraph::Constraints<_Graph> {};
deba@1136
   509
deba@1136
   510
    };
deba@1136
   511
deba@1136
   512
    
deba@1136
   513
    /************* New GraphBase stuff **************/
deba@1136
   514
deba@1136
   515
deba@1136
   516
//     /// A minimal GraphBase concept
deba@1136
   517
deba@1136
   518
//     /// This class describes a minimal concept which can be extended to a
deba@1136
   519
//     /// full-featured graph with \ref GraphFactory.
deba@1136
   520
//     class GraphBase {
deba@1136
   521
//     public:
deba@1136
   522
deba@1136
   523
//       GraphBase() {}
deba@1136
   524
deba@1136
   525
//       /// \bug Should we demand that Node and Edge be subclasses of the
deba@1136
   526
//       /// Graph class???
deba@1136
   527
deba@1136
   528
//       typedef GraphItem<'n'> Node;
deba@1136
   529
//       typedef GraphItem<'e'> Edge;
deba@1136
   530
deba@1136
   531
// //       class Node : public BaseGraphItem<'n'> {};
deba@1136
   532
// //       class Edge : public BaseGraphItem<'e'> {};
deba@1136
   533
deba@1136
   534
//       // Graph operation
deba@1136
   535
//       void firstNode(Node &n) const { }
deba@1136
   536
//       void firstEdge(Edge &e) const { }
deba@1136
   537
deba@1136
   538
//       void firstOutEdge(Edge &e, Node) const { }
deba@1136
   539
//       void firstInEdge(Edge &e, Node) const { }
deba@1136
   540
deba@1136
   541
//       void nextNode(Node &n) const { }
deba@1136
   542
//       void nextEdge(Edge &e) const { }
deba@1136
   543
deba@1136
   544
deba@1136
   545
//       // Question: isn't it reasonable if this methods have a Node
deba@1136
   546
//       // parameter? Like this:
deba@1136
   547
//       // Edge& nextOut(Edge &e, Node) const { return e; }
deba@1136
   548
//       void nextOutEdge(Edge &e) const { }
deba@1136
   549
//       void nextInEdge(Edge &e) const { }
deba@1136
   550
deba@1136
   551
//       Node target(Edge) const { return Node(); }
deba@1136
   552
//       Node source(Edge) const { return Node(); }
deba@1136
   553
      
deba@1136
   554
deba@1136
   555
//       // Do we need id, nodeNum, edgeNum and co. in this basic graphbase
deba@1136
   556
//       // concept?
deba@1136
   557
deba@1136
   558
deba@1136
   559
//       // Maps.
deba@1136
   560
//       //
deba@1136
   561
//       // We need a special slimer concept which does not provide maps (it
deba@1136
   562
//       // wouldn't be strictly slimer, cause for map-factory id() & friends
deba@1136
   563
//       // a required...)
deba@1136
   564
deba@1136
   565
//       template<typename T>
deba@1136
   566
//       class NodeMap : public GraphMap<GraphBase, Node, T> {};
deba@1136
   567
deba@1136
   568
//       template<typename T>
deba@1136
   569
//       class EdgeMap : public GraphMap<GraphBase, Node, T> {};
deba@1136
   570
//     };
deba@1136
   571
klao@959
   572
    // @}
klao@959
   573
  } //namespace concept  
klao@959
   574
} //namespace lemon
klao@959
   575
klao@959
   576
klao@959
   577
klao@959
   578
#endif // LEMON_CONCEPT_GRAPH_H