lemon/concept/graph.h
author hegyi
Wed, 27 Jul 2005 11:02:51 +0000
changeset 1595 3bde58e2d5ca
parent 1470 9b6f8c3587f0
child 1620 09feafe81053
permissions -rw-r--r--
Documentation was added to GUI.
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@1030
    34
    /// \addtogroup graph_concepts
klao@959
    35
    /// @{
klao@959
    36
klao@961
    37
    /**************** The full-featured graph concepts ****************/
klao@959
    38
deba@1136
    39
ladanyi@1426
    40
    /// \brief Modular static graph class.
deba@1136
    41
    ///     
deba@1136
    42
    /// It should be the same as the \c StaticGraph class.
deba@1136
    43
    class _StaticGraph 
klao@961
    44
      :  virtual public BaseGraphComponent,
ladanyi@1426
    45
         public IterableGraphComponent, public MappableGraphComponent {
klao@959
    46
    public:
alpar@1448
    47
      ///\e
alpar@1448
    48
alpar@1448
    49
      ///\todo undocumented
alpar@1448
    50
      ///
alpar@1448
    51
      typedef False UndirTag;
alpar@1448
    52
      
klao@959
    53
      typedef BaseGraphComponent::Node Node;
klao@959
    54
      typedef BaseGraphComponent::Edge Edge;
klao@959
    55
deba@989
    56
      template <typename _Graph>
deba@989
    57
      struct Constraints {
ladanyi@1426
    58
        void constraints() {
ladanyi@1426
    59
          checkConcept<IterableGraphComponent, _Graph>();
ladanyi@1426
    60
          checkConcept<MappableGraphComponent, _Graph>();
ladanyi@1426
    61
        }
deba@989
    62
      };
klao@959
    63
    };
klao@959
    64
ladanyi@1426
    65
    /// \brief Modular extendable graph class.
deba@1136
    66
    ///     
deba@1136
    67
    /// It should be the same as the \c ExtendableGraph class.
deba@1136
    68
    class _ExtendableGraph 
deba@1136
    69
      :  virtual public BaseGraphComponent, public _StaticGraph,
ladanyi@1426
    70
         public ExtendableGraphComponent, public ClearableGraphComponent {
klao@959
    71
    public:
klao@959
    72
      typedef BaseGraphComponent::Node Node;
klao@959
    73
      typedef BaseGraphComponent::Edge Edge;
klao@959
    74
deba@989
    75
      template <typename _Graph>
deba@989
    76
      struct Constraints {
ladanyi@1426
    77
        void constraints() {
ladanyi@1426
    78
          checkConcept<_StaticGraph, _Graph >();
ladanyi@1426
    79
          checkConcept<ExtendableGraphComponent, _Graph >();
ladanyi@1426
    80
          checkConcept<ClearableGraphComponent, _Graph >();
ladanyi@1426
    81
        }
deba@989
    82
      };
klao@959
    83
    };
klao@959
    84
ladanyi@1426
    85
    /// \brief Modular erasable graph class.
deba@1136
    86
    ///     
deba@1136
    87
    /// It should be the same as the \c ErasableGraph class.
deba@1136
    88
    class _ErasableGraph 
deba@1136
    89
      :  virtual public BaseGraphComponent, public _ExtendableGraph,
ladanyi@1426
    90
         public ErasableGraphComponent {
klao@959
    91
    public:
klao@959
    92
      typedef BaseGraphComponent::Node Node;
klao@959
    93
      typedef BaseGraphComponent::Edge Edge;
klao@959
    94
deba@989
    95
      template <typename _Graph>
deba@989
    96
      struct Constraints {
ladanyi@1426
    97
        void constraints() {
ladanyi@1426
    98
          checkConcept<_ExtendableGraph, _Graph >();
ladanyi@1426
    99
          checkConcept<ErasableGraphComponent, _Graph >();
ladanyi@1426
   100
        }
deba@989
   101
      };
klao@959
   102
    };
klao@959
   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@1136
   179
      };
deba@1136
   180
    
deba@1136
   181
      /// This iterator goes through each node.
deba@1136
   182
deba@1136
   183
      /// This iterator goes through each node.
deba@1136
   184
      /// Its usage is quite simple, for example you can count the number
