| 
klao@959
 | 
     1  | 
/* -*- C++ -*-
  | 
| 
klao@959
 | 
     2  | 
 *
  | 
| 
alpar@1956
 | 
     3  | 
 * This file is a part of LEMON, a generic C++ optimization library
  | 
| 
alpar@1956
 | 
     4  | 
 *
  | 
| 
alpar@1956
 | 
     5  | 
 * Copyright (C) 2003-2006
  | 
| 
alpar@1956
 | 
     6  | 
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
  | 
| 
alpar@1359
 | 
     7  | 
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
  | 
| 
klao@959
 | 
     8  | 
 *
  | 
| 
klao@959
 | 
     9  | 
 * Permission to use, modify and distribute this software is granted
  | 
| 
klao@959
 | 
    10  | 
 * provided that this copyright notice appears in all copies. For
  | 
| 
klao@959
 | 
    11  | 
 * precise terms see the accompanying LICENSE file.
  | 
| 
klao@959
 | 
    12  | 
 *
  | 
| 
klao@959
 | 
    13  | 
 * This software is provided "AS IS" with no warranty of any kind,
  | 
| 
klao@959
 | 
    14  | 
 * express or implied, and with no claim as to its suitability for any
  | 
| 
klao@959
 | 
    15  | 
 * purpose.
  | 
| 
klao@959
 | 
    16  | 
 *
  | 
| 
klao@959
 | 
    17  | 
 */
  | 
| 
klao@959
 | 
    18  | 
  | 
| 
klao@959
 | 
    19  | 
#ifndef LEMON_CONCEPT_GRAPH_H
  | 
| 
klao@959
 | 
    20  | 
#define LEMON_CONCEPT_GRAPH_H
  | 
| 
klao@959
 | 
    21  | 
  | 
| 
klao@1030
 | 
    22  | 
///\ingroup graph_concepts
  | 
| 
klao@959
 | 
    23  | 
///\file
  | 
| 
klao@959
 | 
    24  | 
///\brief Declaration of Graph.
  | 
| 
klao@959
 | 
    25  | 
  | 
| 
deba@1993
 | 
    26  | 
#include <lemon/bits/invalid.h>
  | 
| 
deba@1993
 | 
    27  | 
#include <lemon/bits/utility.h>
  | 
| 
klao@959
 | 
    28  | 
#include <lemon/concept/maps.h>
  | 
| 
klao@959
 | 
    29  | 
#include <lemon/concept_check.h>
  | 
| 
deba@2126
 | 
    30  | 
#include <lemon/concept/graph_components.h>
  | 
| 
klao@959
 | 
    31  | 
  | 
| 
klao@959
 | 
    32  | 
namespace lemon {
 | 
| 
klao@959
 | 
    33  | 
  namespace concept {
 | 
| 
deba@1136
 | 
    34  | 
  | 
| 
alpar@1620
 | 
    35  | 
    /// \addtogroup graph_concepts
  | 
| 
alpar@1620
 | 
    36  | 
    /// @{
 | 
| 
alpar@1620
 | 
    37  | 
  | 
| 
alpar@2117
 | 
    38  | 
    /// The directed graph concept
  | 
| 
alpar@2117
 | 
    39  | 
  | 
| 
alpar@2117
 | 
    40  | 
    /// This class describes the \ref concept "concept" of the
  | 
| 
alpar@2117
 | 
    41  | 
    /// immutable directed graphs.
  | 
| 
deba@1136
 | 
    42  | 
    ///
  | 
| 
alpar@2117
 | 
    43  | 
    /// Note that actual graph implementation like @ref ListGraph or
  | 
| 
alpar@2117
 | 
    44  | 
    /// @ref SmartGraph may have several additional functionality.
  | 
| 
deba@1136
 | 
    45  | 
    ///
  | 
| 
alpar@2117
 | 
    46  | 
    /// \sa concept
  | 
| 
deba@2111
 | 
    47  | 
    class Graph {
 | 
| 
alpar@2132
 | 
    48  | 
    private:
  | 
| 
alpar@2132
 | 
    49  | 
      ///Graphs are \e not copy constructible. Use GraphCopy() instead.
  | 
| 
alpar@2132
 | 
    50  | 
      
  | 
| 
alpar@2132
 | 
    51  | 
      ///Graphs are \e not copy constructible. Use GraphCopy() instead.
  | 
| 
alpar@2132
 | 
    52  | 
      ///
  | 
| 
alpar@2134
 | 
    53  | 
      Graph(const Graph &) {};
 | 
| 
alpar@2132
 | 
    54  | 
      ///\brief Assignment of \ref Graph "Graph"s to another ones are
  | 
| 
alpar@2132
 | 
    55  | 
      ///\e not allowed. Use GraphCopy() instead.
  | 
| 
alpar@2132
 | 
    56  | 
      
