Changeset 30:10a3f2e0928c in lemon-0.x
- Timestamp:
- 01/21/04 15:51:05 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@43
- Location:
- src/work
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/marci_graph_concept.txt
r19 r30 1 1 ETIK-OL-NOLIB-NEGRES graph concept-ek. 2 2 3 Ebben a dokumentacioban graph concept tervek es azok megvalositas tarol irok.3 Ebben a dokumentacioban graph concept tervek es azok megvalositasarol irok. 4 4 A felsorolt rutinok, osztalyok egyaltalan nem kikristalyosodottak, 1-1 elemi 5 operacio el egzesere gyakran tobb mod is rendelkezesre all. A tervezesi fazisban pont annak kell kiderulnie, hogy milyen metodusok tavolithatok el, s milyen5 operacio elvegzesere gyakran tobb mod is rendelkezesre all. A tervezesi fazisban pont annak kell kiderulnie, hogy milyen metodusok tavolithatok el, s milyen 6 6 ujakra van szukseg. 7 7 … … 27 27 trivialis node iterator, csak cimezni lehet vele, pl property vectort 28 28 29 <<<<<<< marci_graph_concept.txt 30 class each_node_iterator 31 node iterator a graf pontjainak bejarasara, node_iterator-ra konvertalhato 32 ======= 29 33 class each_node_iterator; 30 34 node iterator a graf pontjainak bejarasara, node_iterator-a konvertalhato 35 >>>>>>> 1.3 31 36 32 37 class edge_iterator; … … 36 41 edge iterator a graf osszes elenek bejarasara 37 42 43 <<<<<<< marci_graph_concept.txt 44 class out_edge_iterator 45 edge iterator 1 pont ki eleinek bejarasara, edge_iterator-ra konvertalhato 46 ======= 38 47 class out_edge_iterator; 39 48 edge iterator 1 pont ki eleinek bejarasara, edge_iterator-a konvertalhato 40 49 >>>>>>> 1.3 50 51 <<<<<<< marci_graph_concept.txt 52 class in_edge_iterator 53 edge iterator 1 pont be eleinek bejarasara, edge_iterator-ra konvertalhato 54 ======= 41 55 class in_edge_iterator; 42 56 edge iterator 1 pont be eleinek bejarasara, edge_iterator-a konvertalhato 57 >>>>>>> 1.3 43 58 59 <<<<<<< marci_graph_concept.txt 60 class sym_edge_iterator 61 edge iterator 1 pont be es ki eleinek bejarasara, edge_iterator-ra 62 konvertalhato 63 ======= 44 64 class sym_edge_iterator; 45 65 edge iterator 1 pont be es ki eleinek bejarasara, edge_iterator-a konvertalhato 66 >>>>>>> 1.3 46 67 47 68 default constructor: -
src/work/preflow_push_hl.hh
r20 r30 84 84 reverse_bfs<list_graph> bfs(G, t); 85 85 bfs.run(); 86 for(each_node_iterator v=G.first_node(); v. is_valid(); ++v) {86 for(each_node_iterator v=G.first_node(); v.valid(); ++v) { 87 87 level.put(v, bfs.dist(v)); 88 88 //std::cout << "the level of " << v << " is " << bfs.dist(v); … … 98 98 /* Starting flow. It is everywhere 0 at the moment. */ 99 99 100 for(out_edge_iterator i=G.first_out_edge(s); i. is_valid(); ++i)100 for(out_edge_iterator i=G.first_out_edge(s); i.valid(); ++i) 101 101 { 102 102 node_iterator w=G.head(i); … … 130 130 int newlevel=2*n-2; //In newlevel we maintain the next level of w. 131 131 132 for(out_edge_iterator e=G.first_out_edge(w); e. is_valid(); ++e) {132 for(out_edge_iterator e=G.first_out_edge(w); e.valid(); ++e) { 133 133 node_iterator v=G.head(e); 134 134 /*e is the edge wv.*/ … … 171 171 } //if (flow.get(e)<capacity.get(e)) 172 172 173 } //for(out_edge_iterator e=G.first_out_edge(w); e. is_valid(); ++e)173 } //for(out_edge_iterator e=G.first_out_edge(w); e.valid(); ++e) 174 174 175 175 176 176 177 for(in_edge_iterator e=G.first_in_edge(w); e. is_valid(); ++e) {177 for(in_edge_iterator e=G.first_in_edge(w); e.valid(); ++e) { 178 178 node_iterator v=G.tail(e); 179 179 /*e is the edge vw.*/ … … 289 289 queue.pop(); 290 290 291 for(in_edge_iterator e=G.first_in_edge(w) ; e. is_valid(); ++e) {291 for(in_edge_iterator e=G.first_in_edge(w) ; e.valid(); ++e) { 292 292 node_iterator v=G.tail(e); 293 293 if (mincutvector.get(v) && flow.get(e) < capacity.get(e) ) { … … 297 297 } // for 298 298 299 for(out_edge_iterator e=G.first_out_edge(w) ; e. is_valid(); ++e) {299 for(out_edge_iterator e=G.first_out_edge(w) ; e.valid(); ++e) { 300 300 node_iterator v=G.head(e); 301 301 if (mincutvector.get(v) && flow.get(e) > 0 ) { -
src/work/preflow_push_max_flow.hh
r21 r30 81 81 reverse_bfs<list_graph> bfs(G, t); 82 82 bfs.run(); 83 for(each_node_iterator v=G.first_node(); v. is_valid(); ++v)83 for(each_node_iterator v=G.first_node(); v.valid(); ++v) 84 84 { 85 85 int dist=bfs.dist(v); … … 94 94 /* Starting flow. It is everywhere 0 at the moment. */ 95 95 96 for(out_edge_iterator i=G.first_out_edge(s); i. is_valid(); ++i)96 for(out_edge_iterator i=G.first_out_edge(s); i.valid(); ++i) 97 97 { 98 98 node_iterator w=G.head(i); … … 127 127 int newlevel=2*n-2; //In newlevel we maintain the next level of w. 128 128 129 for(out_edge_iterator e=G.first_out_edge(w); e. is_valid(); ++e) {129 for(out_edge_iterator e=G.first_out_edge(w); e.valid(); ++e) { 130 130 node_iterator v=G.head(e); 131 131 /*e is the edge wv.*/ … … 168 168 } //if (flow.get(e)<capacity.get(e)) 169 169 170 } //for(out_edge_iterator e=G.first_out_edge(w); e. is_valid(); ++e)170 } //for(out_edge_iterator e=G.first_out_edge(w); e.valid(); ++e) 171 171 172 172 173 173 174 for(in_edge_iterator e=G.first_in_edge(w); e. is_valid(); ++e) {174 for(in_edge_iterator e=G.first_in_edge(w); e.valid(); ++e) { 175 175 node_iterator v=G.tail(e); 176 176 /*e is the edge vw.*/ … … 244 244 /*If the level of w gets empty.*/ 245 245 246 for (each_node_iterator v=G.first_node() ; v. is_valid() ; ++v) {246 for (each_node_iterator v=G.first_node() ; v.valid() ; ++v) { 247 247 if (level.get(v) >= l ) { 248 248 level.put(v,n); … … 278 278 else break; 279 279 } 280 for (each_node_iterator v=G.first_node(); v. is_valid(); ++v) {280 for (each_node_iterator v=G.first_node(); v.valid(); ++v) { 281 281 if (level.get(v) > e) mincutvector.put(v, true); 282 282 } -
src/work/proba.cc
r23 r30 9 9 #include <preflow_push_max_flow.hh> 10 10 #include <reverse_bfs.hh> 11 //#include <dijkstra.hh> 11 12 12 13 using namespace marci; … … 25 26 list_graph flow_test; 26 27 27 / /Ahuja könyv példája, maxflowvalue=1328 /* //Ahuja könyv példája, maxflowvalue=13 28 29 node_iterator s=flow_test.add_node(); 29 30 node_iterator v1=flow_test.add_node(); … … 46 47 edge_iterator s_v2=flow_test.add_edge(s, v2); 47 48 edge_iterator s_v3=flow_test.add_edge(s, v3); 48 49 49 edge_iterator v2_v4=flow_test.add_edge(v2, v4); 50 50 edge_iterator v2_v5=flow_test.add_edge(v2, v5); 51 52 51 edge_iterator v3_v5=flow_test.add_edge(v3, v5); 53 54 52 edge_iterator v4_t=flow_test.add_edge(v4, t); 55 53 edge_iterator v5_t=flow_test.add_edge(v5, t); 54 edge_iterator v2_s=flow_test.add_edge(v2, s); 56 55 57 56 edge_property_vector<list_graph, int> cap(flow_test); … … 64 63 cap.put(v4_t, 8); 65 64 cap.put(v5_t, 8); 66 65 cap.put(v2_s, 0); 66 */ 67 67 68 68 69 69 //Marci példája, maxflowvalue=23 70 /*node_iterator s=flow_test.add_node();70 node_iterator s=flow_test.add_node(); 71 71 node_iterator v1=flow_test.add_node(); 72 72 node_iterator v2=flow_test.add_node(); … … 98 98 edge_iterator v3_v3=flow_test.add_edge(v3, v3); 99 99 edge_iterator s_w=flow_test.add_edge(s, w); 100 edge_iterator v2_s=flow_test.add_edge(v2, s); 100 101 101 102 … … 114 115 cap.put(v3_v3, 4); 115 116 cap.put(s_w, 4); 116 */117 cap.put(v2_s, 0); 117 118 118 119 … … 156 157 bfs_test.run(); 157 158 158 for (each_node_iterator w=flow_test.first_node(); w. is_valid(); ++w) {159 for (each_node_iterator w=flow_test.first_node(); w.valid(); ++w) { 159 160 std::cout <<"The distance of " << w << " is " << bfs_test.dist(w) <<std::endl; 160 161 } … … 175 176 176 177 edge_property_vector<list_graph, int> flow=preflow_push_test.allflow(); 177 for (each_edge_iterator e=flow_test.first_edge(); e. is_valid(); ++e) {178 for (each_edge_iterator e=flow_test.first_edge(); e.valid(); ++e) { 178 179 std::cout <<"Flow on edge " << flow_test.tail(e) <<"-" << flow_test.head(e)<< " is " <<flow.get(e) <<std::endl; 179 180 } … … 182 183 node_property_vector<list_graph, bool> mincut=preflow_push_test.mincut(); 183 184 184 for (each_node_iterator v=flow_test.first_node(); v. is_valid(); ++v) {185 for (each_node_iterator v=flow_test.first_node(); v.valid(); ++v) { 185 186 if (mincut.get(v)) std::cout <<node_name.get(v)<< " "; 186 187 } … … 202 203 node_property_vector<list_graph, bool> mincut2=max_flow_test.mincut(); 203 204 204 for (each_node_iterator v=flow_test.first_node(); v. is_valid(); ++v) {205 for (each_node_iterator v=flow_test.first_node(); v.valid(); ++v) { 205 206 if (mincut2.get(v)) std::cout <<node_name.get(v)<< " "; 206 207 } … … 210 211 211 212 213 // std::cout << "Testing dijkstra..." << std::endl; 214 215 // dijkstra<list_graph, int> dijkstra_test(flow_test, s, cap); 216 217 // dijkstra_test.run(); 218 219 // for (each_node_iterator w=flow_test.first_node(); w.valid(); ++w) { 220 // std::cout <<"The distance of " << w << " is " << dijkstra_test.dist(w) <<std::endl; 221 // } 222 223 224 225 212 226 return 0; 213 227 } -
src/work/reverse_bfs.hh
r22 r30 68 68 bfs_queue.pop(); 69 69 70 for(in_edge_iterator e=G.first_in_edge(v); e. is_valid(); ++e) {70 for(in_edge_iterator e=G.first_in_edge(v); e.valid(); ++e) { 71 71 node_iterator w=G.tail(e); 72 72 if (!reached.get(w)) {
Note: See TracChangeset
for help on using the changeset viewer.