deba@1136
   185
      /// of nodes in graph \c g of type \c Graph like this:
deba@1136
   186
      /// \code
deba@1136
   187
      /// int count=0;
ladanyi@1426
   188
      /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
deba@1136
   189
      /// \endcode
deba@1136
   190
      class NodeIt : public Node {
deba@1136
   191
      public:
ladanyi@1426
   192
        /// Default constructor
deba@1136
   193
ladanyi@1426
   194
        /// @warning The default constructor sets the iterator
ladanyi@1426
   195
        /// to an undefined value.
ladanyi@1426
   196
        NodeIt() { }
ladanyi@1426
   197
        /// Copy constructor.
ladanyi@1426
   198
        
ladanyi@1426
   199
        /// Copy constructor.
ladanyi@1426
   200
        ///
ladanyi@1426
   201
        NodeIt(const NodeIt& n) : Node(n) { }
ladanyi@1426
   202
        /// Invalid constructor \& conversion.
deba@1136
   203
ladanyi@1426
   204
        /// Initialize the iterator to be invalid.
ladanyi@1426
   205
        /// \sa Invalid for more details.
ladanyi@1426
   206
        NodeIt(Invalid) { }
ladanyi@1426
   207
        /// Sets the iterator to the first node.
deba@1136
   208
ladanyi@1426
   209
        /// Sets the iterator to the first node of \c g.
ladanyi@1426
   210
        ///
ladanyi@1426
   211
        NodeIt(const StaticGraph&) { }
ladanyi@1426
   212
        /// Node -> NodeIt conversion.
deba@1136
   213
deba@1470
   214
        /// Sets the iterator to the node of \c the graph pointed by 
deba@1470
   215
	/// the trivial iterator.
ladanyi@1426
   216
        /// This feature necessitates that each time we 
ladanyi@1426
   217
        /// iterate the edge-set, the iteration order is the same.
deba@1470
   218
        NodeIt(const StaticGraph&, const Node&) { }
ladanyi@1426
   219
        /// Next node.
deba@1136
   220
ladanyi@1426
   221
        /// Assign the iterator to the next node.
ladanyi@1426
   222
        ///
ladanyi@1426
   223
        NodeIt& operator++() { return *this; }
deba@1136
   224
      };
deba@1136
   225
    
deba@1136
   226
    
deba@1136
   227
      /// The base type of the edge iterators.
deba@1136
   228
deba@1136
   229
      /// The base type of the edge iterators.
deba@1136
   230
      ///
deba@1136
   231
      class Edge {
deba@1136
   232
      public:
ladanyi@1426
   233
        /// Default constructor
deba@1136
   234
ladanyi@1426
   235
        /// @warning The default constructor sets the iterator
ladanyi@1426
   236
        /// to an undefined value.
ladanyi@1426
   237
        Edge() { }
ladanyi@1426
   238
        /// Copy constructor.
deba@1136
   239
ladanyi@1426
   240
        /// Copy constructor.
ladanyi@1426
   241
        ///
ladanyi@1426
   242
        Edge(const Edge&) { }
ladanyi@1426
   243
        /// Initialize the iterator to be invalid.
deba@1136
   244
ladanyi@1426
   245
        /// Initialize the iterator to be invalid.
ladanyi@1426
   246
        ///
ladanyi@1426
   247
        Edge(Invalid) { }
ladanyi@1426
   248
        /// Equality operator
deba@1136
   249
ladanyi@1426
   250
        /// Two iterators are equal if and only if they point to the
ladanyi@1426
   251
        /// same object or both are invalid.
ladanyi@1426
   252
        bool operator==(Edge) const { return true; }
ladanyi@1426
   253
        /// Inequality operator
deba@1136
   254
ladanyi@1426
   255
        /// \sa operator==(Node n)
ladanyi@1426
   256
        ///
ladanyi@1426
   257
        bool operator!=(Edge) const { return true; }
deba@1136
   258
      };
deba@1136
   259
    
deba@1136
   260
      /// This iterator goes trough the outgoing edges of a node.
deba@1136
   261
deba@1136
   262
      /// This iterator goes trough the \e outgoing edges of a certain node
deba@1136
   263
      /// of a graph.