  | 
| 
alpar@2132
 | 
    57  | 
      ///Assignment of \ref Graph "Graph"s to another ones are
  | 
| 
alpar@2132
 | 
    58  | 
      ///\e not allowed.  Use GraphCopy() instead.
  | 
| 
alpar@2132
 | 
    59  | 
  | 
| 
alpar@2133
 | 
    60  | 
      void operator=(const Graph &) {}
 | 
| 
deba@1136
 | 
    61  | 
    public:
  | 
| 
alpar@1448
 | 
    62  | 
      ///\e
  | 
| 
alpar@1448
 | 
    63  | 
  | 
| 
deba@1136
 | 
    64  | 
      /// Defalult constructor.
  | 
| 
deba@1136
 | 
    65  | 
  | 
| 
deba@1136
 | 
    66  | 
      /// Defalult constructor.
  | 
| 
deba@1136
 | 
    67  | 
      ///
  | 
| 
deba@2111
 | 
    68  | 
      Graph() { }
 | 
| 
alpar@2128
 | 
    69  | 
      /// Class for identifying a node of the graph
  | 
| 
deba@1136
 | 
    70  | 
  | 
| 
alpar@2128
 | 
    71  | 
      /// This class identifies a node of the graph. It also serves
  | 
| 
alpar@2128
 | 
    72  | 
      /// as a base class of the node iterators,
  | 
| 
alpar@2128
 | 
    73  | 
      /// thus they will convert to this type.
  | 
| 
deba@1136
 | 
    74  | 
      class Node {
 | 
| 
deba@1136
 | 
    75  | 
      public:
  | 
| 
ladanyi@1426
 | 
    76  | 
        /// Default constructor
  | 
| 
deba@1136
 | 
    77  | 
  | 
| 
ladanyi@1426
 | 
    78  | 
        /// @warning The default constructor sets the iterator
  | 
| 
ladanyi@1426
 | 
    79  | 
        /// to an undefined value.
  | 
| 
ladanyi@1426
 | 
    80  | 
        Node() { }
 | 
| 
ladanyi@1426
 | 
    81  | 
        /// Copy constructor.
  | 
| 
deba@1136
 | 
    82  | 
  | 
| 
ladanyi@1426
 | 
    83  | 
        /// Copy constructor.
  | 
| 
ladanyi@1426
 | 
    84  | 
        ///
  | 
| 
ladanyi@1426
 | 
    85  | 
        Node(const Node&) { }
 | 
| 
deba@1136
 | 
    86  | 
  | 
| 
ladanyi@1426
 | 
    87  | 
        /// Invalid constructor \& conversion.
  | 
| 
deba@1136
 | 
    88  | 
  | 
| 
ladanyi@1426
 | 
    89  | 
        /// This constructor initializes the iterator to be invalid.
  | 
| 
ladanyi@1426
 | 
    90  | 
        /// \sa Invalid for more details.
  | 
| 
ladanyi@1426
 | 
    91  | 
        Node(Invalid) { }
 | 
| 
ladanyi@1426
 | 
    92  | 
        /// Equality operator
  | 
| 
deba@1136
 | 
    93  | 
  | 
| 
ladanyi@1426
 | 
    94  | 
        /// Two iterators are equal if and only if they point to the
  | 
| 
ladanyi@1426
 | 
    95  | 
        /// same object or both are invalid.
  | 
| 
ladanyi@1426
 | 
    96  | 
        bool operator==(Node) const { return true; }
 | 
| 
deba@1136
 | 
    97  | 
  | 
| 
ladanyi@1426
 | 
    98  | 
        /// Inequality operator
  | 
| 
ladanyi@1426
 | 
    99  | 
        
  | 
| 
ladanyi@1426
 | 
   100  | 
        /// \sa operator==(Node n)
  | 
| 
ladanyi@1426
 | 
   101  | 
        ///
  | 
| 
ladanyi@1426
 | 
   102  | 
        bool operator!=(Node) const { return true; }
 | 
| 
deba@1136
 | 
   103  | 
  | 
| 
deba@1622
 | 
   104  | 
	/// Artificial ordering operator.
  | 
| 
deba@1622
 | 
   105  | 
	
  | 
| 
deba@1622
 | 
   106  | 
	/// To allow the use of graph descriptors as key type in std::map or
  | 
| 
deba@1622
 | 
   107  | 
	/// similar associative container we require this.
  | 
| 
deba@1622
 | 
   108  | 
	///
  | 
| 
deba@1622
 | 
   109  | 
	/// \note This operator only have to define some strict ordering of
  | 
| 
deba@1622
 | 
   110  | 
	/// the items; this order has nothing to do with the iteration
  | 
| 
deba@1622
 | 
   111  | 
	/// ordering of the items.
  | 
| 
deba@1622
 | 
   112  | 
	bool operator<(Node) const { return false; }
 | 
| 
deba@1622
 | 
   113  | 
  | 
| 
deba@1136
 | 
   114  | 
      };
  | 
| 
deba@1136
 | 
   115  | 
    
