src/work/marci/bipartite_graph_wrapper.h
changeset 1002 ea3ecb3c9846
parent 986 e997802b855c
equal deleted inserted replaced
17:c17a262e6422 18:7bb85981283e
   792     /// This class is to wrap a node-map of \c Graph and two variables 
   792     /// This class is to wrap a node-map of \c Graph and two variables 
   793     /// storing values for \c S_NODE and \c T_NODE to a node-map of 
   793     /// storing values for \c S_NODE and \c T_NODE to a node-map of 
   794     /// stGraphWrapper<Graph, sIterableMap, tIterableMap>.
   794     /// stGraphWrapper<Graph, sIterableMap, tIterableMap>.
   795     template<typename NM> class NodeMapWrapper { 
   795     template<typename NM> class NodeMapWrapper { 
   796     public:
   796     public:
   797       typedef Node KeyType;
   797       typedef Node Key;
   798       typedef typename NM::ValueType ValueType;
   798       typedef typename NM::Value Value;
   799     protected:
   799     protected:
   800       NM* nm;
   800       NM* nm;
   801       ValueType* s_value, t_value;
   801       Value* s_value, t_value;
   802     public:
   802     public:
   803       NodeMapWrapper(NM& _nm, ValueType& _s_value, ValueType& _t_value) : 
   803       NodeMapWrapper(NM& _nm, Value& _s_value, Value& _t_value) : 
   804 	nm(&_nm), s_value(&_s_value), t_value(&_t_value) { }
   804 	nm(&_nm), s_value(&_s_value), t_value(&_t_value) { }
   805       ValueType operator[](const Node& n) const { 
   805       Value operator[](const Node& n) const { 
   806 	switch (n.getSpec()) {
   806 	switch (n.getSpec()) {
   807 	case 0: 
   807 	case 0: 
   808 	  return (*nm)[n];
   808 	  return (*nm)[n];
   809 	case 1:
   809 	case 1:
   810 	  return *s_value;
   810 	  return *s_value;
   811 	case 2: 
   811 	case 2: 
   812 	default:
   812 	default:
   813 	  return *t_value;
   813 	  return *t_value;
   814 	}
   814 	}
   815       }
   815       }
   816       void set(const Node& n, ValueType t) { 
   816       void set(const Node& n, Value t) { 
   817 	switch (n.getSpec()) {
   817 	switch (n.getSpec()) {
   818 	case 0: 
   818 	case 0: 
   819 	  nm->set(n, t);
   819 	  nm->set(n, t);
   820 	  break;
   820 	  break;
   821 	case 1:
   821 	case 1:
   871     /// This class is to wrap an edge-map and a node-map of \c Graph 
   871     /// This class is to wrap an edge-map and a node-map of \c Graph 
   872     /// to an edge-map of stGraphWrapper<Graph, sIterableMap, tIterableMap>.
   872     /// to an edge-map of stGraphWrapper<Graph, sIterableMap, tIterableMap>.
   873     template<typename EM, typename NM> 
   873     template<typename EM, typename NM> 
   874     class EdgeMapWrapper {
   874     class EdgeMapWrapper {
   875     public: 
   875     public: 
   876       typedef Edge KeyType;
   876       typedef Edge Key;
   877       typedef typename EM::ValueType ValueType;
   877       typedef typename EM::Value Value;
   878     protected:
   878     protected:
   879       EM* em;
   879       EM* em;
   880       NM* nm;
   880       NM* nm;
   881     public:
   881     public:
   882       EdgeMapWrapper(EM& _em, NM& _nm) : em(&_em), nm(&_nm) { }
   882       EdgeMapWrapper(EM& _em, NM& _nm) : em(&_em), nm(&_nm) { }
   883       ValueType operator[](const Edge& e) const { 
   883       Value operator[](const Edge& e) const { 
   884 	switch (e.getSpec()) {
   884 	switch (e.getSpec()) {
   885 	case 0: 
   885 	case 0: 
   886 	  return (*em)[e];
   886 	  return (*em)[e];
   887 	case 1:
   887 	case 1:
   888 	  return (*nm)[e.getNode()];
   888 	  return (*nm)[e.getNode()];
   889 	case 2:
   889 	case 2:
   890 	default:
   890 	default:
   891 	  return (*nm)[e.getNode()];
   891 	  return (*nm)[e.getNode()];
   892 	}
   892 	}
   893       }
   893       }
   894       void set(const Edge& e, ValueType t) { 
   894       void set(const Edge& e, Value t) { 
   895 	switch (e.getSpec()) {
   895 	switch (e.getSpec()) {
   896 	case 0: 
   896 	case 0: 
   897 	  em->set(e, t);
   897 	  em->set(e, t);
   898 	  break;
   898 	  break;
   899 	case 1:
   899 	case 1: