Changeset 389:770cc1f4861f in lemon-0.x
- Timestamp:
- 04/24/04 14:44:41 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@520
- Location:
- src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
src/include/invalid.h
r253 r389 28 28 const Invalid INVALID = Invalid(); 29 29 30 } ;30 } //namespace hugo 31 31 32 32 #endif -
src/include/maps.h
r346 r389 93 93 94 94 template<typename T1, typename Comp1> 95 StdMap(const StdMap<Key,T1,Comp1> &m, const T &_v) { FIXME; } 95 StdMap(const StdMap<Key,T1,Comp1> &m, const T &_v) { 96 //FIXME; 97 } 96 98 97 99 ReferenceType operator[](const Key &k) { … … 99 101 } 100 102 ConstReferenceType operator[](const Key &k) const { 101 typename parent::iterator i = lower_bound(__k); 103 //marci jav typename parent::iterator i = lower_bound(__k); 104 typename parent::iterator i = lower_bound(k); 102 105 if (i == end() || key_comp()(k, (*i).first)) 103 106 return v; -
src/work/jacint/preflow.h
r372 r389 53 53 54 54 template <typename Graph, typename T, 55 typename CapMap=typename Graph:: EdgeMap<T>,56 typename FlowMap=typename Graph:: EdgeMap<T> >55 typename CapMap=typename Graph::template EdgeMap<T>, 56 typename FlowMap=typename Graph::template EdgeMap<T> > 57 57 class Preflow { 58 58 … … 100 100 int b=k; //bound on the highest level under n of an active node 101 101 102 typename Graph:: NodeMap<int> level(G,n);103 typename Graph:: NodeMap<T> excess(G);102 typename Graph::template NodeMap<int> level(G,n); 103 typename Graph::template NodeMap<T> excess(G); 104 104 105 105 std::vector<Node> active(n-1,INVALID); 106 typename Graph:: NodeMap<Node> next(G,INVALID);106 typename Graph::template NodeMap<Node> next(G,INVALID); 107 107 //Stack of the active nodes in level i < n. 108 108 //We use it in both phases. 109 109 110 typename Graph:: NodeMap<Node> left(G,INVALID);111 typename Graph:: NodeMap<Node> right(G,INVALID);110 typename Graph::template NodeMap<Node> left(G,INVALID); 111 typename Graph::template NodeMap<Node> right(G,INVALID); 112 112 std::vector<Node> level_list(n,INVALID); 113 113 /* -
src/work/list_graph.h
r368 r389 30 30 template <typename T> class NodeMap; 31 31 template <typename T> class EdgeMap; 32 private:32 // private: 33 33 template <typename T> friend class NodeMap; 34 34 template <typename T> friend class EdgeMap; … … 76 76 }; 77 77 78 private: 78 79 int node_id; 79 80 int edge_id; -
src/work/makefile
r347 r389 1 1 INCLUDEDIRS ?= -I../include -I. -I./{marci,jacint,alpar,klao,akos} 2 CXXFLAGS = -g -O -Wall $(INCLUDEDIRS) -ansi -pedantic2 CXXFLAGS = -g -O2 -W -Wall $(INCLUDEDIRS) -ansi -pedantic 3 3 4 4 BINARIES ?= bin_heap_demo … … 6 6 # Hat, ez elismerem, hogy nagyon ronda, de mukodik minden altalam 7 7 # ismert rendszeren :-) (Misi) 8 #CXX := $(shell type -p g++-3.4 || type -p g++-3.3 || type -p g++-3.2 || type -p g++-3.0 || type -p g++-3 || echo g++) 8 9 CXX := $(shell type -p g++-3.3 || type -p g++-3.2 || type -p g++-3.0 || type -p g++-3 || echo g++) 9 10 CC := $(CXX) -
src/work/marci/bfs_iterator.h
r360 r389 147 147 bool isANodeExamined() const { return !(graph->valid(actual_edge)); } 148 148 Node aNode() const { return actual_node; /*FIXME*/} 149 Node bNode() const { return G.bNode(actual_edge); }149 Node bNode() const { return graph->bNode(actual_edge); } 150 150 const ReachedMap& getReachedMap() const { return reached; } 151 151 const std::stack<OutEdgeIt>& getDfsStack() const { return dfs_stack; } -
src/work/marci/bfsit_vs_byhand.cc
r360 r389 4 4 5 5 #include <list_graph.h> 6 #include <smart_graph.h>6 //#include <smart_graph.h> 7 7 #include <dimacs.h> 8 8 #include <time_measure.h> -
src/work/marci/bipartite_graph_wrapper_test.cc
r379 r389 5 5 6 6 #include <list_graph.h> 7 #include <smart_graph.h>7 //#include <smart_graph.h> 8 8 //#include <dimacs.h> 9 9 #include <time_measure.h> -
src/work/marci/edmonds_karp.h
r360 r389 276 276 bool _augment=false; 277 277 278 BfsIterator< ResGW, typename ResGW::NodeMap<bool> > bfs(res_graph); 278 BfsIterator< ResGW, typename ResGW::template NodeMap<bool> > 279 bfs(res_graph); 279 280 bfs.pushAndSetReached(s); 280 281 281 typename ResGW:: NodeMap<ResGWEdge> pred(res_graph);282 typename ResGW::template NodeMap<ResGWEdge> pred(res_graph); 282 283 pred.set(s, INVALID); 283 284 284 typename ResGW:: NodeMap<Number> free(res_graph);285 typename ResGW::template NodeMap<Number> free(res_graph); 285 286 286 287 //searching for augmenting path … … 319 320 protected: 320 321 const MapGraphWrapper* g; 321 typename MapGraphWrapper:: NodeMap<int> dist;322 typename MapGraphWrapper::template NodeMap<int> dist; 322 323 public: 323 324 DistanceMap(MapGraphWrapper& _g) : g(&_g), dist(*g, g->nodeNum()) { } … … 340 341 ResGW res_graph(*g, *capacity, *flow); 341 342 342 BfsIterator< ResGW, typename ResGW::NodeMap<bool> > bfs(res_graph); 343 BfsIterator< ResGW, typename ResGW::template NodeMap<bool> > 344 bfs(res_graph); 343 345 344 346 bfs.pushAndSetReached(s); … … 358 360 DistanceMap<ResGW> > FilterResGW; 359 361 FilterResGW filter_res_graph(res_graph, true_map, dist); 360 typename ResGW::NodeMap<typename MG::Node> res_graph_to_F(res_graph); 362 typename ResGW::template NodeMap<typename MG::Node> 363 res_graph_to_F(res_graph); 361 364 { 362 365 typename ResGW::NodeIt n; … … 368 371 typename MG::Node sF=res_graph_to_F[s]; 369 372 typename MG::Node tF=res_graph_to_F[t]; 370 typename MG:: EdgeMap<ResGWEdge> original_edge(F);371 typename MG:: EdgeMap<Number> residual_capacity(F);373 typename MG::template EdgeMap<ResGWEdge> original_edge(F); 374 typename MG::template EdgeMap<Number> residual_capacity(F); 372 375 373 376 //Making F to the graph containing the edges of the residual graph … … 392 395 //computing blocking flow with dfs 393 396 394 DfsIterator< MG, typename MG:: NodeMap<bool> > dfs(F);395 typename MG:: NodeMap<typename MG::Edge> pred(F);397 DfsIterator< MG, typename MG::template NodeMap<bool> > dfs(F); 398 typename MG::template NodeMap<typename MG::Edge> pred(F); 396 399 pred.set(sF, INVALID); 397 400 //invalid iterators for sources 398 401 399 typename MG:: NodeMap<Number> free(F);402 typename MG::template NodeMap<Number> free(F); 400 403 401 404 dfs.pushAndSetReached(sF); … … 450 453 451 454 //bfs for distances on the residual graph 452 BfsIterator< ResGW, typename ResGW::NodeMap<bool> > bfs(res_graph); 455 BfsIterator< ResGW, typename ResGW::template NodeMap<bool> > 456 bfs(res_graph); 453 457 bfs.pushAndSetReached(s); 454 typename ResGW::NodeMap<int> dist(res_graph); //filled up with 0's 458 typename ResGW::template NodeMap<int> 459 dist(res_graph); //filled up with 0's 455 460 456 461 //F will contain the physical copy of the residual graph 457 462 //with the set of edges which are on shortest paths 458 463 MG F; 459 typename ResGW::NodeMap<typename MG::Node> res_graph_to_F(res_graph); 464 typename ResGW::template NodeMap<typename MG::Node> 465 res_graph_to_F(res_graph); 460 466 { 461 467 typename ResGW::NodeIt n; … … 467 473 typename MG::Node sF=res_graph_to_F[s]; 468 474 typename MG::Node tF=res_graph_to_F[t]; 469 typename MG:: EdgeMap<ResGWEdge> original_edge(F);470 typename MG:: EdgeMap<Number> residual_capacity(F);475 typename MG::template EdgeMap<ResGWEdge> original_edge(F); 476 typename MG::template EdgeMap<Number> residual_capacity(F); 471 477 472 478 while ( !bfs.finished() ) { … … 498 504 __augment=false; 499 505 //computing blocking flow with dfs 500 DfsIterator< MG, typename MG:: NodeMap<bool> > dfs(F);501 typename MG:: NodeMap<typename MG::Edge> pred(F);506 DfsIterator< MG, typename MG::template NodeMap<bool> > dfs(F); 507 typename MG::template NodeMap<typename MG::Edge> pred(F); 502 508 pred.set(sF, INVALID); 503 509 //invalid iterators for sources 504 510 505 typename MG:: NodeMap<Number> free(F);511 typename MG::template NodeMap<Number> free(F); 506 512 507 513 dfs.pushAndSetReached(sF); … … 554 560 ResGW res_graph(*g, *capacity, *flow); 555 561 556 BfsIterator< ResGW, typename ResGW::NodeMap<bool> > bfs(res_graph); 562 BfsIterator< ResGW, typename ResGW::template NodeMap<bool> > 563 bfs(res_graph); 557 564 558 565 bfs.pushAndSetReached(s); … … 574 581 //Subgraph, which is able to delete edges which are already 575 582 //met by the dfs 576 typename FilterResGW:: NodeMap<typename FilterResGW::OutEdgeIt>583 typename FilterResGW::template NodeMap<typename FilterResGW::OutEdgeIt> 577 584 first_out_edges(filter_res_graph); 578 585 typename FilterResGW::NodeIt v; … … 585 592 } 586 593 typedef ErasingFirstGraphWrapper<FilterResGW, typename FilterResGW:: 587 NodeMap<typename FilterResGW::OutEdgeIt> > ErasingResGW;594 template NodeMap<typename FilterResGW::OutEdgeIt> > ErasingResGW; 588 595 ErasingResGW erasing_res_graph(filter_res_graph, first_out_edges); 589 596 … … 594 601 __augment=false; 595 602 //computing blocking flow with dfs 596 DfsIterator< ErasingResGW, typename ErasingResGW::NodeMap<bool> > 603 DfsIterator< ErasingResGW, 604 typename ErasingResGW::template NodeMap<bool> > 597 605 dfs(erasing_res_graph); 598 typename ErasingResGW::NodeMap<typename ErasingResGW::OutEdgeIt> 599 pred(erasing_res_graph); 606 typename ErasingResGW:: 607 template NodeMap<typename ErasingResGW::OutEdgeIt> 608 pred(erasing_res_graph); 600 609 pred.set(s, INVALID); 601 610 //invalid iterators for sources 602 611 603 typename ErasingResGW::NodeMap<Number> free1(erasing_res_graph); 612 typename ErasingResGW::template NodeMap<Number> 613 free1(erasing_res_graph); 604 614 605 615 dfs.pushAndSetReached( -
src/work/marci/edmonds_karp_demo.cc
r376 r389 4 4 5 5 #include <list_graph.h> 6 #include <smart_graph.h>6 //#include <smart_graph.h> 7 7 #include <dimacs.h> 8 8 #include <edmonds_karp.h> -
src/work/marci/graph_wrapper.h
r381 r389 184 184 void clear() const { graph->clear(); } 185 185 186 template<typename T> class NodeMap : public Graph::NodeMap<T> { 187 public: 188 NodeMap(const GraphWrapper<Graph>& _G) : 189 Graph::NodeMap<T>(*(_G.graph)) { } 190 NodeMap(const GraphWrapper<Graph>& _G, T a) : 191 Graph::NodeMap<T>(*(_G.graph), a) { } 192 }; 193 194 template<typename T> class EdgeMap : public Graph::EdgeMap<T> { 195 public: 196 EdgeMap(const GraphWrapper<Graph>& _G) : 197 Graph::EdgeMap<T>(*(_G.graph)) { } 198 EdgeMap(const GraphWrapper<Graph>& _G, T a) : 199 Graph::EdgeMap<T>(*(_G.graph), a) { } 186 template<typename T> class NodeMap : public Graph::template NodeMap<T> { 187 typedef typename Graph::template NodeMap<T> Parent; 188 public: 189 NodeMap(const GraphWrapper<Graph>& _G) : Parent(*(_G.graph)) { } 190 NodeMap(const GraphWrapper<Graph>& _G, T a) : Parent(*(_G.graph), a) { } 191 }; 192 193 template<typename T> class EdgeMap : public Graph::template EdgeMap<T> { 194 typedef typename Graph::template EdgeMap<T> Parent; 195 public: 196 EdgeMap(const GraphWrapper<Graph>& _G) : Parent(*(_G.graph)) { } 197 EdgeMap(const GraphWrapper<Graph>& _G, T a) : Parent(*(_G.graph), a) { } 200 198 }; 201 199 }; … … 253 251 254 252 using GraphWrapper<Graph>::next; 255 OutEdgeIt& next(OutEdgeIt& i) const { graph->next(i.e); return i; } 256 InEdgeIt& next(InEdgeIt& i) const { graph->next(i.e); return i; } 257 258 Node aNode(const OutEdgeIt& e) const { return Node(graph->aNode(e.e)); } 259 Node aNode(const InEdgeIt& e) const { return Node(graph->aNode(e.e)); } 260 Node bNode(const OutEdgeIt& e) const { return Node(graph->bNode(e.e)); } 261 Node bNode(const InEdgeIt& e) const { return Node(graph->bNode(e.e)); } 253 OutEdgeIt& next(OutEdgeIt& i) const { this->graph->next(i.e); return i; } 254 InEdgeIt& next(InEdgeIt& i) const { this->graph->next(i.e); return i; } 255 256 Node aNode(const OutEdgeIt& e) const { 257 return Node(this->graph->aNode(e.e)); } 258 Node aNode(const InEdgeIt& e) const { 259 return Node(this->graph->aNode(e.e)); } 260 Node bNode(const OutEdgeIt& e) const { 261 return Node(this->graph->bNode(e.e)); } 262 Node bNode(const InEdgeIt& e) const { 263 return Node(this->graph->bNode(e.e)); } 262 264 263 265 Node tail(const Edge& e) const { … … 367 369 368 370 NodeIt& next(NodeIt& i) const { 369 graph->next(i.n); 370 while (graph->valid(i) && !(*node_filter_map)[i.n]) { graph->next(i.n); } 371 this->graph->next(i.n); 372 while (this->graph->valid(i) && !(*node_filter_map)[i.n]) { 373 this->graph->next(i.n); } 371 374 return i; 372 375 } 373 376 OutEdgeIt& next(OutEdgeIt& i) const { 374 graph->next(i.e); 375 while (graph->valid(i) && !(*edge_filter_map)[i.e]) { graph->next(i.e); } 377 this->graph->next(i.e); 378 while (this->graph->valid(i) && !(*edge_filter_map)[i.e]) { 379 this->graph->next(i.e); } 376 380 return i; 377 381 } 378 382 InEdgeIt& next(InEdgeIt& i) const { 379 graph->next(i.e); 380 while (graph->valid(i) && !(*edge_filter_map)[i.e]) { graph->next(i.e); } 383 this->graph->next(i.e); 384 while (this->graph->valid(i) && !(*edge_filter_map)[i.e]) { 385 this->graph->next(i.e); } 381 386 return i; 382 387 } 383 388 EdgeIt& next(EdgeIt& i) const { 384 graph->next(i.e); 385 while (graph->valid(i) && !(*edge_filter_map)[i.e]) { graph->next(i.e); } 389 this->graph->next(i.e); 390 while (this->graph->valid(i) && !(*edge_filter_map)[i.e]) { 391 this->graph->next(i.e); } 386 392 return i; 387 393 } 388 394 389 Node aNode(const OutEdgeIt& e) const { return Node(graph->aNode(e.e)); } 390 Node aNode(const InEdgeIt& e) const { return Node(graph->aNode(e.e)); } 391 Node bNode(const OutEdgeIt& e) const { return Node(graph->bNode(e.e)); } 392 Node bNode(const InEdgeIt& e) const { return Node(graph->bNode(e.e)); } 395 Node aNode(const OutEdgeIt& e) const { 396 return Node(this->graph->aNode(e.e)); } 397 Node aNode(const InEdgeIt& e) const { 398 return Node(this->graph->aNode(e.e)); } 399 Node bNode(const OutEdgeIt& e) const { 400 return Node(this->graph->bNode(e.e)); } 401 Node bNode(const InEdgeIt& e) const { 402 return Node(this->graph->bNode(e.e)); } 393 403 394 404 ///\todo … … 470 480 OutEdgeIt& next(OutEdgeIt& e) const { 471 481 if (e.out_or_in) { 472 typename Graph::Node n=graph->tail(e.out); 473 graph->next(e.out); 474 if (!graph->valid(e.out)) { e.out_or_in=false; graph->first(e.in, n); } 482 typename Graph::Node n=this->graph->tail(e.out); 483 this->graph->next(e.out); 484 if (!this->graph->valid(e.out)) { 485 e.out_or_in=false; this->graph->first(e.in, n); } 475 486 } else { 476 graph->next(e.in);487 this->graph->next(e.in); 477 488 } 478 489 return e; … … 486 497 487 498 Node aNode(const OutEdgeIt& e) const { 488 if (e.out_or_in) return graph->tail(e); else return graph->head(e); } 499 if (e.out_or_in) return this->graph->tail(e); else 500 return this->graph->head(e); } 489 501 Node bNode(const OutEdgeIt& e) const { 490 if (e.out_or_in) return graph->head(e); else return graph->tail(e); } 502 if (e.out_or_in) return this->graph->head(e); else 503 return this->graph->tail(e); } 491 504 }; 492 505 … … 646 659 OutEdgeIt& next(OutEdgeIt& e) const { 647 660 if (e.forward) { 648 Node v=graph->aNode(e.out); 649 graph->next(e.out); 650 while( graph->valid(e.out) && !(resCap(e)>0) ) { graph->next(e.out); } 651 if (!graph->valid(e.out)) { 661 Node v=this->graph->aNode(e.out); 662 this->graph->next(e.out); 663 while( this->graph->valid(e.out) && !(resCap(e)>0) ) { 664 this->graph->next(e.out); } 665 if (!this->graph->valid(e.out)) { 652 666 e.forward=false; 653 graph->first(e.in, v); 654 while( graph->valid(e.in) && !(resCap(e)>0) ) { graph->next(e.in); } 667 this->graph->first(e.in, v); 668 while( this->graph->valid(e.in) && !(resCap(e)>0) ) { 669 this->graph->next(e.in); } 655 670 } 656 671 } else { 657 graph->next(e.in); 658 while( graph->valid(e.in) && !(resCap(e)>0) ) { graph->next(e.in); } 672 this->graph->next(e.in); 673 while( this->graph->valid(e.in) && !(resCap(e)>0) ) { 674 this->graph->next(e.in); } 659 675 } 660 676 return e; … … 663 679 InEdgeIt& next(InEdgeIt& e) const { 664 680 if (e.forward) { 665 Node v=graph->aNode(e.in); 666 graph->next(e.in); 667 while( graph->valid(e.in) && !(resCap(e)>0) ) { graph->next(e.in); } 668 if (!graph->valid(e.in)) { 681 Node v=this->graph->aNode(e.in); 682 this->graph->next(e.in); 683 while( this->graph->valid(e.in) && !(resCap(e)>0) ) { 684 this->graph->next(e.in); } 685 if (!this->graph->valid(e.in)) { 669 686 e.forward=false; 670 graph->first(e.out, v); 671 while( graph->valid(e.out) && !(resCap(e)>0) ) { graph->next(e.out); } 687 this->graph->first(e.out, v); 688 while( this->graph->valid(e.out) && !(resCap(e)>0) ) { 689 this->graph->next(e.out); } 672 690 } 673 691 } else { 674 graph->next(e.out); 675 while( graph->valid(e.out) && !(resCap(e)>0) ) { graph->next(e.out); } 692 this->graph->next(e.out); 693 while( this->graph->valid(e.out) && !(resCap(e)>0) ) { 694 this->graph->next(e.out); } 676 695 } 677 696 return e; … … 679 698 EdgeIt& next(EdgeIt& e) const { 680 699 if (e.forward) { 681 graph->next(e.e); 682 while( graph->valid(e.e) && !(resCap(e)>0) ) { graph->next(e.e); } 683 if (!graph->valid(e.e)) { 700 this->graph->next(e.e); 701 while( this->graph->valid(e.e) && !(resCap(e)>0) ) { 702 this->graph->next(e.e); } 703 if (!this->graph->valid(e.e)) { 684 704 e.forward=false; 685 graph->first(e.e); 686 while( graph->valid(e.e) && !(resCap(e)>0) ) { graph->next(e.e); } 705 this->graph->first(e.e); 706 while( this->graph->valid(e.e) && !(resCap(e)>0) ) { 707 this->graph->next(e.e); } 687 708 } 688 709 } else { 689 graph->next(e.e); 690 while( graph->valid(e.e) && !(resCap(e)>0) ) { graph->next(e.e); } 710 this->graph->next(e.e); 711 while( this->graph->valid(e.e) && !(resCap(e)>0) ) { 712 this->graph->next(e.e); } 691 713 } 692 714 return e; … … 694 716 695 717 Node tail(Edge e) const { 696 return ((e.forward) ? graph->tail(e) :graph->head(e)); }718 return ((e.forward) ? this->graph->tail(e) : this->graph->head(e)); } 697 719 Node head(Edge e) const { 698 return ((e.forward) ? graph->head(e) :graph->tail(e)); }720 return ((e.forward) ? this->graph->head(e) : this->graph->tail(e)); } 699 721 700 722 Node aNode(OutEdgeIt e) const { 701 return ((e.forward) ? graph->aNode(e.out) : graph->aNode(e.in)); } 723 return ((e.forward) ? this->graph->aNode(e.out) : 724 this->graph->aNode(e.in)); } 702 725 Node bNode(OutEdgeIt e) const { 703 return ((e.forward) ? graph->bNode(e.out) : graph->bNode(e.in)); } 726 return ((e.forward) ? this->graph->bNode(e.out) : 727 this->graph->bNode(e.in)); } 704 728 705 729 Node aNode(InEdgeIt e) const { 706 return ((e.forward) ? graph->aNode(e.in) : graph->aNode(e.out)); } 730 return ((e.forward) ? this->graph->aNode(e.in) : 731 this->graph->aNode(e.out)); } 707 732 Node bNode(InEdgeIt e) const { 708 return ((e.forward) ? graph->bNode(e.in) : graph->bNode(e.out)); } 733 return ((e.forward) ? this->graph->bNode(e.in) : 734 this->graph->bNode(e.out)); } 709 735 710 736 // int nodeNum() const { return graph->nodeNum(); } … … 718 744 bool valid(Node n) const { return GraphWrapper<Graph>::valid(n); } 719 745 bool valid(Edge e) const { 720 return graph->valid(e);746 return this->graph->valid(e); 721 747 //return e.forward ? graph->valid(e.out) : graph->valid(e.in); 722 748 } … … 752 778 template <typename T> 753 779 class EdgeMap { 754 typename Graph:: EdgeMap<T> forward_map, backward_map;780 typename Graph::template EdgeMap<T> forward_map, backward_map; 755 781 public: 756 782 EdgeMap(const ResGraphWrapper<Graph, Number, CapacityMap, FlowMap>& _G) : forward_map(*(_G.graph)), backward_map(*(_G.graph)) { } … … 862 888 using GraphWrapper<Graph>::next; 863 889 // NodeIt& next(NodeIt& i) const { graph->next(i.n); return i; } 864 OutEdgeIt& next(OutEdgeIt& i) const { graph->next(i.e); return i; }865 InEdgeIt& next(InEdgeIt& i) const { graph->next(i.e); return i; }866 EdgeIt& next(EdgeIt& i) const { graph->next(i.e); return i; }890 OutEdgeIt& next(OutEdgeIt& i) const { this->graph->next(i.e); return i; } 891 InEdgeIt& next(InEdgeIt& i) const { this->graph->next(i.e); return i; } 892 EdgeIt& next(EdgeIt& i) const { this->graph->next(i.e); return i; } 867 893 868 Node aNode(const OutEdgeIt& e) const { return Node(graph->aNode(e.e)); } 869 Node aNode(const InEdgeIt& e) const { return Node(graph->aNode(e.e)); } 870 Node bNode(const OutEdgeIt& e) const { return Node(graph->bNode(e.e)); } 871 Node bNode(const InEdgeIt& e) const { return Node(graph->bNode(e.e)); } 894 Node aNode(const OutEdgeIt& e) const { 895 return Node(this->graph->aNode(e.e)); } 896 Node aNode(const InEdgeIt& e) const { 897 return Node(this->graph->aNode(e.e)); } 898 Node bNode(const OutEdgeIt& e) const { 899 return Node(this->graph->bNode(e.e)); } 900 Node bNode(const InEdgeIt& e) const { 901 return Node(this->graph->bNode(e.e)); } 872 902 873 903 void erase(const OutEdgeIt& e) const { … … 886 916 template<typename Graph> 887 917 class BipartiteGraphWrapper : public GraphWrapper<Graph> { 888 typedef IterableBoolMap< typename Graph::NodeMap<int> > SFalseTTrueMap; 918 typedef IterableBoolMap< typename Graph::template NodeMap<int> > 919 SFalseTTrueMap; 889 920 SFalseTTrueMap* s_false_t_true_map; 890 921 … … 984 1015 // this->s_false_t_true_map->next(n); return n; 985 1016 // } 986 OutEdgeIt& next(OutEdgeIt& i) const { graph->next(i.e); return i; }987 InEdgeIt& next(InEdgeIt& i) const { graph->next(i.e); return i; }1017 OutEdgeIt& next(OutEdgeIt& i) const { this->graph->next(i.e); return i; } 1018 InEdgeIt& next(InEdgeIt& i) const { this->graph->next(i.e); return i; } 988 1019 989 1020 Node tail(const Edge& e) { … … 1079 1110 friend class GraphWrapper<Graph>; 1080 1111 friend class stGraphWrapper<Graph>; 1081 template <typename T> friend class stGraphWrapper<Graph>::NodeMap;1112 template <typename T> friend class NodeMap; 1082 1113 friend class Edge; 1083 1114 friend class OutEdgeIt; … … 1120 1151 friend class GraphWrapper<Graph>; 1121 1152 friend class stGraphWrapper<Graph>; 1122 template <typename T> friend class stGraphWrapper<Graph>::EdgeMap;1153 template <typename T> friend class EdgeMap; 1123 1154 int spec; 1124 1155 typename Graph::Node n; … … 1274 1305 switch (i.spec) { 1275 1306 case 0: 1276 graph->next(i.n);1277 if (! graph->valid(i.n)) {1307 this->graph->next(i.n); 1308 if (!this->graph->valid(i.n)) { 1278 1309 i.spec=1; 1279 1310 } … … 1291 1322 switch (i.spec) { 1292 1323 case 0: //normal edge 1293 typename Graph::Node v= graph->aNode(i.e);1294 graph->next(i.e);1295 if (! graph->valid(i.e)) { //Az igazi elek vegere ertunk1296 if ( graph->inSClass(v)) { //S, nincs kiel1324 typename Graph::Node v=this->graph->aNode(i.e); 1325 this->graph->next(i.e); 1326 if (!this->graph->valid(i.e)) { //Az igazi elek vegere ertunk 1327 if (this->graph->inSClass(v)) { //S, nincs kiel 1297 1328 i.spec=3; 1298 1329 i.n=INVALID; … … 1304 1335 break; 1305 1336 case 1: //s->vmi 1306 graph->next(i.n);1307 if (! graph->valid(i.n)) i.spec=3;1337 this->graph->next(i.n); 1338 if (!this->graph->valid(i.n)) i.spec=3; 1308 1339 break; 1309 1340 case 2: //vmi->t … … 1317 1348 switch (i.spec) { 1318 1349 case 0: //normal edge 1319 typename Graph::Node v= graph->aNode(i.e);1320 graph->next(i.e);1321 if (! graph->valid(i.e)) { //Az igazi elek vegere ertunk1322 if ( graph->inTClass(v)) { //S, nincs beel1350 typename Graph::Node v=this->graph->aNode(i.e); 1351 this->graph->next(i.e); 1352 if (!this->graph->valid(i.e)) { //Az igazi elek vegere ertunk 1353 if (this->graph->inTClass(v)) { //S, nincs beel 1323 1354 i.spec=3; 1324 1355 i.n=INVALID; … … 1334 1365 break; 1335 1366 case 2: //vmi->t 1336 graph->next(i.n);1337 if (! graph->valid(i.n)) i.spec=3;1367 this->graph->next(i.n); 1368 if (!this->graph->valid(i.n)) i.spec=3; 1338 1369 break; 1339 1370 } … … 1344 1375 switch (i.spec) { 1345 1376 case 0: 1346 graph->next(i.e);1347 if (! graph->valid(i.e)) {1377 this->graph->next(i.e); 1378 if (!this->graph->valid(i.e)) { 1348 1379 i.spec=1; 1349 graph->first(n, S_CLASS);1350 if (! graph->valid(i.n)) {1380 this->graph->first(i.n, S_CLASS); 1381 if (!this->graph->valid(i.n)) { 1351 1382 i.spec=2; 1352 graph->first(n, T_CLASS);1353 if (! graph->valid(i.n))spec=3;1383 this->graph->first(i.n, T_CLASS); 1384 if (!this->graph->valid(i.n)) i.spec=3; 1354 1385 } 1355 1386 } 1356 1387 break; 1357 1388 case 1: 1358 graph->next(i.n);1359 if (! graph->valid(i.n)) {1389 this->graph->next(i.n); 1390 if (!this->graph->valid(i.n)) { 1360 1391 i.spec=2; 1361 graph->first(n, T_CLASS);1362 if (! graph->valid(i.n))spec=3;1392 this->graph->first(i.n, T_CLASS); 1393 if (!this->graph->valid(i.n)) i.spec=3; 1363 1394 } 1364 1395 break; 1365 1396 case 2: 1366 graph->next(i.n);1367 if (! graph->valid(i.n)) i.spec=3;1397 this->graph->next(i.n); 1398 if (!this->graph->valid(i.n)) i.spec=3; 1368 1399 break; 1369 1400 } … … 1374 1405 switch (e.spec) { 1375 1406 case 0: 1376 return Node( graph->tail(e));1407 return Node(this->graph->tail(e)); 1377 1408 break; 1378 1409 case 1: … … 1387 1418 switch (e.spec) { 1388 1419 case 0: 1389 return Node( graph->head(e));1420 return Node(this->graph->head(e)); 1390 1421 break; 1391 1422 case 1: … … 1401 1432 bool valid(const Edge& e) const { return (e.spec<3); } 1402 1433 1403 // int nodeNum() const { return graph->nodeNum(); }1404 // int edgeNum() const { return graph->edgeNum(); }1434 // int nodeNum() const { return this->graph->nodeNum(); } 1435 // int edgeNum() const { return this->graph->edgeNum(); } 1405 1436 1406 1437 Node aNode(const OutEdgeIt& e) const { return tail(e); } … … 1409 1440 Node bNode(const InEdgeIt& e) const { return tail(e); } 1410 1441 1411 // Node addNode() const { return Node( graph->addNode()); }1442 // Node addNode() const { return Node(this->graph->addNode()); } 1412 1443 // Edge addEdge(const Node& tail, const Node& head) const { 1413 // return Edge( graph->addEdge(tail, head)); }1414 1415 // void erase(const Node& i) const { graph->erase(i); }1416 // void erase(const Edge& i) const { graph->erase(i); }1444 // return Edge(this->graph->addEdge(tail, head)); } 1445 1446 // void erase(const Node& i) const { this->graph->erase(i); } 1447 // void erase(const Edge& i) const { this->graph->erase(i); } 1417 1448 1418 // void clear() const { graph->clear(); }1449 // void clear() const { this->graph->clear(); } 1419 1450 1420 template<typename T> class NodeMap : public GraphWrapper<Graph>::NodeMap<T> { 1451 template<typename T> class NodeMap : public GraphWrapper<Graph>::template NodeMap<T> { 1452 typedef typename GraphWrapper<Graph>::template NodeMap<T> Parent; 1421 1453 T s_value, t_value; 1422 1454 public: 1423 NodeMap(const stGraphWrapper<Graph>& _G) : 1424 GraphWrapper<Graph>::NodeMap<T>(_G) { } 1425 NodeMap(const stGraphWrapper<Graph>& _G, T a) :1426 GraphWrapper<Graph>::NodeMap<T>(_G, a), s_value(a),t_value(a) { }1455 NodeMap(const stGraphWrapper<Graph>& _G) : Parent(_G) { } 1456 NodeMap(const stGraphWrapper<Graph>& _G, T a) : Parent(_G, a), 1457 s_value(a), 1458 t_value(a) { } 1427 1459 T operator[](const Node& n) const { 1428 1460 switch (n.spec) { … … 1441 1473 switch (n.spec) { 1442 1474 case 0: 1443 GraphWrapper<Graph>:: NodeMap<T>::set(n, t);1475 GraphWrapper<Graph>::template NodeMap<T>::set(n, t); 1444 1476 break; 1445 1477 case 1: … … 1453 1485 }; 1454 1486 1455 template<typename T> class EdgeMap : public GraphWrapper<Graph>::EdgeMap<T> { 1456 typename GraphWrapper<Graph>::NodeMap<T> node_value; 1457 public: 1458 EdgeMap(const stGraphWrapper<Graph>& _G) : 1459 GraphWrapper<Graph>::EdgeMap<T>(_G), node_value(_G) { } 1460 EdgeMap(const stGraphWrapper<Graph>& _G, T a) : 1461 GraphWrapper<Graph>::EdgeMap<T>(_G, a), node_value(_G, a) { } 1487 template<typename T> class EdgeMap : public GraphWrapper<Graph>::template EdgeMap<T> { 1488 typedef typename Graph::template NodeMap<T> Parent; 1489 typename GraphWrapper<Graph>::template NodeMap<T> node_value; 1490 public: 1491 EdgeMap(const stGraphWrapper<Graph>& _G) : Parent(_G), 1492 node_value(_G) { } 1493 EdgeMap(const stGraphWrapper<Graph>& _G, T a) : Parent(_G, a), 1494 node_value(_G, a) { } 1462 1495 T operator[](const Edge& e) const { 1463 1496 switch (e.spec) { -
src/work/marci/iterator_bfs_demo.cc
r360 r389 5 5 6 6 #include <list_graph.h> 7 #include <smart_graph.h>7 //#include <smart_graph.h> 8 8 #include <bfs_iterator.h> 9 9 #include <graph_wrapper.h> -
src/work/marci/makefile
r380 r389 1 1 CXX2 = g++-2.95 2 CXX3 := $(shell type -p g++-3.3 || type -p g++-3.2 || type -p g++-3.0 || type -p g++-3 || echo g++)3 CXX=$(CXX3)4 CC=$(CXX)2 #CXX3 := $(shell type -p g++-3.3 || type -p g++-3.2 || type -p g++-3.0 || type -p g++-3 || echo g++) 3 #CXX=$(CXX3) 4 #CC=$(CXX) 5 5 #LEDAROOT ?= /ledasrc/LEDA-4.1 6 6 BOOSTROOT ?= /home/marci/boost … … 13 13 #gw_vs_not preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar preflow_demo_leda 14 14 15 all: $(BINARIES) 15 include ../makefile 16 #all: $(BINARIES) 16 17 17 .depend dep depend:18 -$(CXX) $(INCLUDEDIRS) -M $(BINARIES:=.cc) > .depend #2>/dev/null18 #.depend dep depend: 19 # -$(CXX) $(INCLUDEDIRS) -M $(BINARIES:=.cc) > .depend #2>/dev/null 19 20 # -g++ $(INCLUDEDIRS) $(LEDAINCLUDE) -M $(LEDABINARIES:=.cc) >> .depend #2>/dev/null 20 21 21 22 22 23 23 makefile: .depend24 sinclude .depend24 #makefile: .depend 25 #sinclude .depend 25 26 26 27 leda_graph_demo.o: … … 73 74 $(CXX3) $(CXXFLAGS) -I. -I.. -I../athos -o preflow_demo_athos preflow_demo_athos.cc 74 75 75 clean:76 $(RM) *.o $(BINARIES) .depend77 78 .PHONY: all clean dep depend76 #clean: 77 # $(RM) *.o $(BINARIES) .depend 78 # 79 #.PHONY: all clean dep depend
Note: See TracChangeset
for help on using the changeset viewer.