  | 
| 
deba@1136
 | 
   116  | 
      /// This iterator goes through each node.
  | 
| 
deba@1136
 | 
   117  | 
  | 
| 
deba@1136
 | 
   118  | 
      /// This iterator goes through each node.
  | 
| 
deba@1136
 | 
   119  | 
      /// Its usage is quite simple, for example you can count the number
  | 
| 
deba@1136
 | 
   120  | 
      /// of nodes in graph \c g of type \c Graph like this:
  | 
| 
alpar@1946
 | 
   121  | 
      ///\code
  | 
| 
deba@1136
 | 
   122  | 
      /// int count=0;
  | 
| 
ladanyi@1426
 | 
   123  | 
      /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
  | 
| 
alpar@1946
 | 
   124  | 
      ///\endcode
  | 
| 
deba@1136
 | 
   125  | 
      class NodeIt : public Node {
 | 
| 
deba@1136
 | 
   126  | 
      public:
  | 
| 
ladanyi@1426
 | 
   127  | 
        /// Default constructor
  | 
| 
deba@1136
 | 
   128  | 
  | 
| 
ladanyi@1426
 | 
   129  | 
        /// @warning The default constructor sets the iterator
  | 
| 
ladanyi@1426
 | 
   130  | 
        /// to an undefined value.
  | 
| 
ladanyi@1426
 | 
   131  | 
        NodeIt() { }
 | 
| 
ladanyi@1426
 | 
   132  | 
        /// Copy constructor.
  | 
| 
ladanyi@1426
 | 
   133  | 
        
  | 
| 
ladanyi@1426
 | 
   134  | 
        /// Copy constructor.
  | 
| 
ladanyi@1426
 | 
   135  | 
        ///
  | 
| 
ladanyi@1426
 | 
   136  | 
        NodeIt(const NodeIt& n) : Node(n) { }
 | 
| 
ladanyi@1426
 | 
   137  | 
        /// Invalid constructor \& conversion.
  | 
| 
deba@1136
 | 
   138  | 
  | 
| 
ladanyi@1426
 | 
   139  | 
        /// Initialize the iterator to be invalid.
  | 
| 
ladanyi@1426
 | 
   140  | 
        /// \sa Invalid for more details.
  | 
| 
ladanyi@1426
 | 
   141  | 
        NodeIt(Invalid) { }
 | 
| 
ladanyi@1426
 | 
   142  | 
        /// Sets the iterator to the first node.
  | 
| 
deba@1136
 | 
   143  | 
  | 
| 
ladanyi@1426
 | 
   144  | 
        /// Sets the iterator to the first node of \c g.
  | 
| 
ladanyi@1426
 | 
   145  | 
        ///
  | 
| 
deba@2111
 | 
   146  | 
        NodeIt(const Graph&) { }
 | 
| 
ladanyi@1426
 | 
   147  | 
        /// Node -> NodeIt conversion.
  | 
| 
deba@1136
 | 
   148  | 
  | 
| 
deba@1470
 | 
   149  | 
        /// Sets the iterator to the node of \c the graph pointed by 
  | 
| 
deba@1470
 | 
   150  | 
	/// the trivial iterator.
  | 
| 
ladanyi@1426
 | 
   151  | 
        /// This feature necessitates that each time we 
  | 
| 
ladanyi@1426
 | 
   152  | 
        /// iterate the edge-set, the iteration order is the same.
  | 
| 
deba@2111
 | 
   153  | 
        NodeIt(const Graph&, const Node&) { }
 | 
| 
ladanyi@1426
 | 
   154  | 
        /// Next node.
  | 
| 
deba@1136
 | 
   155  | 
  | 
| 
ladanyi@1426
 | 
   156  | 
        /// Assign the iterator to the next node.
  | 
| 
ladanyi@1426
 | 
   157  | 
        ///
  | 
| 
ladanyi@1426
 | 
   158  | 
        NodeIt& operator++() { return *this; }
 | 
| 
deba@1136
 | 
   159  | 
      };
  | 
| 
deba@1136
 | 
   160  | 
    
  | 
| 
deba@1136
 | 
   161  | 
    
