1.1 --- a/lemon/concepts/graph.h Fri Nov 13 12:33:33 2009 +0100
1.2 +++ b/lemon/concepts/graph.h Thu Dec 10 17:05:35 2009 +0100
1.3 @@ -2,7 +2,7 @@
1.4 *
1.5 * This file is a part of LEMON, a generic C++ optimization library.
1.6 *
1.7 - * Copyright (C) 2003-2008
1.8 + * Copyright (C) 2003-2009
1.9 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 *
1.12 @@ -20,11 +20,10 @@
1.13 ///\file
1.14 ///\brief The concept of Undirected Graphs.
1.15
1.16 -#ifndef LEMON_CONCEPT_GRAPH_H
1.17 -#define LEMON_CONCEPT_GRAPH_H
1.18 +#ifndef LEMON_CONCEPTS_GRAPH_H
1.19 +#define LEMON_CONCEPTS_GRAPH_H
1.20
1.21 #include <lemon/concepts/graph_components.h>
1.22 -#include <lemon/concepts/graph.h>
1.23 #include <lemon/core.h>
1.24
1.25 namespace lemon {
1.26 @@ -311,8 +310,8 @@
1.27
1.28 /// The directed arc type. It can be converted to the
1.29 /// edge or it should be inherited from the undirected
1.30 - /// arc.
1.31 - class Arc : public Edge {
1.32 + /// edge.
1.33 + class Arc {
1.34 public:
1.35 /// Default constructor
1.36
1.37 @@ -323,7 +322,7 @@
1.38
1.39 /// Copy constructor.
1.40 ///
1.41 - Arc(const Arc& e) : Edge(e) { }
1.42 + Arc(const Arc&) { }
1.43 /// Initialize the iterator to be invalid.
1.44
1.45 /// Initialize the iterator to be invalid.
1.46 @@ -350,6 +349,8 @@
1.47 /// ordering of the items.
1.48 bool operator<(Arc) const { return false; }
1.49
1.50 + /// Converison to Edge
1.51 + operator Edge() const { return Edge(); }
1.52 };
1.53 /// This iterator goes through each directed arc.
1.54
1.55 @@ -498,12 +499,11 @@
1.56 InArcIt& operator++() { return *this; }
1.57 };
1.58
1.59 - /// \brief Read write map of the nodes to type \c T.
1.60 + /// \brief Reference map of the nodes to type \c T.
1.61 ///
1.62 - /// ReadWrite map of the nodes to type \c T.
1.63 - /// \sa Reference
1.64 + /// Reference map of the nodes to type \c T.
1.65 template<class T>
1.66 - class NodeMap : public ReadWriteMap< Node, T >
1.67 + class NodeMap : public ReferenceMap<Node, T, T&, const T&>
1.68 {
1.69 public:
1.70
1.71 @@ -514,7 +514,8 @@
1.72
1.73 private:
1.74 ///Copy constructor
1.75 - NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
1.76 + NodeMap(const NodeMap& nm) :
1.77 + ReferenceMap<Node, T, T&, const T&>(nm) { }
1.78 ///Assignment operator
1.79 template <typename CMap>
1.80 NodeMap& operator=(const CMap&) {
1.81 @@ -523,12 +524,11 @@
1.82 }
1.83 };
1.84
1.85 - /// \brief Read write map of the directed arcs to type \c T.
1.86 + /// \brief Reference map of the arcs to type \c T.
1.87 ///
1.88 - /// Reference map of the directed arcs to type \c T.
1.89 - /// \sa Reference
1.90 + /// Reference map of the arcs to type \c T.
1.91 template<class T>
1.92 - class ArcMap : public ReadWriteMap<Arc,T>
1.93 + class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
1.94 {
1.95 public:
1.96
1.97 @@ -538,7 +538,8 @@
1.98 ArcMap(const Graph&, T) { }
1.99 private:
1.100 ///Copy constructor
1.101 - ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
1.102 + ArcMap(const ArcMap& em) :
1.103 + ReferenceMap<Arc, T, T&, const T&>(em) { }
1.104 ///Assignment operator
1.105 template <typename CMap>
1.106 ArcMap& operator=(const CMap&) {
1.107 @@ -547,12 +548,11 @@
1.108 }
1.109 };
1.110
1.111 - /// Read write map of the edges to type \c T.
1.112 + /// Reference map of the edges to type \c T.
1.113
1.114 - /// Reference map of the arcs to type \c T.
1.115 - /// \sa Reference
1.116 + /// Reference map of the edges to type \c T.
1.117 template<class T>
1.118 - class EdgeMap : public ReadWriteMap<Edge,T>
1.119 + class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
1.120 {
1.121 public:
1.122
1.123 @@ -562,7 +562,8 @@
1.124 EdgeMap(const Graph&, T) { }
1.125 private:
1.126 ///Copy constructor
1.127 - EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) {}
1.128 + EdgeMap(const EdgeMap& em) :
1.129 + ReferenceMap<Edge, T, T&, const T&>(em) {}
1.130 ///Assignment operator
1.131 template <typename CMap>
1.132 EdgeMap& operator=(const CMap&) {
1.133 @@ -602,23 +603,35 @@
1.134
1.135 /// \brief Opposite node on an arc
1.136 ///
1.137 - /// \return the opposite of the given Node on the given Edge
1.138 + /// \return The opposite of the given node on the given edge.
1.139 Node oppositeNode(Node, Edge) const { return INVALID; }
1.140
1.141 /// \brief First node of the edge.
1.142 ///
1.143 - /// \return the first node of the given Edge.
1.144 + /// \return The first node of the given edge.
1.145 ///
1.146 /// Naturally edges don't have direction and thus
1.147 - /// don't have source and target node. But we use these two methods
1.148 - /// to query the two nodes of the arc. The direction of the arc
1.149 - /// which arises this way is called the inherent direction of the
1.150 + /// don't have source and target node. However we use \c u() and \c v()
1.151 + /// methods to query the two nodes of the arc. The direction of the
1.152 + /// arc which arises this way is called the inherent direction of the
1.153 /// edge, and is used to define the "default" direction
1.154 /// of the directed versions of the arcs.
1.155 - /// \sa direction
1.156 + /// \sa v()
1.157 + /// \sa direction()
1.158 Node u(Edge) const { return INVALID; }
1.159
1.160 /// \brief Second node of the edge.
1.161 + ///
1.162 + /// \return The second node of the given edge.
1.163 + ///
1.164 + /// Naturally edges don't have direction and thus
1.165 + /// don't have source and target node. However we use \c u() and \c v()
1.166 + /// methods to query the two nodes of the arc. The direction of the
1.167 + /// arc which arises this way is called the inherent direction of the
1.168 + /// edge, and is used to define the "default" direction
1.169 + /// of the directed versions of the arcs.
1.170 + /// \sa u()
1.171 + /// \sa direction()
1.172 Node v(Edge) const { return INVALID; }
1.173
1.174 /// \brief Source node of the directed arc.
1.175 @@ -737,6 +750,7 @@
1.176 template <typename _Graph>
1.177 struct Constraints {
1.178 void constraints() {
1.179 + checkConcept<BaseGraphComponent, _Graph>();
1.180 checkConcept<IterableGraphComponent<>, _Graph>();
1.181 checkConcept<IDableGraphComponent<>, _Graph>();
1.182 checkConcept<MappableGraphComponent<>, _Graph>();