1.1 --- a/src/work/marci/bfs_dfs_misc.h Thu May 06 14:25:21 2004 +0000
1.2 +++ b/src/work/marci/bfs_dfs_misc.h Thu May 06 15:10:48 2004 +0000
1.3 @@ -19,27 +19,29 @@
1.4 FOR_EACH_LOC(typename Graph::NodeIt, n, g) {
1.5 if (!reached[n]) {
1.6 bfs.pushAndSetReached(n);
1.7 - bool_map.set(n, false) {
1.8 - while (!bfs.finished()) {
1.9 - if (bfs.isBNodeNewlyReached()) {
1.10 - bool_map.set(bfs.bNode())=!bfs.aNode();
1.11 - } else {
1.12 - if (bool_map[bfs.bNode()]==bool_map[bfs.aNode()]) {
1.13 - return false;
1.14 - }
1.15 + bool_map.set(n, false);
1.16 + while (!bfs.finished()) {
1.17 + if (bfs.isBNodeNewlyReached()) {
1.18 + bool_map.set(bfs.bNode())=!bfs.aNode();
1.19 + } else {
1.20 + if (bool_map[bfs.bNode()]==bool_map[bfs.aNode()]) {
1.21 + return false;
1.22 }
1.23 - ++bfs;
1.24 }
1.25 + ++bfs;
1.26 }
1.27 }
1.28 }
1.29 +
1.30 return true;
1.31 }
1.32
1.33 /// experimental topsort,
1.34 /// I think the final version will work as an iterator
1.35 + /// if the graph is not a acyclic, the na pre-topological order is obtained
1.36 + /// (see Schrijver's book)
1.37 template<typename Graph>
1.38 - void topSort(Graph& g, std::list<typename Graph::Node>& l) {
1.39 + void topSort(const Graph& g, std::list<typename Graph::Node>& l) {
1.40 l.clear();
1.41 typedef typename Graph::template NodeMap<bool> ReachedMap;
1.42 ReachedMap reached(g/*, false*/);