  | 
| 
alpar@2128
 | 
   162  | 
      /// Class for identifying an edge of the graph
  | 
| 
deba@1136
 | 
   163  | 
  | 
| 
alpar@2128
 | 
   164  | 
      /// This class identifies an edge of the graph. It also serves
  | 
| 
alpar@2128
 | 
   165  | 
      /// as a base class of the edge iterators,
  | 
| 
alpar@2128
 | 
   166  | 
      /// thus they will convert to this type.
  | 
| 
deba@1136
 | 
   167  | 
      class Edge {
 | 
| 
deba@1136
 | 
   168  | 
      public:
  | 
| 
ladanyi@1426
 | 
   169  | 
        /// Default constructor
  | 
| 
deba@1136
 | 
   170  | 
  | 
| 
ladanyi@1426
 | 
   171  | 
        /// @warning The default constructor sets the iterator
  | 
| 
ladanyi@1426
 | 
   172  | 
        /// to an undefined value.
  | 
| 
ladanyi@1426
 | 
   173  | 
        Edge() { }
 | 
| 
ladanyi@1426
 | 
   174  | 
        /// Copy constructor.
  | 
| 
deba@1136
 | 
   175  | 
  | 
| 
ladanyi@1426
 | 
   176  | 
        /// Copy constructor.
  | 
| 
ladanyi@1426
 | 
   177  | 
        ///
  | 
| 
ladanyi@1426
 | 
   178  | 
        Edge(const Edge&) { }
 | 
| 
ladanyi@1426
 | 
   179  | 
        /// Initialize the iterator to be invalid.
  | 
| 
deba@1136
 | 
   180  | 
  | 
| 
ladanyi@1426
 | 
   181  | 
        /// Initialize the iterator to be invalid.
  | 
| 
ladanyi@1426
 | 
   182  | 
        ///
  | 
| 
ladanyi@1426
 | 
   183  | 
        Edge(Invalid) { }
 | 
| 
ladanyi@1426
 | 
   184  | 
        /// Equality operator
  | 
| 
deba@1136
 | 
   185  | 
  | 
| 
ladanyi@1426
 | 
   186  | 
        /// Two iterators are equal if and only if they point to the
  | 
| 
ladanyi@1426
 | 
   187  | 
        /// same object or both are invalid.
  | 
| 
ladanyi@1426
 | 
   188  | 
        bool operator==(Edge) const { return true; }
 | 
| 
ladanyi@1426
 | 
   189  | 
        /// Inequality operator
  | 
| 
deba@1136
 | 
   190  | 
  | 
| 
alpar@1620
 | 
   191  | 
        /// \sa operator==(Edge n)
  | 
| 
ladanyi@1426
 | 
   192  | 
        ///
  | 
| 
ladanyi@1426
 | 
   193  | 
        bool operator!=(Edge) const { return true; }
 | 
| 
deba@1622
 | 
   194  | 
  | 
| 
deba@1622
 | 
   195  | 
	/// Artificial ordering operator.
  | 
| 
deba@1622
 | 
   196  | 
	
  | 
| 
deba@1622
 | 
   197  | 
	/// To allow the use of graph descriptors as key type in std::map or
  | 
| 
deba@1622
 | 
   198  | 
	/// similar associative container we require this.
  | 
| 
deba@1622
 | 
   199  | 
	///
  | 
| 
deba@1622
 | 
   200  | 
	/// \note This operator only have to define some strict ordering of
  | 
| 
deba@1622
 | 
   201  | 
	/// the items; this order has nothing to do with the iteration
  | 
| 
deba@1622
 | 
   202  | 
	/// ordering of the items.
  | 
| 
deba@1622
 | 
   203  | 
	bool operator<(Edge) const { return false; }
 | 
| 
deba@1136
 | 
   204  | 
      };
  | 
| 
deba@1136
 | 
   205  | 
    
  | 
| 
deba@1136
 | 
   206  | 
      /// This iterator goes trough the outgoing edges of a node.
  | 
| 
deba@1136
 | 
   207  | 
  | 
| 
deba@1136
 | 
   208  | 
      /// This iterator goes trough the \e outgoing edges of a certain node
  | 
| 
deba@1136
 | 
   209  | 
      /// of a graph.
  | 
| 
deba@1136
 | 
   210  | 
      /// Its usage is quite simple, for example you can count the number
  | 
| 
deba@1136
 | 
   211  | 
      /// of outgoing edges of a node \c n
  | 
| 
deba@1136
 | 
   212  | 
      /// in graph \c g of type \c Graph as follows.
  | 
| 
alpar@1946
 | 
   213  | 
      ///\code
  | 
| 
deba@1136
 | 
   214  | 
      /// int count=0;
  | 
| 
deba@1136
 | 
   215  | 
      /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
  | 
| 
alpar@1946
 | 
   216  | 
      ///\endcode
  | 
| 
deba@1136
 | 
   217  | 
    
  | 
| 
deba@1136
 | 
   218  | 
      class OutEdgeIt : public Edge {
 | 
| 
deba@1136
 | 
   219  | 
      public:
  | 
| 
ladanyi@1426
 | 
   220  | 
        /// Default constructor
  | 
| 
deba@1136
 | 
   221  | 
  | 
| 
ladanyi@1426
 | 
   222  | 
        /// @warning The default constructor sets the iterator
  | 
| 
ladanyi@1426
 | 
   223  | 
        /// to an undefined value.
  | 
| 
ladanyi@1426
 | 
   224  | 
        OutEdgeIt() { }
 | 
| 
ladanyi@1426
 | 
   225  | 
        /// Copy constructor.
  | 
| 
deba@1136
 | 
   226  | 
  | 
| 
ladanyi@1426
 | 
   227  | 
        /// Copy constructor.
  | 
| 
ladanyi@1426
 | 
   228  | 
        ///
  | 
| 
ladanyi@1426
 | 
   229  | 
        OutEdgeIt(const OutEdgeIt& e) : Edge(e) { }
 | 
| 
ladanyi@1426
 | 
   230  | 
        /// Initialize the iterator to be invalid.
  | 
| 
deba@1136
 | 
   231  | 
  | 
| 
ladanyi@1426
 | 
   232  | 
        /// Initialize the iterator to be invalid.
  | 
| 
ladanyi@1426
 | 
   233  | 
        ///
  | 
| 
ladanyi@1426
 | 
   234  | 
        OutEdgeIt(Invalid) { }
 | 
| 
ladanyi@1426
 | 
   235  | 
        /// This constructor sets the iterator to the first outgoing edge.
  | 
| 
deba@1136
 | 
   236  | 
    