deba@1136
   264
      /// Its usage is quite simple, for example you can count the number
deba@1136
   265
      /// of outgoing edges of a node \c n
deba@1136
   266
      /// in graph \c g of type \c Graph as follows.
deba@1136
   267
      /// \code
deba@1136
   268
      /// int count=0;
deba@1136
   269
      /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
deba@1136
   270
      /// \endcode
deba@1136
   271
    
deba@1136
   272
      class OutEdgeIt : public Edge {
deba@1136
   273
      public:
ladanyi@1426
   274
        /// Default constructor
deba@1136
   275
ladanyi@1426
   276
        /// @warning The default constructor sets the iterator
ladanyi@1426
   277
        /// to an undefined value.
ladanyi@1426
   278
        OutEdgeIt() { }
ladanyi@1426
   279
        /// Copy constructor.
deba@1136
   280
ladanyi@1426
   281
        /// Copy constructor.
ladanyi@1426
   282
        ///
ladanyi@1426
   283
        OutEdgeIt(const OutEdgeIt& e) : Edge(e) { }
ladanyi@1426
   284
        /// Initialize the iterator to be invalid.
deba@1136
   285
ladanyi@1426
   286
        /// Initialize the iterator to be invalid.
ladanyi@1426
   287
        ///
ladanyi@1426
   288
        OutEdgeIt(Invalid) { }
ladanyi@1426
   289
        /// This constructor sets the iterator to the first outgoing edge.
deba@1136
   290
    
ladanyi@1426
   291
        /// This constructor sets the iterator to the first outgoing edge of
ladanyi@1426
   292
        /// the node.
ladanyi@1426
   293
        ///@param n the node
ladanyi@1426
   294
        ///@param g the graph
ladanyi@1426
   295
        OutEdgeIt(const StaticGraph&, const Node&) { }
ladanyi@1426
   296
        /// Edge -> OutEdgeIt conversion
deba@1136
   297
deba@1470
   298
        /// Sets the iterator to the value of the trivial iterator.
deba@1470
   299
	/// This feature necessitates that each time we 
ladanyi@1426
   300
        /// iterate the edge-set, the iteration order is the same.
deba@1470
   301
        OutEdgeIt(const StaticGraph&, const Edge&) { }
ladanyi@1426
   302
        ///Next outgoing edge
ladanyi@1426
   303
        
ladanyi@1426
   304
        /// Assign the iterator to the next 
ladanyi@1426
   305
        /// outgoing edge of the corresponding node.
ladanyi@1426
   306
        OutEdgeIt& operator++() { return *this; }
deba@1136
   307
      };
deba@1136
   308
deba@1136
   309
      /// This iterator goes trough the incoming edges of a node.
deba@1136
   310
deba@1136
   311
      /// This iterator goes trough the \e incoming edges of a certain node
deba@1136
   312
      /// of a graph.
deba@1136
   313
      /// Its usage is quite simple, for example you can count the number
deba@1136
   314
      /// of outgoing edges of a node \c n
deba@1136
   315
      /// in graph \c g of type \c Graph as follows.
deba@1136
   316
      /// \code
deba@1136
   317
      /// int count=0;
deba@1136
   318
      /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
deba@1136
   319
      /// \endcode
deba@1136
   320
