lemon/adaptors.h
changeset 448 9d9990909fc8
parent 447 3c0d39b6388c
child 449 91fcb8ed4cdc
equal deleted inserted replaced
3:efbe29bf9269 4:c3396240dba8
    72 
    72 
    73     typedef ArcNumTagIndicator<Digraph> ArcNumTag;
    73     typedef ArcNumTagIndicator<Digraph> ArcNumTag;
    74     int arcNum() const { return _digraph->arcNum(); }
    74     int arcNum() const { return _digraph->arcNum(); }
    75 
    75 
    76     typedef FindArcTagIndicator<Digraph> FindArcTag;
    76     typedef FindArcTagIndicator<Digraph> FindArcTag;
    77     Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) {
    77     Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) const {
    78       return _digraph->findArc(u, v, prev);
    78       return _digraph->findArc(u, v, prev);
    79     }
    79     }
    80 
    80 
    81     Node addNode() { return _digraph->addNode(); }
    81     Node addNode() { return _digraph->addNode(); }
    82     Arc addArc(const Node& u, const Node& v) { return _digraph->addArc(u, v); }
    82     Arc addArc(const Node& u, const Node& v) { return _digraph->addArc(u, v); }
    83 
    83 
    84     void erase(const Node& n) const { _digraph->erase(n); }
    84     void erase(const Node& n) { _digraph->erase(n); }
    85     void erase(const Arc& a) const { _digraph->erase(a); }
    85     void erase(const Arc& a) { _digraph->erase(a); }
    86 
    86 
    87     void clear() const { _digraph->clear(); }
    87     void clear() { _digraph->clear(); }
    88 
    88 
    89     int id(const Node& n) const { return _digraph->id(n); }
    89     int id(const Node& n) const { return _digraph->id(n); }
    90     int id(const Arc& a) const { return _digraph->id(a); }
    90     int id(const Arc& a) const { return _digraph->id(a); }
    91 
    91 
    92     Node nodeFromId(int ix) const { return _digraph->nodeFromId(ix); }
    92     Node nodeFromId(int ix) const { return _digraph->nodeFromId(ix); }
   203 
   203 
   204     typedef EdgeNumTagIndicator<Graph> EdgeNumTag;
   204     typedef EdgeNumTagIndicator<Graph> EdgeNumTag;
   205     int edgeNum() const { return _graph->edgeNum(); }
   205     int edgeNum() const { return _graph->edgeNum(); }
   206 
   206 
   207     typedef FindArcTagIndicator<Graph> FindArcTag;
   207     typedef FindArcTagIndicator<Graph> FindArcTag;
   208     Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) {
   208     Arc findArc(const Node& u, const Node& v,
       
   209                 const Arc& prev = INVALID) const {
   209       return _graph->findArc(u, v, prev);
   210       return _graph->findArc(u, v, prev);
   210     }
   211     }
   211 
   212 
   212     typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
   213     typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
   213     Edge findEdge(const Node& u, const Node& v, const Edge& prev = INVALID) {
   214     Edge findEdge(const Node& u, const Node& v,
       
   215                   const Edge& prev = INVALID) const {
   214       return _graph->findEdge(u, v, prev);
   216       return _graph->findEdge(u, v, prev);
   215     }
   217     }
   216 
   218 
   217     Node addNode() { return _graph->addNode(); }
   219     Node addNode() { return _graph->addNode(); }
   218     Edge addEdge(const Node& u, const Node& v) { return _graph->addEdge(u, v); }
   220     Edge addEdge(const Node& u, const Node& v) { return _graph->addEdge(u, v); }
   334 
   336 
   335     Arc addArc(const Node& u, const Node& v) { return Parent::addArc(v, u); }
   337     Arc addArc(const Node& u, const Node& v) { return Parent::addArc(v, u); }
   336 
   338 
   337     typedef FindArcTagIndicator<Digraph> FindArcTag;
   339     typedef FindArcTagIndicator<Digraph> FindArcTag;
   338     Arc findArc(const Node& u, const Node& v,
   340     Arc findArc(const Node& u, const Node& v,
   339                 const Arc& prev = INVALID) {
   341                 const Arc& prev = INVALID) const {
   340       return Parent::findArc(v, u, prev);
   342       return Parent::findArc(v, u, prev);
   341     }
   343     }
   342 
   344 
   343   };
   345   };
   344 
   346 
   473     typedef False NodeNumTag;
   475     typedef False NodeNumTag;
   474     typedef False ArcNumTag;
   476     typedef False ArcNumTag;
   475 
   477 
   476     typedef FindArcTagIndicator<Digraph> FindArcTag;
   478     typedef FindArcTagIndicator<Digraph> FindArcTag;
   477     Arc findArc(const Node& source, const Node& target,
   479     Arc findArc(const Node& source, const Node& target,
   478                 const Arc& prev = INVALID) {
   480                 const Arc& prev = INVALID) const {
   479       if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
   481       if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
   480         return INVALID;
   482         return INVALID;
   481       }
   483       }
   482       Arc arc = Parent::findArc(source, target, prev);
   484       Arc arc = Parent::findArc(source, target, prev);
   483       while (arc != INVALID && !(*_arc_filter)[arc]) {
   485       while (arc != INVALID && !(*_arc_filter)[arc]) {
   616     typedef False NodeNumTag;
   618     typedef False NodeNumTag;
   617     typedef False ArcNumTag;
   619     typedef False ArcNumTag;
   618 
   620 
   619     typedef FindArcTagIndicator<Digraph> FindArcTag;
   621     typedef FindArcTagIndicator<Digraph> FindArcTag;
   620     Arc findArc(const Node& source, const Node& target,
   622     Arc findArc(const Node& source, const Node& target,
   621                 const Arc& prev = INVALID) {
   623                 const Arc& prev = INVALID) const {
   622       if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
   624       if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
   623         return INVALID;
   625         return INVALID;
   624       }
   626       }
   625       Arc arc = Parent::findArc(source, target, prev);
   627       Arc arc = Parent::findArc(source, target, prev);
   626       while (arc != INVALID && !(*_arc_filter)[arc]) {
   628       while (arc != INVALID && !(*_arc_filter)[arc]) {
   942     typedef False ArcNumTag;
   944     typedef False ArcNumTag;
   943     typedef False EdgeNumTag;
   945     typedef False EdgeNumTag;
   944 
   946 
   945     typedef FindArcTagIndicator<Graph> FindArcTag;
   947     typedef FindArcTagIndicator<Graph> FindArcTag;
   946     Arc findArc(const Node& u, const Node& v,
   948     Arc findArc(const Node& u, const Node& v,
   947                 const Arc& prev = INVALID) {
   949                 const Arc& prev = INVALID) const {
   948       if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) {
   950       if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) {
   949         return INVALID;
   951         return INVALID;
   950       }
   952       }
   951       Arc arc = Parent::findArc(u, v, prev);
   953       Arc arc = Parent::findArc(u, v, prev);
   952       while (arc != INVALID && !(*_edge_filter_map)[arc]) {
   954       while (arc != INVALID && !(*_edge_filter_map)[arc]) {
   955       return arc;
   957       return arc;
   956     }
   958     }
   957 
   959 
   958     typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
   960     typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
   959     Edge findEdge(const Node& u, const Node& v,
   961     Edge findEdge(const Node& u, const Node& v,
   960                   const Edge& prev = INVALID) {
   962                   const Edge& prev = INVALID) const {
   961       if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) {
   963       if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) {
   962         return INVALID;
   964         return INVALID;
   963       }
   965       }
   964       Edge edge = Parent::findEdge(u, v, prev);
   966       Edge edge = Parent::findEdge(u, v, prev);
   965       while (edge != INVALID && !(*_edge_filter_map)[edge]) {
   967       while (edge != INVALID && !(*_edge_filter_map)[edge]) {
  1141     typedef False ArcNumTag;
  1143     typedef False ArcNumTag;
  1142     typedef False EdgeNumTag;
  1144     typedef False EdgeNumTag;
  1143 
  1145 
  1144     typedef FindArcTagIndicator<Graph> FindArcTag;
  1146     typedef FindArcTagIndicator<Graph> FindArcTag;
  1145     Arc findArc(const Node& u, const Node& v,
  1147     Arc findArc(const Node& u, const Node& v,
  1146                 const Arc& prev = INVALID) {
  1148                 const Arc& prev = INVALID) const {
  1147       Arc arc = Parent::findArc(u, v, prev);
  1149       Arc arc = Parent::findArc(u, v, prev);
  1148       while (arc != INVALID && !(*_edge_filter_map)[arc]) {
  1150       while (arc != INVALID && !(*_edge_filter_map)[arc]) {
  1149         arc = Parent::findArc(u, v, arc);
  1151         arc = Parent::findArc(u, v, arc);
  1150       }
  1152       }
  1151       return arc;
  1153       return arc;
  1152     }
  1154     }
  1153 
  1155 
  1154     typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
  1156     typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
  1155     Edge findEdge(const Node& u, const Node& v,
  1157     Edge findEdge(const Node& u, const Node& v,
  1156                   const Edge& prev = INVALID) {
  1158                   const Edge& prev = INVALID) const {
  1157       Edge edge = Parent::findEdge(u, v, prev);
  1159       Edge edge = Parent::findEdge(u, v, prev);
  1158       while (edge != INVALID && !(*_edge_filter_map)[edge]) {
  1160       while (edge != INVALID && !(*_edge_filter_map)[edge]) {
  1159         edge = Parent::findEdge(u, v, edge);
  1161         edge = Parent::findEdge(u, v, edge);
  1160       }
  1162       }
  1161       return edge;
  1163       return edge;
  2241     typedef EdgeNumTagIndicator<Graph> ArcNumTag;
  2243     typedef EdgeNumTagIndicator<Graph> ArcNumTag;
  2242     int arcNum() const { return _graph->edgeNum(); }
  2244     int arcNum() const { return _graph->edgeNum(); }
  2243 
  2245 
  2244     typedef FindEdgeTagIndicator<Graph> FindArcTag;
  2246     typedef FindEdgeTagIndicator<Graph> FindArcTag;
  2245     Arc findArc(const Node& u, const Node& v,
  2247     Arc findArc(const Node& u, const Node& v,
  2246                 const Arc& prev = INVALID) {
  2248                 const Arc& prev = INVALID) const {
  2247       Arc arc = prev;
  2249       Arc arc = prev;
  2248       bool d = arc == INVALID ? true : (*_direction)[arc];
  2250       bool d = arc == INVALID ? true : (*_direction)[arc];
  2249       if (d) {
  2251       if (d) {
  2250         arc = _graph->findEdge(u, v, arc);
  2252         arc = _graph->findEdge(u, v, arc);
  2251         while (arc != INVALID && !(*_direction)[arc]) {
  2253         while (arc != INVALID && !(*_direction)[arc]) {
  3095   ///
  3097   ///
  3096   /// \tparam _Digraph It must be conform to the \ref concepts::Digraph
  3098   /// \tparam _Digraph It must be conform to the \ref concepts::Digraph
  3097   /// "Digraph concept". The type can be specified to be const.
  3099   /// "Digraph concept". The type can be specified to be const.
  3098   template <typename _Digraph>
  3100   template <typename _Digraph>
  3099   class SplitNodes
  3101   class SplitNodes
  3100     : public DigraphAdaptorExtender<SplitNodesBase<_Digraph> > {
  3102     : public DigraphAdaptorExtender<SplitNodesBase<const _Digraph> > {
  3101   public:
  3103   public:
  3102     typedef _Digraph Digraph;
  3104     typedef _Digraph Digraph;
  3103     typedef DigraphAdaptorExtender<SplitNodesBase<Digraph> > Parent;
  3105     typedef DigraphAdaptorExtender<SplitNodesBase<const Digraph> > Parent;
  3104 
  3106 
  3105     typedef typename Digraph::Node DigraphNode;
  3107     typedef typename Digraph::Node DigraphNode;
  3106     typedef typename Digraph::Arc DigraphArc;
  3108     typedef typename Digraph::Arc DigraphArc;
  3107 
  3109 
  3108     typedef typename Parent::Node Node;
  3110     typedef typename Parent::Node Node;
  3109     typedef typename Parent::Arc Arc;
  3111     typedef typename Parent::Arc Arc;
  3110 
  3112 
  3111     /// \brief Constructor of the adaptor.
  3113     /// \brief Constructor of the adaptor.
  3112     ///
  3114     ///
  3113     /// Constructor of the adaptor.
  3115     /// Constructor of the adaptor.
  3114     SplitNodes(Digraph& g) {
  3116     SplitNodes(const Digraph& g) {
  3115       Parent::setDigraph(g);
  3117       Parent::setDigraph(g);
  3116     }
  3118     }
  3117 
  3119 
  3118     /// \brief Returns true when the node is in-node.
  3120     /// \brief Returns true when the node is in-node.
  3119     ///
  3121     ///