[Lemon-commits] [lemon_svn] marci: r722 - in hugo/trunk/src: hugo work/marci
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:41:09 CET 2006
Author: marci
Date: Thu May 6 17:10:48 2004
New Revision: 722
Added:
hugo/trunk/src/work/marci/top_sort.dim
hugo/trunk/src/work/marci/top_sort_test.cc
Modified:
hugo/trunk/src/hugo/dimacs.h
hugo/trunk/src/work/marci/bfs_dfs_misc.h
hugo/trunk/src/work/marci/makefile
Log:
Modified: hugo/trunk/src/hugo/dimacs.h
==============================================================================
--- hugo/trunk/src/hugo/dimacs.h (original)
+++ hugo/trunk/src/hugo/dimacs.h Thu May 6 17:10:48 2004
@@ -77,7 +77,6 @@
typename Graph::Node u;
NullMap<typename Graph::Edge, int> n;
readDimacs(is, g, n, u, u, n);
- std::cout<<"igen en.";
}
/// sg problem
Modified: hugo/trunk/src/work/marci/bfs_dfs_misc.h
==============================================================================
--- hugo/trunk/src/work/marci/bfs_dfs_misc.h (original)
+++ hugo/trunk/src/work/marci/bfs_dfs_misc.h Thu May 6 17:10:48 2004
@@ -19,27 +19,29 @@
FOR_EACH_LOC(typename Graph::NodeIt, n, g) {
if (!reached[n]) {
bfs.pushAndSetReached(n);
- bool_map.set(n, false) {
- while (!bfs.finished()) {
- if (bfs.isBNodeNewlyReached()) {
- bool_map.set(bfs.bNode())=!bfs.aNode();
- } else {
- if (bool_map[bfs.bNode()]==bool_map[bfs.aNode()]) {
- return false;
- }
+ bool_map.set(n, false);
+ while (!bfs.finished()) {
+ if (bfs.isBNodeNewlyReached()) {
+ bool_map.set(bfs.bNode())=!bfs.aNode();
+ } else {
+ if (bool_map[bfs.bNode()]==bool_map[bfs.aNode()]) {
+ return false;
}
- ++bfs;
}
+ ++bfs;
}
}
}
+
return true;
}
/// experimental topsort,
/// I think the final version will work as an iterator
+ /// if the graph is not a acyclic, the na pre-topological order is obtained
+ /// (see Schrijver's book)
template<typename Graph>
- void topSort(Graph& g, std::list<typename Graph::Node>& l) {
+ void topSort(const Graph& g, std::list<typename Graph::Node>& l) {
l.clear();
typedef typename Graph::template NodeMap<bool> ReachedMap;
ReachedMap reached(g/*, false*/);
Modified: hugo/trunk/src/work/marci/makefile
==============================================================================
--- hugo/trunk/src/work/marci/makefile (original)
+++ hugo/trunk/src/work/marci/makefile Thu May 6 17:10:48 2004
@@ -4,7 +4,7 @@
INCLUDEDIRS ?= -I../.. -I../../hugo -I.. -I../{marci,jacint,alpar,klao,akos,athos} -I$(BOOSTROOT)
LEDABINARIES = leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo
-BINARIES = max_flow_demo iterator_bfs_demo macro_test lg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test bipartite_matching_try bipartite_matching_try_2 bipartite_matching_try_3
+BINARIES = max_flow_demo iterator_bfs_demo macro_test lg_vs_sg bfsit_vs_byhand bipartite_graph_wrapper_test bipartite_matching_try bipartite_matching_try_2 bipartite_matching_try_3 top_sort_test
#gw_vs_not preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar preflow_demo_leda
include ../makefile
Added: hugo/trunk/src/work/marci/top_sort.dim
==============================================================================
--- (empty file)
+++ hugo/trunk/src/work/marci/top_sort.dim Thu May 6 17:10:48 2004
@@ -0,0 +1,5 @@
+p mat 5 4
+a 1 3
+a 2 3
+a 3 5
+a 3 4
Added: hugo/trunk/src/work/marci/top_sort_test.cc
==============================================================================
--- (empty file)
+++ hugo/trunk/src/work/marci/top_sort_test.cc Thu May 6 17:10:48 2004
@@ -0,0 +1,25 @@
+// -*- c++ -*-
+#include <iostream>
+#include <fstream>
+#include <list>
+
+#include <hugo/dimacs.h>
+#include <bfs_dfs_misc.h>
+#include <list_graph.h>
+
+using namespace hugo;
+
+int main() {
+ typedef ListGraph Graph;
+ Graph g;
+ readDimacs(std::cin, g);
+ std::list<Graph::Node> l;
+ topSort(g, l);
+ std::cout << "Leaving order of dfs which is pretopological..." << std::endl;
+ for(std::list<Graph::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
+ std::cout << *i << " ";
+ }
+ std::cout << std::endl;
+
+ return 0;
+}
More information about the Lemon-commits
mailing list