src/work/marci/bipartite_graph_wrapper.h
changeset 497 500456d50d21
parent 496 7c463a7635d4
child 498 eb8bfa683d92
equal deleted inserted replaced
1:6f59c8a84dde 2:e4c2da8f611d
    24   /// graph or a directed graph with edges oriented from S to T.
    24   /// graph or a directed graph with edges oriented from S to T.
    25   ///
    25   ///
    26   ///\author Marton Makai
    26   ///\author Marton Makai
    27   template<typename Graph> 
    27   template<typename Graph> 
    28   class BipartiteGraphWrapper : public GraphWrapper<Graph> {
    28   class BipartiteGraphWrapper : public GraphWrapper<Graph> {
       
    29   protected:
    29     typedef IterableBoolMap< typename Graph::template NodeMap<int> > 
    30     typedef IterableBoolMap< typename Graph::template NodeMap<int> > 
    30     SFalseTTrueMap;
    31     SFalseTTrueMap;
    31     SFalseTTrueMap* s_false_t_true_map;
    32     SFalseTTrueMap* s_false_t_true_map;
       
    33 
       
    34     BipartiteGraphWrapper() : GraphWrapper<Graph>(0) { }
       
    35     void setSFalseTTrueMap(SFalseTTrueMap& _s_false_t_true_map) { 
       
    36       s_false_t_true_map=_s_false_t_true_map;
       
    37     }
    32 
    38 
    33   public:
    39   public:
    34     //marci
    40     //marci
    35     //FIXME vhogy igy kellene, csak az en forditom nem eszi meg
    41     //FIXME vhogy igy kellene, csak az en forditom nem eszi meg
    36     //static const bool S_CLASS=false;
    42     //static const bool S_CLASS=false;
   173     }
   179     }
   174     bool inTClass(const Node& n) const {
   180     bool inTClass(const Node& n) const {
   175       return (*(this->s_false_t_true_map))[n];
   181       return (*(this->s_false_t_true_map))[n];
   176     }
   182     }
   177   };
   183   };
       
   184 
       
   185   ///\bug Do not use this while the bipartitemap augmentation 
       
   186   /// does not work well.
       
   187   template<typename Graph>
       
   188   class BipartiteGraph : public BipartiteGraphWrapper<Graph> {
       
   189     typedef IterableBoolMap< typename Graph::template NodeMap<int> > 
       
   190     SFalseTTrueMap;
       
   191     typedef BipartiteGraphWrapper<Graph> Parent;
       
   192   protected:
       
   193     Graph gr;
       
   194     typename Graph::template NodeMap<int> bipartite_map;
       
   195     SFalseTTrueMap s_false_t_true_map;
       
   196   public:
       
   197     typedef typename Parent::Node Node;
       
   198     typedef typename Parent::Edge Edge;
       
   199     BipartiteGraph() : BipartiteGraphWrapper<Graph>(0), 
       
   200 		       gr(), bipartite_map(gr), 
       
   201 		       s_false_t_true_map(bipartite_map) { 
       
   202       Parent::setGraph(gr); 
       
   203       Parent::setSFalseTTrueMap(bipartite_map);
       
   204     }
       
   205 
       
   206     /// the \c bool parameter which can be \c S_Class or \c T_Class shows 
       
   207     /// the color class where the new node is to be inserted.
       
   208     void addNode(bool);
       
   209 
       
   210     /// A new edge is inserted.
       
   211     ///\pre \c tail have to be in \c S_Class and \c head in \c T_Class.
       
   212     void addEdge(const Node& tail, const Node& head);
       
   213 
       
   214     void erase(const Node&);
       
   215     void erase(const Edge&);
       
   216     
       
   217     void clear() {
       
   218       FOR_EACH_LOC(typename Parent::EdgeIt, e, G) erase(e);
       
   219       FOR_EACH_LOC(typename Parent::NodeIt, n, G) erase(n);
       
   220     }
       
   221   };
       
   222 
   178 
   223 
   179   template<typename Graph>
   224   template<typename Graph>
   180   class stGraphWrapper;
   225   class stGraphWrapper;
   181 
   226 
   182 //   template<typename Graph> 
   227 //   template<typename Graph>