deba@1136
   321
      class InEdgeIt : public Edge {
deba@1136
   322
      public:
ladanyi@1426
   323
        /// Default constructor
deba@1136
   324
ladanyi@1426
   325
        /// @warning The default constructor sets the iterator
ladanyi@1426
   326
        /// to an undefined value.
ladanyi@1426
   327
        InEdgeIt() { }
ladanyi@1426
   328
        /// Copy constructor.
deba@1136
   329
ladanyi@1426
   330
        /// Copy constructor.
ladanyi@1426
   331
        ///
ladanyi@1426
   332
        InEdgeIt(const InEdgeIt& e) : Edge(e) { }
ladanyi@1426
   333
        /// Initialize the iterator to be invalid.
deba@1136
   334
ladanyi@1426
   335
        /// Initialize the iterator to be invalid.
ladanyi@1426
   336
        ///
ladanyi@1426
   337
        InEdgeIt(Invalid) { }
ladanyi@1426
   338
        /// This constructor sets the iterator to first incoming edge.
deba@1136
   339
    
ladanyi@1426
   340
        /// This constructor set the iterator to the first incoming edge of
ladanyi@1426
   341
        /// the node.
ladanyi@1426
   342
        ///@param n the node
ladanyi@1426
   343
        ///@param g the graph
ladanyi@1426
   344
        InEdgeIt(const StaticGraph&, const Node&) { }
ladanyi@1426
   345
        /// Edge -> InEdgeIt conversion
deba@1136
   346
ladanyi@1426
   347
        /// Sets the iterator to the value of the trivial iterator \c e.
ladanyi@1426
   348
        /// This feature necessitates that each time we 
ladanyi@1426
   349
        /// iterate the edge-set, the iteration order is the same.
ladanyi@1426
   350
        InEdgeIt(const StaticGraph&, const Edge&) { }
ladanyi@1426
   351
        /// Next incoming edge
deba@1136
   352
ladanyi@1426
   353
        /// Assign the iterator to the next inedge of the corresponding node.
ladanyi@1426
   354
        ///
ladanyi@1426
   355
        InEdgeIt& operator++() { return *this; }
deba@1136
   356
      };
deba@1136
   357
      /// This iterator goes through each edge.
deba@1136
   358
deba@1136
   359
      /// This iterator goes through each edge of a graph.
deba@1136
   360
      /// Its usage is quite simple, for example you can count the number
deba@1136
   361
      /// of edges in a graph \c g of type \c Graph as follows:
deba@1136
   362
      /// \code
deba@1136
   363
      /// int count=0;
deba@1136
   364
      /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
deba@1136
   365
      /// \endcode
deba@1136
   366
      class EdgeIt : public Edge {
deba@1136
   367
      public:
ladanyi@1426
   368
        /// Default constructor
deba@1136
   369
ladanyi@1426
   370
        /// @warning The default constructor sets the iterator
ladanyi@1426
   371
        /// to an undefined value.
ladanyi@1426
   372
        EdgeIt() { }
ladanyi@1426
   373
        /// Copy constructor.
deba@1136
   374
ladanyi@1426
   375
        /// Copy constructor.
ladanyi@1426
   376
        ///
ladanyi@1426
   377
        EdgeIt(const EdgeIt& e) : Edge(e) { }
ladanyi@1426
   378
        /// Initialize the iterator to be invalid.
deba@1136
   379
ladanyi@1426
   380
        /// Initialize the iterator to be invalid.
ladanyi@1426
   381
        ///
ladanyi@1426
   382
        EdgeIt(Invalid) { }
ladanyi@1426
   383
        /// This constructor sets the iterator to the first edge.
deba@1136
   384
    
ladanyi@1426
   385
        /// This constructor sets the iterator to the first edge of \c g.
ladanyi@1426
   386
        ///@param g the graph
ladanyi@1426
   387
        EdgeIt(const StaticGraph&) { }
ladanyi@1426
   388
        /// Edge -> EdgeIt conversion
deba@1136
   389
ladanyi@1426
   390
        /// Sets the iterator to the value of the trivial iterator \c e.
ladanyi@1426
   391
        /// This feature necessitates that each time we 
ladanyi@1426
   392
        /// iterate the edge-set, the iteration order is the same.
ladanyi@1426
   393
        EdgeIt(const StaticGraph&, const Edge&) { } 
ladanyi@1426
   394
        ///Next edge
ladanyi@1426
   395
        
ladanyi@1426
   396
        /// Assign the iterator to the next edge.
ladanyi@1426
   397
        EdgeIt& operator++() { return *this; }
deba@1136
   398
      };
deba@1136
   399
      ///Gives back the target node of an edge.
deba@1136
   400
deba@1136
   401
      ///Gives back the target node of an edge.
deba@1136
   402
      ///
deba@1136
   403
      Node target(Edge) const { return INVALID; }
deba@1136
   404
      ///Gives back the source node of an edge.
deba@1136
   405
deba@1136
   406
      ///Gives back the source node of an edge.
deba@1136
   407
      ///
deba@1136
   408
      Node source(Edge) const { return INVALID; }
deba@1563
   409
deba@1563
   410
      /// Gives back the first Node in the iterating order.
