Changeset 510:72143568cadc in lemon0.x
 Timestamp:
 05/03/04 12:04:27 (16 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@670
 Location:
 src/work
 Files:

 1 added
 4 edited
Legend:
 Unmodified
 Added
 Removed

src/work/jacint/max_flow.h
r488 r510 89 89 //typename Graph::template NodeMap<int> level; 90 90 typename Graph::template NodeMap<Num> excess; 91 // protected: 92 // MaxFlow() { } 93 // void set(const Graph& _G, Node _s, Node _t, const CapMap& _capacity, 94 // FlowMap& _flow) 95 // { 96 // g=&_G; 97 // s=_s; 98 // t=_t; 99 // capacity=&_capacity; 100 // flow=&_flow; 101 // n=_G.nodeNum; 102 // level.set (_G); //kellene vmi ilyesmi fv 103 // excess(_G,0); //itt is 104 // } 91 105 92 106 public: 
src/work/marci/bipartite_graph_wrapper.h
r502 r510 311 311 //invalid, 3, invalid) 312 312 template <typename T> class NodeMap; 313 template <typename T , typename Parent> class EdgeMap;313 template <typename T> class EdgeMap; 314 314 315 315 // template <typename T> friend class NodeMap; … … 386 386 friend class GraphWrapper<Graph>; 387 387 friend class stGraphWrapper<Graph>; 388 template <typename T , typename Parent> friend class EdgeMap;388 template <typename T> friend class EdgeMap; 389 389 int spec; 390 390 typename Graph::Node n; … … 413 413 friend std::ostream& operator<< (std::ostream& os, const Edge& i); 414 414 int getSpec() const { return spec; } 415 typename Graph::Node getNode() const { return n; } 415 416 }; 416 417 … … 703 704 template<typename T> class NodeMap : public GraphWrapper<Graph>::template NodeMap<T> { 704 705 typedef typename GraphWrapper<Graph>::template NodeMap<T> Parent; 706 protected: 705 707 T s_value, t_value; 706 708 public: … … 715 717 case 0: 716 718 return Parent::operator[](n); 717 break;718 719 case 1: 719 720 return s_value; 720 break;721 721 case 2: 722 722 default: 723 723 return t_value; 724 break;725 724 } 726 725 } … … 741 740 }; 742 741 743 template<typename T, 744 typename Parent= 745 typename GraphWrapper<Graph>::template EdgeMap<T> > 746 class EdgeMap : public Parent { 747 //typedef typename GraphWrapper<Graph>::template EdgeMap<T> Parent; 742 /// This class is to wrap a nodemap of \c Graph and two variables 743 /// storing values for \c S_NODE and \c T_NODE to a nodemap of 744 /// stGraphWrapper<Graph>. 745 template<typename NM> class NodeMapWrapper { 746 public: 747 typedef Node KeyType; 748 typedef typename NM::ValueType ValueType; 749 protected: 750 NM* nm; 751 ValueType* s_value, t_value; 752 public: 753 NodeMapWrapper(NM& _nm, ValueType& _s_value, ValueType& _t_value) : 754 nm(&_nm), s_value(&_s_value), t_value(&_t_value) { } 755 ValueType operator[](const Node& n) const { 756 switch (n.getSpec()) { 757 case 0: 758 return (*nm)[n]; 759 case 1: 760 return *s_value; 761 case 2: 762 default: 763 return *t_value; 764 } 765 } 766 void set(const Node& n, ValueType t) { 767 switch (n.getSpec()) { 768 case 0: 769 nm>set(n, t); 770 break; 771 case 1: 772 *s_value=t; 773 break; 774 case 2: 775 default: 776 *t_value=t; 777 break; 778 } 779 } 780 }; 781 782 template<typename T> 783 class EdgeMap : public GraphWrapper<Graph>::template EdgeMap<T> { 784 typedef typename GraphWrapper<Graph>::template EdgeMap<T> Parent; 785 protected: 748 786 typename GraphWrapper<Graph>::template NodeMap<T> node_value; 749 787 public: … … 756 794 case 0: 757 795 return Parent::operator[](e); 758 break;759 796 case 1: 760 797 return node_value[e.n]; 761 break;762 798 case 2: 763 799 default: 764 800 return node_value[e.n]; 765 break;766 801 } 767 802 } … … 782 817 }; 783 818 784 // template<typename T> class EdgeMap : public GraphWrapper<Graph>::template EdgeMap<T> { 785 // typedef typename GraphWrapper<Graph>::template EdgeMap<T> Parent; 786 // typename GraphWrapper<Graph>::template NodeMap<T> node_value; 787 // public: 788 // EdgeMap(const stGraphWrapper<Graph>& _G) : Parent(_G), 789 // node_value(_G) { } 790 // EdgeMap(const stGraphWrapper<Graph>& _G, T a) : Parent(_G, a), 791 // node_value(_G, a) { } 792 // T operator[](const Edge& e) const { 793 // switch (e.spec) { 794 // case 0: 795 // return Parent::operator[](e); 796 // break; 797 // case 1: 798 // return node_value[e.n]; 799 // break; 800 // case 2: 801 // default: 802 // return node_value[e.n]; 803 // break; 804 // } 805 // } 806 // void set(const Edge& e, T t) { 807 // switch (e.spec) { 808 // case 0: 809 // GraphWrapper<Graph>::template EdgeMap<T>::set(e, t); 810 // break; 811 // case 1: 812 // node_value.set(e.n, t); 813 // break; 814 // case 2: 815 // default: 816 // node_value.set(e.n, t); 817 // break; 818 // } 819 // } 820 // }; 819 /// This class is to wrap an edgemap and a nodemap of \c Graph 820 /// to an edgemap of stGraphWrapper<Graph>. 821 template<typename EM, typename NM> 822 class EdgeMapWrapper { 823 public: 824 typedef Edge KeyType; 825 typedef typename EM::ValueType ValueType; 826 protected: 827 EM* em; 828 NM* nm; 829 public: 830 EdgeMapWrapper(EM& _em, NM& _nm) : em(&_em), nm(&_nm) { } 831 ValueType operator[](const Edge& e) const { 832 switch (e.getSpec()) { 833 case 0: 834 return (*em)[e]; 835 case 1: 836 return (*nm)[e.getNode()]; 837 case 2: 838 default: 839 return (*nm)[e.getNode()]; 840 } 841 } 842 void set(const Edge& e, ValueType t) { 843 switch (e.getSpec()) { 844 case 0: 845 em>set(e, t); 846 break; 847 case 1: 848 nm>set(e.getNode(), t); 849 break; 850 case 2: 851 default: 852 nm>set(e.getNode(), t); 853 break; 854 } 855 } 856 }; 857 821 858 822 859 // template<typename G> … … 841 878 842 879 843 #endif //HUGO_ GRAPH_WRAPPER_H844 880 #endif //HUGO_BIPARTITE_GRAPH_WRAPPER_H 881 
src/work/marci/bipartite_matching_try_2.cc
r501 r510 73 73 } 74 74 75 std::cout << "Edges of the bipartite graph:" << std::endl;76 FOR_EACH_LOC(EdgeIt, e, g) std::cout << e << " ";77 std::cout << std::endl;75 // std::cout << "Edges of the bipartite graph:" << std::endl; 76 // FOR_EACH_LOC(EdgeIt, e, g) std::cout << e << " "; 77 // std::cout << std::endl; 78 78 79 std::cout << "Nodes:" << std::endl;80 FOR_EACH_LOC(Graph::NodeIt, v, g) std::cout << v << " ";81 std::cout << std::endl;82 std::cout << "Nodes in T:" << std::endl;83 FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";84 std::cout << std::endl;85 std::cout << "Nodes in S:" << std::endl;86 FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";87 std::cout << std::endl;79 // std::cout << "Nodes:" << std::endl; 80 // FOR_EACH_LOC(Graph::NodeIt, v, g) std::cout << v << " "; 81 // std::cout << std::endl; 82 // std::cout << "Nodes in T:" << std::endl; 83 // FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " "; 84 // std::cout << std::endl; 85 // std::cout << "Nodes in S:" << std::endl; 86 // FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " "; 87 // std::cout << std::endl; 88 88 89 std::cout << "Erasing the first node..." << std::endl;90 NodeIt n;91 g.first(n);92 g.erase(n);93 std::cout << "Nodes of the bipartite graph:" << std::endl;94 FOR_EACH_GLOB(n, g) std::cout << n << " ";95 std::cout << std::endl;89 // std::cout << "Erasing the first node..." << std::endl; 90 // NodeIt n; 91 // g.first(n); 92 // g.erase(n); 93 // std::cout << "Nodes of the bipartite graph:" << std::endl; 94 // FOR_EACH_GLOB(n, g) std::cout << n << " "; 95 // std::cout << std::endl; 96 96 97 std::cout << "Nodes in T:" << std::endl;98 FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " ";99 std::cout << std::endl;100 std::cout << "Nodes in S:" << std::endl;101 FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " ";102 std::cout << std::endl;97 // std::cout << "Nodes in T:" << std::endl; 98 // FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::T_CLASS) std::cout << v << " "; 99 // std::cout << std::endl; 100 // std::cout << "Nodes in S:" << std::endl; 101 // FOR_EACH_INC_LOC(Graph::ClassNodeIt, v, g, Graph::S_CLASS) std::cout << v << " "; 102 // std::cout << std::endl; 103 103 104 104 typedef stGraphWrapper<Graph> stGW; … … 120 120 std::cout << "max flow value: " << max_flow_test.flowValue() << std::endl; 121 121 std::cout << "elapsed time: " << ts << std::endl; 122 FOR_EACH_LOC(stGW::EdgeIt, e, stgw) {123 if (flow[e]) std::cout << e << std::endl;124 }125 std::cout << std::endl;122 // FOR_EACH_LOC(stGW::EdgeIt, e, stgw) { 123 // if (flow[e]) std::cout << e << std::endl; 124 // } 125 // std::cout << std::endl; 126 126 127 127 return 0; 
src/work/marci/makefile
r498 r510 5 5 6 6 LEDABINARIES = leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo 7 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 7 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 8 8 #gw_vs_not preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar preflow_demo_leda 9 9
Note: See TracChangeset
for help on using the changeset viewer.