  | 
| 
ladanyi@1426
 | 
   237  | 
        /// This constructor sets the iterator to the first outgoing edge of
  | 
| 
ladanyi@1426
 | 
   238  | 
        /// the node.
  | 
| 
deba@2111
 | 
   239  | 
        OutEdgeIt(const Graph&, const Node&) { }
 | 
| 
ladanyi@1426
 | 
   240  | 
        /// Edge -> OutEdgeIt conversion
  | 
| 
deba@1136
 | 
   241  | 
  | 
| 
deba@1470
 | 
   242  | 
        /// Sets the iterator to the value of the trivial iterator.
  | 
| 
deba@1470
 | 
   243  | 
	/// This feature necessitates that each time we 
  | 
| 
ladanyi@1426
 | 
   244  | 
        /// iterate the edge-set, the iteration order is the same.
  | 
| 
deba@2111
 | 
   245  | 
        OutEdgeIt(const Graph&, const Edge&) { }
 | 
| 
ladanyi@1426
 | 
   246  | 
        ///Next outgoing edge
  | 
| 
ladanyi@1426
 | 
   247  | 
        
  | 
| 
ladanyi@1426
 | 
   248  | 
        /// Assign the iterator to the next 
  | 
| 
ladanyi@1426
 | 
   249  | 
        /// outgoing edge of the corresponding node.
  | 
| 
ladanyi@1426
 | 
   250  | 
        OutEdgeIt& operator++() { return *this; }
 | 
| 
deba@1136
 | 
   251  | 
      };
  | 
| 
deba@1136
 | 
   252  | 
  | 
| 
deba@1136
 | 
   253  | 
      /// This iterator goes trough the incoming edges of a node.
  | 
| 
deba@1136
 | 
   254  | 
  | 
| 
deba@1136
 | 
   255  | 
      /// This iterator goes trough the \e incoming edges of a certain node
  | 
| 
deba@1136
 | 
   256  | 
      /// of a graph.
  | 
| 
deba@1136
 | 
   257  | 
      /// Its usage is quite simple, for example you can count the number
  | 
| 
deba@1136
 | 
   258  | 
      /// of outgoing edges of a node \c n
  | 
| 
deba@1136
 | 
   259  | 
      /// in graph \c g of type \c Graph as follows.
  | 
| 
alpar@1946
 | 
   260  | 
      ///\code
  | 
| 
deba@1136
 | 
   261  | 
      /// int count=0;
  | 
| 
deba@1136
 | 
   262  | 
      /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
  | 
| 
alpar@1946
 | 
   263  | 
      ///\endcode
  | 
| 
deba@1136
 | 
   264  | 
  | 
| 
deba@1136
 | 
   265  | 
      class InEdgeIt : public Edge {
 | 
| 
deba@1136
 | 
   266  | 
      public:
  | 
| 
ladanyi@1426
 | 
   267  | 
        /// Default constructor
  | 
| 
deba@1136
 | 
   268  | 
  | 
| 
ladanyi@1426
 | 
   269  | 
        /// @warning The default constructor sets the iterator
  | 
| 
ladanyi@1426
 | 
   270  | 
        /// to an undefined value.
  | 
| 
ladanyi@1426
 | 
   271  | 
        InEdgeIt() { }
 | 
| 
ladanyi@1426
 | 
   272  | 
        /// Copy constructor.
  | 
| 
deba@1136
 | 
   273  | 
  | 
| 
ladanyi@1426
 | 
   274  | 
        /// Copy constructor.
  | 
| 
ladanyi@1426
 | 
   275  | 
        ///
  | 
| 
ladanyi@1426
 | 
   276  | 
        InEdgeIt(const InEdgeIt& e) : Edge(e) { }
 | 
| 
ladanyi@1426
 | 
   277  | 
        /// Initialize the iterator to be invalid.
  | 
| 
deba@1136
 | 
   278  | 
  | 
| 
ladanyi@1426
 | 
   279  | 
        /// Initialize the iterator to be invalid.
  | 
| 
ladanyi@1426
 | 
   280  | 
        ///
  | 
| 
ladanyi@1426
 | 
   281  | 
        InEdgeIt(Invalid) { }
 | 
| 
ladanyi@1426
 | 
   282  | 
        /// This constructor sets the iterator to first incoming edge.
  | 
| 
deba@1136
 | 
   283  | 
    
