Port preflow push max flow alg. from svn -r3516 (#176)
Namely,
- port the files
- apply the migrate script
- apply the unify script
- break the long lines in lemon/preflow.h
- convert the .dim test file to .lgf
- fix compilation problems
1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #include <lemon/concepts/digraph.h>
20 #include <lemon/smart_graph.h>
21 #include <lemon/list_graph.h>
22 #include <lemon/lgf_reader.h>
23 #include <lemon/dfs.h>
24 #include <lemon/path.h>
26 #include "graph_test.h"
27 #include "test_tools.h"
29 using namespace lemon;
55 void checkDfsCompile()
57 typedef concepts::Digraph Digraph;
58 typedef Dfs<Digraph> DType;
59 typedef Digraph::Node Node;
60 typedef Digraph::Arc Arc;
79 e = dfs_test.predArc(t);
80 s = dfs_test.predNode(t);
81 b = dfs_test.reached(t);
82 d = dfs_test.distMap();
83 p = dfs_test.predMap();
84 pp = dfs_test.path(t);
88 ::SetPredMap<concepts::ReadWriteMap<Node,Arc> >
89 ::SetDistMap<concepts::ReadWriteMap<Node,int> >
90 ::SetReachedMap<concepts::ReadWriteMap<Node,bool> >
91 ::SetProcessedMap<concepts::WriteMap<Node,bool> >
92 ::SetStandardProcessedMap
100 e = dfs_test.predArc(t);
101 s = dfs_test.predNode(t);
102 b = dfs_test.reached(t);
103 pp = dfs_test.path(t);
107 void checkDfsFunctionCompile()
110 typedef concepts::Digraph Digraph;
111 typedef Digraph::Arc Arc;
112 typedef Digraph::Node Node;
117 b=dfs(g).run(Node(),Node());
120 .predMap(concepts::ReadWriteMap<Node,Arc>())
121 .distMap(concepts::ReadWriteMap<Node,VType>())
122 .reachedMap(concepts::ReadWriteMap<Node,bool>())
123 .processedMap(concepts::WriteMap<Node,bool>())
126 .predMap(concepts::ReadWriteMap<Node,Arc>())
127 .distMap(concepts::ReadWriteMap<Node,VType>())
128 .reachedMap(concepts::ReadWriteMap<Node,bool>())
129 .processedMap(concepts::WriteMap<Node,bool>())
130 .path(concepts::Path<Digraph>())
134 .predMap(concepts::ReadWriteMap<Node,Arc>())
135 .distMap(concepts::ReadWriteMap<Node,VType>())
136 .reachedMap(concepts::ReadWriteMap<Node,bool>())
137 .processedMap(concepts::WriteMap<Node,bool>())
141 template <class Digraph>
143 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
148 std::istringstream input(test_lgf);
149 digraphReader(G, input).
154 Dfs<Digraph> dfs_test(G);
157 Path<Digraph> p = dfs_test.path(t);
158 check(p.length() == dfs_test.dist(t),"path() found a wrong path.");
159 check(checkPath(G, p),"path() found a wrong path.");
160 check(pathSource(G, p) == s,"path() found a wrong path.");
161 check(pathTarget(G, p) == t,"path() found a wrong path.");
163 for(NodeIt v(G); v!=INVALID; ++v) {
164 if (dfs_test.reached(v)) {
165 check(v==s || dfs_test.predArc(v)!=INVALID, "Wrong tree.");
166 if (dfs_test.predArc(v)!=INVALID ) {
167 Arc e=dfs_test.predArc(v);
169 check(u==dfs_test.predNode(v),"Wrong tree.");
170 check(dfs_test.dist(v) - dfs_test.dist(u) == 1,
171 "Wrong distance. (" << dfs_test.dist(u) << "->"
172 << dfs_test.dist(v) << ")");
178 NullMap<Node,Arc> myPredMap;
179 dfs(G).predMap(myPredMap).run(s);
185 checkDfs<ListDigraph>();
186 checkDfs<SmartDigraph>();