lemon/concept/graph.h
author alpar
Thu, 17 Nov 2005 10:16:29 +0000
changeset 1812 a6f019fa6e7a
parent 1643 9285f3777553
child 1875 98698b69a902
permissions -rw-r--r--
split(Edge) member function added.
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>
alpar@1448
    25
#include <lemon/utility.h>
klao@959
    26
#include <lemon/concept/maps.h>
klao@959
    27
#include <lemon/concept_check.h>
klao@959
    28
#include <lemon/concept/graph_component.h>
klao@959
    29
klao@959
    30
namespace lemon {
klao@959
    31
  namespace concept {
deba@1136
    32
klao@959
    33
    
klao@961
    34
    /**************** The full-featured graph concepts ****************/
klao@959
    35
deba@1136
    36
klao@1760
    37
    // \brief Modular static graph class.
klao@1760
    38
    //     
klao@1760
    39
    // It should be the same as the \c StaticGraph class.
deba@1136
    40
    class _StaticGraph 
klao@961
    41
      :  virtual public BaseGraphComponent,
ladanyi@1426
    42
         public IterableGraphComponent, public MappableGraphComponent {
klao@959
    43
    public:
alpar@1448
    44
alpar@1448
    45
      typedef False UndirTag;
alpar@1448
    46
      
klao@959
    47
      typedef BaseGraphComponent::Node Node;
klao@959
    48
      typedef BaseGraphComponent::Edge Edge;
klao@959
    49
deba@989
    50
      template <typename _Graph>
deba@989
    51
      struct Constraints {
ladanyi@1426
    52
        void constraints() {
ladanyi@1426
    53
          checkConcept<IterableGraphComponent, _Graph>();
ladanyi@1426
    54
          checkConcept<MappableGraphComponent, _Graph>();
ladanyi@1426
    55
        }
deba@989
    56
      };
klao@959
    57
    };
klao@959
    58
klao@1760
    59
    // \brief Modular extendable graph class.
klao@1760
    60
    //     
klao@1760
    61
    // It should be the same as the \c ExtendableGraph class.
deba@1136
    62
    class _ExtendableGraph 
deba@1136
    63
      :  virtual public BaseGraphComponent, public _StaticGraph,
ladanyi@1426
    64
         public ExtendableGraphComponent, public ClearableGraphComponent {
klao@959
    65
    public:
klao@959
    66
      typedef BaseGraphComponent::Node Node;
klao@959
    67
      typedef BaseGraphComponent::Edge Edge;
klao@959
    68
deba@989
    69
      template <typename _Graph>
deba@989
    70
      struct Constraints {
ladanyi@1426
    71
        void constraints() {
ladanyi@1426
    72
          checkConcept<_StaticGraph, _Graph >();
ladanyi@1426
    73
          checkConcept<ExtendableGraphComponent, _Graph >();
ladanyi@1426
    74
          checkConcept<ClearableGraphComponent, _Graph >();
ladanyi@1426
    75
        }
deba@989
    76
      };
klao@959
    77
    };
klao@959
    78
klao@1760
    79
    // \brief Modular erasable graph class.
klao@1760
    80
    //     
klao@1760
    81
    // It should be the same as the \c ErasableGraph class.
deba@1136
    82
    class _ErasableGraph 
deba@1136
    83
      :  virtual public BaseGraphComponent, public _ExtendableGraph,
ladanyi@1426
    84
         public ErasableGraphComponent {
klao@959
    85
    public:
klao@959
    86
      typedef BaseGraphComponent::Node Node;
klao@959
    87
      typedef BaseGraphComponent::Edge Edge;
klao@959
    88
deba@989
    89
      template <typename _Graph>
deba@989
    90
      struct Constraints {
ladanyi@1426
    91
        void constraints() {
ladanyi@1426
    92
          checkConcept<_ExtendableGraph, _Graph >();
ladanyi@1426
    93
          checkConcept<ErasableGraphComponent, _Graph >();
ladanyi@1426
    94
        }
deba@989
    95
      };
klao@959
    96
    };
klao@959
    97
alpar@1620
    98
    /// \addtogroup graph_concepts
alpar@1620
    99
    /// @{
alpar@1620
   100
deba@1136
   101
    /// An empty static graph class.
deba@1136
   102
  
deba@1136
   103
    /// This class provides all the common features of a graph structure,
deba@1136
   104
    /// however completely without implementations and real data structures
deba@1136
   105
    /// behind the interface.
deba@1136
   106
    /// All graph algorithms should compile with this class, but it will not
deba@1136
   107
    /// run properly, of course.
deba@1136
   108
    ///
deba@1136
   109
    /// It can be used for checking the interface compatibility,
deba@1136
   110
    /// or it can serve as a skeleton of a new graph structure.
deba@1136
   111
    /// 
deba@1136
   112
    /// Also, you will find here the full documentation of a certain graph
deba@1136
   113
    /// feature, the documentation of a real graph imlementation
deba@1136
   114
    /// like @ref ListGraph or
deba@1136
   115
    /// @ref SmartGraph will just refer to this structure.
deba@1136
   116
    ///
deba@1136
   117
    /// \todo A pages describing the concept of concept description would
deba@1136
   118
    /// be nice.
deba@1136
   119
    class StaticGraph
deba@1136
   120
    {
deba@1136
   121
    public:
alpar@1448
   122
      ///\e
alpar@1448
   123
alpar@1448
   124
      ///\todo undocumented
alpar@1448
   125
      ///
alpar@1448
   126
      typedef False UndirTag;
alpar@1448
   127
deba@1136
   128
      /// Defalult constructor.
deba@1136
   129
deba@1136
   130
      /// Defalult constructor.
deba@1136
   131
      ///
deba@1136
   132
      StaticGraph() { }
deba@1136
   133
      ///Copy consructor.
deba@1136
   134
deba@1136
   135
//       ///\todo It is not clear, what we expect from a copy constructor.
deba@1136
   136
//       ///E.g. How to assign the nodes/edges to each other? What about maps?
deba@1136
   137
//       StaticGraph(const StaticGraph& g) { }
deba@1136
   138
deba@1136
   139
      /// The base type of node iterators, 
deba@1136
   140
      /// or in other words, the trivial node iterator.
deba@1136
   141
deba@1136
   142
      /// This is the base type of each node iterator,
deba@1136
   143
      /// thus each kind of node iterator converts to this.
deba@1136
   144
      /// More precisely each kind of node iterator should be inherited 
deba@1136
   145
      /// from the trivial node iterator.
deba@1136
   146
      class Node {
deba@1136
   147
      public:
ladanyi@1426
   148
        /// Default constructor
deba@1136
   149
ladanyi@1426
   150
        /// @warning The default constructor sets the iterator
ladanyi@1426
   151
        /// to an undefined value.
ladanyi@1426
   152
        Node() { }
ladanyi@1426
   153
        /// Copy constructor.
deba@1136
   154
ladanyi@1426
   155
        /// Copy constructor.
ladanyi@1426
   156
        ///
ladanyi@1426
   157
        Node(const Node&) { }
deba@1136
   158
ladanyi@1426
   159
        /// Invalid constructor \& conversion.
deba@1136
   160
ladanyi@1426
   161
        /// This constructor initializes the iterator to be invalid.
ladanyi@1426
   162
        /// \sa Invalid for more details.
ladanyi@1426
   163
        Node(Invalid) { }
ladanyi@1426
   164
        /// Equality operator
deba@1136
   165
ladanyi@1426
   166
        /// Two iterators are equal if and only if they point to the
ladanyi@1426
   167
        /// same object or both are invalid.
ladanyi@1426
   168
        bool operator==(Node) const { return true; }
deba@1136
   169
ladanyi@1426
   170
        /// Inequality operator
ladanyi@1426
   171
        
ladanyi@1426
   172
        /// \sa operator==(Node n)
ladanyi@1426
   173
        ///
ladanyi@1426
   174
        bool operator!=(Node) const { return true; }
deba@1136
   175
deba@1622
   176
	/// Artificial ordering operator.
deba@1622
   177
	
deba@1622
   178
	/// To allow the use of graph descriptors as key type in std::map or
deba@1622
   179
	/// similar associative container we require this.
deba@1622
   180
	///
deba@1622
   181
	/// \note This operator only have to define some strict ordering of
deba@1622
   182
	/// the items; this order has nothing to do with the iteration
deba@1622
   183
	/// ordering of the items.
deba@1622
   184
	///
deba@1622
   185
	/// \bug This is a technical requirement. Do we really need this?
deba@1622
   186
	bool operator<(Node) const { return false; }
deba@1622
   187
deba@1136
   188
      };
deba@1136
   189
    
deba@1136
   190
      /// This iterator goes through each node.
deba@1136
   191
deba@1136
   192
      /// This iterator goes through each node.
deba@1136
   193
      /// Its usage is quite simple, for example you can count the number
deba@1136
   194
      /// of nodes in graph \c g of type \c Graph like this:
deba@1136
   195
      /// \code
deba@1136
   196
      /// int count=0;
ladanyi@1426
   197
      /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
deba@1136
   198
      /// \endcode
deba@1136
   199
      class NodeIt : public Node {
deba@1136
   200
      public:
ladanyi@1426
   201
        /// Default constructor
deba@1136
   202
ladanyi@1426
   203
        /// @warning The default constructor sets the iterator
ladanyi@1426
   204
        /// to an undefined value.
ladanyi@1426
   205
        NodeIt() { }
ladanyi@1426
   206
        /// Copy constructor.
ladanyi@1426
   207
        
ladanyi@1426
   208
        /// Copy constructor.
ladanyi@1426
   209
        ///
ladanyi@1426
   210
        NodeIt(const NodeIt& n) : Node(n) { }
ladanyi@1426
   211
        /// Invalid constructor \& conversion.
deba@1136
   212
ladanyi@1426
   213
        /// Initialize the iterator to be invalid.
ladanyi@1426
   214
        /// \sa Invalid for more details.
ladanyi@1426
   215
        NodeIt(Invalid) { }
ladanyi@1426
   216
        /// Sets the iterator to the first node.
deba@1136
   217
ladanyi@1426
   218
        /// Sets the iterator to the first node of \c g.
ladanyi@1426
   219
        ///
ladanyi@1426
   220
        NodeIt(const StaticGraph&) { }
ladanyi@1426
   221
        /// Node -> NodeIt conversion.
deba@1136
   222
deba@1470
   223
        /// Sets the iterator to the node of \c the graph pointed by 
deba@1470
   224
	/// the trivial iterator.
ladanyi@1426
   225
        /// This feature necessitates that each time we 
ladanyi@1426
   226
        /// iterate the edge-set, the iteration order is the same.
deba@1470
   227
        NodeIt(const StaticGraph&, const Node&) { }
ladanyi@1426
   228
        /// Next node.
deba@1136
   229
ladanyi@1426
   230
        /// Assign the iterator to the next node.
ladanyi@1426
   231
        ///
ladanyi@1426
   232
        NodeIt& operator++() { return *this; }
deba@1136
   233
      };
deba@1136
   234
    
deba@1136
   235
    
deba@1136
   236
      /// The base type of the edge iterators.
deba@1136
   237
deba@1136
   238
      /// The base type of the edge iterators.
deba@1136
   239
      ///
deba@1136
   240
      class Edge {
deba@1136
   241
      public:
ladanyi@1426
   242
        /// Default constructor
deba@1136
   243
ladanyi@1426
   244
        /// @warning The default constructor sets the iterator
ladanyi@1426
   245
        /// to an undefined value.
ladanyi@1426
   246
        Edge() { }
ladanyi@1426
   247
        /// Copy constructor.
deba@1136
   248
ladanyi@1426
   249
        /// Copy constructor.
ladanyi@1426
   250
        ///
ladanyi@1426
   251
        Edge(const Edge&) { }
ladanyi@1426
   252
        /// Initialize the iterator to be invalid.
deba@1136
   253
ladanyi@1426
   254
        /// Initialize the iterator to be invalid.
ladanyi@1426
   255
        ///
ladanyi@1426
   256
        Edge(Invalid) { }
ladanyi@1426
   257
        /// Equality operator
deba@1136
   258
ladanyi@1426
   259
        /// Two iterators are equal if and only if they point to the
ladanyi@1426
   260
        /// same object or both are invalid.
ladanyi@1426
   261
        bool operator==(Edge) const { return true; }
ladanyi@1426
   262
        /// Inequality operator
deba@1136
   263
alpar@1620
   264
        /// \sa operator==(Edge n)
ladanyi@1426
   265
        ///
ladanyi@1426
   266
        bool operator!=(Edge) const { return true; }
deba@1622
   267
deba@1622
   268
	/// Artificial ordering operator.
deba@1622
   269
	
deba@1622
   270
	/// To allow the use of graph descriptors as key type in std::map or
deba@1622
   271
	/// similar associative container we require this.
deba@1622
   272
	///
deba@1622
   273
	/// \note This operator only have to define some strict ordering of
deba@1622
   274
	/// the items; this order has nothing to do with the iteration
deba@1622
   275
	/// ordering of the items.
deba@1622
   276
	///
deba@1622
   277
	/// \bug This is a technical requirement. Do we really need this?
deba@1622
   278
	bool operator<(Edge) const { return false; }
deba@1136
   279
      };
deba@1136
   280
    
deba@1136
   281
      /// This iterator goes trough the outgoing edges of a node.
deba@1136
   282
deba@1136
   283
      /// This iterator goes trough the \e outgoing edges of a certain node
deba@1136
   284
      /// of a graph.
deba@1136
   285
      /// Its usage is quite simple, for example you can count the number
deba@1136
   286
      /// of outgoing edges of a node \c n
deba@1136
   287
      /// in graph \c g of type \c Graph as follows.
deba@1136
   288
      /// \code
deba@1136
   289
      /// int count=0;
deba@1136
   290
      /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
deba@1136
   291
      /// \endcode
deba@1136
   292
    
deba@1136
   293
      class OutEdgeIt : public Edge {
deba@1136
   294
      public:
ladanyi@1426
   295
        /// Default constructor
deba@1136
   296
ladanyi@1426
   297
        /// @warning The default constructor sets the iterator
ladanyi@1426
   298
        /// to an undefined value.
ladanyi@1426
   299
        OutEdgeIt() { }
ladanyi@1426
   300
        /// Copy constructor.
deba@1136
   301
ladanyi@1426
   302
        /// Copy constructor.
ladanyi@1426
   303
        ///
ladanyi@1426
   304
        OutEdgeIt(const OutEdgeIt& e) : Edge(e) { }
ladanyi@1426
   305
        /// Initialize the iterator to be invalid.
deba@1136
   306
ladanyi@1426
   307
        /// Initialize the iterator to be invalid.
ladanyi@1426
   308
        ///
ladanyi@1426
   309
        OutEdgeIt(Invalid) { }
ladanyi@1426
   310
        /// This constructor sets the iterator to the first outgoing edge.
deba@1136
   311
    
ladanyi@1426
   312
        /// This constructor sets the iterator to the first outgoing edge of
ladanyi@1426
   313
        /// the node.
ladanyi@1426
   314
        OutEdgeIt(const StaticGraph&, const Node&) { }
ladanyi@1426
   315
        /// Edge -> OutEdgeIt conversion
deba@1136
   316
deba@1470
   317
        /// Sets the iterator to the value of the trivial iterator.
deba@1470
   318
	/// This feature necessitates that each time we 
ladanyi@1426
   319
        /// iterate the edge-set, the iteration order is the same.
deba@1470
   320
        OutEdgeIt(const StaticGraph&, const Edge&) { }
ladanyi@1426
   321
        ///Next outgoing edge
ladanyi@1426
   322
        
ladanyi@1426
   323
        /// Assign the iterator to the next 
ladanyi@1426
   324
        /// outgoing edge of the corresponding node.
ladanyi@1426
   325
        OutEdgeIt& operator++() { return *this; }
deba@1136
   326
      };
deba@1136
   327
deba@1136
   328
      /// This iterator goes trough the incoming edges of a node.
deba@1136
   329
deba@1136
   330
      /// This iterator goes trough the \e incoming edges of a certain node
deba@1136
   331
      /// of a graph.
deba@1136
   332
      /// Its usage is quite simple, for example you can count the number
deba@1136
   333
      /// of outgoing edges of a node \c n
deba@1136
   334
      /// in graph \c g of type \c Graph as follows.
deba@1136
   335
      /// \code
deba@1136
   336
      /// int count=0;
deba@1136
   337
      /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
deba@1136
   338
      /// \endcode
deba@1136
   339
deba@1136
   340
      class InEdgeIt : public Edge {
deba@1136
   341
      public:
ladanyi@1426
   342
        /// Default constructor
deba@1136
   343
ladanyi@1426
   344
        /// @warning The default constructor sets the iterator
ladanyi@1426
   345
        /// to an undefined value.
ladanyi@1426
   346
        InEdgeIt() { }
ladanyi@1426
   347
        /// Copy constructor.
deba@1136
   348
ladanyi@1426
   349
        /// Copy constructor.
ladanyi@1426
   350
        ///
ladanyi@1426
   351
        InEdgeIt(const InEdgeIt& e) : Edge(e) { }
ladanyi@1426
   352
        /// Initialize the iterator to be invalid.
deba@1136
   353
ladanyi@1426
   354
        /// Initialize the iterator to be invalid.
ladanyi@1426
   355
        ///
ladanyi@1426
   356
        InEdgeIt(Invalid) { }
ladanyi@1426
   357
        /// This constructor sets the iterator to first incoming edge.
deba@1136
   358
    
ladanyi@1426
   359
        /// This constructor set the iterator to the first incoming edge of
ladanyi@1426
   360
        /// the node.
ladanyi@1426
   361
        InEdgeIt(const StaticGraph&, const Node&) { }
ladanyi@1426
   362
        /// Edge -> InEdgeIt conversion
deba@1136
   363
ladanyi@1426
   364
        /// Sets the iterator to the value of the trivial iterator \c e.
ladanyi@1426
   365
        /// This feature necessitates that each time we 
ladanyi@1426
   366
        /// iterate the edge-set, the iteration order is the same.
ladanyi@1426
   367
        InEdgeIt(const StaticGraph&, const Edge&) { }
ladanyi@1426
   368
        /// Next incoming edge
deba@1136
   369
ladanyi@1426
   370
        /// Assign the iterator to the next inedge of the corresponding node.
ladanyi@1426
   371
        ///
ladanyi@1426
   372
        InEdgeIt& operator++() { return *this; }
deba@1136
   373
      };
deba@1136
   374
      /// This iterator goes through each edge.
deba@1136
   375
deba@1136
   376
      /// This iterator goes through each edge of a graph.
deba@1136
   377
      /// Its usage is quite simple, for example you can count the number
deba@1136
   378
      /// of edges in a graph \c g of type \c Graph as follows:
deba@1136
   379
      /// \code
deba@1136
   380
      /// int count=0;
deba@1136
   381
      /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
deba@1136
   382
      /// \endcode
deba@1136
   383
      class EdgeIt : public Edge {
deba@1136
   384
      public:
ladanyi@1426
   385
        /// Default constructor
deba@1136
   386
ladanyi@1426
   387
        /// @warning The default constructor sets the iterator
ladanyi@1426
   388
        /// to an undefined value.
ladanyi@1426
   389
        EdgeIt() { }
ladanyi@1426
   390
        /// Copy constructor.
deba@1136
   391
ladanyi@1426
   392
        /// Copy constructor.
ladanyi@1426
   393
        ///
ladanyi@1426
   394
        EdgeIt(const EdgeIt& e) : Edge(e) { }
ladanyi@1426
   395
        /// Initialize the iterator to be invalid.
deba@1136
   396
ladanyi@1426
   397
        /// Initialize the iterator to be invalid.
ladanyi@1426
   398
        ///
ladanyi@1426
   399
        EdgeIt(Invalid) { }
ladanyi@1426
   400
        /// This constructor sets the iterator to the first edge.
deba@1136
   401
    
ladanyi@1426
   402
        /// This constructor sets the iterator to the first edge of \c g.
ladanyi@1426
   403
        ///@param g the graph
alpar@1643
   404
        EdgeIt(const StaticGraph& g) { ignore_unused_variable_warning(g); }
ladanyi@1426
   405
        /// Edge -> EdgeIt conversion
deba@1136
   406
ladanyi@1426
   407
        /// Sets the iterator to the value of the trivial iterator \c e.
ladanyi@1426
   408
        /// This feature necessitates that each time we 
ladanyi@1426
   409
        /// iterate the edge-set, the iteration order is the same.
ladanyi@1426
   410
        EdgeIt(const StaticGraph&, const Edge&) { } 
ladanyi@1426
   411
        ///Next edge
ladanyi@1426
   412
        
ladanyi@1426
   413
        /// Assign the iterator to the next edge.
ladanyi@1426
   414
        EdgeIt& operator++() { return *this; }
deba@1136
   415
      };
deba@1136
   416
      ///Gives back the target node of an edge.
deba@1136
   417
deba@1136
   418
      ///Gives back the target node of an edge.
deba@1136
   419
      ///
deba@1136
   420
      Node target(Edge) const { return INVALID; }
deba@1136
   421
      ///Gives back the source node of an edge.
deba@1136
   422
deba@1136
   423
      ///Gives back the source node of an edge.
deba@1136
   424
      ///
deba@1136
   425
      Node source(Edge) const { return INVALID; }
deba@1563
   426
alpar@1630
   427
//       /// Gives back the first Node in the iterating order.
deba@1563
   428
      
alpar@1630
   429
//       /// Gives back the first Node in the iterating order.
alpar@1630
   430
//       ///     
deba@1563
   431
      void first(Node&) const {}
deba@1563
   432
alpar@1630
   433
//       /// Gives back the next Node in the iterating order.
deba@1563
   434
      
alpar@1630
   435
//       /// Gives back the next Node in the iterating order.
alpar@1630
   436
//       ///     
deba@1563
   437
      void next(Node&) const {}
deba@1563
   438
alpar@1630
   439
//       /// Gives back the first Edge in the iterating order.
deba@1563
   440
      
alpar@1630
   441
//       /// Gives back the first Edge in the iterating order.
alpar@1630
   442
//       ///     
deba@1563
   443
      void first(Edge&) const {}
alpar@1630
   444
//       /// Gives back the next Edge in the iterating order.
deba@1563
   445
      
alpar@1630
   446
//       /// Gives back the next Edge in the iterating order.
alpar@1630
   447
//       ///     
deba@1563
   448
      void next(Edge&) const {}
deba@1563
   449
deba@1563
   450
alpar@1630
   451
//       /// Gives back the first of the Edges point to the given Node.
deba@1563
   452
      
alpar@1630
   453
//       /// Gives back the first of the Edges point to the given Node.
alpar@1630
   454
//       ///     
deba@1563
   455
      void firstIn(Edge&, const Node&) const {}
deba@1563
   456
alpar@1630
   457
//       /// Gives back the next of the Edges points to the given Node.
deba@1563
   458
deba@1563
   459
alpar@1630
   460
//       /// Gives back the next of the Edges points to the given Node.
alpar@1630
   461
//       ///
deba@1563
   462
      void nextIn(Edge&) const {}
deba@1563
   463
alpar@1630
   464
//       /// Gives back the first of the Edges start from the given Node.
deba@1563
   465
      
alpar@1630
   466
//       /// Gives back the first of the Edges start from the given Node.
alpar@1630
   467
//       ///     
deba@1563
   468
      void firstOut(Edge&, const Node&) const {}
deba@1563
   469
alpar@1630
   470
//       /// Gives back the next of the Edges start from the given Node.
deba@1563
   471
      
alpar@1630
   472
//       /// Gives back the next of the Edges start from the given Node.
alpar@1630
   473
//       ///     
deba@1563
   474
      void nextOut(Edge&) const {}
deba@1563
   475
deba@1563
   476
      /// \brief The base node of the iterator.
deba@1563
   477
      ///
deba@1563
   478
      /// Gives back the base node of the iterator.
deba@1627
   479
      /// It is always the target of the pointed edge.
deba@1563
   480
      Node baseNode(const InEdgeIt&) const { return INVALID; }
deba@1563
   481
deba@1563
   482
      /// \brief The running node of the iterator.
deba@1563
   483
      ///
deba@1563
   484
      /// Gives back the running node of the iterator.
deba@1627
   485
      /// It is always the source of the pointed edge.
deba@1563
   486
      Node runningNode(const InEdgeIt&) const { return INVALID; }
deba@1563
   487
deba@1563
   488
      /// \brief The base node of the iterator.
deba@1563
   489
      ///
deba@1563
   490
      /// Gives back the base node of the iterator.
deba@1627
   491
      /// It is always the source of the pointed edge.
deba@1563
   492
      Node baseNode(const OutEdgeIt&) const { return INVALID; }
deba@1563
   493
deba@1563
   494
      /// \brief The running node of the iterator.
deba@1563
   495
      ///
deba@1563
   496
      /// Gives back the running node of the iterator.
deba@1627
   497
      /// It is always the target of the pointed edge.
deba@1563
   498
      Node runningNode(const OutEdgeIt&) const { return INVALID; }
deba@1136
   499
deba@1627
   500
      /// \brief The opposite node on the given edge.
deba@1627
   501
      ///
deba@1627
   502
      /// Gives back the opposite node on the given edge.
deba@1627
   503
      Node oppositeNode(const Node&, const Edge&) const { return INVALID; }
deba@1627
   504
deba@1627
   505
      /// \brief Read write map of the nodes to type \c T.
deba@1627
   506
      /// 
deba@1136
   507
      /// ReadWrite map of the nodes to type \c T.
deba@1136
   508
      /// \sa Reference
deba@1136
   509
      /// \warning Making maps that can handle bool type (NodeMap<bool>)
deba@1136
   510
      /// needs some extra attention!
alpar@1630
   511
      /// \todo Wrong documentation
deba@1136
   512
      template<class T> 
deba@1136
   513
      class NodeMap : public ReadWriteMap< Node, T >
deba@1136
   514
      {
deba@1136
   515
      public:
deba@1136
   516
ladanyi@1426
   517
        ///\e
ladanyi@1426
   518
        NodeMap(const StaticGraph&) { }
ladanyi@1426
   519
        ///\e
ladanyi@1426
   520
        NodeMap(const StaticGraph&, T) { }
deba@1136
   521
ladanyi@1426
   522
        ///Copy constructor
ladanyi@1426
   523
        NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
ladanyi@1426
   524
        ///Assignment operator
ladanyi@1426
   525
        NodeMap& operator=(const NodeMap&) { return *this; }
ladanyi@1426
   526
        // \todo fix this concept
deba@1136
   527
      };
deba@1136
   528
deba@1627
   529
      /// \brief Read write map of the edges to type \c T.
deba@1627
   530
      ///
deba@1627
   531
      /// Reference map of the edges to type \c T.
deba@1136
   532
      /// \sa Reference
deba@1136
   533
      /// \warning Making maps that can handle bool type (EdgeMap<bool>)
deba@1136
   534
      /// needs some extra attention!
alpar@1630
   535
      /// \todo Wrong documentation
deba@1136
   536
      template<class T> 
deba@1136
   537
      class EdgeMap : public ReadWriteMap<Edge,T>
deba@1136
   538
      {
deba@1136
   539
      public:
deba@1136
   540
ladanyi@1426
   541
        ///\e
ladanyi@1426
   542
        EdgeMap(const StaticGraph&) { }
ladanyi@1426
   543
        ///\e
ladanyi@1426
   544
        EdgeMap(const StaticGraph&, T) { }
ladanyi@1426
   545
        ///Copy constructor
ladanyi@1426
   546
        EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { }
ladanyi@1426
   547
        ///Assignment operator
ladanyi@1426
   548
        EdgeMap& operator=(const EdgeMap&) { return *this; }
ladanyi@1426
   549
        // \todo fix this concept    
deba@1136
   550
      };
deba@1136
   551
deba@1136
   552
      template <typename _Graph>
deba@1136
   553
      struct Constraints : public _StaticGraph::Constraints<_Graph> {};
deba@1136
   554
deba@1136
   555
    };
deba@1136
   556
deba@1136
   557
    /// An empty non-static graph class.
deba@1136
   558
    
ladanyi@1426
   559
    /// This class provides everything that \ref StaticGraph does.
ladanyi@1426
   560
    /// Additionally it enables building graphs from scratch.
deba@1136
   561
    class ExtendableGraph : public StaticGraph
deba@1136
   562
    {
deba@1136
   563
    public:
deba@1136
   564
      /// Defalult constructor.
deba@1136
   565
deba@1136
   566
      /// Defalult constructor.
deba@1136
   567
      ///
deba@1136
   568
      ExtendableGraph() { }
deba@1136
   569
      ///Add a new node to the graph.
deba@1136
   570
deba@1136
   571
      /// \return the new node.
deba@1136
   572
      ///
deba@1136
   573
      Node addNode() { return INVALID; }
deba@1136
   574
      ///Add a new edge to the graph.
deba@1136
   575
deba@1136
   576
      ///Add a new edge to the graph with source node \c s
deba@1136
   577
      ///and target node \c t.
deba@1136
   578
      ///\return the new edge.
alpar@1367
   579
      Edge addEdge(Node, Node) { return INVALID; }
deba@1136
   580
    
deba@1136
   581
      /// Resets the graph.
deba@1136
   582
deba@1136
   583
      /// This function deletes all edges and nodes of the graph.
deba@1136
   584
      /// It also frees the memory allocated to store them.
deba@1136
   585
      /// \todo It might belong to \ref ErasableGraph.
deba@1136
   586
      void clear() { }
deba@1136
   587
deba@1136
   588
      template <typename _Graph>
deba@1136
   589
      struct Constraints : public _ExtendableGraph::Constraints<_Graph> {};
deba@1136
   590
deba@1136
   591
    };
deba@1136
   592
deba@1136
   593
    /// An empty erasable graph class.
deba@1136
   594
  
ladanyi@1426
   595
    /// This class is an extension of \ref ExtendableGraph. It makes it
deba@1136
   596
    /// possible to erase edges or nodes.
deba@1136
   597
    class ErasableGraph : public ExtendableGraph
deba@1136
   598
    {
deba@1136
   599
    public:
deba@1136
   600
      /// Defalult constructor.
deba@1136
   601
deba@1136
   602
      /// Defalult constructor.
deba@1136
   603
      ///
deba@1136
   604
      ErasableGraph() { }
deba@1136
   605
      /// Deletes a node.
deba@1136
   606
deba@1136
   607
      /// Deletes node \c n node.
deba@1136
   608
      ///
alpar@1367
   609
      void erase(Node) { }
deba@1136
   610
      /// Deletes an edge.
deba@1136
   611
deba@1136
   612
      /// Deletes edge \c e edge.
deba@1136
   613
      ///
alpar@1367
   614
      void erase(Edge) { }
deba@1136
   615
deba@1136
   616
      template <typename _Graph>
deba@1136
   617
      struct Constraints : public _ErasableGraph::Constraints<_Graph> {};
deba@1136
   618
deba@1136
   619
    };
deba@1136
   620
    
klao@959
   621
    // @}
klao@959
   622
  } //namespace concept  
klao@959
   623
} //namespace lemon
klao@959
   624
klao@959
   625
klao@959
   626
klao@959
   627
#endif // LEMON_CONCEPT_GRAPH_H