Changeset 577:e8703f0a6e2f in lemon-0.x
- Timestamp:
- 05/07/04 13:57:34 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@753
- Location:
- src/work
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/makefile
r493 r577 1 1 INCLUDEDIRS ?= -I../include -I. -I./{marci,jacint,alpar,klao,akos} 2 CXXFLAGS = -g -O 3-W -Wall $(INCLUDEDIRS) -ansi -pedantic2 CXXFLAGS = -g -O0 -W -Wall $(INCLUDEDIRS) -ansi -pedantic 3 3 4 4 BINARIES ?= bin_heap_demo -
src/work/marci/bfs_dfs_misc.h
r552 r577 40 40 /// I think the final version will work as an iterator 41 41 /// if the graph is not a acyclic, the na pre-topological order is obtained 42 /// (see Schrijver's book) 43 template<typename Graph> 44 void topSort(const Graph& g, std::list<typename Graph::Node>& l) { 42 /// (see Schrijver's book). 43 /// PredMap have to be a writtable node-map. 44 /// If the graph is directed and not acyclic, 45 /// then going back from the returned node via the pred information, a 46 /// cycle is obtained. 47 template<typename Graph, typename PredMap> 48 typename Graph::Node 49 topSort(const Graph& g, std::list<typename Graph::Node>& l, 50 PredMap& pred) { 45 51 l.clear(); 46 52 typedef typename Graph::template NodeMap<bool> ReachedMap; 53 typedef typename Graph::template NodeMap<bool> ExaminedMap; 47 54 ReachedMap reached(g/*, false*/); 55 ExaminedMap examined(g/*, false*/); 48 56 DfsIterator<Graph, ReachedMap> dfs(g, reached); 49 57 FOR_EACH_LOC(typename Graph::NodeIt, n, g) { 50 58 if (!reached[n]) { 51 59 dfs.pushAndSetReached(n); 60 pred.set(n, INVALID); 52 61 while (!dfs.finished()) { 53 62 ++dfs; 63 if (dfs.isBNodeNewlyReached()) { 64 ///\bug hugo 0.2-ben Edge kell 65 pred.set(dfs.aNode(), typename Graph::OutEdgeIt(dfs)); 66 } else { 67 ///\bug ugyanaz 68 if (g.valid(typename Graph::OutEdgeIt(dfs)) && 69 !examined[dfs.bNode()]) { 70 ///\bug hugo 0.2-ben Edge kell 71 pred.set(dfs.bNode(), typename Graph::OutEdgeIt(dfs)); 72 return dfs.aNode(); 73 } 74 } 54 75 if (dfs.isANodeExamined()) { 55 76 l.push_back(dfs.aNode()); 77 examined.set(dfs.aNode(), true); 56 78 } 57 79 } 58 80 } 59 81 } 82 return INVALID; 60 83 } 61 84 } //namespace hugo -
src/work/marci/bfsit_vs_byhand.cc
r555 r577 20 20 typedef Graph::OutEdgeIt OutEdgeIt; 21 21 22 Graph G;22 Graph g; 23 23 Node s, t; 24 Graph::EdgeMap<int> cap(G); 25 readDimacsMaxFlow(std::cin, G, s, t, cap); 26 Graph::NodeMap<OutEdgeIt> pred(G); 24 Graph::EdgeMap<int> cap(g); 25 //readDimacsMaxFlow(std::cin, g, s, t, cap); 26 readDimacs(std::cin, g); 27 28 Graph::NodeMap<OutEdgeIt> pred(g); 27 29 Timer ts; 28 30 { 29 31 ts.reset(); 30 Graph::NodeMap<bool> reached( G);32 Graph::NodeMap<bool> reached(g); 31 33 reached.set(s, true); 32 34 pred.set(s, INVALID); … … 37 39 bfs_queue.pop(); 38 40 OutEdgeIt e; 39 for( G.first(e,v); G.valid(e); G.next(e)) {40 Node w= G.head(e);41 for(g.first(e,v); g.valid(e); g.next(e)) { 42 Node w=g.head(e); 41 43 if (!reached[w]) { 42 44 bfs_queue.push(w); … … 52 54 { 53 55 ts.reset(); 54 BfsIterator< Graph, Graph::NodeMap<bool> > bfs( G);56 BfsIterator< Graph, Graph::NodeMap<bool> > bfs(g); 55 57 bfs.pushAndSetReached(s); 56 58 pred.set(s, INVALID); 57 59 while (!bfs.finished()) { 58 60 ++bfs; 59 if ( G.valid(bfs) && bfs.isBNodeNewlyReached())61 if (g.valid(bfs) && bfs.isBNodeNewlyReached()) 60 62 pred.set(bfs.bNode(), bfs); 61 63 } -
src/work/marci/lg_vs_sg.cc
r555 r577 26 26 typedef Graph::EdgeIt EdgeIt; 27 27 28 Graph G;28 Graph g; 29 29 Node s, t; 30 Graph::EdgeMap<int> cap( G);30 Graph::EdgeMap<int> cap(g); 31 31 std::ifstream ins(in.c_str()); 32 readDimacsMaxFlow(ins, G, s, t, cap); 32 //readDimacsMaxFlow(ins, g, s, t, cap); 33 readDimacs(ins, g, cap, s, t); 33 34 34 35 Timer ts; 35 Graph::EdgeMap<int> flow( G); //0 flow36 Graph::EdgeMap<int> flow(g); //0 flow 36 37 MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 37 max_flow_test( G, s, t, cap, flow/*, true*/);38 max_flow_test(g, s, t, cap, flow/*, true*/); 38 39 39 40 std::cout << "ListGraph ..." << std::endl; … … 49 50 { 50 51 std::cout << "physical blocking flow augmentation ..." << std::endl; 51 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);52 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 52 53 ts.reset(); 53 54 int i=0; … … 60 61 // { 61 62 // std::cout << "faster physical blocking flow augmentation ..." << std::endl; 62 // FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);63 // FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 63 64 // ts.reset(); 64 65 // int i=0; … … 71 72 { 72 73 std::cout << "on-the-fly blocking flow augmentation ..." << std::endl; 73 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);74 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 74 75 ts.reset(); 75 76 int i=0; … … 82 83 { 83 84 std::cout << "on-the-fly shortest path augmentation ..." << std::endl; 84 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);85 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 85 86 ts.reset(); 86 87 int i=0; … … 98 99 typedef Graph::EdgeIt EdgeIt; 99 100 100 Graph G;101 Graph g; 101 102 Node s, t; 102 Graph::EdgeMap<int> cap( G);103 Graph::EdgeMap<int> cap(g); 103 104 std::ifstream ins(in.c_str()); 104 readDimacsMaxFlow(ins, G, s, t, cap); 105 //readDimacsMaxFlow(ins, g, s, t, cap); 106 readDimacs(ins, g, cap, s, t); 105 107 106 108 Timer ts; 107 Graph::EdgeMap<int> flow( G); //0 flow109 Graph::EdgeMap<int> flow(g); //0 flow 108 110 MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 109 max_flow_test( G, s, t, cap, flow/*, true*/);111 max_flow_test(g, s, t, cap, flow/*, true*/); 110 112 // MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 111 // max_flow_test( G, s, t, cap, flow);113 // max_flow_test(g, s, t, cap, flow); 112 114 113 115 std::cout << "SmatrGraph ..." << std::endl; … … 115 117 { 116 118 std::cout << "preflow ..." << std::endl; 117 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);119 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 118 120 ts.reset(); 119 121 max_flow_test.run(); … … 124 126 { 125 127 std::cout << "physical blocking flow augmentation ..." << std::endl; 126 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);128 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 127 129 ts.reset(); 128 130 int i=0; … … 135 137 // { 136 138 // std::cout << "faster physical blocking flow augmentation ..." << std::endl; 137 // FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);139 // FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 138 140 // ts.reset(); 139 141 // int i=0; … … 146 148 { 147 149 std::cout << "on-the-fly blocking flow augmentation ..." << std::endl; 148 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);150 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 149 151 ts.reset(); 150 152 int i=0; … … 157 159 { 158 160 std::cout << "on-the-fly shortest path augmentation ..." << std::endl; 159 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);161 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 160 162 ts.reset(); 161 163 int i=0; -
src/work/marci/max_flow_demo.cc
r555 r577 64 64 65 65 66 Graph G;66 Graph g; 67 67 Node s, t; 68 Graph::EdgeMap<int> cap(G); 69 readDimacsMaxFlow(std::cin, G, s, t, cap); 68 Graph::EdgeMap<int> cap(g); 69 //readDimacsMaxFlow(std::cin, g, s, t, cap); 70 readDimacs(std::cin, g, cap, s, t); 70 71 Timer ts; 71 Graph::EdgeMap<int> flow( G); //0 flow72 Graph::EdgeMap<int> flow(g); //0 flow 72 73 MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 73 max_flow_test( G, s, t, cap, flow);74 max_flow_test(g, s, t, cap, flow); 74 75 75 76 { … … 83 84 { 84 85 std::cout << "preflow ..." << std::endl; 85 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);86 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 86 87 ts.reset(); 87 88 max_flow_test.preflow(MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >::GEN_FLOW); … … 92 93 // { 93 94 // std::cout << "wrapped preflow ..." << std::endl; 94 // FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);95 // FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 95 96 // ts.reset(); 96 97 // pre_flow_res.run(); … … 101 102 { 102 103 std::cout << "physical blocking flow augmentation ..." << std::endl; 103 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);104 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 104 105 ts.reset(); 105 106 int i=0; … … 112 113 // { 113 114 // std::cout << "faster physical blocking flow augmentation ..." << std::endl; 114 // FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);115 // FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 115 116 // ts.reset(); 116 117 // int i=0; … … 123 124 { 124 125 std::cout << "on-the-fly blocking flow augmentation ..." << std::endl; 125 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);126 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 126 127 ts.reset(); 127 128 int i=0; … … 134 135 { 135 136 std::cout << "on-the-fly shortest path augmentation ..." << std::endl; 136 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);137 FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0); 137 138 ts.reset(); 138 139 int i=0; -
src/work/marci/top_sort.dim
r552 r577 3 3 a 2 3 4 4 a 3 5 5 a 3 45 a 4 3 6 6 a 5 4 -
src/work/marci/top_sort_test.cc
r557 r577 8 8 #include <list_graph.h> 9 9 #include <hugo/graph_wrapper.h> 10 #include <hugo/maps.h> 10 11 11 12 using namespace hugo; … … 17 18 { 18 19 std::list<Graph::Node> l; 19 topSort(g, l); 20 NullMap<Graph::Node, Graph::Edge> pred; 21 topSort(g, l, pred); 20 22 std::cout << "Leaving order of dfs which is pretopological..." << std::endl; 21 23 for(std::list<Graph::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) { … … 29 31 GW gw(g); 30 32 std::list<GW::Node> l; 31 topSort(gw, l); 33 NullMap<GW::Node, GW::Edge> pred; 34 topSort(gw, l, pred); 32 35 std::cout << "Same in the revered oriented graph..." << std::endl; 33 36 for(std::list<GW::Node>::const_iterator i=l.begin(); i!=l.end(); ++i) {
Note: See TracChangeset
for help on using the changeset viewer.