[Lemon-commits] Alpar Juttner: Merge
Lemon HG
hg at lemon.cs.elte.hu
Mon Jan 12 14:27:22 CET 2009
details: http://lemon.cs.elte.hu/hg/lemon/rev/a1155a9e8e09
changeset: 490:a1155a9e8e09
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Mon Jan 12 13:18:03 2009 +0000
description:
Merge
diffstat:
5 files changed, 880 insertions(+), 355 deletions(-)
lemon/adaptors.h | 25
test/CMakeLists.txt | 2
test/Makefile.am | 4
test/adaptors_test.cc | 1180 ++++++++++++++++++++++++++++++++-------------
tools/lemon-0.x-to-1.x.sh | 24
diffs (truncated from 1743 to 300 lines):
diff --git a/lemon/adaptors.h b/lemon/adaptors.h
--- a/lemon/adaptors.h
+++ b/lemon/adaptors.h
@@ -2666,10 +2666,10 @@
/// \brief Adaptor class for composing the residual digraph for directed
/// flow and circulation problems.
///
- /// Residual can be used for composing the \e residual digraph for directed
- /// flow and circulation problems. Let \f$ G=(V, A) \f$ be a directed graph
- /// and let \f$ F \f$ be a number type. Let \f$ flow, cap: A\to F \f$ be
- /// functions on the arcs.
+ /// ResidualDigraph can be used for composing the \e residual digraph
+ /// for directed flow and circulation problems. Let \f$ G=(V, A) \f$
+ /// be a directed graph and let \f$ F \f$ be a number type.
+ /// Let \f$ flow, cap: A\to F \f$ be functions on the arcs.
/// This adaptor implements a digraph structure with node set \f$ V \f$
/// and arc set \f$ A_{forward}\cup A_{backward} \f$,
/// where \f$ A_{forward}=\{uv : uv\in A, flow(uv)<cap(uv)\} \f$ and
@@ -2704,13 +2704,13 @@
/// is convertible to the \c Arc type of the adapted digraph.
#ifdef DOXYGEN
template<typename GR, typename CM, typename FM, typename TL>
- class Residual
+ class ResidualDigraph
#else
template<typename GR,
typename CM = typename GR::template ArcMap<int>,
typename FM = CM,
typename TL = Tolerance<typename CM::Value> >
- class Residual :
+ class ResidualDigraph :
public FilterArcs<
Undirector<const GR>,
typename Undirector<const GR>::template CombinedArcMap<
@@ -2730,7 +2730,7 @@
typedef TL Tolerance;
typedef typename CapacityMap::Value Value;
- typedef Residual Adaptor;
+ typedef ResidualDigraph Adaptor;
protected:
@@ -2761,8 +2761,8 @@
///
/// Constructor of the residual digraph adaptor. The parameters are the
/// digraph, the capacity map, the flow map, and a tolerance object.
- Residual(const Digraph& digraph, const CapacityMap& capacity,
- FlowMap& flow, const Tolerance& tolerance = Tolerance())
+ ResidualDigraph(const Digraph& digraph, const CapacityMap& capacity,
+ FlowMap& flow, const Tolerance& tolerance = Tolerance())
: Parent(), _capacity(&capacity), _flow(&flow), _graph(digraph),
_forward_filter(capacity, flow, tolerance),
_backward_filter(capacity, flow, tolerance),
@@ -2869,10 +2869,9 @@
/// \ingroup graph_adaptors
/// \relates Residual
template<typename GR, typename CM, typename FM>
- Residual<GR, CM, FM> residual(const GR& digraph,
- const CM& capacity_map,
- FM& flow_map) {
- return Residual<GR, CM, FM> (digraph, capacity_map, flow_map);
+ ResidualDigraph<GR, CM, FM>
+ residualDigraph(const GR& digraph, const CM& capacity_map, FM& flow_map) {
+ return ResidualDigraph<GR, CM, FM> (digraph, capacity_map, flow_map);
}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -3,6 +3,7 @@
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
SET(TESTS
+ adaptors_test
bfs_test
circulation_test
counter_test
@@ -11,7 +12,6 @@
dijkstra_test
dim_test
error_test
- graph_adaptor_test
graph_copy_test
graph_test
graph_utils_test
diff --git a/test/Makefile.am b/test/Makefile.am
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -6,6 +6,7 @@
test/test_tools.h
check_PROGRAMS += \
+ test/adaptors_test \
test/bfs_test \
test/circulation_test \
test/counter_test \
@@ -14,7 +15,6 @@
test/dijkstra_test \
test/dim_test \
test/error_test \
- test/graph_adaptor_test \
test/graph_copy_test \
test/graph_test \
test/graph_utils_test \
@@ -43,6 +43,7 @@
TESTS += $(check_PROGRAMS)
XFAIL_TESTS += test/test_tools_fail$(EXEEXT)
+test_adaptors_test_SOURCES = test/adaptors_test.cc
test_bfs_test_SOURCES = test/bfs_test.cc
test_circulation_test_SOURCES = test/circulation_test.cc
test_counter_test_SOURCES = test/counter_test.cc
@@ -51,7 +52,6 @@
test_dijkstra_test_SOURCES = test/dijkstra_test.cc
test_dim_test_SOURCES = test/dim_test.cc
test_error_test_SOURCES = test/error_test.cc
-test_graph_adaptor_test_SOURCES = test/graph_adaptor_test.cc
test_graph_copy_test_SOURCES = test/graph_copy_test.cc
test_graph_test_SOURCES = test/graph_test.cc
test_graph_utils_test_SOURCES = test/graph_utils_test.cc
diff --git a/test/graph_adaptor_test.cc b/test/adaptors_test.cc
rename from test/graph_adaptor_test.cc
rename to test/adaptors_test.cc
--- a/test/graph_adaptor_test.cc
+++ b/test/adaptors_test.cc
@@ -16,35 +16,48 @@
*
*/
-#include<iostream>
-#include<lemon/concept_check.h>
+#include <iostream>
+#include <limits>
-#include<lemon/list_graph.h>
-#include<lemon/smart_graph.h>
-
-#include<lemon/concepts/digraph.h>
-#include<lemon/concepts/graph.h>
-
-#include<lemon/adaptors.h>
-
-#include <limits>
+#include <lemon/list_graph.h>
+#include <lemon/grid_graph.h>
#include <lemon/bfs.h>
#include <lemon/path.h>
-#include"test/test_tools.h"
-#include"test/graph_test.h"
+#include <lemon/concepts/digraph.h>
+#include <lemon/concepts/graph.h>
+#include <lemon/concepts/graph_components.h>
+#include <lemon/concepts/maps.h>
+#include <lemon/concept_check.h>
+
+#include <lemon/adaptors.h>
+
+#include "test/test_tools.h"
+#include "test/graph_test.h"
using namespace lemon;
void checkReverseDigraph() {
+ // Check concepts
checkConcept<concepts::Digraph, ReverseDigraph<concepts::Digraph> >();
+ checkConcept<concepts::Digraph, ReverseDigraph<ListDigraph> >();
+ checkConcept<concepts::AlterableDigraphComponent<>,
+ ReverseDigraph<ListDigraph> >();
+ checkConcept<concepts::ExtendableDigraphComponent<>,
+ ReverseDigraph<ListDigraph> >();
+ checkConcept<concepts::ErasableDigraphComponent<>,
+ ReverseDigraph<ListDigraph> >();
+ checkConcept<concepts::ClearableDigraphComponent<>,
+ ReverseDigraph<ListDigraph> >();
+ // Create a digraph and an adaptor
typedef ListDigraph Digraph;
typedef ReverseDigraph<Digraph> Adaptor;
Digraph digraph;
Adaptor adaptor(digraph);
+ // Add nodes and arcs to the original digraph
Digraph::Node n1 = digraph.addNode();
Digraph::Node n2 = digraph.addNode();
Digraph::Node n3 = digraph.addNode();
@@ -53,6 +66,7 @@
Digraph::Arc a2 = digraph.addArc(n1, n3);
Digraph::Arc a3 = digraph.addArc(n2, n3);
+ // Check the adaptor
checkGraphNodeList(adaptor, 3);
checkGraphArcList(adaptor, 3);
checkGraphConArcList(adaptor, 3);
@@ -71,18 +85,87 @@
checkGraphNodeMap(adaptor);
checkGraphArcMap(adaptor);
+ // Check the orientation of the arcs
for (Adaptor::ArcIt a(adaptor); a != INVALID; ++a) {
check(adaptor.source(a) == digraph.target(a), "Wrong reverse");
check(adaptor.target(a) == digraph.source(a), "Wrong reverse");
}
+
+ // Add and erase nodes and arcs in the digraph through the adaptor
+ Adaptor::Node n4 = adaptor.addNode();
+
+ Adaptor::Arc a4 = adaptor.addArc(n4, n3);
+ Adaptor::Arc a5 = adaptor.addArc(n2, n4);
+ Adaptor::Arc a6 = adaptor.addArc(n2, n4);
+ Adaptor::Arc a7 = adaptor.addArc(n1, n4);
+ Adaptor::Arc a8 = adaptor.addArc(n1, n2);
+
+ adaptor.erase(a1);
+ adaptor.erase(n3);
+
+ // Check the adaptor
+ checkGraphNodeList(adaptor, 3);
+ checkGraphArcList(adaptor, 4);
+ checkGraphConArcList(adaptor, 4);
+
+ checkGraphOutArcList(adaptor, n1, 2);
+ checkGraphOutArcList(adaptor, n2, 2);
+ checkGraphOutArcList(adaptor, n4, 0);
+
+ checkGraphInArcList(adaptor, n1, 0);
+ checkGraphInArcList(adaptor, n2, 1);
+ checkGraphInArcList(adaptor, n4, 3);
+
+ checkNodeIds(adaptor);
+ checkArcIds(adaptor);
+
+ checkGraphNodeMap(adaptor);
+ checkGraphArcMap(adaptor);
+
+ // Check the digraph
+ checkGraphNodeList(digraph, 3);
+ checkGraphArcList(digraph, 4);
+ checkGraphConArcList(digraph, 4);
+
+ checkGraphOutArcList(digraph, n1, 0);
+ checkGraphOutArcList(digraph, n2, 1);
+ checkGraphOutArcList(digraph, n4, 3);
+
+ checkGraphInArcList(digraph, n1, 2);
+ checkGraphInArcList(digraph, n2, 2);
+ checkGraphInArcList(digraph, n4, 0);
+
+ checkNodeIds(digraph);
+ checkArcIds(digraph);
+
+ checkGraphNodeMap(digraph);
+ checkGraphArcMap(digraph);
+
+ // Check the conversion of nodes and arcs
+ Digraph::Node nd = n4;
+ nd = n4;
+ Adaptor::Node na = n1;
+ na = n2;
+ Digraph::Arc ad = a4;
+ ad = a5;
+ Adaptor::Arc aa = a1;
+ aa = a2;
}
void checkSubDigraph() {
- checkConcept<concepts::Digraph,
- SubDigraph<concepts::Digraph,
- concepts::Digraph::NodeMap<bool>,
- concepts::Digraph::ArcMap<bool> > >();
+ // Check concepts
+ checkConcept<concepts::Digraph, SubDigraph<concepts::Digraph> >();
+ checkConcept<concepts::Digraph, SubDigraph<ListDigraph> >();
+ checkConcept<concepts::AlterableDigraphComponent<>,
+ SubDigraph<ListDigraph> >();
+ checkConcept<concepts::ExtendableDigraphComponent<>,
+ SubDigraph<ListDigraph> >();
+ checkConcept<concepts::ErasableDigraphComponent<>,
+ SubDigraph<ListDigraph> >();
+ checkConcept<concepts::ClearableDigraphComponent<>,
+ SubDigraph<ListDigraph> >();
+ // Create a digraph and an adaptor
typedef ListDigraph Digraph;
typedef Digraph::NodeMap<bool> NodeFilter;
typedef Digraph::ArcMap<bool> ArcFilter;
@@ -93,179 +176,16 @@
ArcFilter arc_filter(digraph);
Adaptor adaptor(digraph, node_filter, arc_filter);
+ // Add nodes and arcs to the original digraph and the adaptor
Digraph::Node n1 = digraph.addNode();
Digraph::Node n2 = digraph.addNode();
- Digraph::Node n3 = digraph.addNode();
+ Adaptor::Node n3 = adaptor.addNode();
+
+ node_filter[n1] = node_filter[n2] = node_filter[n3] = true;
More information about the Lemon-commits
mailing list