lemon/ugraph_adaptor.h
changeset 2085 1970a93dfaa8
parent 2069 d55adbe1fc78
child 2087 67258b5a057b
equal deleted inserted replaced
8:7c788c95658d 9:989676e541fe
    36 
    36 
    37 #include <iostream>
    37 #include <iostream>
    38 
    38 
    39 namespace lemon {
    39 namespace lemon {
    40 
    40 
    41   /// \ingroup graph_adaptors
       
    42   ///
       
    43   /// \brief Base type for the Graph Adaptors
    41   /// \brief Base type for the Graph Adaptors
    44   ///
    42   ///
    45   /// This is the base type for most of LEMON graph adaptors. 
    43   /// This is the base type for most of LEMON graph adaptors. 
    46   /// This class implements a trivial graph adaptor i.e. it only wraps the 
    44   /// This class implements a trivial graph adaptor i.e. it only wraps the 
    47   /// functions and types of the graph. The purpose of this class is to 
    45   /// functions and types of the graph. The purpose of this class is to 
   231     };
   229     };
   232 
   230 
   233   };
   231   };
   234 
   232 
   235   /// \ingroup graph_adaptors
   233   /// \ingroup graph_adaptors
       
   234   ///
       
   235   /// \brief Trivial undirected graph adaptor
       
   236   ///
       
   237   /// This class is an adaptor which does not change the adapted undirected
       
   238   /// graph. It can be used only to test the undirected graph adaptors.
   236   template <typename _UGraph>
   239   template <typename _UGraph>
   237   class UGraphAdaptor 
   240   class UGraphAdaptor 
   238     : public UGraphAdaptorExtender< UGraphAdaptorBase<_UGraph> > { 
   241     : public UGraphAdaptorExtender< UGraphAdaptorBase<_UGraph> > { 
   239   public:
   242   public:
   240     typedef _UGraph Graph;
   243     typedef _UGraph Graph;
   346       Parent::nextInc(i, d); 
   349       Parent::nextInc(i, d); 
   347       while (i!=INVALID && (!(*uedge_filter_map)[i] 
   350       while (i!=INVALID && (!(*uedge_filter_map)[i] 
   348             || !(*node_filter_map)[Parent::source(i)])) Parent::nextInc(i, d); 
   351             || !(*node_filter_map)[Parent::source(i)])) Parent::nextInc(i, d); 
   349     }
   352     }
   350 
   353 
   351     ///\e
   354     /// \brief Hide the given node in the graph.
   352 
   355     ///
   353     /// This function hides \c n in the graph, i.e. the iteration 
   356     /// This function hides \c n in the graph, i.e. the iteration 
   354     /// jumps over it. This is done by simply setting the value of \c n  
   357     /// jumps over it. This is done by simply setting the value of \c n  
   355     /// to be false in the corresponding node-map.
   358     /// to be false in the corresponding node-map.
   356     void hide(const Node& n) const { node_filter_map->set(n, false); }
   359     void hide(const Node& n) const { node_filter_map->set(n, false); }
   357 
   360 
   358     ///\e
   361     /// \brief Hide the given undirected edge in the graph.
   359 
   362     ///
   360     /// This function hides \c e in the graph, i.e. the iteration 
   363     /// This function hides \c e in the graph, i.e. the iteration 
   361     /// jumps over it. This is done by simply setting the value of \c e  
   364     /// jumps over it. This is done by simply setting the value of \c e  
   362     /// to be false in the corresponding edge-map.
   365     /// to be false in the corresponding uedge-map.
   363     void hide(const UEdge& e) const { uedge_filter_map->set(e, false); }
   366     void hide(const UEdge& e) const { uedge_filter_map->set(e, false); }
   364 
   367 
   365     ///\e
   368     /// \brief Unhide the given node in the graph.
   366 
   369     ///
   367     /// The value of \c n is set to be true in the node-map which stores 
   370     /// The value of \c n is set to be true in the node-map which stores 
   368     /// hide information. If \c n was hidden previuosly, then it is shown 
   371     /// hide information. If \c n was hidden previuosly, then it is shown 
   369     /// again
   372     /// again
   370      void unHide(const Node& n) const { node_filter_map->set(n, true); }
   373      void unHide(const Node& n) const { node_filter_map->set(n, true); }
   371 
   374 
   372     ///\e
   375     /// \brief Hide the given undirected edge in the graph.
   373 
   376     ///
   374     /// The value of \c e is set to be true in the edge-map which stores 
   377     /// The value of \c e is set to be true in the uedge-map which stores 
   375     /// hide information. If \c e was hidden previuosly, then it is shown 
   378     /// hide information. If \c e was hidden previuosly, then it is shown 
   376     /// again
   379     /// again
   377     void unHide(const UEdge& e) const { uedge_filter_map->set(e, true); }
   380     void unHide(const UEdge& e) const { uedge_filter_map->set(e, true); }
   378 
   381 
       
   382     /// \brief Returns true if \c n is hidden.
       
   383     ///
   379     /// Returns true if \c n is hidden.
   384     /// Returns true if \c n is hidden.
   380     
       
   381     ///\e
       
   382     ///
       
   383     bool hidden(const Node& n) const { return !(*node_filter_map)[n]; }
   385     bool hidden(const Node& n) const { return !(*node_filter_map)[n]; }
   384 
   386 
   385     /// Returns true if \c n is hidden.
   387     /// \brief Returns true if \c e is hidden.
   386     
   388     ///
   387     ///\e
   389     /// Returns true if \c e is hidden.
   388     ///
       
   389     bool hidden(const UEdge& e) const { return !(*uedge_filter_map)[e]; }
   390     bool hidden(const UEdge& e) const { return !(*uedge_filter_map)[e]; }
   390 
   391 
   391     typedef False NodeNumTag;
   392     typedef False NodeNumTag;
   392     typedef False EdgeNumTag;
   393     typedef False EdgeNumTag;
   393 
   394 
   575     void nextInc(UEdge& i, bool& d) const { 
   576     void nextInc(UEdge& i, bool& d) const { 
   576       Parent::nextInc(i, d); 
   577       Parent::nextInc(i, d); 
   577       while (i!=INVALID && !(*uedge_filter_map)[i]) Parent::nextInc(i, d); 
   578       while (i!=INVALID && !(*uedge_filter_map)[i]) Parent::nextInc(i, d); 
   578     }
   579     }
   579 
   580 
   580     ///\e
   581     /// \brief Hide the given node in the graph.
   581 
   582     ///
   582     /// This function hides \c n in the graph, i.e. the iteration 
   583     /// This function hides \c n in the graph, i.e. the iteration 
   583     /// jumps over it. This is done by simply setting the value of \c n  
   584     /// jumps over it. This is done by simply setting the value of \c n  
   584     /// to be false in the corresponding node-map.
   585     /// to be false in the corresponding node-map.
   585     void hide(const Node& n) const { node_filter_map->set(n, false); }
   586     void hide(const Node& n) const { node_filter_map->set(n, false); }
   586 
   587 
   587     ///\e
   588     /// \brief Hide the given undirected edge in the graph.
   588 
   589     ///
   589     /// This function hides \c e in the graph, i.e. the iteration 
   590     /// This function hides \c e in the graph, i.e. the iteration 
   590     /// jumps over it. This is done by simply setting the value of \c e  
   591     /// jumps over it. This is done by simply setting the value of \c e  
   591     /// to be false in the corresponding edge-map.
   592     /// to be false in the corresponding uedge-map.
   592     void hide(const UEdge& e) const { uedge_filter_map->set(e, false); }
   593     void hide(const UEdge& e) const { uedge_filter_map->set(e, false); }
   593 
   594 
   594     ///\e
   595     /// \brief Unhide the given node in the graph.
   595 
   596     ///
   596     /// The value of \c n is set to be true in the node-map which stores 
   597     /// The value of \c n is set to be true in the node-map which stores 
   597     /// hide information. If \c n was hidden previuosly, then it is shown 
   598     /// hide information. If \c n was hidden previuosly, then it is shown 
   598     /// again
   599     /// again
   599      void unHide(const Node& n) const { node_filter_map->set(n, true); }
   600      void unHide(const Node& n) const { node_filter_map->set(n, true); }
   600 
   601 
   601     ///\e
   602     /// \brief Hide the given undirected edge in the graph.
   602 
   603     ///
   603     /// The value of \c e is set to be true in the edge-map which stores 
   604     /// The value of \c e is set to be true in the uedge-map which stores 
   604     /// hide information. If \c e was hidden previuosly, then it is shown 
   605     /// hide information. If \c e was hidden previuosly, then it is shown 
   605     /// again
   606     /// again
   606     void unHide(const UEdge& e) const { uedge_filter_map->set(e, true); }
   607     void unHide(const UEdge& e) const { uedge_filter_map->set(e, true); }
   607 
   608 
       
   609     /// \brief Returns true if \c n is hidden.
       
   610     ///
   608     /// Returns true if \c n is hidden.
   611     /// Returns true if \c n is hidden.
   609     
       
   610     ///\e
       
   611     ///
       
   612     bool hidden(const Node& n) const { return !(*node_filter_map)[n]; }
   612     bool hidden(const Node& n) const { return !(*node_filter_map)[n]; }
   613 
   613 
   614     /// Returns true if \c n is hidden.
   614     /// \brief Returns true if \c e is hidden.
   615     
   615     ///
   616     ///\e
   616     /// Returns true if \c e is hidden.
   617     ///
       
   618     bool hidden(const UEdge& e) const { return !(*uedge_filter_map)[e]; }
   617     bool hidden(const UEdge& e) const { return !(*uedge_filter_map)[e]; }
   619 
   618 
   620     typedef False NodeNumTag;
   619     typedef False NodeNumTag;
   621     typedef False EdgeNumTag;
   620     typedef False EdgeNumTag;
   622 
   621 
   731   /// edge-iterator cares only the filter on the edge-set.
   730   /// edge-iterator cares only the filter on the edge-set.
   732   /// This way the edge-map
   731   /// This way the edge-map
   733   /// should filter all edges which's source or target is filtered by the 
   732   /// should filter all edges which's source or target is filtered by the 
   734   /// node-filter.
   733   /// node-filter.
   735   ///
   734   ///
   736   /// Note that \c n is of type \c SubGA::NodeIt, but it can be converted to
       
   737   /// \c Graph::Node that is why \c g.id(n) can be applied.
       
   738   /// 
       
   739   template<typename _UGraph, typename NodeFilterMap, 
   735   template<typename _UGraph, typename NodeFilterMap, 
   740 	   typename UEdgeFilterMap, bool checked = true>
   736 	   typename UEdgeFilterMap, bool checked = true>
   741   class SubUGraphAdaptor : 
   737   class SubUGraphAdaptor : 
   742     public UGraphAdaptorExtender<
   738     public UGraphAdaptorExtender<
   743     SubUGraphAdaptorBase<_UGraph, NodeFilterMap, UEdgeFilterMap, checked> > {
   739     SubUGraphAdaptorBase<_UGraph, NodeFilterMap, UEdgeFilterMap, checked> > {