deba@1563
   411
      
deba@1563
   412
      /// Gives back the first Node in the iterating order.
deba@1563
   413
      ///     
deba@1563
   414
      void first(Node&) const {}
deba@1563
   415
deba@1563
   416
      /// Gives back the next Node in the iterating order.
deba@1563
   417
      
deba@1563
   418
      /// Gives back the next Node in the iterating order.
deba@1563
   419
      ///     
deba@1563
   420
      void next(Node&) const {}
deba@1563
   421
deba@1563
   422
      /// Gives back the first Edge in the iterating order.
deba@1563
   423
      
deba@1563
   424
      /// Gives back the first Edge in the iterating order.
deba@1563
   425
      ///     
deba@1563
   426
      void first(Edge&) const {}
deba@1563
   427
      /// Gives back the next Edge in the iterating order.
deba@1563
   428
      
deba@1563
   429
      /// Gives back the next Edge in the iterating order.
deba@1563
   430
      ///     
deba@1563
   431
      void next(Edge&) const {}
deba@1563
   432
deba@1563
   433
deba@1563
   434
      /// Gives back the first of the Edges point to the given Node.
deba@1563
   435
      
deba@1563
   436
      /// Gives back the first of the Edges point to the given Node.
deba@1563
   437
      ///     
deba@1563
   438
      void firstIn(Edge&, const Node&) const {}
deba@1563
   439
deba@1563
   440
      /// Gives back the next of the Edges points to the given Node.
deba@1563
   441
deba@1563
   442
deba@1563
   443
      /// Gives back the next of the Edges points to the given Node.
deba@1563
   444
      ///
deba@1563
   445
      void nextIn(Edge&) const {}
deba@1563
   446
deba@1563
   447
      /// Gives back the first of the Edges start from the given Node.
deba@1563
   448
      
deba@1563
   449
      /// Gives back the first of the Edges start from the given Node.
deba@1563
   450
      ///     
deba@1563
   451
      void firstOut(Edge&, const Node&) const {}
deba@1563
   452
deba@1563
   453
      /// Gives back the next of the Edges start from the given Node.
deba@1563
   454
      
deba@1563
   455
      /// Gives back the next of the Edges start from the given Node.
deba@1563
   456
      ///     
deba@1563
   457
      void nextOut(Edge&) const {}
deba@1563
   458
deba@1563
   459
      /// \brief The base node of the iterator.
deba@1563
   460
      ///
deba@1563
   461
      /// Gives back the base node of the iterator.
deba@1563
   462
      Node baseNode(const InEdgeIt&) const { return INVALID; }
deba@1563
   463
deba@1563
   464
      /// \brief The running node of the iterator.
deba@1563
   465
      ///
deba@1563
   466
      /// Gives back the running node of the iterator.
deba@1563
   467
      Node runningNode(const InEdgeIt&) const { return INVALID; }
deba@1563
   468
deba@1563
   469
      /// \brief The base node of the iterator.
deba@1563
   470
      ///
deba@1563
   471
      /// Gives back the base node of the iterator.
deba@1563
   472
      Node baseNode(const OutEdgeIt&) const { return INVALID; }
deba@1563
   473
deba@1563
   474
      /// \brief The running node of the iterator.
deba@1563
   475
      ///
deba@1563
   476
      /// Gives back the running node of the iterator.
deba@1563
   477
      Node runningNode(const OutEdgeIt&) const { return INVALID; }
deba@1136
   478
      /// Read write map of the nodes to type \c T.
deba@1136
   479
deba@1136
   480
      /// \ingroup concept
deba@1136
   481
      /// ReadWrite map of the nodes to type \c T.
deba@1136
   482
      /// \sa Reference
deba@1136
   483
      /// \warning Making maps that can handle bool type (NodeMap<bool>)
deba@1136
   484
      /// needs some extra attention!
deba@1136
   485
      template<class T> 
deba@1136
   486
      class NodeMap : public ReadWriteMap< Node, T >
deba@1136
   487
      {
deba@1136
   488
      public:
deba@1136
   489
ladanyi@1426
   490
        ///\e
ladanyi@1426
   491
        NodeMap(const StaticGraph&) { }
ladanyi@1426
   492
        ///\e
ladanyi@1426
   493
        NodeMap(const StaticGraph&, T) { }
deba@1136
   494
ladanyi@1426
   495
        ///Copy constructor
ladanyi@1426
   496
        NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
ladanyi@1426
   497
        ///Assignment operator
ladanyi@1426
   498
        NodeMap& operator=(const NodeMap&) { return *this; }
ladanyi@1426
   499
        // \todo fix this concept
deba@1136
   500
      };
deba@1136
   501
deba@1136
   502
      /// Read write map of the edges to type \c T.
deba@1136
   503
deba@1136
   504
      /// \ingroup concept
deba@1136
   505
      ///Reference map of the edges to type \c T.
deba@1136
   506
      /// \sa Reference
deba@1136
   507
      /// \warning Making maps that can handle bool type (EdgeMap<bool>)
deba@1136
   508
      /// needs some extra attention!
deba@1136
   509
      template<class T> 
deba@1136
   510
      class EdgeMap : public ReadWriteMap<Edge,T>
deba@1136
   511
      {
deba@1136
   512
      public:
deba@1136
   513
ladanyi@1426
   514
        ///\e
ladanyi@1426
   515
        EdgeMap(const StaticGraph&) { }
ladanyi@1426
   516
        ///\e
ladanyi@1426
   517
        EdgeMap(const StaticGraph&, T) { }
ladanyi@1426
   518
        ///Copy constructor
ladanyi@1426
   519
        EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { }
ladanyi@1426
   520
        ///Assignment operator
ladanyi@1426
   521
        EdgeMap& operator=(const EdgeMap&) { return *this; }
ladanyi@1426
   522
        // \todo fix this concept    
deba@1136
   523
      };
deba@1136
   524
deba@1136
   525
      template <typename _Graph>
deba@1136
   526
      struct Constraints : public _StaticGraph::Constraints<_Graph> {};
deba@1136
   527
deba@1136
   528
    };
deba@1136
   529
deba@1136
   530
    /// An empty non-static graph class.
deba@1136
   531
    
ladanyi@1426
   532
    /// This class provides everything that \ref StaticGraph does.
ladanyi@1426
   533
    /// Additionally it enables building graphs from scratch.
deba@1136
   534
    class ExtendableGraph : public StaticGraph
deba@1136
   535
    {
deba@1136
   536
    public:
deba@1136
   537
      /// Defalult constructor.
deba@1136
   538
deba@1136
   539
      /// Defalult constructor.
deba@1136
   540
      ///
deba@1136
   541
      ExtendableGraph() { }
deba@1136
   542
      ///Add a new node to the graph.
deba@1136
   543
deba@1136
   544
      /// \return the new node.
deba@1136
   545
      ///
deba@1136
   546
      Node addNode() { return INVALID; }
deba@1136
   547
      ///Add a new edge to the graph.
deba@1136
   548
deba@1136
   549
      ///Add a new edge to the graph with source node \c s
deba@1136
   550
      ///and target node \c t.
deba@1136
   551
      ///\return the new edge.
alpar@1367
   552
      Edge addEdge(Node, Node) { return INVALID; }
deba@1136
   553
    
deba@1136
   554
      /// Resets the graph.
deba@1136
   555
deba@1136
   556
      /// This function deletes all edges and nodes of the graph.
deba@1136
   557
      /// It also frees the memory allocated to store them.
deba@1136
   558
      /// \todo It might belong to \ref ErasableGraph.
deba@1136
   559
      void clear() { }
deba@1136
   560
deba@1136
   561
      template <typename _Graph>
deba@1136
   562
      struct Constraints : public _ExtendableGraph::Constraints<_Graph> {};
deba@1136
   563
deba@1136
   564
    };
deba@1136
   565
deba@1136
   566
    /// An empty erasable graph class.
deba@1136
   567
  
ladanyi@1426
   568
    /// This class is an extension of \ref ExtendableGraph. It makes it
deba@1136
   569
    /// possible to erase edges or nodes.
deba@1136
   570
    class ErasableGraph : public ExtendableGraph
