lemon/adaptors.h
changeset 446 d369e885d196
parent 416 76287c8caa26
child 447 3c0d39b6388c
equal deleted inserted replaced
0:24393885e9fc 2:be3781bdf4e6
    68     Node target(const Arc& a) const { return _digraph->target(a); }
    68     Node target(const Arc& a) const { return _digraph->target(a); }
    69 
    69 
    70     typedef NodeNumTagIndicator<Digraph> NodeNumTag;
    70     typedef NodeNumTagIndicator<Digraph> NodeNumTag;
    71     int nodeNum() const { return _digraph->nodeNum(); }
    71     int nodeNum() const { return _digraph->nodeNum(); }
    72 
    72 
    73     typedef EdgeNumTagIndicator<Digraph> EdgeNumTag;
    73     typedef ArcNumTagIndicator<Digraph> ArcNumTag;
    74     int arcNum() const { return _digraph->arcNum(); }
    74     int arcNum() const { return _digraph->arcNum(); }
    75 
    75 
    76     typedef FindEdgeTagIndicator<Digraph> FindEdgeTag;
    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) {
    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(); }
   196     Node target(const Arc& a) const { return _graph->target(a); }
   196     Node target(const Arc& a) const { return _graph->target(a); }
   197 
   197 
   198     typedef NodeNumTagIndicator<Graph> NodeNumTag;
   198     typedef NodeNumTagIndicator<Graph> NodeNumTag;
   199     int nodeNum() const { return _graph->nodeNum(); }
   199     int nodeNum() const { return _graph->nodeNum(); }
   200 
   200 
       
   201     typedef ArcNumTagIndicator<Graph> ArcNumTag;
       
   202     int arcNum() const { return _graph->arcNum(); }
       
   203 
   201     typedef EdgeNumTagIndicator<Graph> EdgeNumTag;
   204     typedef EdgeNumTagIndicator<Graph> EdgeNumTag;
   202     int arcNum() const { return _graph->arcNum(); }
       
   203     int edgeNum() const { return _graph->edgeNum(); }
   205     int edgeNum() const { return _graph->edgeNum(); }
   204 
   206 
   205     typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
   207     typedef FindArcTagIndicator<Graph> FindArcTag;
   206     Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) {
   208     Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) {
   207       return _graph->findArc(u, v, prev);
   209       return _graph->findArc(u, v, prev);
   208     }
   210     }
       
   211 
       
   212     typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
   209     Edge findEdge(const Node& u, const Node& v, const Edge& prev = INVALID) {
   213     Edge findEdge(const Node& u, const Node& v, const Edge& prev = INVALID) {
   210       return _graph->findEdge(u, v, prev);
   214       return _graph->findEdge(u, v, prev);
   211     }
   215     }
   212 
   216 
   213     Node addNode() { return _graph->addNode(); }
   217     Node addNode() { return _graph->addNode(); }
   328     Node source(const Arc& a) const { return Parent::target(a); }
   332     Node source(const Arc& a) const { return Parent::target(a); }
   329     Node target(const Arc& a) const { return Parent::source(a); }
   333     Node target(const Arc& a) const { return Parent::source(a); }
   330 
   334 
   331     Arc addArc(const Node& u, const Node& v) { return Parent::addArc(v, u); }
   335     Arc addArc(const Node& u, const Node& v) { return Parent::addArc(v, u); }
   332 
   336 
   333     typedef FindEdgeTagIndicator<Digraph> FindEdgeTag;
   337     typedef FindArcTagIndicator<Digraph> FindArcTag;
   334     Arc findArc(const Node& u, const Node& v,
   338     Arc findArc(const Node& u, const Node& v,
   335                 const Arc& prev = INVALID) {
   339                 const Arc& prev = INVALID) {
   336       return Parent::findArc(v, u, prev);
   340       return Parent::findArc(v, u, prev);
   337     }
   341     }
   338 
   342 
   465 
   469 
   466     bool hidden(const Node& n) const { return !(*_node_filter)[n]; }
   470     bool hidden(const Node& n) const { return !(*_node_filter)[n]; }
   467     bool hidden(const Arc& a) const { return !(*_arc_filter)[a]; }
   471     bool hidden(const Arc& a) const { return !(*_arc_filter)[a]; }
   468 
   472 
   469     typedef False NodeNumTag;
   473     typedef False NodeNumTag;
   470     typedef False EdgeNumTag;
   474     typedef False ArcNumTag;
   471 
   475 
   472     typedef FindEdgeTagIndicator<Digraph> FindEdgeTag;
   476     typedef FindArcTagIndicator<Digraph> FindArcTag;
   473     Arc findArc(const Node& source, const Node& target,
   477     Arc findArc(const Node& source, const Node& target,
   474                 const Arc& prev = INVALID) {
   478                 const Arc& prev = INVALID) {
   475       if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
   479       if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
   476         return INVALID;
   480         return INVALID;
   477       }
   481       }
   608 
   612 
   609     bool hidden(const Node& n) const { return !(*_node_filter)[n]; }
   613     bool hidden(const Node& n) const { return !(*_node_filter)[n]; }
   610     bool hidden(const Arc& e) const { return !(*_arc_filter)[e]; }
   614     bool hidden(const Arc& e) const { return !(*_arc_filter)[e]; }
   611 
   615 
   612     typedef False NodeNumTag;
   616     typedef False NodeNumTag;
   613     typedef False EdgeNumTag;
   617     typedef False ArcNumTag;
   614 
   618 
   615     typedef FindEdgeTagIndicator<Digraph> FindEdgeTag;
   619     typedef FindArcTagIndicator<Digraph> FindArcTag;
   616     Arc findArc(const Node& source, const Node& target,
   620     Arc findArc(const Node& source, const Node& target,
   617                 const Arc& prev = INVALID) {
   621                 const Arc& prev = INVALID) {
   618       if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
   622       if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
   619         return INVALID;
   623         return INVALID;
   620       }
   624       }
   933 
   937 
   934     bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; }
   938     bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; }
   935     bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; }
   939     bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; }
   936 
   940 
   937     typedef False NodeNumTag;
   941     typedef False NodeNumTag;
       
   942     typedef False ArcNumTag;
   938     typedef False EdgeNumTag;
   943     typedef False EdgeNumTag;
   939 
   944 
   940     typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
   945     typedef FindArcTagIndicator<Graph> FindArcTag;
   941     Arc findArc(const Node& u, const Node& v,
   946     Arc findArc(const Node& u, const Node& v,
   942                 const Arc& prev = INVALID) {
   947                 const Arc& prev = INVALID) {
   943       if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) {
   948       if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) {
   944         return INVALID;
   949         return INVALID;
   945       }
   950       }
   947       while (arc != INVALID && !(*_edge_filter_map)[arc]) {
   952       while (arc != INVALID && !(*_edge_filter_map)[arc]) {
   948         arc = Parent::findArc(u, v, arc);
   953         arc = Parent::findArc(u, v, arc);
   949       }
   954       }
   950       return arc;
   955       return arc;
   951     }
   956     }
       
   957 
       
   958     typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
   952     Edge findEdge(const Node& u, const Node& v,
   959     Edge findEdge(const Node& u, const Node& v,
   953                   const Edge& prev = INVALID) {
   960                   const Edge& prev = INVALID) {
   954       if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) {
   961       if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) {
   955         return INVALID;
   962         return INVALID;
   956       }
   963       }
  1129 
  1136 
  1130     bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; }
  1137     bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; }
  1131     bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; }
  1138     bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; }
  1132 
  1139 
  1133     typedef False NodeNumTag;
  1140     typedef False NodeNumTag;
       
  1141     typedef False ArcNumTag;
  1134     typedef False EdgeNumTag;
  1142     typedef False EdgeNumTag;
  1135 
  1143 
  1136     typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
  1144     typedef FindArcTagIndicator<Graph> FindArcTag;
  1137     Arc findArc(const Node& u, const Node& v,
  1145     Arc findArc(const Node& u, const Node& v,
  1138                 const Arc& prev = INVALID) {
  1146                 const Arc& prev = INVALID) {
  1139       Arc arc = Parent::findArc(u, v, prev);
  1147       Arc arc = Parent::findArc(u, v, prev);
  1140       while (arc != INVALID && !(*_edge_filter_map)[arc]) {
  1148       while (arc != INVALID && !(*_edge_filter_map)[arc]) {
  1141         arc = Parent::findArc(u, v, arc);
  1149         arc = Parent::findArc(u, v, arc);
  1142       }
  1150       }
  1143       return arc;
  1151       return arc;
  1144     }
  1152     }
       
  1153 
       
  1154     typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
  1145     Edge findEdge(const Node& u, const Node& v,
  1155     Edge findEdge(const Node& u, const Node& v,
  1146                   const Edge& prev = INVALID) {
  1156                   const Edge& prev = INVALID) {
  1147       Edge edge = Parent::findEdge(u, v, prev);
  1157       Edge edge = Parent::findEdge(u, v, prev);
  1148       while (edge != INVALID && !(*_edge_filter_map)[edge]) {
  1158       while (edge != INVALID && !(*_edge_filter_map)[edge]) {
  1149         edge = Parent::findEdge(u, v, edge);
  1159         edge = Parent::findEdge(u, v, edge);
  1844 
  1854 
  1845     void clear() { _digraph->clear(); }
  1855     void clear() { _digraph->clear(); }
  1846 
  1856 
  1847     typedef NodeNumTagIndicator<Digraph> NodeNumTag;
  1857     typedef NodeNumTagIndicator<Digraph> NodeNumTag;
  1848     int nodeNum() const { return 2 * _digraph->arcNum(); }
  1858     int nodeNum() const { return 2 * _digraph->arcNum(); }
  1849     typedef EdgeNumTagIndicator<Digraph> EdgeNumTag;
  1859 
       
  1860     typedef ArcNumTagIndicator<Digraph> ArcNumTag;
  1850     int arcNum() const { return 2 * _digraph->arcNum(); }
  1861     int arcNum() const { return 2 * _digraph->arcNum(); }
       
  1862 
       
  1863     typedef ArcNumTag EdgeNumTag;
  1851     int edgeNum() const { return _digraph->arcNum(); }
  1864     int edgeNum() const { return _digraph->arcNum(); }
  1852 
  1865 
  1853     typedef FindEdgeTagIndicator<Digraph> FindEdgeTag;
  1866     typedef FindArcTagIndicator<Digraph> FindArcTag;
  1854     Arc findArc(Node s, Node t, Arc p = INVALID) const {
  1867     Arc findArc(Node s, Node t, Arc p = INVALID) const {
  1855       if (p == INVALID) {
  1868       if (p == INVALID) {
  1856         Edge arc = _digraph->findArc(s, t);
  1869         Edge arc = _digraph->findArc(s, t);
  1857         if (arc != INVALID) return direct(arc, true);
  1870         if (arc != INVALID) return direct(arc, true);
  1858         arc = _digraph->findArc(t, s);
  1871         arc = _digraph->findArc(t, s);
  1867         if (arc != INVALID) return direct(arc, false);
  1880         if (arc != INVALID) return direct(arc, false);
  1868       }
  1881       }
  1869       return INVALID;
  1882       return INVALID;
  1870     }
  1883     }
  1871 
  1884 
       
  1885     typedef FindArcTag FindEdgeTag;
  1872     Edge findEdge(Node s, Node t, Edge p = INVALID) const {
  1886     Edge findEdge(Node s, Node t, Edge p = INVALID) const {
  1873       if (s != t) {
  1887       if (s != t) {
  1874         if (p == INVALID) {
  1888         if (p == INVALID) {
  1875           Edge arc = _digraph->findArc(s, t);
  1889           Edge arc = _digraph->findArc(s, t);
  1876           if (arc != INVALID) return arc;
  1890           if (arc != INVALID) return arc;
  2222     }
  2236     }
  2223 
  2237 
  2224     typedef NodeNumTagIndicator<Graph> NodeNumTag;
  2238     typedef NodeNumTagIndicator<Graph> NodeNumTag;
  2225     int nodeNum() const { return _graph->nodeNum(); }
  2239     int nodeNum() const { return _graph->nodeNum(); }
  2226 
  2240 
  2227     typedef EdgeNumTagIndicator<Graph> EdgeNumTag;
  2241     typedef EdgeNumTagIndicator<Graph> ArcNumTag;
  2228     int arcNum() const { return _graph->edgeNum(); }
  2242     int arcNum() const { return _graph->edgeNum(); }
  2229 
  2243 
  2230     typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
  2244     typedef FindEdgeTagIndicator<Graph> FindArcTag;
  2231     Arc findArc(const Node& u, const Node& v,
  2245     Arc findArc(const Node& u, const Node& v,
  2232                 const Arc& prev = INVALID) {
  2246                 const Arc& prev = INVALID) {
  2233       Arc arc = prev;
  2247       Arc arc = prev;
  2234       bool d = arc == INVALID ? true : (*_direction)[arc];
  2248       bool d = arc == INVALID ? true : (*_direction)[arc];
  2235       if (d) {
  2249       if (d) {
  2882     static Arc arc(const DigraphArc& e) {
  2896     static Arc arc(const DigraphArc& e) {
  2883       return Arc(e);
  2897       return Arc(e);
  2884     }
  2898     }
  2885 
  2899 
  2886     typedef True NodeNumTag;
  2900     typedef True NodeNumTag;
  2887 
       
  2888     int nodeNum() const {
  2901     int nodeNum() const {
  2889       return  2 * countNodes(*_digraph);
  2902       return  2 * countNodes(*_digraph);
  2890     }
  2903     }
  2891 
  2904 
  2892     typedef True EdgeNumTag;
  2905     typedef True ArcNumTag;
  2893     int arcNum() const {
  2906     int arcNum() const {
  2894       return countArcs(*_digraph) + countNodes(*_digraph);
  2907       return countArcs(*_digraph) + countNodes(*_digraph);
  2895     }
  2908     }
  2896 
  2909 
  2897     typedef True FindEdgeTag;
  2910     typedef True FindArcTag;
  2898     Arc findArc(const Node& u, const Node& v,
  2911     Arc findArc(const Node& u, const Node& v,
  2899                 const Arc& prev = INVALID) const {
  2912                 const Arc& prev = INVALID) const {
  2900       if (inNode(u)) {
  2913       if (inNode(u)) {
  2901         if (outNode(v)) {
  2914         if (outNode(v)) {
  2902           if (static_cast<const DigraphNode&>(u) ==
  2915           if (static_cast<const DigraphNode&>(u) ==