[Lemon-commits] Alpar Juttner: Merge
Lemon HG
hg at lemon.cs.elte.hu
Sun Mar 16 08:35:44 CET 2008
details: http://lemon.cs.elte.hu/hg/lemon/rev/8161012eaa61
changeset: 84:8161012eaa61
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Sun Mar 16 07:32:43 2008 +0000
description:
Merge
diffstat:
4 files changed, 1605 insertions(+), 1386 deletions(-)
doc/groups.dox | 56 -
lemon/concepts/maps.h | 101 -
lemon/maps.h | 2558 ++++++++++++++++++++++++-------------------------
test/maps_test.cc | 276 ++++-
diffs (truncated from 3545 to 300 lines):
diff -r c46b3453455f -r 8161012eaa61 doc/groups.dox
--- a/doc/groups.dox Thu Feb 28 17:06:02 2008 +0100
+++ b/doc/groups.dox Sun Mar 16 07:32:43 2008 +0000
@@ -38,13 +38,13 @@ accessed. LEMON provides several physic
accessed. LEMON provides several physical graph structures to meet
the diverging requirements of the possible users. In order to save on
running time or on memory usage, some structures may fail to provide
-some graph features like edge or node deletion.
+some graph features like arc/edge or node deletion.
Alteration of standard containers need a very limited number of
operations, these together satisfy the everyday requirements.
In the case of graph structures, different operations are needed which do
not alter the physical graph, but gives another view. If some nodes or
-edges have to be hidden or the reverse oriented graph have to be used, then
+arcs have to be hidden or the reverse oriented graph have to be used, then
this is the case. It also may happen that in a flow implementation
the residual graph can be accessed by another algorithm, or a node-set
is to be shrunk for another algorithm.
@@ -81,10 +81,10 @@ new maps from existing ones.
/**
@defgroup graph_maps Graph Maps
@ingroup maps
-\brief Special Graph-Related Maps.
+\brief Special graph-related maps.
This group describes maps that are specifically designed to assign
-values to the nodes and edges of graphs.
+values to the nodes and arcs of graphs.
*/
@@ -96,15 +96,15 @@ This group describes map adaptors that a
This group describes map adaptors that are used to create "implicit"
maps from other maps.
-Most of them are \ref lemon::concepts::ReadMap "ReadMap"s. They can
-make arithmetic operations between one or two maps (negation, scaling,
-addition, multiplication etc.) or e.g. convert a map to another one
-of different Value type.
+Most of them are \ref lemon::concepts::ReadMap "read-only maps".
+They can make arithmetic and logical operations between one or two maps
+(negation, shifting, addition, multiplication, logical 'and', 'or',
+'not' etc.) or e.g. convert a map to another one of different Value type.
The typical usage of this classes is passing implicit maps to
algorithms. If a function type algorithm is called then the function
type map adaptors can be used comfortable. For example let's see the
-usage of map adaptors with the \c graphToEps() function:
+usage of map adaptors with the \c digraphToEps() function.
\code
Color nodeColor(int deg) {
if (deg >= 2) {
@@ -116,39 +116,37 @@ usage of map adaptors with the \c graphT
}
}
- Graph::NodeMap<int> degree_map(graph);
+ Digraph::NodeMap<int> degree_map(graph);
- graphToEps(graph, "graph.eps")
+ digraphToEps(graph, "graph.eps")
.coords(coords).scaleToA4().undirected()
- .nodeColors(composeMap(functorMap(nodeColor), degree_map))
+ .nodeColors(composeMap(functorToMap(nodeColor), degree_map))
.run();
\endcode
-The \c functorMap() function makes an \c int to \c Color map from the
+The \c functorToMap() function makes an \c int to \c Color map from the
\e nodeColor() function. The \c composeMap() compose the \e degree_map
-and the previous created map. The composed map is proper function to
-get color of each node.
+and the previously created map. The composed map is a proper function to
+get the color of each node.
The usage with class type algorithms is little bit harder. In this
case the function type map adaptors can not be used, because the
function map adaptors give back temporary objects.
\code
- Graph graph;
-
- typedef Graph::EdgeMap<double> DoubleEdgeMap;
- DoubleEdgeMap length(graph);
- DoubleEdgeMap speed(graph);
-
- typedef DivMap<DoubleEdgeMap, DoubleEdgeMap> TimeMap;
-
+ Digraph graph;
+
+ typedef Digraph::ArcMap<double> DoubleArcMap;
+ DoubleArcMap length(graph);
+ DoubleArcMap speed(graph);
+
+ typedef DivMap<DoubleArcMap, DoubleArcMap> TimeMap;
TimeMap time(length, speed);
- Dijkstra<Graph, TimeMap> dijkstra(graph, time);
+ Dijkstra<Digraph, TimeMap> dijkstra(graph, time);
dijkstra.run(source, target);
\endcode
-
-We have a length map and a maximum speed map on a graph. The minimum
-time to pass the edge can be calculated as the division of the two
-maps which can be done implicitly with the \c DivMap template
+We have a length map and a maximum speed map on the arcs of a digraph.
+The minimum time to pass the arc can be calculated as the division of
+the two maps which can be done implicitly with the \c DivMap template
class. We use the implicit minimum time map as the length map of the
\c Dijkstra algorithm.
*/
@@ -315,7 +313,7 @@ This group describes the algorithms for
This group contains algorithm objects and functions to calculate
matchings in graphs and bipartite graphs. The general matching problem is
-finding a subset of the edges which does not shares common endpoints.
+finding a subset of the arcs which does not shares common endpoints.
There are several different algorithms for calculate matchings in
graphs. The matching problems in bipartite graphs are generally
diff -r c46b3453455f -r 8161012eaa61 lemon/concepts/maps.h
--- a/lemon/concepts/maps.h Thu Feb 28 17:06:02 2008 +0100
+++ b/lemon/concepts/maps.h Sun Mar 16 07:32:43 2008 +0000
@@ -29,7 +29,7 @@ namespace lemon {
namespace lemon {
namespace concepts {
-
+
/// \addtogroup concept
/// @{
@@ -42,39 +42,39 @@ namespace lemon {
{
public:
/// The key type of the map.
- typedef K Key;
+ typedef K Key;
/// The value type of the map. (The type of objects associated with the keys).
typedef T Value;
- /// Returns the value associated with a key.
+ /// Returns the value associated with the given key.
- /// Returns the value associated with a key.
- /// \bug Value shouldn't need to be default constructible.
- ///
- Value operator[](const Key &) const {return Value();}
+ /// Returns the value associated with the given key.
+ /// \bug Value shouldn't need to be default constructible.
+ Value operator[](const Key &) const { return Value(); }
template<typename _ReadMap>
struct Constraints {
void constraints() {
Value val = m[key];
val = m[key];
- typename _ReadMap::Value own_val = m[own_key];
- own_val = m[own_key];
+ typename _ReadMap::Value own_val = m[own_key];
+ own_val = m[own_key];
+ ignore_unused_variable_warning(key);
ignore_unused_variable_warning(val);
+ ignore_unused_variable_warning(own_key);
ignore_unused_variable_warning(own_val);
- ignore_unused_variable_warning(key);
}
- Key& key;
- typename _ReadMap::Key& own_key;
- _ReadMap& m;
+ const Key& key;
+ const typename _ReadMap::Key& own_key;
+ const _ReadMap& m;
};
-
+
};
/// Writable map concept
-
+
/// Writable map concept.
///
template<typename K, typename T>
@@ -82,39 +82,37 @@ namespace lemon {
{
public:
/// The key type of the map.
- typedef K Key;
+ typedef K Key;
/// The value type of the map. (The type of objects associated with the keys).
typedef T Value;
- /// Sets the value associated with a key.
- void set(const Key &,const Value &) {}
+ /// Sets the value associated with the given key.
+ void set(const Key &, const Value &) {}
- ///Default constructor
+ /// Default constructor.
WriteMap() {}
template <typename _WriteMap>
struct Constraints {
void constraints() {
- // No constraints for constructor.
m.set(key, val);
m.set(own_key, own_val);
+
ignore_unused_variable_warning(key);
ignore_unused_variable_warning(val);
ignore_unused_variable_warning(own_key);
ignore_unused_variable_warning(own_val);
}
-
- Value& val;
- typename _WriteMap::Value own_val;
- Key& key;
- typename _WriteMap::Key& own_key;
+ const Key& key;
+ const Value& val;
+ const typename _WriteMap::Key& own_key;
+ const typename _WriteMap::Value own_val;
_WriteMap& m;
-
};
};
/// Read/writable map concept
-
+
/// Read/writable map concept.
///
template<typename K, typename T>
@@ -123,14 +121,15 @@ namespace lemon {
{
public:
/// The key type of the map.
- typedef K Key;
+ typedef K Key;
/// The value type of the map. (The type of objects associated with the keys).
typedef T Value;
- /// Returns the value associated with a key.
- Value operator[](const Key &) const {return Value();}
- /// Sets the value associated with a key.
- void set(const Key & ,const Value &) {}
+ /// Returns the value associated with the given key.
+ Value operator[](const Key &) const { return Value(); }
+
+ /// Sets the value associated with the given key.
+ void set(const Key &, const Value &) {}
template<typename _ReadWriteMap>
struct Constraints {
@@ -140,13 +139,12 @@ namespace lemon {
}
};
};
-
-
+
+
/// Dereferable map concept
-
+
/// Dereferable map concept.
///
- /// \todo Rethink this concept.
template<typename K, typename T, typename R, typename CR>
class ReferenceMap : public ReadWriteMap<K,T>
{
@@ -154,7 +152,7 @@ namespace lemon {
/// Tag for reference maps.
typedef True ReferenceMapTag;
/// The key type of the map.
- typedef K Key;
+ typedef K Key;
/// The value type of the map. (The type of objects associated with the keys).
typedef T Value;
/// The reference type of the map.
@@ -166,33 +164,38 @@ namespace lemon {
Value tmp;
public:
- ///Returns a reference to the value associated with a key.
+ /// Returns a reference to the value associated with the given key.
Reference operator[](const Key &) { return tmp; }
- ///Returns a const reference to the value associated with a key.
+
+ /// Returns a const reference to the value associated with the given key.
ConstReference operator[](const Key &) const { return tmp; }
- /// Sets the value associated with a key.
+
+ /// Sets the value associated with the given key.
void set(const Key &k,const Value &t) { operator[](k)=t; }
template<typename _ReferenceMap>
struct Constraints {
More information about the Lemon-commits
mailing list