Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt	(revision 726)
+++ test/CMakeLists.txt	(revision 745)
@@ -10,4 +10,5 @@
 SET(TESTS
   adaptors_test
+  bellman_ford_test
   bfs_test
   circulation_test
Index: test/Makefile.am
===================================================================
--- test/Makefile.am	(revision 696)
+++ test/Makefile.am	(revision 745)
@@ -8,4 +8,5 @@
 check_PROGRAMS += \
 	test/adaptors_test \
+	test/bellman_ford_test \
 	test/bfs_test \
 	test/circulation_test \
@@ -53,4 +54,5 @@
 
 test_adaptors_test_SOURCES = test/adaptors_test.cc
+test_bellman_ford_test_SOURCES = test/bellman_ford_test.cc
 test_bfs_test_SOURCES = test/bfs_test.cc
 test_circulation_test_SOURCES = test/circulation_test.cc
Index: test/bellman_ford_test.cc
===================================================================
--- test/bellman_ford_test.cc	(revision 745)
+++ test/bellman_ford_test.cc	(revision 745)
@@ -0,0 +1,227 @@
+/* -*- mode: C++; indent-tabs-mode: nil; -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library.
+ *
+ * Copyright (C) 2003-2009
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+#include <lemon/concepts/digraph.h>
+#include <lemon/smart_graph.h>
+#include <lemon/list_graph.h>
+#include <lemon/lgf_reader.h>
+#include <lemon/bellman_ford.h>
+#include <lemon/path.h>
+
+#include "graph_test.h"
+#include "test_tools.h"
+
+using namespace lemon;
+
+char test_lgf[] =
+  "@nodes\n"
+  "label\n"
+  "0\n"
+  "1\n"
+  "2\n"
+  "3\n"
+  "4\n"
+  "@arcs\n"
+  "    length\n"
+  "0 1 3\n"
+  "1 2 -3\n"
+  "1 2 -5\n"
+  "1 3 -2\n"
+  "0 2 -1\n"
+  "1 2 -4\n"
+  "0 3 2\n"
+  "4 2 -5\n"
+  "2 3 1\n"
+  "@attributes\n"
+  "source 0\n"
+  "target 3\n";
+
+
+void checkBellmanFordCompile()
+{
+  typedef int Value;
+  typedef concepts::Digraph Digraph;
+  typedef concepts::ReadMap<Digraph::Arc,Value> LengthMap;
+  typedef BellmanFord<Digraph, LengthMap> BF;
+  typedef Digraph::Node Node;
+  typedef Digraph::Arc Arc;
+
+  Digraph gr;
+  Node s, t, n;
+  Arc e;
+  Value l;
+  int k;
+  bool b;
+  BF::DistMap d(gr);
+  BF::PredMap p(gr);
+  LengthMap length;
+  concepts::Path<Digraph> pp;
+
+  {
+    BF bf_test(gr,length);
+    const BF& const_bf_test = bf_test;
+
+    bf_test.run(s);
+    bf_test.run(s,k);
+
+    bf_test.init();
+    bf_test.addSource(s);
+    bf_test.addSource(s, 1);
+    b = bf_test.processNextRound();
+    b = bf_test.processNextWeakRound();
+
+    bf_test.start();
+    bf_test.checkedStart();
+    bf_test.limitedStart(k);
+
+    l  = const_bf_test.dist(t);
+    e  = const_bf_test.predArc(t);
+    s  = const_bf_test.predNode(t);
+    b  = const_bf_test.reached(t);
+    d  = const_bf_test.distMap();
+    p  = const_bf_test.predMap();
+    pp = const_bf_test.path(t);
+    
+    for (BF::ActiveIt it(const_bf_test); it != INVALID; ++it) {}
+  }
+  {
+    BF::SetPredMap<concepts::ReadWriteMap<Node,Arc> >
+      ::SetDistMap<concepts::ReadWriteMap<Node,Value> >
+      ::SetOperationTraits<BellmanFordDefaultOperationTraits<Value> >
+      ::Create bf_test(gr,length);
+
+    LengthMap length_map;
+    concepts::ReadWriteMap<Node,Arc> pred_map;
+    concepts::ReadWriteMap<Node,Value> dist_map;
+    
+    bf_test
+      .lengthMap(length_map)
+      .predMap(pred_map)
+      .distMap(dist_map);
+
+    bf_test.run(s);
+    bf_test.run(s,k);
+
+    bf_test.init();
+    bf_test.addSource(s);
+    bf_test.addSource(s, 1);
+    b = bf_test.processNextRound();
+    b = bf_test.processNextWeakRound();
+
+    bf_test.start();
+    bf_test.checkedStart();
+    bf_test.limitedStart(k);
+
+    l  = bf_test.dist(t);
+    e  = bf_test.predArc(t);
+    s  = bf_test.predNode(t);
+    b  = bf_test.reached(t);
+    pp = bf_test.path(t);
+  }
+}
+
+void checkBellmanFordFunctionCompile()
+{
+  typedef int Value;
+  typedef concepts::Digraph Digraph;
+  typedef Digraph::Arc Arc;
+  typedef Digraph::Node Node;
+  typedef concepts::ReadMap<Digraph::Arc,Value> LengthMap;
+
+  Digraph g;
+  bool b;
+  bellmanFord(g,LengthMap()).run(Node());
+  b = bellmanFord(g,LengthMap()).run(Node(),Node());
+  bellmanFord(g,LengthMap())
+    .predMap(concepts::ReadWriteMap<Node,Arc>())
+    .distMap(concepts::ReadWriteMap<Node,Value>())
+    .run(Node());
+  b=bellmanFord(g,LengthMap())
+    .predMap(concepts::ReadWriteMap<Node,Arc>())
+    .distMap(concepts::ReadWriteMap<Node,Value>())
+    .path(concepts::Path<Digraph>())
+    .dist(Value())
+    .run(Node(),Node());
+}
+
+
+template <typename Digraph, typename Value>
+void checkBellmanFord() {
+  TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
+  typedef typename Digraph::template ArcMap<Value> LengthMap;
+
+  Digraph gr;
+  Node s, t;
+  LengthMap length(gr);
+
+  std::istringstream input(test_lgf);
+  digraphReader(gr, input).
+    arcMap("length", length).
+    node("source", s).
+    node("target", t).
+    run();
+
+  BellmanFord<Digraph, LengthMap>
+    bf(gr, length);
+  bf.run(s);
+  Path<Digraph> p = bf.path(t);
+
+  check(bf.reached(t) && bf.dist(t) == -1, "Bellman-Ford found a wrong path.");
+  check(p.length() == 3, "path() found a wrong path.");
+  check(checkPath(gr, p), "path() found a wrong path.");
+  check(pathSource(gr, p) == s, "path() found a wrong path.");
+  check(pathTarget(gr, p) == t, "path() found a wrong path.");
+  
+  ListPath<Digraph> path;
+  Value dist;
+  bool reached = bellmanFord(gr,length).path(path).dist(dist).run(s,t);
+
+  check(reached && dist == -1, "Bellman-Ford found a wrong path.");
+  check(path.length() == 3, "path() found a wrong path.");
+  check(checkPath(gr, path), "path() found a wrong path.");
+  check(pathSource(gr, path) == s, "path() found a wrong path.");
+  check(pathTarget(gr, path) == t, "path() found a wrong path.");
+
+  for(ArcIt e(gr); e!=INVALID; ++e) {
+    Node u=gr.source(e);
+    Node v=gr.target(e);
+    check(!bf.reached(u) || (bf.dist(v) - bf.dist(u) <= length[e]),
+          "Wrong output. dist(target)-dist(source)-arc_length=" <<
+          bf.dist(v) - bf.dist(u) - length[e]);
+  }
+
+  for(NodeIt v(gr); v!=INVALID; ++v) {
+    if (bf.reached(v)) {
+      check(v==s || bf.predArc(v)!=INVALID, "Wrong tree.");
+      if (bf.predArc(v)!=INVALID ) {
+        Arc e=bf.predArc(v);
+        Node u=gr.source(e);
+        check(u==bf.predNode(v),"Wrong tree.");
+        check(bf.dist(v) - bf.dist(u) == length[e],
+              "Wrong distance! Difference: " <<
+              bf.dist(v) - bf.dist(u) - length[e]);
+      }
+    }
+  }
+}
+
+int main() {
+  checkBellmanFord<ListDigraph, int>();
+  checkBellmanFord<SmartDigraph, double>();
+  return 0;
+}
Index: test/circulation_test.cc
===================================================================
--- test/circulation_test.cc	(revision 736)
+++ test/circulation_test.cc	(revision 658)
@@ -88,9 +88,4 @@
     .supplyMap(supply)
     .flowMap(flow);
-  
-  const CirculationType::Elevator& elev = const_circ_test.elevator();
-  circ_test.elevator(const_cast<CirculationType::Elevator&>(elev));
-  CirculationType::Tolerance tol = const_circ_test.tolerance();
-  circ_test.tolerance(tol);
 
   circ_test.init();
Index: test/maps_test.cc
===================================================================
--- test/maps_test.cc	(revision 742)
+++ test/maps_test.cc	(revision 554)
@@ -23,5 +23,4 @@
 #include <lemon/concepts/maps.h>
 #include <lemon/maps.h>
-#include <lemon/smart_graph.h>
 
 #include "test_tools.h"
@@ -351,225 +350,4 @@
   }
 
-  // CrossRefMap
-  {
-    typedef SmartDigraph Graph;
-    DIGRAPH_TYPEDEFS(Graph);
-
-    checkConcept<ReadWriteMap<Node, int>,
-                 CrossRefMap<Graph, Node, int> >();
-    
-    Graph gr;
-    typedef CrossRefMap<Graph, Node, char> CRMap;
-    typedef CRMap::ValueIterator ValueIt;
-    CRMap map(gr);
-    
-    Node n0 = gr.addNode();
-    Node n1 = gr.addNode();
-    Node n2 = gr.addNode();
-    
-    map.set(n0, 'A');
-    map.set(n1, 'B');
-    map.set(n2, 'C');
-    map.set(n2, 'A');
-    map.set(n0, 'C');
-
-    check(map[n0] == 'C' && map[n1] == 'B' && map[n2] == 'A',
-          "Wrong CrossRefMap");
-    check(map('A') == n2 && map.inverse()['A'] == n2, "Wrong CrossRefMap");
-    check(map('B') == n1 && map.inverse()['B'] == n1, "Wrong CrossRefMap");
-    check(map('C') == n0 && map.inverse()['C'] == n0, "Wrong CrossRefMap");
-
-    ValueIt it = map.beginValue();
-    check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' &&
-          it == map.endValue(), "Wrong value iterator");
-  }
-  
-  // Iterable bool map
-  {
-    typedef SmartGraph Graph;
-    typedef SmartGraph::Node Item;
-
-    typedef IterableBoolMap<SmartGraph, SmartGraph::Node> Ibm;
-    checkConcept<ReferenceMap<Item, bool, bool&, const bool&>, Ibm>();
-
-    const int num = 10;
-    Graph g;
-    std::vector<Item> items;
-    for (int i = 0; i < num; ++i) {
-      items.push_back(g.addNode());
-    }
-
-    Ibm map1(g, true);
-    int n = 0;
-    for (Ibm::TrueIt it(map1); it != INVALID; ++it) {
-      check(map1[static_cast<Item>(it)], "Wrong TrueIt");
-      ++n;
-    }
-    check(n == num, "Wrong number");
-
-    n = 0;
-    for (Ibm::ItemIt it(map1, true); it != INVALID; ++it) {
-        check(map1[static_cast<Item>(it)], "Wrong ItemIt for true");
-        ++n;
-    }
-    check(n == num, "Wrong number");
-    check(Ibm::FalseIt(map1) == INVALID, "Wrong FalseIt");
-    check(Ibm::ItemIt(map1, false) == INVALID, "Wrong ItemIt for false");
-
-    map1[items[5]] = true;
-
-    n = 0;
-    for (Ibm::ItemIt it(map1, true); it != INVALID; ++it) {
-        check(map1[static_cast<Item>(it)], "Wrong ItemIt for true");
-        ++n;
-    }
-    check(n == num, "Wrong number");
-
-    map1[items[num / 2]] = false;
-    check(map1[items[num / 2]] == false, "Wrong map value");
-
-    n = 0;
-    for (Ibm::TrueIt it(map1); it != INVALID; ++it) {
-        check(map1[static_cast<Item>(it)], "Wrong TrueIt for true");
-        ++n;
-    }
-    check(n == num - 1, "Wrong number");
-
-    n = 0;
-    for (Ibm::FalseIt it(map1); it != INVALID; ++it) {
-        check(!map1[static_cast<Item>(it)], "Wrong FalseIt for true");
-        ++n;
-    }
-    check(n == 1, "Wrong number");
-
-    map1[items[0]] = false;
-    check(map1[items[0]] == false, "Wrong map value");
-
-    map1[items[num - 1]] = false;
-    check(map1[items[num - 1]] == false, "Wrong map value");
-
-    n = 0;
-    for (Ibm::TrueIt it(map1); it != INVALID; ++it) {
-        check(map1[static_cast<Item>(it)], "Wrong TrueIt for true");
-        ++n;
-    }
-    check(n == num - 3, "Wrong number");
-    check(map1.trueNum() == num - 3, "Wrong number");
-
-    n = 0;
-    for (Ibm::FalseIt it(map1); it != INVALID; ++it) {
-        check(!map1[static_cast<Item>(it)], "Wrong FalseIt for true");
-        ++n;
-    }
-    check(n == 3, "Wrong number");
-    check(map1.falseNum() == 3, "Wrong number");
-  }
-
-  // Iterable int map
-  {
-    typedef SmartGraph Graph;
-    typedef SmartGraph::Node Item;
-    typedef IterableIntMap<SmartGraph, SmartGraph::Node> Iim;
-
-    checkConcept<ReferenceMap<Item, int, int&, const int&>, Iim>();
-
-    const int num = 10;
-    Graph g;
-    std::vector<Item> items;
-    for (int i = 0; i < num; ++i) {
-      items.push_back(g.addNode());
-    }
-
-    Iim map1(g);
-    check(map1.size() == 0, "Wrong size");
-
-    for (int i = 0; i < num; ++i) {
-      map1[items[i]] = i;
-    }
-    check(map1.size() == num, "Wrong size");
-
-    for (int i = 0; i < num; ++i) {
-      Iim::ItemIt it(map1, i);
-      check(static_cast<Item>(it) == items[i], "Wrong value");
-      ++it;
-      check(static_cast<Item>(it) == INVALID, "Wrong value");
-    }
-
-    for (int i = 0; i < num; ++i) {
-      map1[items[i]] = i % 2;
-    }
-    check(map1.size() == 2, "Wrong size");
-
-    int n = 0;
-    for (Iim::ItemIt it(map1, 0); it != INVALID; ++it) {
-      check(map1[static_cast<Item>(it)] == 0, "Wrong value");
-      ++n;
-    }
-    check(n == (num + 1) / 2, "Wrong number");
-
-    for (Iim::ItemIt it(map1, 1); it != INVALID; ++it) {
-      check(map1[static_cast<Item>(it)] == 1, "Wrong value");
-      ++n;
-    }
-    check(n == num, "Wrong number");
-
-  }
-
-  // Iterable value map
-  {
-    typedef SmartGraph Graph;
-    typedef SmartGraph::Node Item;
-    typedef IterableValueMap<SmartGraph, SmartGraph::Node, double> Ivm;
-
-    checkConcept<ReadWriteMap<Item, double>, Ivm>();
-
-    const int num = 10;
-    Graph g;
-    std::vector<Item> items;
-    for (int i = 0; i < num; ++i) {
-      items.push_back(g.addNode());
-    }
-
-    Ivm map1(g, 0.0);
-    check(distance(map1.beginValue(), map1.endValue()) == 1, "Wrong size");
-    check(*map1.beginValue() == 0.0, "Wrong value");
-
-    for (int i = 0; i < num; ++i) {
-      map1.set(items[i], static_cast<double>(i));
-    }
-    check(distance(map1.beginValue(), map1.endValue()) == num, "Wrong size");
-
-    for (int i = 0; i < num; ++i) {
-      Ivm::ItemIt it(map1, static_cast<double>(i));
-      check(static_cast<Item>(it) == items[i], "Wrong value");
-      ++it;
-      check(static_cast<Item>(it) == INVALID, "Wrong value");
-    }
-
-    for (Ivm::ValueIterator vit = map1.beginValue();
-         vit != map1.endValue(); ++vit) {
-      check(map1[static_cast<Item>(Ivm::ItemIt(map1, *vit))] == *vit,
-            "Wrong ValueIterator");
-    }
-
-    for (int i = 0; i < num; ++i) {
-      map1.set(items[i], static_cast<double>(i % 2));
-    }
-    check(distance(map1.beginValue(), map1.endValue()) == 2, "Wrong size");
-
-    int n = 0;
-    for (Ivm::ItemIt it(map1, 0.0); it != INVALID; ++it) {
-      check(map1[static_cast<Item>(it)] == 0.0, "Wrong value");
-      ++n;
-    }
-    check(n == (num + 1) / 2, "Wrong number");
-
-    for (Ivm::ItemIt it(map1, 1.0); it != INVALID; ++it) {
-      check(map1[static_cast<Item>(it)] == 1.0, "Wrong value");
-      ++n;
-    }
-    check(n == num, "Wrong number");
-
-  }
   return 0;
 }
Index: test/preflow_test.cc
===================================================================
--- test/preflow_test.cc	(revision 736)
+++ test/preflow_test.cc	(revision 632)
@@ -95,9 +95,4 @@
   PreflowType preflow_test(g, cap, n, n);
   const PreflowType& const_preflow_test = preflow_test;
-  
-  const PreflowType::Elevator& elev = const_preflow_test.elevator();
-  preflow_test.elevator(const_cast<PreflowType::Elevator&>(elev));
-  PreflowType::Tolerance tol = const_preflow_test.tolerance();
-  preflow_test.tolerance(tol);
 
   preflow_test
