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