Changeset 64:72bd463289a9 in lemon-0.x for src/work
- Timestamp:
- 02/05/04 16:06:45 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@79
- Location:
- src/work
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/bfs_iterator.hh
r58 r64 406 406 public: 407 407 BfsIterator2(const Graph& _G) : G(_G), reached(G, false) { } 408 void pushAndSetReached( constNodeIt s) {408 void pushAndSetReached(NodeIt s) { 409 409 reached.set(s, true); 410 410 if (bfs_queue.empty()) { … … 445 445 if (!bfs_queue.empty()) { 446 446 actual_edge=bfs_queue.front(); 447 } else { 448 actual_edge=OutEdgeIt(); 449 } 450 if (actual_edge.valid()) { 451 NodeIt w=G.bNode(actual_edge); 452 if (!reached.get(w)) { 453 bfs_queue.push(G.template first<OutEdgeIt>(w)); 454 reached.set(w, true); 455 b_node_newly_reached=true; 456 } else { 457 b_node_newly_reached=false; 447 if (actual_edge.valid()) { 448 NodeIt w=G.bNode(actual_edge); 449 if (!reached.get(w)) { 450 bfs_queue.push(G.template first<OutEdgeIt>(w)); 451 reached.set(w, true); 452 b_node_newly_reached=true; 453 } else { 454 b_node_newly_reached=false; 455 } 458 456 } 459 457 } … … 469 467 }; 470 468 471 472 469 } // namespace marci 473 470 -
src/work/edmonds_karp.hh
r59 r64 42 42 } 43 43 bool valid() const { return sym.valid(); } 44 void augment( constT a) const {44 void augment(T a) const { 45 45 if (resG->G.aNode(sym)==resG->G.tail(sym)) { 46 46 resG->flow.set(sym, resG->flow.get(sym)+a); … … 57 57 //OutEdgeIt(const OutEdgeIt& e) { resG=e.resG; sym=e.sym; } 58 58 private: 59 OutEdgeIt(const ResGraph<Graph, T, FlowMap, CapacityMap>& _resG, constNodeIt v) {59 OutEdgeIt(const ResGraph<Graph, T, FlowMap, CapacityMap>& _resG, NodeIt v) { 60 60 resG=&_resG; 61 61 sym=resG->G.template first<OldSymEdgeIt>(v); … … 70 70 }; 71 71 72 void getFirst(OutEdgeIt& e, constNodeIt v) const {72 void getFirst(OutEdgeIt& e, NodeIt v) const { 73 73 e=OutEdgeIt(*this, v); 74 74 } … … 83 83 84 84 template< typename It > 85 It first( constNodeIt v) const {85 It first(NodeIt v) const { 86 86 It e; 87 87 getFirst(e, v); … … 89 89 } 90 90 91 NodeIt tail( constEdgeIt e) const { return G.aNode(e.sym); }92 NodeIt head( constEdgeIt e) const { return G.bNode(e.sym); }93 94 NodeIt aNode( constOutEdgeIt e) const { return G.aNode(e.sym); }95 NodeIt bNode( constOutEdgeIt e) const { return G.bNode(e.sym); }96 97 int id( constNodeIt v) const { return G.id(v); }91 NodeIt tail(EdgeIt e) const { return G.aNode(e.sym); } 92 NodeIt head(EdgeIt e) const { return G.bNode(e.sym); } 93 94 NodeIt aNode(OutEdgeIt e) const { return G.aNode(e.sym); } 95 NodeIt bNode(OutEdgeIt e) const { return G.bNode(e.sym); } 96 97 int id(NodeIt v) const { return G.id(v); } 98 98 99 99 template <typename ValueType> … … 102 102 public: 103 103 NodeMap(const ResGraph<Graph, T, FlowMap, CapacityMap>& _G) : node_map(_G.G) { } 104 NodeMap(const ResGraph<Graph, T, FlowMap, CapacityMap>& _G, constValueType a) : node_map(_G.G, a) { }105 void set( const NodeIt nit, constValueType a) { node_map.set(nit, a); }106 ValueType get( constNodeIt nit) const { return node_map.get(nit); }104 NodeMap(const ResGraph<Graph, T, FlowMap, CapacityMap>& _G, ValueType a) : node_map(_G.G, a) { } 105 void set(NodeIt nit, ValueType a) { node_map.set(nit, a); } 106 ValueType get(NodeIt nit) const { return node_map.get(nit); } 107 107 }; 108 108 … … 117 117 typedef typename Graph::InEdgeIt InEdgeIt; 118 118 const Graph& G; 119 constNodeIt s;120 constNodeIt t;119 NodeIt s; 120 NodeIt t; 121 121 FlowMap& flow; 122 122 const CapacityMap& capacity; … … 125 125 typedef typename AugGraph::EdgeIt AugEdgeIt; 126 126 public: 127 MaxFlow(const Graph& _G, const NodeIt _s, constNodeIt _t, FlowMap& _flow, const CapacityMap& _capacity) : G(_G), s(_s), t(_t), flow(_flow), capacity(_capacity) { }127 MaxFlow(const Graph& _G, NodeIt _s, NodeIt _t, FlowMap& _flow, const CapacityMap& _capacity) : G(_G), s(_s), t(_t), flow(_flow), capacity(_capacity) { } 128 128 bool augment() { 129 129 AugGraph res_graph(G, flow, capacity); -
src/work/list_graph.hh
r59 r64 41 41 public: 42 42 NodeMap(const ListGraph& _G) : G(_G), container(_G.node_id) { } 43 NodeMap(const ListGraph& _G, constValueType a) :43 NodeMap(const ListGraph& _G, ValueType a) : 44 44 G(_G), container(_G.node_id, a) { } 45 void set( const NodeIt nit, constValueType a) { container[G.id(nit)]=a; }46 ValueType get( constNodeIt nit) const { return container[G.id(nit)]; }45 void set(NodeIt nit, ValueType a) { container[G.id(nit)]=a; } 46 ValueType get(NodeIt nit) const { return container[G.id(nit)]; } 47 47 }; 48 48 … … 53 53 public: 54 54 EdgeMap(const ListGraph& _G) : G(_G), container(_G.edge_id) { } 55 EdgeMap(const ListGraph& _G, constValueType a) :55 EdgeMap(const ListGraph& _G, ValueType a) : 56 56 G(_G), container(_G.edge_id, a) { } 57 void set( const EdgeIt eit, constValueType a) { container[G.id(eit)]=a; }58 ValueType get( constEdgeIt eit) const { return container[G.id(eit)]; }57 void set(EdgeIt eit, ValueType a) { container[G.id(eit)]=a; } 58 ValueType get(EdgeIt eit) const { return container[G.id(eit)]; } 59 59 }; 60 60 … … 227 227 //InEdgeIt firstInEdge(const NodeIt v) const { return InEdgeIt(v); } 228 228 //SymEdgeIt firstSymEdge(const NodeIt v) const { return SymEdgeIt(v); } 229 NodeIt tail( constEdgeIt e) const { return e.tailNode(); }230 NodeIt head( constEdgeIt e) const { return e.headNode(); }229 NodeIt tail(EdgeIt e) const { return e.tailNode(); } 230 NodeIt head(EdgeIt e) const { return e.headNode(); } 231 231 232 232 NodeIt aNode(const OutEdgeIt& e) const { return e.aNode(); } … … 249 249 void getFirst(EachNodeIt& v) const { v=EachNodeIt(*this); } 250 250 void getFirst(EachEdgeIt& e) const { e=EachEdgeIt(*this); } 251 void getFirst(OutEdgeIt& e, const NodeIt&v) const { e=OutEdgeIt(v); }252 void getFirst(InEdgeIt& e, const NodeIt&v) const { e=InEdgeIt(v); }253 void getFirst(SymEdgeIt& e, const NodeIt&v) const { e=SymEdgeIt(v); }254 void getTail(NodeIt& n, const EdgeIt& e) const { n=tail(e); }255 void getHead(NodeIt& n, const EdgeIt& e) const { n=head(e); }256 257 void getANode(NodeIt& n, const OutEdgeIt& e) const { n=e.aNode(); }258 void getANode(NodeIt& n, const InEdgeIt& e) const { n=e.aNode(); }259 void getANode(NodeIt& n, const SymEdgeIt& e) const { n=e.aNode(); }260 void getBNode(NodeIt& n, const OutEdgeIt& e) const { n=e.bNode(); }261 void getBNode(NodeIt& n, const InEdgeIt& e) const { n=e.bNode(); }262 void getBNode(NodeIt& n, const SymEdgeIt& e) const { n=e.bNode(); }251 void getFirst(OutEdgeIt& e, NodeIt v) const { e=OutEdgeIt(v); } 252 void getFirst(InEdgeIt& e, NodeIt v) const { e=InEdgeIt(v); } 253 void getFirst(SymEdgeIt& e, NodeIt v) const { e=SymEdgeIt(v); } 254 //void getTail(NodeIt& n, const EdgeIt& e) const { n=tail(e); } 255 //void getHead(NodeIt& n, const EdgeIt& e) const { n=head(e); } 256 257 //void getANode(NodeIt& n, const OutEdgeIt& e) const { n=e.aNode(); } 258 //void getANode(NodeIt& n, const InEdgeIt& e) const { n=e.aNode(); } 259 //void getANode(NodeIt& n, const SymEdgeIt& e) const { n=e.aNode(); } 260 //void getBNode(NodeIt& n, const OutEdgeIt& e) const { n=e.bNode(); } 261 //void getBNode(NodeIt& n, const InEdgeIt& e) const { n=e.bNode(); } 262 //void getBNode(NodeIt& n, const SymEdgeIt& e) const { n=e.bNode(); } 263 263 //void get_invalid(NodeIt& n) { n=NodeIt(); } 264 264 //void get_invalid(EdgeIt& e) { e=EdgeIt(); } … … 275 275 276 276 template< typename It > 277 It first( constNodeIt v) const {277 It first(NodeIt v) const { 278 278 It e; 279 279 getFirst(e, v); … … 284 284 /* these are important for the implementation of property vectors */ 285 285 286 int id( constNodeIt v) const { return v.node->id; }287 int id( constEdgeIt e) const { return e.edge->id; }286 int id(NodeIt v) const { return v.node->id; } 287 int id(EdgeIt e) const { return e.edge->id; } 288 288 289 289 /* adding nodes and edges */ 290 290 291 291 NodeIt addNode() { return NodeIt(_add_node()); } 292 EdgeIt addEdge( const NodeIt u, constNodeIt v) {292 EdgeIt addEdge(NodeIt u, NodeIt v) { 293 293 return EdgeIt(_add_edge(u.node, v.node)); 294 294 } 295 295 296 void deleteNode( constNodeIt i) {296 void deleteNode(NodeIt i) { 297 297 while (first<OutEdgeIt>(i).valid()) deleteEdge(first<OutEdgeIt>(i)); 298 298 while (first<InEdgeIt>(i).valid()) deleteEdge(first<InEdgeIt>(i)); … … 300 300 } 301 301 302 void deleteEdge( constEdgeIt e) { _delete_edge(e.edge); }303 304 void setTail( const EdgeIt e, constNodeIt tail) {302 void deleteEdge(EdgeIt e) { _delete_edge(e.edge); } 303 304 void setTail(EdgeIt e, NodeIt tail) { 305 305 _set_tail(e.edge, tail.node); 306 306 } 307 307 308 void setHead( const EdgeIt e, constNodeIt head) {308 void setHead(EdgeIt e, NodeIt head) { 309 309 _set_head(e.edge, head.node); 310 310 } … … 329 329 protected: 330 330 node_item* node; 331 friend int ListGraph::id( constNodeIt v) const;331 friend int ListGraph::id(NodeIt v) const; 332 332 public: 333 333 NodeIt() : node(0) { } … … 361 361 protected: 362 362 edge_item* edge; 363 friend int ListGraph::id( constEdgeIt e) const;363 friend int ListGraph::id(EdgeIt e) const; 364 364 public: 365 365 EdgeIt() : edge(0) { } … … 407 407 public: 408 408 OutEdgeIt() : EdgeIt(), v(0) { } 409 OutEdgeIt(const ListGraph& G, constNodeIt _v) : v(_v.node) { edge=v->_first_out_edge; }409 OutEdgeIt(const ListGraph& G, NodeIt _v) : v(_v.node) { edge=v->_first_out_edge; } 410 410 OutEdgeIt& operator++() { edge=edge->_next_out; return *this; } 411 411 protected: … … 422 422 public: 423 423 InEdgeIt() : EdgeIt(), v(0) { } 424 InEdgeIt(const ListGraph& G, constNodeIt _v) : v(_v.node) { edge=v->_first_in_edge; }424 InEdgeIt(const ListGraph& G, NodeIt _v) : v(_v.node) { edge=v->_first_in_edge; } 425 425 InEdgeIt& operator++() { edge=edge->_next_in; return *this; } 426 426 protected: … … 442 442 public: 443 443 SymEdgeIt() : EdgeIt(), v(0) { } 444 SymEdgeIt(const ListGraph& G, constNodeIt _v) : v(_v.node) {444 SymEdgeIt(const ListGraph& G, NodeIt _v) : v(_v.node) { 445 445 out_or_in=1; 446 446 edge=v->_first_out_edge;
Note: See TracChangeset
for help on using the changeset viewer.