  | 
| 
ladanyi@1426
 | 
   284  | 
        /// This constructor set the iterator to the first incoming edge of
  | 
| 
ladanyi@1426
 | 
   285  | 
        /// the node.
  | 
| 
deba@2111
 | 
   286  | 
        InEdgeIt(const Graph&, const Node&) { }
 | 
| 
ladanyi@1426
 | 
   287  | 
        /// Edge -> InEdgeIt conversion
  | 
| 
deba@1136
 | 
   288  | 
  | 
| 
ladanyi@1426
 | 
   289  | 
        /// Sets the iterator to the value of the trivial iterator \c e.
  | 
| 
ladanyi@1426
 | 
   290  | 
        /// This feature necessitates that each time we 
  | 
| 
ladanyi@1426
 | 
   291  | 
        /// iterate the edge-set, the iteration order is the same.
  | 
| 
deba@2111
 | 
   292  | 
        InEdgeIt(const Graph&, const Edge&) { }
 | 
| 
ladanyi@1426
 | 
   293  | 
        /// Next incoming edge
  | 
| 
deba@1136
 | 
   294  | 
  | 
| 
ladanyi@1426
 | 
   295  | 
        /// Assign the iterator to the next inedge of the corresponding node.
  | 
| 
ladanyi@1426
 | 
   296  | 
        ///
  | 
| 
ladanyi@1426
 | 
   297  | 
        InEdgeIt& operator++() { return *this; }
 | 
| 
deba@1136
 | 
   298  | 
      };
  | 
| 
deba@1136
 | 
   299  | 
      /// This iterator goes through each edge.
  | 
| 
deba@1136
 | 
   300  | 
  | 
| 
deba@1136
 | 
   301  | 
      /// This iterator goes through each edge of a graph.
  | 
| 
deba@1136
 | 
   302  | 
      /// Its usage is quite simple, for example you can count the number
  | 
| 
deba@1136
 | 
   303  | 
      /// of edges in a graph \c g of type \c Graph as follows:
  | 
| 
alpar@1946
 | 
   304  | 
      ///\code
  | 
| 
deba@1136
 | 
   305  | 
      /// int count=0;
  | 
| 
deba@1136
 | 
   306  | 
      /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
  | 
| 
alpar@1946
 | 
   307  | 
      ///\endcode
  | 
| 
deba@1136
 | 
   308  | 
      class EdgeIt : public Edge {
 | 
| 
deba@1136
 | 
   309  | 
      public:
  | 
| 
ladanyi@1426
 | 
   310  | 
        /// Default constructor
  | 
| 
deba@1136
 | 
   311  | 
  | 
| 
ladanyi@1426
 | 
   312  | 
        /// @warning The default constructor sets the iterator
  | 
| 
ladanyi@1426
 | 
   313  | 
        /// to an undefined value.
  | 
| 
ladanyi@1426
 | 
   314  | 
        EdgeIt() { }
 | 
| 
ladanyi@1426
 | 
   315  | 
        /// Copy constructor.
  | 
| 
deba@1136
 | 
   316  | 
  | 
| 
ladanyi@1426
 | 
   317  | 
        /// Copy constructor.
  | 
| 
ladanyi@1426
 | 
   318  | 
        ///
  | 
| 
ladanyi@1426
 | 
   319  | 
        EdgeIt(const EdgeIt& e) : Edge(e) { }
 | 
| 
ladanyi@1426
 | 
   320  | 
        /// Initialize the iterator to be invalid.
  | 
| 
deba@1136
 | 
   321  | 
  | 
| 
ladanyi@1426
 | 
   322  | 
        /// Initialize the iterator to be invalid.
  | 
| 
ladanyi@1426
 | 
   323  | 
        ///
  | 
| 
ladanyi@1426
 | 
   324  | 
        EdgeIt(Invalid) { }
 | 
| 
ladanyi@1426
 | 
   325  | 
        /// This constructor sets the iterator to the first edge.
  | 
| 
deba@1136
 | 
   326  | 
    
  | 
| 
ladanyi@1426
 | 
   327  | 
        /// This constructor sets the iterator to the first edge of \c g.
  | 
| 
ladanyi@1426
 | 
   328  | 
        ///@param g the graph
  | 
| 
deba@2111
 | 
   329  | 
        EdgeIt(const Graph& g) { ignore_unused_variable_warning(g); }
 | 
| 
ladanyi@1426
 | 
   330  | 
        /// Edge -> EdgeIt conversion
  | 
| 
deba@1136
 | 
   331  | 
  | 
| 
ladanyi@1426
 | 
   332  | 
        /// Sets the iterator to the value of the trivial iterator \c e.
  | 
| 
ladanyi@1426
 | 
   333  | 
        /// This feature necessitates that each time we 
  | 
| 
ladanyi@1426
 | 
   334  | 
        /// iterate the edge-set, the iteration order is the same.
  | 
| 
deba@2111
 | 
   335  | 
        EdgeIt(const Graph&, const Edge&) { } 
 | 
| 
ladanyi@1426
 | 
   336  | 
        ///Next edge
  | 
| 
ladanyi@1426
 | 
   337  | 
        
