# HG changeset patch
# User Peter Kovacs <kpeter@inf.elte.hu>
# Date 1248726073 -7200
# Node ID a4d00df8852e1f58f3d8b4339329337dae765162
# Parent 257e91516e09d8d6be58236c587e3e0199770412
Fix the interface of bfs(), dfs(), dijkstra() (#304)
diff --git a/lemon/bfs.h b/lemon/bfs.h
a
|
b
|
|
1144 | 1144 | ///\ref named-func-param "Named parameter" |
1145 | 1145 | ///for getting the shortest path to the target node. |
1146 | 1146 | template<class T> |
1147 | | BfsWizard<SetPathBase<T> > path(const T &t) |
| 1147 | BfsWizard<SetPathBase<T> > path(T &t) |
1148 | 1148 | { |
1149 | | Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t)); |
| 1149 | Base::_path=reinterpret_cast<void*>(&t); |
1150 | 1150 | return BfsWizard<SetPathBase<T> >(*this); |
1151 | 1151 | } |
1152 | 1152 | |
… |
… |
|
1155 | 1155 | /// |
1156 | 1156 | ///\ref named-func-param "Named parameter" |
1157 | 1157 | ///for getting the distance of the target node. |
1158 | | BfsWizard dist(const int &d) |
| 1158 | BfsWizard dist(int &d) |
1159 | 1159 | { |
1160 | | Base::_di=const_cast<int*>(&d); |
| 1160 | Base::_di=&d; |
1161 | 1161 | return *this; |
1162 | 1162 | } |
1163 | 1163 | |
diff --git a/lemon/dfs.h b/lemon/dfs.h
a
|
b
|
|
1076 | 1076 | ///\ref named-func-param "Named parameter" |
1077 | 1077 | ///for getting the DFS path to the target node. |
1078 | 1078 | template<class T> |
1079 | | DfsWizard<SetPathBase<T> > path(const T &t) |
| 1079 | DfsWizard<SetPathBase<T> > path(T &t) |
1080 | 1080 | { |
1081 | | Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t)); |
| 1081 | Base::_path=reinterpret_cast<void*>(&t); |
1082 | 1082 | return DfsWizard<SetPathBase<T> >(*this); |
1083 | 1083 | } |
1084 | 1084 | |
… |
… |
|
1087 | 1087 | /// |
1088 | 1088 | ///\ref named-func-param "Named parameter" |
1089 | 1089 | ///for getting the distance of the target node. |
1090 | | DfsWizard dist(const int &d) |
| 1090 | DfsWizard dist(int &d) |
1091 | 1091 | { |
1092 | | Base::_di=const_cast<int*>(&d); |
| 1092 | Base::_di=&d; |
1093 | 1093 | return *this; |
1094 | 1094 | } |
1095 | 1095 | |
diff --git a/lemon/dijkstra.h b/lemon/dijkstra.h
a
|
b
|
|
1245 | 1245 | ///\ref named-func-param "Named parameter" |
1246 | 1246 | ///for getting the shortest path to the target node. |
1247 | 1247 | template<class T> |
1248 | | DijkstraWizard<SetPathBase<T> > path(const T &t) |
| 1248 | DijkstraWizard<SetPathBase<T> > path(T &t) |
1249 | 1249 | { |
1250 | | Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t)); |
| 1250 | Base::_path=reinterpret_cast<void*>(&t); |
1251 | 1251 | return DijkstraWizard<SetPathBase<T> >(*this); |
1252 | 1252 | } |
1253 | 1253 | |
… |
… |
|
1256 | 1256 | /// |
1257 | 1257 | ///\ref named-func-param "Named parameter" |
1258 | 1258 | ///for getting the distance of the target node. |
1259 | | DijkstraWizard dist(const Value &d) |
| 1259 | DijkstraWizard dist(Value &d) |
1260 | 1260 | { |
1261 | | Base::_di=reinterpret_cast<void*>(const_cast<Value*>(&d)); |
| 1261 | Base::_di=reinterpret_cast<void*>(&d); |
1262 | 1262 | return *this; |
1263 | 1263 | } |
1264 | 1264 | |
diff --git a/test/bfs_test.cc b/test/bfs_test.cc
a
|
b
|
|
150 | 150 | |
151 | 151 | Digraph g; |
152 | 152 | bool b; |
| 153 | concepts::Path<Digraph> p; |
| 154 | int d; |
153 | 155 | bfs(g).run(Node()); |
154 | 156 | b=bfs(g).run(Node(),Node()); |
155 | 157 | bfs(g).run(); |
… |
… |
|
164 | 166 | .distMap(concepts::ReadWriteMap<Node,VType>()) |
165 | 167 | .reachedMap(concepts::ReadWriteMap<Node,bool>()) |
166 | 168 | .processedMap(concepts::WriteMap<Node,bool>()) |
167 | | .path(concepts::Path<Digraph>()) |
168 | | .dist(VType()) |
| 169 | .path(p) |
| 170 | .dist(d) |
169 | 171 | .run(Node(),Node()); |
170 | 172 | bfs(g) |
171 | 173 | .predMap(concepts::ReadWriteMap<Node,Arc>()) |
diff --git a/test/dfs_test.cc b/test/dfs_test.cc
a
|
b
|
|
148 | 148 | |
149 | 149 | Digraph g; |
150 | 150 | bool b; |
| 151 | concepts::Path<Digraph> p; |
| 152 | int d; |
151 | 153 | dfs(g).run(Node()); |
152 | 154 | b=dfs(g).run(Node(),Node()); |
153 | 155 | dfs(g).run(); |
… |
… |
|
162 | 164 | .distMap(concepts::ReadWriteMap<Node,VType>()) |
163 | 165 | .reachedMap(concepts::ReadWriteMap<Node,bool>()) |
164 | 166 | .processedMap(concepts::WriteMap<Node,bool>()) |
165 | | .path(concepts::Path<Digraph>()) |
166 | | .dist(VType()) |
| 167 | .path(p) |
| 168 | .dist(d) |
167 | 169 | .run(Node(),Node()); |
168 | 170 | dfs(g) |
169 | 171 | .predMap(concepts::ReadWriteMap<Node,Arc>()) |
diff --git a/test/dijkstra_test.cc b/test/dijkstra_test.cc
a
|
b
|
|
162 | 162 | |
163 | 163 | Digraph g; |
164 | 164 | bool b; |
| 165 | concepts::Path<Digraph> p; |
| 166 | VType d; |
165 | 167 | dijkstra(g,LengthMap()).run(Node()); |
166 | 168 | b=dijkstra(g,LengthMap()).run(Node(),Node()); |
167 | 169 | dijkstra(g,LengthMap()) |
… |
… |
|
173 | 175 | .predMap(concepts::ReadWriteMap<Node,Arc>()) |
174 | 176 | .distMap(concepts::ReadWriteMap<Node,VType>()) |
175 | 177 | .processedMap(concepts::WriteMap<Node,bool>()) |
176 | | .path(concepts::Path<Digraph>()) |
177 | | .dist(VType()) |
| 178 | .path(p) |
| 179 | .dist(d) |
178 | 180 | .run(Node(),Node()); |
179 | 181 | } |
180 | 182 | |