COIN-OR::LEMON - Graph Library

Ticket #67: adaptor-rename-aea2dc0518ce.patch

File adaptor-rename-aea2dc0518ce.patch, 17.7 KB (added by Peter Kovacs, 16 years ago)
  • lemon/adaptors.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1231506205 -3600
    # Node ID aea2dc0518cefa8e0816ff95f46ec10d9eb87253
    # Parent  fbd6e04acf442526df6438491a1bd212bbee43fe
    Rename convenience functions in subgraph adaptors (#67)
    
     - Rename hide(), unHide() to disable(), enable().
     - Add new set function status(Item, bool).
     - Remove hidden() and add status() instead
       (which returns the opposite value).
    
    diff --git a/lemon/adaptors.h b/lemon/adaptors.h
    a b  
    474474        Parent::nextOut(i);
    475475    }
    476476
    477     void hide(const Node& n) const { _node_filter->set(n, false); }
    478     void hide(const Arc& a) const { _arc_filter->set(a, false); }
     477    void status(const Node& n, bool v) const { _node_filter->set(n, v); }
     478    void status(const Arc& a, bool v) const { _arc_filter->set(a, v); }
    479479
    480     void unHide(const Node& n) const { _node_filter->set(n, true); }
    481     void unHide(const Arc& a) const { _arc_filter->set(a, true); }
    482 
    483     bool hidden(const Node& n) const { return !(*_node_filter)[n]; }
    484     bool hidden(const Arc& a) const { return !(*_arc_filter)[a]; }
     480    bool status(const Node& n) const { return (*_node_filter)[n]; }
     481    bool status(const Arc& a) const { return (*_arc_filter)[a]; }
    485482
    486483    typedef False NodeNumTag;
    487484    typedef False ArcNumTag;
     
    617614      while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextOut(i);
    618615    }
    619616
    620     void hide(const Node& n) const { _node_filter->set(n, false); }
    621     void hide(const Arc& e) const { _arc_filter->set(e, false); }
     617    void status(const Node& n, bool v) const { _node_filter->set(n, v); }
     618    void status(const Arc& a, bool v) const { _arc_filter->set(a, v); }
    622619
    623     void unHide(const Node& n) const { _node_filter->set(n, true); }
    624     void unHide(const Arc& e) const { _arc_filter->set(e, true); }
    625 
    626     bool hidden(const Node& n) const { return !(*_node_filter)[n]; }
    627     bool hidden(const Arc& e) const { return !(*_arc_filter)[e]; }
     620    bool status(const Node& n) const { return (*_node_filter)[n]; }
     621    bool status(const Arc& a) const { return (*_arc_filter)[a]; }
    628622
    629623    typedef False NodeNumTag;
    630624    typedef False ArcNumTag;
     
    774768      setArcFilterMap(arc_filter);
    775769    }
    776770
    777     /// \brief Hides the given node
     771    /// \brief Sets the status of the given node
    778772    ///
    779     /// This function hides the given node in the subdigraph,
    780     /// i.e. the iteration jumps over it.
     773    /// This function sets the status of the given node.
    781774    /// It is done by simply setting the assigned value of \c n
    782     /// to be \c false in the node filter map.
    783     void hide(const Node& n) const { Parent::hide(n); }
     775    /// to \c v in the node filter map.
     776    void status(const Node& n, bool v) const { Parent::status(n, v); }
    784777
    785     /// \brief Hides the given arc
     778    /// \brief Sets the status of the given arc
    786779    ///
    787     /// This function hides the given arc in the subdigraph,
    788     /// i.e. the iteration jumps over it.
     780    /// This function sets the status of the given arc.
    789781    /// It is done by simply setting the assigned value of \c a
    790     /// to be \c false in the arc filter map.
    791     void hide(const Arc& a) const { Parent::hide(a); }
     782    /// to \c v in the arc filter map.
     783    void status(const Arc& a, bool v) const { Parent::status(a, v); }
    792784
    793     /// \brief Shows the given node
     785    /// \brief Returns the status of the given node
    794786    ///
    795     /// This function shows the given node in the subdigraph.
    796     /// It is done by simply setting the assigned value of \c n
    797     /// to be \c true in the node filter map.
    798     void unHide(const Node& n) const { Parent::unHide(n); }
     787    /// This function returns the status of the given node.
     788    /// It is \c true if the given node is enabled (i.e. not hidden).
     789    bool status(const Node& n) const { return Parent::status(n); }
    799790
    800     /// \brief Shows the given arc
     791    /// \brief Returns the status of the given arc
    801792    ///
    802     /// This function shows the given arc in the subdigraph.
    803     /// It is done by simply setting the assigned value of \c a
    804     /// to be \c true in the arc filter map.
    805     void unHide(const Arc& a) const { Parent::unHide(a); }
     793    /// This function returns the status of the given arc.
     794    /// It is \c true if the given arc is enabled (i.e. not hidden).
     795    bool status(const Arc& a) const { return Parent::status(a); }
    806796
    807     /// \brief Returns \c true if the given node is hidden.
     797    /// \brief Disables the given node
    808798    ///
    809     /// This function returns \c true if the given node is hidden.
    810     bool hidden(const Node& n) const { return Parent::hidden(n); }
     799    /// This function disables the given node in the subdigraph,
     800    /// so the iteration jumps over it.
     801    /// It is the same as \ref status() "status(n, false)".
     802    void disable(const Node& n) const { Parent::status(n, false); }
    811803
    812     /// \brief Returns \c true if the given arc is hidden.
     804    /// \brief Disables the given arc
    813805    ///
    814     /// This function returns \c true if the given arc is hidden.
    815     bool hidden(const Arc& a) const { return Parent::hidden(a); }
     806    /// This function disables the given arc in the subdigraph,
     807    /// so the iteration jumps over it.
     808    /// It is the same as \ref status() "status(a, false)".
     809    void disable(const Arc& a) const { Parent::status(a, false); }
     810
     811    /// \brief Enables the given node
     812    ///
     813    /// This function enables the given node in the subdigraph.
     814    /// It is the same as \ref status() "status(n, true)".
     815    void enable(const Node& n) const { Parent::status(n, true); }
     816
     817    /// \brief Enables the given arc
     818    ///
     819    /// This function enables the given arc in the subdigraph.
     820    /// It is the same as \ref status() "status(a, true)".
     821    void enable(const Arc& a) const { Parent::status(a, true); }
    816822
    817823  };
    818824
     
    970976        Parent::nextInc(i, d);
    971977    }
    972978
    973     void hide(const Node& n) const { _node_filter_map->set(n, false); }
    974     void hide(const Edge& e) const { _edge_filter_map->set(e, false); }
     979    void status(const Node& n, bool v) const { _node_filter_map->set(n, v); }
     980    void status(const Edge& e, bool v) const { _edge_filter_map->set(e, v); }
    975981
    976     void unHide(const Node& n) const { _node_filter_map->set(n, true); }
    977     void unHide(const Edge& e) const { _edge_filter_map->set(e, true); }
    978 
    979     bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; }
    980     bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; }
     982    bool status(const Node& n) const { return (*_node_filter_map)[n]; }
     983    bool status(const Edge& e) const { return (*_edge_filter_map)[e]; }
    981984
    982985    typedef False NodeNumTag;
    983986    typedef False ArcNumTag;
     
    11721175      while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextInc(i, d);
    11731176    }
    11741177
    1175     void hide(const Node& n) const { _node_filter_map->set(n, false); }
    1176     void hide(const Edge& e) const { _edge_filter_map->set(e, false); }
     1178    void status(const Node& n, bool v) const { _node_filter_map->set(n, v); }
     1179    void status(const Edge& e, bool v) const { _edge_filter_map->set(e, v); }
    11771180
    1178     void unHide(const Node& n) const { _node_filter_map->set(n, true); }
    1179     void unHide(const Edge& e) const { _edge_filter_map->set(e, true); }
    1180 
    1181     bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; }
    1182     bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; }
     1181    bool status(const Node& n) const { return (*_node_filter_map)[n]; }
     1182    bool status(const Edge& e) const { return (*_edge_filter_map)[e]; }
    11831183
    11841184    typedef False NodeNumTag;
    11851185    typedef False ArcNumTag;
     
    13631363      setEdgeFilterMap(edge_filter_map);
    13641364    }
    13651365
    1366     /// \brief Hides the given node
     1366    /// \brief Sets the status of the given node
    13671367    ///
    1368     /// This function hides the given node in the subgraph,
    1369     /// i.e. the iteration jumps over it.
     1368    /// This function sets the status of the given node.
    13701369    /// It is done by simply setting the assigned value of \c n
    1371     /// to be \c false in the node filter map.
    1372     void hide(const Node& n) const { Parent::hide(n); }
     1370    /// to \c v in the node filter map.
     1371    void status(const Node& n, bool v) const { Parent::status(n, v); }
    13731372
    1374     /// \brief Hides the given edge
     1373    /// \brief Sets the status of the given edge
    13751374    ///
    1376     /// This function hides the given edge in the subgraph,
    1377     /// i.e. the iteration jumps over it.
     1375    /// This function sets the status of the given edge.
    13781376    /// It is done by simply setting the assigned value of \c e
    1379     /// to be \c false in the edge filter map.
    1380     void hide(const Edge& e) const { Parent::hide(e); }
     1377    /// to \c v in the edge filter map.
     1378    void status(const Edge& e, bool v) const { Parent::status(e, v); }
    13811379
    1382     /// \brief Shows the given node
     1380    /// \brief Returns the status of the given node
    13831381    ///
    1384     /// This function shows the given node in the subgraph.
    1385     /// It is done by simply setting the assigned value of \c n
    1386     /// to be \c true in the node filter map.
    1387     void unHide(const Node& n) const { Parent::unHide(n); }
     1382    /// This function returns the status of the given node.
     1383    /// It is \c true if the given node is enabled (i.e. not hidden).
     1384    bool status(const Node& n) const { return Parent::status(n); }
    13881385
    1389     /// \brief Shows the given edge
     1386    /// \brief Returns the status of the given edge
    13901387    ///
    1391     /// This function shows the given edge in the subgraph.
    1392     /// It is done by simply setting the assigned value of \c e
    1393     /// to be \c true in the edge filter map.
    1394     void unHide(const Edge& e) const { Parent::unHide(e); }
     1388    /// This function returns the status of the given edge.
     1389    /// It is \c true if the given edge is enabled (i.e. not hidden).
     1390    bool status(const Edge& e) const { return Parent::status(e); }
    13951391
    1396     /// \brief Returns \c true if the given node is hidden.
     1392    /// \brief Disables the given node
    13971393    ///
    1398     /// This function returns \c true if the given node is hidden.
    1399     bool hidden(const Node& n) const { return Parent::hidden(n); }
     1394    /// This function disables the given node in the subdigraph,
     1395    /// so the iteration jumps over it.
     1396    /// It is the same as \ref status() "status(n, false)".
     1397    void disable(const Node& n) const { Parent::status(n, false); }
    14001398
    1401     /// \brief Returns \c true if the given edge is hidden.
     1399    /// \brief Disables the given edge
    14021400    ///
    1403     /// This function returns \c true if the given edge is hidden.
    1404     bool hidden(const Edge& e) const { return Parent::hidden(e); }
     1401    /// This function disables the given edge in the subgraph,
     1402    /// so the iteration jumps over it.
     1403    /// It is the same as \ref status() "status(e, false)".
     1404    void disable(const Edge& e) const { Parent::status(e, false); }
     1405
     1406    /// \brief Enables the given node
     1407    ///
     1408    /// This function enables the given node in the subdigraph.
     1409    /// It is the same as \ref status() "status(n, true)".
     1410    void enable(const Node& n) const { Parent::status(n, true); }
     1411
     1412    /// \brief Enables the given edge
     1413    ///
     1414    /// This function enables the given edge in the subgraph.
     1415    /// It is the same as \ref status() "status(e, true)".
     1416    void enable(const Edge& e) const { Parent::status(e, true); }
     1417
    14051418  };
    14061419
    14071420  /// \brief Returns a read-only SubGraph adaptor
     
    15191532      Parent::setArcFilterMap(const_true_map);
    15201533    }
    15211534
    1522     /// \brief Hides the given node
     1535    /// \brief Sets the status of the given node
    15231536    ///
    1524     /// This function hides the given node in the subgraph,
    1525     /// i.e. the iteration jumps over it.
     1537    /// This function sets the status of the given node.
    15261538    /// It is done by simply setting the assigned value of \c n
    1527     /// to be \c false in the node filter map.
    1528     void hide(const Node& n) const { Parent::hide(n); }
     1539    /// to \c v in the node filter map.
     1540    void status(const Node& n, bool v) const { Parent::status(n, v); }
    15291541
    1530     /// \brief Shows the given node
     1542    /// \brief Returns the status of the given node
    15311543    ///
    1532     /// This function shows the given node in the subgraph.
    1533     /// It is done by simply setting the assigned value of \c n
    1534     /// to be \c true in the node filter map.
    1535     void unHide(const Node& n) const { Parent::unHide(n); }
     1544    /// This function returns the status of the given node.
     1545    /// It is \c true if the given node is enabled (i.e. not hidden).
     1546    bool status(const Node& n) const { return Parent::status(n); }
    15361547
    1537     /// \brief Returns \c true if the given node is hidden.
     1548    /// \brief Disables the given node
    15381549    ///
    1539     /// This function returns \c true if the given node is hidden.
    1540     bool hidden(const Node& n) const { return Parent::hidden(n); }
     1550    /// This function disables the given node, so the iteration
     1551    /// jumps over it.
     1552    /// It is the same as \ref status() "status(n, false)".
     1553    void disable(const Node& n) const { Parent::status(n, false); }
     1554
     1555    /// \brief Enables the given node
     1556    ///
     1557    /// This function enables the given node.
     1558    /// It is the same as \ref status() "status(n, true)".
     1559    void enable(const Node& n) const { Parent::status(n, true); }
    15411560
    15421561  };
    15431562
     
    15691588      Parent::setEdgeFilterMap(const_true_map);
    15701589    }
    15711590
    1572     void hide(const Node& n) const { Parent::hide(n); }
    1573     void unHide(const Node& n) const { Parent::unHide(n); }
    1574     bool hidden(const Node& n) const { return Parent::hidden(n); }
     1591    void status(const Node& n, bool v) const { Parent::status(n, v); }
     1592    bool status(const Node& n) const { return Parent::status(n); }
     1593    void disable(const Node& n) const { Parent::status(n, false); }
     1594    void enable(const Node& n) const { Parent::status(n, true); }
    15751595
    15761596  };
    15771597
     
    16561676      Parent::setArcFilterMap(arc_filter);
    16571677    }
    16581678
    1659     /// \brief Hides the given arc
     1679    /// \brief Sets the status of the given arc
    16601680    ///
    1661     /// This function hides the given arc in the subdigraph,
    1662     /// i.e. the iteration jumps over it.
     1681    /// This function sets the status of the given arc.
    16631682    /// It is done by simply setting the assigned value of \c a
    1664     /// to be \c false in the arc filter map.
    1665     void hide(const Arc& a) const { Parent::hide(a); }
     1683    /// to \c v in the arc filter map.
     1684    void status(const Arc& a, bool v) const { Parent::status(a, v); }
    16661685
    1667     /// \brief Shows the given arc
     1686    /// \brief Returns the status of the given arc
    16681687    ///
    1669     /// This function shows the given arc in the subdigraph.
    1670     /// It is done by simply setting the assigned value of \c a
    1671     /// to be \c true in the arc filter map.
    1672     void unHide(const Arc& a) const { Parent::unHide(a); }
     1688    /// This function returns the status of the given arc.
     1689    /// It is \c true if the given arc is enabled (i.e. not hidden).
     1690    bool status(const Arc& a) const { return Parent::status(a); }
    16731691
    1674     /// \brief Returns \c true if the given arc is hidden.
     1692    /// \brief Disables the given arc
    16751693    ///
    1676     /// This function returns \c true if the given arc is hidden.
    1677     bool hidden(const Arc& a) const { return Parent::hidden(a); }
     1694    /// This function disables the given arc in the subdigraph,
     1695    /// so the iteration jumps over it.
     1696    /// It is the same as \ref status() "status(a, false)".
     1697    void disable(const Arc& a) const { Parent::status(a, false); }
     1698
     1699    /// \brief Enables the given arc
     1700    ///
     1701    /// This function enables the given arc in the subdigraph.
     1702    /// It is the same as \ref status() "status(a, true)".
     1703    void enable(const Arc& a) const { Parent::status(a, true); }
    16781704
    16791705  };
    16801706
     
    17541780      Parent::setEdgeFilterMap(edge_filter_map);
    17551781    }
    17561782
    1757     /// \brief Hides the given edge
     1783    /// \brief Sets the status of the given edge
    17581784    ///
    1759     /// This function hides the given edge in the subgraph,
    1760     /// i.e. the iteration jumps over it.
     1785    /// This function sets the status of the given edge.
    17611786    /// It is done by simply setting the assigned value of \c e
    1762     /// to be \c false in the edge filter map.
    1763     void hide(const Edge& e) const { Parent::hide(e); }
     1787    /// to \c v in the edge filter map.
     1788    void status(const Edge& e, bool v) const { Parent::status(e, v); }
    17641789
    1765     /// \brief Shows the given edge
     1790    /// \brief Returns the status of the given edge
    17661791    ///
    1767     /// This function shows the given edge in the subgraph.
    1768     /// It is done by simply setting the assigned value of \c e
    1769     /// to be \c true in the edge filter map.
    1770     void unHide(const Edge& e) const { Parent::unHide(e); }
     1792    /// This function returns the status of the given edge.
     1793    /// It is \c true if the given edge is enabled (i.e. not hidden).
     1794    bool status(const Edge& e) const { return Parent::status(e); }
    17711795
    1772     /// \brief Returns \c true if the given edge is hidden.
     1796    /// \brief Disables the given edge
    17731797    ///
    1774     /// This function returns \c true if the given edge is hidden.
    1775     bool hidden(const Edge& e) const { return Parent::hidden(e); }
     1798    /// This function disables the given edge in the subgraph,
     1799    /// so the iteration jumps over it.
     1800    /// It is the same as \ref status() "status(e, false)".
     1801    void disable(const Edge& e) const { Parent::status(e, false); }
     1802
     1803    /// \brief Enables the given edge
     1804    ///
     1805    /// This function enables the given edge in the subgraph.
     1806    /// It is the same as \ref status() "status(e, true)".
     1807    void enable(const Edge& e) const { Parent::status(e, true); }
    17761808
    17771809  };
    17781810
     
    27672799      }
    27682800    }
    27692801
    2770     /// \brief Augment on the given arc in the residual digraph.
     2802    /// \brief Augments on the given arc in the residual digraph.
    27712803    ///
    2772     /// Augment on the given arc in the residual digraph. It increases
     2804    /// Augments on the given arc in the residual digraph. It increases
    27732805    /// or decreases the flow value on the original arc according to the
    27742806    /// direction of the residual arc.
    27752807    void augment(const Arc& a, const Value& v) const {