  | 
| 
ladanyi@1426
 | 
   338  | 
        /// Assign the iterator to the next edge.
  | 
| 
ladanyi@1426
 | 
   339  | 
        EdgeIt& operator++() { return *this; }
 | 
| 
deba@1136
 | 
   340  | 
      };
  | 
| 
deba@1136
 | 
   341  | 
      ///Gives back the target node of an edge.
  | 
| 
deba@1136
 | 
   342  | 
  | 
| 
deba@1136
 | 
   343  | 
      ///Gives back the target node of an edge.
  | 
| 
deba@1136
 | 
   344  | 
      ///
  | 
| 
deba@1136
 | 
   345  | 
      Node target(Edge) const { return INVALID; }
 | 
| 
deba@1136
 | 
   346  | 
      ///Gives back the source node of an edge.
  | 
| 
deba@1136
 | 
   347  | 
  | 
| 
deba@1136
 | 
   348  | 
      ///Gives back the source node of an edge.
  | 
| 
deba@1136
 | 
   349  | 
      ///
  | 
| 
deba@1136
 | 
   350  | 
      Node source(Edge) const { return INVALID; }
 | 
| 
deba@1563
 | 
   351  | 
  | 
| 
deba@1563
 | 
   352  | 
      void first(Node&) const {}
 | 
| 
deba@1563
 | 
   353  | 
      void next(Node&) const {}
 | 
| 
deba@1563
 | 
   354  | 
  | 
| 
deba@1563
 | 
   355  | 
      void first(Edge&) const {}
 | 
| 
deba@1563
 | 
   356  | 
      void next(Edge&) const {}
 | 
| 
deba@1563
 | 
   357  | 
  | 
| 
deba@1563
 | 
   358  | 
  | 
| 
deba@1563
 | 
   359  | 
      void firstIn(Edge&, const Node&) const {}
 | 
| 
deba@1563
 | 
   360  | 
      void nextIn(Edge&) const {}
 | 
| 
deba@1563
 | 
   361  | 
  | 
| 
deba@1563
 | 
   362  | 
      void firstOut(Edge&, const Node&) const {}
 | 
| 
deba@1563
 | 
   363  | 
      void nextOut(Edge&) const {}
 | 
| 
deba@1563
 | 
   364  | 
  | 
| 
deba@1563
 | 
   365  | 
      /// \brief The base node of the iterator.
  | 
| 
deba@1563
 | 
   366  | 
      ///
  | 
| 
deba@1563
 | 
   367  | 
      /// Gives back the base node of the iterator.
  | 
| 
deba@1627
 | 
   368  | 
      /// It is always the target of the pointed edge.
  | 
| 
deba@1563
 | 
   369  | 
      Node baseNode(const InEdgeIt&) const { return INVALID; }
 | 
| 
deba@1563
 | 
   370  | 
  | 
| 
deba@1563
 | 
   371  | 
      /// \brief The running node of the iterator.
  | 
| 
deba@1563
 | 
   372  | 
      ///
  | 
| 
deba@1563
 | 
   373  | 
      /// Gives back the running node of the iterator.
  | 
| 
deba@1627
 | 
   374  | 
      /// It is always the source of the pointed edge.
  | 
| 
deba@1563
 | 
   375  | 
      Node runningNode(const InEdgeIt&) const { return INVALID; }
 | 
| 
deba@1563
 | 
   376  | 
  | 
| 
deba@1563
 | 
   377  | 
      /// \brief The base node of the iterator.
  | 
| 
deba@1563
 | 
   378  | 
      ///
  | 
| 
deba@1563
 | 
   379  | 
      /// Gives back the base node of the iterator.
  | 
| 
deba@1627
 | 
   380  | 
      /// It is always the source of the pointed edge.
  | 
| 
deba@1563
 | 
   381  | 
      Node baseNode(const OutEdgeIt&) const { return INVALID; }
 | 
| 
deba@1563
 | 
   382  | 
  | 
| 
deba@1563
 | 
   383  | 
      /// \brief The running node of the iterator.
  | 
| 
deba@1563
 | 
   384  | 
      ///
  | 
| 
deba@1563
 | 
   385  | 
      /// Gives back the running node of the iterator.
  | 
| 
deba@1627
 | 
   386  | 
      /// It is always the target of the pointed edge.
  | 
| 
deba@1563
 | 
   387  | 
      Node runningNode(const OutEdgeIt&) const { return INVALID; }
 | 
| 
deba@1136
 | 
   388  | 
  | 
| 
deba@1627
 | 
   389  | 
      /// \brief The opposite node on the given edge.
  | 
| 
deba@1627
 | 
   390  | 
      ///
  | 
| 
deba@1627
 | 
   391  | 
      /// Gives back the opposite node on the given edge.
  | 
| 
deba@1627
 | 
   392  | 
      Node oppositeNode(const Node&, const Edge&) const { return INVALID; }
 | 
| 
deba@1627
 | 
   393  | 
  | 
| 
deba@1627
 | 
   394  | 
      /// \brief Read write map of the nodes to type \c T.
  | 
| 
deba@1627
 | 
   395  | 
      /// 
  | 
| 
deba@1136
 | 
   396  | 
      /// ReadWrite map of the nodes to type \c T.
  | 
| 
deba@1136
 | 
   397  | 
      /// \sa Reference
  | 
| 
deba@1136
 | 
   398  | 
      template<class T> 
  | 
| 
deba@2121
 | 
   399  | 
      class NodeMap : public ReadWriteMap< Node, T > {
 | 
| 
deba@1136
 | 
   400  | 
      public:
  | 
| 
deba@1136
 | 
   401  | 
  | 
| 
ladanyi@1426
 | 
   402  | 
        ///\e
  | 
| 
deba@2111
 | 
   403  | 
        NodeMap(const Graph&) { }
 | 
| 
ladanyi@1426
 | 
   404  | 
        ///\e
  | 
| 
deba@2111
 | 
   405  | 
        NodeMap(const Graph&, T) { }
 | 
| 
deba@1136
 | 
   406  | 
  | 
| 
ladanyi@1426
 | 
   407  | 
        ///Copy constructor
  | 
| 
ladanyi@1426
 | 
   408  | 
        NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
 | 
| 
ladanyi@1426
 | 
   409  | 
        ///Assignment operator
  | 
| 
deba@2121
 | 
   410  | 
        template <typename CMap>
  | 
| 
deba@2121
 | 
   411  | 
        NodeMap& operator=(const CMap&) { 
 | 
| 
deba@2121
 | 
   412  | 
          checkConcept<ReadMap<Node, T>, CMap>();
  | 
| 
deba@2121
 | 
   413  | 
          return *this; 
  | 
| 
deba@2121
 | 
   414  | 
        }
  | 
| 
deba@1136
 | 
   415  | 
      };
  | 
| 
deba@1136
 | 
   416  | 
  | 
| 
deba@1627
 | 
   417  | 
      /// \brief Read write map of the edges to type \c T.
  | 
| 
deba@1627
 | 
   418  | 
      ///
  | 
| 
deba@1627
 | 
   419  | 
      /// Reference map of the edges to type \c T.
  | 
| 
deba@1136
 | 
   420  | 
      /// \sa Reference
  | 
| 
deba@1136
 | 
   421  | 
      template<class T> 
  | 
| 
deba@2121
 | 
   422  | 
      class EdgeMap : public ReadWriteMap<Edge,T> {
 | 
| 
deba@1136
 | 
   423  | 
      public:
  | 
| 
deba@1136
 | 
   424  | 
  | 
| 
ladanyi@1426
 | 
   425  | 
        ///\e
  | 
| 
deba@2111
 | 
   426  | 
        EdgeMap(const Graph&) { }
 | 
| 
ladanyi@1426
 | 
   427  | 
        ///\e
  | 
| 
deba@2111
 | 
   428  | 
        EdgeMap(const Graph&, T) { }
 | 
| 
ladanyi@1426
 | 
   429  | 
        ///Copy constructor
  | 
| 
ladanyi@1426
 | 
   430  | 
        EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { }
 | 
| 
ladanyi@1426
 | 
   431  | 
        ///Assignment operator
  | 
| 
deba@2121
 | 
   432  | 
        template <typename CMap>
  | 
| 
deba@2121
 | 
   433  | 
        EdgeMap& operator=(const CMap&) { 
 | 
| 
deba@2121
 | 
   434  | 
          checkConcept<ReadMap<Edge, T>, CMap>();
  | 
| 
deba@2121
 | 
   435  | 
          return *this; 
  | 
| 
deba@2121
 | 
   436  | 
        }
  | 
| 
deba@1136
 | 
   437  | 
      };
  | 
| 
deba@1136
 | 
   438  | 
  | 
| 
deba@2111
 | 
   439  | 
      template <typename RGraph>
  | 
| 
deba@2121
 | 
   440  | 
      struct Constraints {
 | 
| 
deba@2121
 | 
   441  | 
        void constraints() {
 | 
| 
deba@2121
 | 
   442  | 
          checkConcept<BaseIterableGraphComponent<>, Graph>();
  | 
| 
deba@2121
 | 
   443  | 
          checkConcept<IterableGraphComponent<>, Graph>();
  | 
| 
deba@2121
 | 
   444  | 
          checkConcept<MappableGraphComponent<>, Graph>();
  | 
| 
deba@2121
 | 
   445  | 
        }
  | 
| 
deba@2121
 | 
   446  | 
      };
  | 
| 
deba@1136
 | 
   447  | 
  | 
| 
deba@1136
 | 
   448  | 
    };
  | 
| 
deba@1136
 | 
   449  | 
    
  | 
| 
klao@959
 | 
   450  | 
    // @}
  | 
| 
klao@959
 | 
   451  | 
  } //namespace concept  
  | 
| 
klao@959
 | 
   452  | 
} //namespace lemon
  | 
| 
klao@959
 | 
   453  | 
  | 
| 
klao@959
 | 
   454  | 
  | 
| 
klao@959
 | 
   455  | 
  | 
| 
klao@959
 | 
   456  | 
#endif // LEMON_CONCEPT_GRAPH_H
  |