deba@1136
   571
    {
deba@1136
   572
    public:
deba@1136
   573
      /// Defalult constructor.
deba@1136
   574
deba@1136
   575
      /// Defalult constructor.
deba@1136
   576
      ///
deba@1136
   577
      ErasableGraph() { }
deba@1136
   578
      /// Deletes a node.
deba@1136
   579
deba@1136
   580
      /// Deletes node \c n node.
deba@1136
   581
      ///
alpar@1367
   582
      void erase(Node) { }
deba@1136
   583
      /// Deletes an edge.
deba@1136
   584
deba@1136
   585
      /// Deletes edge \c e edge.
deba@1136
   586
      ///
alpar@1367
   587
      void erase(Edge) { }
deba@1136
   588
deba@1136
   589
      template <typename _Graph>
deba@1136
   590
      struct Constraints : public _ErasableGraph::Constraints<_Graph> {};
deba@1136
   591
deba@1136
   592
    };
deba@1136
   593
deba@1136
   594
    
deba@1136
   595
    /************* New GraphBase stuff **************/
deba@1136
   596
deba@1136
   597
deba@1136
   598
//     /// A minimal GraphBase concept
deba@1136
   599
deba@1136
   600
//     /// This class describes a minimal concept which can be extended to a
deba@1136
   601
//     /// full-featured graph with \ref GraphFactory.
deba@1136
   602
//     class GraphBase {
deba@1136
   603
//     public:
deba@1136
   604
deba@1136
   605
//       GraphBase() {}
deba@1136
   606
deba@1136
   607
//       /// \bug Should we demand that Node and Edge be subclasses of the
deba@1136
   608
//       /// Graph class???
deba@1136
   609
deba@1136
   610
//       typedef GraphItem<'n'> Node;
deba@1136
   611
//       typedef GraphItem<'e'> Edge;
deba@1136
   612
deba@1136
   613
// //       class Node : public BaseGraphItem<'n'> {};
deba@1136
   614
// //       class Edge : public BaseGraphItem<'e'> {};
deba@1136
   615
deba@1136
   616
//       // Graph operation
deba@1136
   617
//       void firstNode(Node &n) const { }
deba@1136
   618
//       void firstEdge(Edge &e) const { }
deba@1136
   619
deba@1136
   620
//       void firstOutEdge(Edge &e, Node) const { }
deba@1136
   621
//       void firstInEdge(Edge &e, Node) const { }
deba@1136
   622
deba@1136
   623
//       void nextNode(Node &n) const { }
deba@1136
   624
//       void nextEdge(Edge &e) const { }
deba@1136
   625
deba@1136
   626
deba@1136
   627
//       // Question: isn't it reasonable if this methods have a Node
deba@1136
   628
//       // parameter? Like this:
deba@1136
   629
//       // Edge& nextOut(Edge &e, Node) const { return e; }
deba@1136
   630
//       void nextOutEdge(Edge &e) const { }
deba@1136
   631
//       void nextInEdge(Edge &e) const { }
deba@1136
   632
deba@1136
   633
//       Node target(Edge) const { return Node(); }
deba@1136
   634
//       Node source(Edge) const { return Node(); }
deba@1136
   635
      
deba@1136
   636
deba@1136
   637
//       // Do we need id, nodeNum, edgeNum and co. in this basic graphbase
deba@1136
   638
//       // concept?
deba@1136
   639
deba@1136
   640
deba@1136
   641
//       // Maps.
deba@1136
   642
//       //
deba@1136
   643
//       // We need a special slimer concept which does not provide maps (it
deba@1136
   644
//       // wouldn't be strictly slimer, cause for map-factory id() & friends
deba@1136
   645
//       // a required...)
deba@1136
   646
deba@1136
   647
//       template<typename T>
deba@1136
   648
//       class NodeMap : public GraphMap<GraphBase, Node, T> {};
deba@1136
   649
deba@1136
   650
//       template<typename T>
deba@1136
   651
//       class EdgeMap : public GraphMap<GraphBase, Node, T> {};
deba@1136
   652
//     };
deba@1136
   653
klao@959
   654
    // @}
klao@959
   655
  } //namespace concept  
klao@959
   656
} //namespace lemon
klao@959
   657
klao@959
   658
klao@959
   659
klao@959
   660
#endif // LEMON_CONCEPT_GRAPH_H