Changeset 606:c5fd2d996909 in lemon for lemon/maps.h
- Timestamp:
- 03/29/09 23:08:20 (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/maps.h
r463 r606 64 64 class NullMap : public MapBase<K, V> { 65 65 public: 66 typedef MapBase<K, V> Parent; 67 typedef typename Parent::Key Key; 68 typedef typename Parent::Value Value; 66 ///\e 67 typedef K Key; 68 ///\e 69 typedef V Value; 69 70 70 71 /// Gives back a default constructed element. … … 103 104 V _value; 104 105 public: 105 typedef MapBase<K, V> Parent; 106 typedef typename Parent::Key Key; 107 typedef typename Parent::Value Value; 106 ///\e 107 typedef K Key; 108 ///\e 109 typedef V Value; 108 110 109 111 /// Default constructor … … 169 171 class ConstMap<K, Const<V, v> > : public MapBase<K, V> { 170 172 public: 171 typedef MapBase<K, V> Parent; 172 typedef typename Parent::Key Key; 173 typedef typename Parent::Value Value; 173 ///\e 174 typedef K Key; 175 ///\e 176 typedef V Value; 174 177 175 178 /// Constructor. … … 203 206 class IdentityMap : public MapBase<T, T> { 204 207 public: 205 typedef MapBase<T, T> Parent; 206 typedef typename Parent::Key Key; 207 typedef typename Parent::Value Value; 208 ///\e 209 typedef T Key; 210 ///\e 211 typedef T Value; 208 212 209 213 /// Gives back the given value without any modification. … … 246 250 public: 247 251 248 typedef MapBase<int, V> Parent;249 252 /// Key type 250 typedef typename Parent::KeyKey;253 typedef int Key; 251 254 /// Value type 252 typedef typename Parent::ValueValue;255 typedef V Value; 253 256 /// Reference type 254 257 typedef typename Vector::reference Reference; … … 354 357 /// The simplest way of using this map is through the sparseMap() 355 358 /// function. 356 template <typename K, typename V, typename Comp are= std::less<K> >359 template <typename K, typename V, typename Comp = std::less<K> > 357 360 class SparseMap : public MapBase<K, V> { 358 361 template <typename K1, typename V1, typename C1> … … 360 363 public: 361 364 362 typedef MapBase<K, V> Parent;363 365 /// Key type 364 typedef typename Parent::KeyKey;366 typedef K Key; 365 367 /// Value type 366 typedef typename Parent::ValueValue;368 typedef V Value; 367 369 /// Reference type 368 370 typedef Value& Reference; … … 374 376 private: 375 377 376 typedef std::map<K, V, Comp are> Map;378 typedef std::map<K, V, Comp> Map; 377 379 Map _map; 378 380 Value _value; … … 490 492 const M2 &_m2; 491 493 public: 492 typedef MapBase<typename M2::Key, typename M1::Value> Parent; 493 typedef typename Parent::Key Key; 494 typedef typename Parent::Value Value; 494 ///\e 495 typedef typename M2::Key Key; 496 ///\e 497 typedef typename M1::Value Value; 495 498 496 499 /// Constructor 497 500 ComposeMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} 498 501 499 /// 502 ///\e 500 503 typename MapTraits<M1>::ConstReturnValue 501 504 operator[](const Key &k) const { return _m1[_m2[k]]; } … … 546 549 F _f; 547 550 public: 548 typedef MapBase<typename M1::Key, V> Parent; 549 typedef typename Parent::Key Key; 550 typedef typename Parent::Value Value; 551 ///\e 552 typedef typename M1::Key Key; 553 ///\e 554 typedef V Value; 551 555 552 556 /// Constructor 553 557 CombineMap(const M1 &m1, const M2 &m2, const F &f = F()) 554 558 : _m1(m1), _m2(m2), _f(f) {} 555 /// 559 ///\e 556 560 Value operator[](const Key &k) const { return _f(_m1[k],_m2[k]); } 557 561 }; … … 616 620 F _f; 617 621 public: 618 typedef MapBase<K, V> Parent; 619 typedef typename Parent::Key Key; 620 typedef typename Parent::Value Value; 622 ///\e 623 typedef K Key; 624 ///\e 625 typedef V Value; 621 626 622 627 /// Constructor 623 628 FunctorToMap(const F &f = F()) : _f(f) {} 624 /// 629 ///\e 625 630 Value operator[](const Key &k) const { return _f(k); } 626 631 }; … … 670 675 const M &_m; 671 676 public: 672 typedef MapBase<typename M::Key, typename M::Value> Parent; 673 typedef typename Parent::Key Key; 674 typedef typename Parent::Value Value; 675 676 typedef typename Parent::Key argument_type; 677 typedef typename Parent::Value result_type; 677 ///\e 678 typedef typename M::Key Key; 679 ///\e 680 typedef typename M::Value Value; 681 682 typedef typename M::Key argument_type; 683 typedef typename M::Value result_type; 678 684 679 685 /// Constructor 680 686 MapToFunctor(const M &m) : _m(m) {} 681 /// 687 ///\e 682 688 Value operator()(const Key &k) const { return _m[k]; } 683 /// 689 ///\e 684 690 Value operator[](const Key &k) const { return _m[k]; } 685 691 }; … … 710 716 const M &_m; 711 717 public: 712 typedef MapBase<typename M::Key, V> Parent; 713 typedef typename Parent::Key Key; 714 typedef typename Parent::Value Value; 718 ///\e 719 typedef typename M::Key Key; 720 ///\e 721 typedef V Value; 715 722 716 723 /// Constructor … … 720 727 ConvertMap(const M &m) : _m(m) {} 721 728 722 /// 729 ///\e 723 730 Value operator[](const Key &k) const { return _m[k]; } 724 731 }; … … 752 759 M2 &_m2; 753 760 public: 754 typedef MapBase<typename M1::Key, typename M1::Value> Parent; 755 typedef typename Parent::Key Key; 756 typedef typename Parent::Value Value; 761 ///\e 762 typedef typename M1::Key Key; 763 ///\e 764 typedef typename M1::Value Value; 757 765 758 766 /// Constructor … … 798 806 const M2 &_m2; 799 807 public: 800 typedef MapBase<typename M1::Key, typename M1::Value> Parent; 801 typedef typename Parent::Key Key; 802 typedef typename Parent::Value Value; 808 ///\e 809 typedef typename M1::Key Key; 810 ///\e 811 typedef typename M1::Value Value; 803 812 804 813 /// Constructor 805 814 AddMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} 806 /// 815 ///\e 807 816 Value operator[](const Key &k) const { return _m1[k]+_m2[k]; } 808 817 }; … … 846 855 const M2 &_m2; 847 856 public: 848 typedef MapBase<typename M1::Key, typename M1::Value> Parent; 849 typedef typename Parent::Key Key; 850 typedef typename Parent::Value Value; 857 ///\e 858 typedef typename M1::Key Key; 859 ///\e 860 typedef typename M1::Value Value; 851 861 852 862 /// Constructor 853 863 SubMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} 854 /// 864 ///\e 855 865 Value operator[](const Key &k) const { return _m1[k]-_m2[k]; } 856 866 }; … … 895 905 const M2 &_m2; 896 906 public: 897 typedef MapBase<typename M1::Key, typename M1::Value> Parent; 898 typedef typename Parent::Key Key; 899 typedef typename Parent::Value Value; 907 ///\e 908 typedef typename M1::Key Key; 909 ///\e 910 typedef typename M1::Value Value; 900 911 901 912 /// Constructor 902 913 MulMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {} 903 /// 914 ///\e 904 915 Value operator[](const Key &k) const { return _m1[k]*_m2[k]; } 905 916 }; … … 943 954 const M2 &_m2; 944 955 public: 945 typedef MapBase<typename M1::Key, typename M1::Value> Parent; 946 typedef typename Parent::Key Key; 947 typedef typename Parent::Value Value; 956 ///\e 957 typedef typename M1::Key Key; 958 ///\e 959 typedef typename M1::Value Value; 948 960 949 961 /// Constructor 950 962 DivMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {} 951 /// 963 ///\e 952 964 Value operator[](const Key &k) const { return _m1[k]/_m2[k]; } 953 965 }; … … 993 1005 C _v; 994 1006 public: 995 typedef MapBase<typename M::Key, typename M::Value> Parent; 996 typedef typename Parent::Key Key; 997 typedef typename Parent::Value Value; 1007 ///\e 1008 typedef typename M::Key Key; 1009 ///\e 1010 typedef typename M::Value Value; 998 1011 999 1012 /// Constructor … … 1003 1016 /// \param v The constant value. 1004 1017 ShiftMap(const M &m, const C &v) : _m(m), _v(v) {} 1005 /// 1018 ///\e 1006 1019 Value operator[](const Key &k) const { return _m[k]+_v; } 1007 1020 }; … … 1023 1036 C _v; 1024 1037 public: 1025 typedef MapBase<typename M::Key, typename M::Value> Parent; 1026 typedef typename Parent::Key Key; 1027 typedef typename Parent::Value Value; 1038 ///\e 1039 typedef typename M::Key Key; 1040 ///\e 1041 typedef typename M::Value Value; 1028 1042 1029 1043 /// Constructor … … 1033 1047 /// \param v The constant value. 1034 1048 ShiftWriteMap(M &m, const C &v) : _m(m), _v(v) {} 1035 /// 1049 ///\e 1036 1050 Value operator[](const Key &k) const { return _m[k]+_v; } 1037 /// 1051 ///\e 1038 1052 void set(const Key &k, const Value &v) { _m.set(k, v-_v); } 1039 1053 }; … … 1094 1108 C _v; 1095 1109 public: 1096 typedef MapBase<typename M::Key, typename M::Value> Parent; 1097 typedef typename Parent::Key Key; 1098 typedef typename Parent::Value Value; 1110 ///\e 1111 typedef typename M::Key Key; 1112 ///\e 1113 typedef typename M::Value Value; 1099 1114 1100 1115 /// Constructor … … 1104 1119 /// \param v The constant value. 1105 1120 ScaleMap(const M &m, const C &v) : _m(m), _v(v) {} 1106 /// 1121 ///\e 1107 1122 Value operator[](const Key &k) const { return _v*_m[k]; } 1108 1123 }; … … 1125 1140 C _v; 1126 1141 public: 1127 typedef MapBase<typename M::Key, typename M::Value> Parent; 1128 typedef typename Parent::Key Key; 1129 typedef typename Parent::Value Value; 1142 ///\e 1143 typedef typename M::Key Key; 1144 ///\e 1145 typedef typename M::Value Value; 1130 1146 1131 1147 /// Constructor … … 1135 1151 /// \param v The constant value. 1136 1152 ScaleWriteMap(M &m, const C &v) : _m(m), _v(v) {} 1137 /// 1153 ///\e 1138 1154 Value operator[](const Key &k) const { return _v*_m[k]; } 1139 /// 1155 ///\e 1140 1156 void set(const Key &k, const Value &v) { _m.set(k, v/_v); } 1141 1157 }; … … 1194 1210 const M& _m; 1195 1211 public: 1196 typedef MapBase<typename M::Key, typename M::Value> Parent; 1197 typedef typename Parent::Key Key; 1198 typedef typename Parent::Value Value; 1212 ///\e 1213 typedef typename M::Key Key; 1214 ///\e 1215 typedef typename M::Value Value; 1199 1216 1200 1217 /// Constructor 1201 1218 NegMap(const M &m) : _m(m) {} 1202 /// 1219 ///\e 1203 1220 Value operator[](const Key &k) const { return -_m[k]; } 1204 1221 }; … … 1229 1246 M &_m; 1230 1247 public: 1231 typedef MapBase<typename M::Key, typename M::Value> Parent; 1232 typedef typename Parent::Key Key; 1233 typedef typename Parent::Value Value; 1248 ///\e 1249 typedef typename M::Key Key; 1250 ///\e 1251 typedef typename M::Value Value; 1234 1252 1235 1253 /// Constructor 1236 1254 NegWriteMap(M &m) : _m(m) {} 1237 /// 1255 ///\e 1238 1256 Value operator[](const Key &k) const { return -_m[k]; } 1239 /// 1257 ///\e 1240 1258 void set(const Key &k, const Value &v) { _m.set(k, -v); } 1241 1259 }; … … 1283 1301 const M &_m; 1284 1302 public: 1285 typedef MapBase<typename M::Key, typename M::Value> Parent; 1286 typedef typename Parent::Key Key; 1287 typedef typename Parent::Value Value; 1303 ///\e 1304 typedef typename M::Key Key; 1305 ///\e 1306 typedef typename M::Value Value; 1288 1307 1289 1308 /// Constructor 1290 1309 AbsMap(const M &m) : _m(m) {} 1291 /// 1310 ///\e 1292 1311 Value operator[](const Key &k) const { 1293 1312 Value tmp = _m[k]; … … 1338 1357 class TrueMap : public MapBase<K, bool> { 1339 1358 public: 1340 typedef MapBase<K, bool> Parent; 1341 typedef typename Parent::Key Key; 1342 typedef typename Parent::Value Value; 1359 ///\e 1360 typedef K Key; 1361 ///\e 1362 typedef bool Value; 1343 1363 1344 1364 /// Gives back \c true. … … 1375 1395 class FalseMap : public MapBase<K, bool> { 1376 1396 public: 1377 typedef MapBase<K, bool> Parent; 1378 typedef typename Parent::Key Key; 1379 typedef typename Parent::Value Value; 1397 ///\e 1398 typedef K Key; 1399 ///\e 1400 typedef bool Value; 1380 1401 1381 1402 /// Gives back \c false. … … 1420 1441 const M2 &_m2; 1421 1442 public: 1422 typedef MapBase<typename M1::Key, bool> Parent; 1423 typedef typename Parent::Key Key; 1424 typedef typename Parent::Value Value; 1443 ///\e 1444 typedef typename M1::Key Key; 1445 ///\e 1446 typedef bool Value; 1425 1447 1426 1448 /// Constructor 1427 1449 AndMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} 1428 /// 1450 ///\e 1429 1451 Value operator[](const Key &k) const { return _m1[k]&&_m2[k]; } 1430 1452 }; … … 1468 1490 const M2 &_m2; 1469 1491 public: 1470 typedef MapBase<typename M1::Key, bool> Parent; 1471 typedef typename Parent::Key Key; 1472 typedef typename Parent::Value Value; 1492 ///\e 1493 typedef typename M1::Key Key; 1494 ///\e 1495 typedef bool Value; 1473 1496 1474 1497 /// Constructor 1475 1498 OrMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} 1476 /// 1499 ///\e 1477 1500 Value operator[](const Key &k) const { return _m1[k]||_m2[k]; } 1478 1501 }; … … 1507 1530 const M &_m; 1508 1531 public: 1509 typedef MapBase<typename M::Key, bool> Parent; 1510 typedef typename Parent::Key Key; 1511 typedef typename Parent::Value Value; 1532 ///\e 1533 typedef typename M::Key Key; 1534 ///\e 1535 typedef bool Value; 1512 1536 1513 1537 /// Constructor 1514 1538 NotMap(const M &m) : _m(m) {} 1515 /// 1539 ///\e 1516 1540 Value operator[](const Key &k) const { return !_m[k]; } 1517 1541 }; … … 1533 1557 M &_m; 1534 1558 public: 1535 typedef MapBase<typename M::Key, bool> Parent; 1536 typedef typename Parent::Key Key; 1537 typedef typename Parent::Value Value; 1559 ///\e 1560 typedef typename M::Key Key; 1561 ///\e 1562 typedef bool Value; 1538 1563 1539 1564 /// Constructor 1540 1565 NotWriteMap(M &m) : _m(m) {} 1541 /// 1566 ///\e 1542 1567 Value operator[](const Key &k) const { return !_m[k]; } 1543 /// 1568 ///\e 1544 1569 void set(const Key &k, bool v) { _m.set(k, !v); } 1545 1570 }; … … 1596 1621 const M2 &_m2; 1597 1622 public: 1598 typedef MapBase<typename M1::Key, bool> Parent; 1599 typedef typename Parent::Key Key; 1600 typedef typename Parent::Value Value; 1623 ///\e 1624 typedef typename M1::Key Key; 1625 ///\e 1626 typedef bool Value; 1601 1627 1602 1628 /// Constructor 1603 1629 EqualMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} 1604 /// 1630 ///\e 1605 1631 Value operator[](const Key &k) const { return _m1[k]==_m2[k]; } 1606 1632 }; … … 1644 1670 const M2 &_m2; 1645 1671 public: 1646 typedef MapBase<typename M1::Key, bool> Parent; 1647 typedef typename Parent::Key Key; 1648 typedef typename Parent::Value Value; 1672 ///\e 1673 typedef typename M1::Key Key; 1674 ///\e 1675 typedef bool Value; 1649 1676 1650 1677 /// Constructor 1651 1678 LessMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} 1652 /// 1679 ///\e 1653 1680 Value operator[](const Key &k) const { return _m1[k]<_m2[k]; } 1654 1681 }; … … 1706 1733 /// function. 1707 1734 /// 1708 /// \tparam I tThe type of the iterator.1709 /// \tparam K eThe key type of the map. The default value set1735 /// \tparam IT The type of the iterator. 1736 /// \tparam KEY The key type of the map. The default value set 1710 1737 /// according to the iterator type should work in most cases. 1711 1738 /// … … 1713 1740 /// for the elements or the iterator should be an inserter iterator. 1714 1741 #ifdef DOXYGEN 1715 template <typename I t, typename Ke>1742 template <typename IT, typename KEY> 1716 1743 #else 1717 template <typename I t,1718 typename K e=typename _maps_bits::IteratorTraits<It>::Value>1744 template <typename IT, 1745 typename KEY = typename _maps_bits::IteratorTraits<IT>::Value> 1719 1746 #endif 1720 class LoggerBoolMap { 1721 public: 1722 typedef It Iterator; 1723 1724 typedef Ke Key; 1747 class LoggerBoolMap : public MapBase<KEY, bool> { 1748 public: 1749 1750 ///\e 1751 typedef KEY Key; 1752 ///\e 1725 1753 typedef bool Value; 1754 ///\e 1755 typedef IT Iterator; 1726 1756 1727 1757 /// Constructor … … 1786 1816 /// @{ 1787 1817 1788 /// Provides an immutable and unique id for each item in the graph. 1789 1790 /// The IdMap class provides a unique and immutable id for each item of the 1791 /// same type (e.g. node) in the graph. This id is <ul><li>\b unique: 1792 /// different items (nodes) get different ids <li>\b immutable: the id of an 1793 /// item (node) does not change (even if you delete other nodes). </ul> 1794 /// Through this map you get access (i.e. can read) the inner id values of 1795 /// the items stored in the graph. This map can be inverted with its member 1818 /// \brief Provides an immutable and unique id for each item in a graph. 1819 /// 1820 /// IdMap provides a unique and immutable id for each item of the 1821 /// same type (\c Node, \c Arc or \c Edge) in a graph. This id is 1822 /// - \b unique: different items get different ids, 1823 /// - \b immutable: the id of an item does not change (even if you 1824 /// delete other nodes). 1825 /// 1826 /// Using this map you get access (i.e. can read) the inner id values of 1827 /// the items stored in the graph, which is returned by the \c id() 1828 /// function of the graph. This map can be inverted with its member 1796 1829 /// class \c InverseMap or with the \c operator() member. 1797 1830 /// 1798 template <typename _Graph, typename _Item> 1799 class IdMap { 1800 public: 1801 typedef _Graph Graph; 1831 /// \tparam GR The graph type. 1832 /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or 1833 /// \c GR::Edge). 1834 /// 1835 /// \see DescriptorMap 1836 template <typename GR, typename K> 1837 class IdMap : public MapBase<K, int> { 1838 public: 1839 /// The graph type of IdMap. 1840 typedef GR Graph; 1841 /// The key type of IdMap (\c Node, \c Arc or \c Edge). 1842 typedef K Item; 1843 /// The key type of IdMap (\c Node, \c Arc or \c Edge). 1844 typedef K Key; 1845 /// The value type of IdMap. 1802 1846 typedef int Value; 1803 typedef _Item Item;1804 typedef _Item Key;1805 1847 1806 1848 /// \brief Constructor. … … 1814 1856 int operator[](const Item& item) const { return _graph->id(item);} 1815 1857 1816 /// \brief Gives back the item by its id.1817 /// 1818 /// Gives back the item by its id.1858 /// \brief Gives back the \e item by its id. 1859 /// 1860 /// Gives back the \e item by its id. 1819 1861 Item operator()(int id) { return _graph->fromId(id, Item()); } 1820 1862 … … 1824 1866 public: 1825 1867 1826 /// \brief Th eclass represents the inverse of its owner (IdMap).1827 /// 1828 /// Th eclass represents the inverse of its owner (IdMap).1868 /// \brief This class represents the inverse of its owner (IdMap). 1869 /// 1870 /// This class represents the inverse of its owner (IdMap). 1829 1871 /// \see inverse() 1830 1872 class InverseMap { … … 1844 1886 /// 1845 1887 /// Gives back the given item from its id. 1846 ///1847 1888 Item operator[](int id) const { return _graph->fromId(id, Item());} 1848 1889 … … 1855 1896 /// Gives back the inverse of the IdMap. 1856 1897 InverseMap inverse() const { return InverseMap(*_graph);} 1857 1858 }; 1859 1860 1861 /// \brief General invertable graph-map type. 1862 1863 /// This type provides simple invertable graph-maps. 1864 /// The InvertableMap wraps an arbitrary ReadWriteMap 1898 }; 1899 1900 1901 /// \brief General invertable graph map type. 1902 1903 /// This class provides simple invertable graph maps. 1904 /// It wraps an arbitrary \ref concepts::ReadWriteMap "ReadWriteMap" 1865 1905 /// and if a key is set to a new value then store it 1866 1906 /// in the inverse map. … … 1869 1909 /// with stl compatible forward iterator. 1870 1910 /// 1871 /// \tparam _Graph The graph type. 1872 /// \tparam _Item The item type of the graph. 1873 /// \tparam _Value The value type of the map. 1911 /// \tparam GR The graph type. 1912 /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or 1913 /// \c GR::Edge). 1914 /// \tparam V The value type of the map. 1874 1915 /// 1875 1916 /// \see IterableValueMap 1876 template <typename _Graph, typename _Item, typename _Value>1917 template <typename GR, typename K, typename V> 1877 1918 class InvertableMap 1878 : protected ItemSetTraits< _Graph, _Item>::template Map<_Value>::Type {1919 : protected ItemSetTraits<GR, K>::template Map<V>::Type { 1879 1920 private: 1880 1921 1881 typedef typename ItemSetTraits<_Graph, _Item>:: 1882 template Map<_Value>::Type Map; 1883 typedef _Graph Graph; 1884 1885 typedef std::map<_Value, _Item> Container; 1922 typedef typename ItemSetTraits<GR, K>:: 1923 template Map<V>::Type Map; 1924 1925 typedef std::map<V, K> Container; 1886 1926 Container _inv_map; 1887 1927 1888 1928 public: 1889 1929 1890 /// The key type of InvertableMap (Node, Arc, Edge). 1891 typedef typename Map::Key Key; 1892 /// The value type of the InvertableMap. 1893 typedef typename Map::Value Value; 1930 /// The graph type of InvertableMap. 1931 typedef GR Graph; 1932 /// The key type of InvertableMap (\c Node, \c Arc or \c Edge). 1933 typedef K Item; 1934 /// The key type of InvertableMap (\c Node, \c Arc or \c Edge). 1935 typedef K Key; 1936 /// The value type of InvertableMap. 1937 typedef V Value; 1894 1938 1895 1939 /// \brief Constructor. 1896 1940 /// 1897 /// Construct a new InvertableMap for the graph. 1898 /// 1941 /// Construct a new InvertableMap for the given graph. 1899 1942 explicit InvertableMap(const Graph& graph) : Map(graph) {} 1900 1943 … … 1903 1946 /// This iterator is an stl compatible forward 1904 1947 /// iterator on the values of the map. The values can 1905 /// be accessed in the [beginValue, endValue) range. 1906 /// 1948 /// be accessed in the <tt>[beginValue, endValue)</tt> range. 1907 1949 class ValueIterator 1908 1950 : public std::iterator<std::forward_iterator_tag, Value> { … … 1936 1978 /// Returns an stl compatible iterator to the 1937 1979 /// first value of the map. The values of the 1938 /// map can be accessed in the [beginValue, endValue)1980 /// map can be accessed in the <tt>[beginValue, endValue)</tt> 1939 1981 /// range. 1940 1982 ValueIterator beginValue() const { … … 1946 1988 /// Returns an stl compatible iterator after the 1947 1989 /// last value of the map. The values of the 1948 /// map can be accessed in the [beginValue, endValue)1990 /// map can be accessed in the <tt>[beginValue, endValue)</tt> 1949 1991 /// range. 1950 1992 ValueIterator endValue() const { … … 1952 1994 } 1953 1995 1954 /// \brief The setter function of the map.1955 /// 1956 /// Sets the mapped value.1996 /// \brief Sets the value associated with the given key. 1997 /// 1998 /// Sets the value associated with the given key. 1957 1999 void set(const Key& key, const Value& val) { 1958 2000 Value oldval = Map::operator[](key); … … 1965 2007 } 1966 2008 1967 /// \brief The getter function of the map.1968 /// 1969 /// It gives back the value associated with thekey.2009 /// \brief Returns the value associated with the given key. 2010 /// 2011 /// Returns the value associated with the given key. 1970 2012 typename MapTraits<Map>::ConstReturnValue 1971 2013 operator[](const Key& key) const { … … 1983 2025 protected: 1984 2026 1985 /// \brief Erase the key from the map .1986 /// 1987 /// Erase the key to the map. It is called by the2027 /// \brief Erase the key from the map and the inverse map. 2028 /// 2029 /// Erase the key from the map and the inverse map. It is called by the 1988 2030 /// \c AlterationNotifier. 1989 2031 virtual void erase(const Key& key) { … … 1996 2038 } 1997 2039 1998 /// \brief Erase more keys from the map .1999 /// 2000 /// Erase more keys from the map . It is called by the2040 /// \brief Erase more keys from the map and the inverse map. 2041 /// 2042 /// Erase more keys from the map and the inverse map. It is called by the 2001 2043 /// \c AlterationNotifier. 2002 2044 virtual void erase(const std::vector<Key>& keys) { … … 2011 2053 } 2012 2054 2013 /// \brief Clear the keys from the map and inverse map.2014 /// 2015 /// Clear the keys from the map and inverse map. It is called by the2055 /// \brief Clear the keys from the map and the inverse map. 2056 /// 2057 /// Clear the keys from the map and the inverse map. It is called by the 2016 2058 /// \c AlterationNotifier. 2017 2059 virtual void clear() { … … 2025 2067 /// 2026 2068 /// The inverse of this map. The subscript operator of the map 2027 /// gives back always the item what was last assigned to the value.2069 /// gives back the item that was last assigned to the value. 2028 2070 class InverseMap { 2029 2071 public: 2030 /// \brief Constructor of the InverseMap.2072 /// \brief Constructor 2031 2073 /// 2032 2074 /// Constructor of the InverseMap. … … 2041 2083 /// \brief Subscript operator. 2042 2084 /// 2043 /// Subscript operator. It gives back alwaysthe item2044 /// what was last assigned to thevalue.2085 /// Subscript operator. It gives back the item 2086 /// that was last assigned to the given value. 2045 2087 Value operator[](const Key& key) const { 2046 2088 return _inverted(key); … … 2051 2093 }; 2052 2094 2053 /// \brief It gives back the just readableinverse map.2054 /// 2055 /// It gives back the just readableinverse map.2095 /// \brief It gives back the read-only inverse map. 2096 /// 2097 /// It gives back the read-only inverse map. 2056 2098 InverseMap inverse() const { 2057 2099 return InverseMap(*this); … … 2061 2103 2062 2104 /// \brief Provides a mutable, continuous and unique descriptor for each 2063 /// item in the graph. 2064 /// 2065 /// The DescriptorMap class provides a unique and continuous (but mutable) 2066 /// descriptor (id) for each item of the same type (e.g. node) in the 2067 /// graph. This id is <ul><li>\b unique: different items (nodes) get 2068 /// different ids <li>\b continuous: the range of the ids is the set of 2069 /// integers between 0 and \c n-1, where \c n is the number of the items of 2070 /// this type (e.g. nodes) (so the id of a node can change if you delete an 2071 /// other node, i.e. this id is mutable). </ul> This map can be inverted 2072 /// with its member class \c InverseMap, or with the \c operator() member. 2073 /// 2074 /// \tparam _Graph The graph class the \c DescriptorMap belongs to. 2075 /// \tparam _Item The Item is the Key of the Map. It may be Node, Arc or 2076 /// Edge. 2077 template <typename _Graph, typename _Item> 2105 /// item in a graph. 2106 /// 2107 /// DescriptorMap provides a unique and continuous (but mutable) 2108 /// descriptor (id) for each item of the same type (\c Node, \c Arc or 2109 /// \c Edge) in a graph. This id is 2110 /// - \b unique: different items get different ids, 2111 /// - \b continuous: the range of the ids is the set of integers 2112 /// between 0 and \c n-1, where \c n is the number of the items of 2113 /// this type (\c Node, \c Arc or \c Edge). So the id of an item can 2114 /// change if you delete an other item of the same type, i.e. this 2115 /// id is mutable. 2116 /// 2117 /// Thus this id is not (necessarily) the same as what can get using 2118 /// the \c id() function of the graph or \ref IdMap. 2119 /// This map can be inverted with its member class \c InverseMap, 2120 /// or with the \c operator() member. 2121 /// 2122 /// \tparam GR The graph type. 2123 /// \tparam K The key type of the map (\c GR::Node, \c GR::Arc or 2124 /// \c GR::Edge). 2125 /// 2126 /// \see IdMap 2127 template <typename GR, typename K> 2078 2128 class DescriptorMap 2079 : protected ItemSetTraits< _Graph, _Item>::template Map<int>::Type {2080 2081 typedef _Item Item;2082 typedef typename ItemSetTraits<_Graph, _Item>::template Map<int>::Type Map; 2083 2084 public:2085 /// The graph class of DescriptorMap.2086 typedef _Graph Graph;2087 2088 /// The key type of DescriptorMap ( Node, Arc,Edge).2089 typedef typename Map::KeyKey;2129 : protected ItemSetTraits<GR, K>::template Map<int>::Type { 2130 2131 typedef typename ItemSetTraits<GR, K>::template Map<int>::Type Map; 2132 2133 public: 2134 /// The graph type of DescriptorMap. 2135 typedef GR Graph; 2136 /// The key type of DescriptorMap (\c Node, \c Arc or \c Edge). 2137 typedef K Item; 2138 /// The key type of DescriptorMap (\c Node, \c Arc or \c Edge). 2139 typedef K Key; 2090 2140 /// The value type of DescriptorMap. 2091 typedef typename Map::ValueValue;2141 typedef int Value; 2092 2142 2093 2143 /// \brief Constructor. 2094 2144 /// 2095 2145 /// Constructor for descriptor map. 2096 explicit DescriptorMap(const Graph& _graph) : Map(_graph) {2146 explicit DescriptorMap(const Graph& gr) : Map(gr) { 2097 2147 Item it; 2098 2148 const typename Map::Notifier* nf = Map::notifier(); … … 2105 2155 protected: 2106 2156 2107 /// \brief Add a new key to the map.2157 /// \brief Adds a new key to the map. 2108 2158 /// 2109 2159 /// Add a new key to the map. It is called by the … … 2215 2265 2216 2266 public: 2267 2217 2268 /// \brief The inverse map type of DescriptorMap. 2218 2269 /// … … 2220 2271 class InverseMap { 2221 2272 public: 2222 /// \brief Constructor of the InverseMap.2273 /// \brief Constructor 2223 2274 /// 2224 2275 /// Constructor of the InverseMap. … … 2235 2286 /// 2236 2287 /// Subscript operator. It gives back the item 2237 /// that the descriptor belongs to currently.2288 /// that the descriptor currently belongs to. 2238 2289 Value operator[](const Key& key) const { 2239 2290 return _inverted(key); … … 2259 2310 }; 2260 2311 2261 /// \brief Returns the source of the given arc. 2262 /// 2263 /// The SourceMap gives back the source Node of the given arc. 2312 /// \brief Map of the source nodes of arcs in a digraph. 2313 /// 2314 /// SourceMap provides access for the source node of each arc in a digraph, 2315 /// which is returned by the \c source() function of the digraph. 2316 /// \tparam GR The digraph type. 2264 2317 /// \see TargetMap 2265 template <typename Digraph>2318 template <typename GR> 2266 2319 class SourceMap { 2267 2320 public: 2268 2321 2269 typedef typename Digraph::Node Value; 2270 typedef typename Digraph::Arc Key; 2322 ///\e 2323 typedef typename GR::Arc Key; 2324 ///\e 2325 typedef typename GR::Node Value; 2271 2326 2272 2327 /// \brief Constructor 2273 2328 /// 2274 /// Constructor 2329 /// Constructor. 2275 2330 /// \param digraph The digraph that the map belongs to. 2276 explicit SourceMap(const Digraph& digraph) : _digraph(digraph) {} 2277 2278 /// \brief The subscript operator. 2279 /// 2280 /// The subscript operator. 2281 /// \param arc The arc 2282 /// \return The source of the arc 2331 explicit SourceMap(const GR& digraph) : _graph(digraph) {} 2332 2333 /// \brief Returns the source node of the given arc. 2334 /// 2335 /// Returns the source node of the given arc. 2283 2336 Value operator[](const Key& arc) const { 2284 return _ digraph.source(arc);2337 return _graph.source(arc); 2285 2338 } 2286 2339 2287 2340 private: 2288 const Digraph& _digraph;2341 const GR& _graph; 2289 2342 }; 2290 2343 … … 2293 2346 /// This function just returns an \c SourceMap class. 2294 2347 /// \relates SourceMap 2295 template <typename Digraph> 2296 inline SourceMap<Digraph> sourceMap(const Digraph& digraph) { 2297 return SourceMap<Digraph>(digraph); 2298 } 2299 2300 /// \brief Returns the target of the given arc. 2301 /// 2302 /// The TargetMap gives back the target Node of the given arc. 2348 template <typename GR> 2349 inline SourceMap<GR> sourceMap(const GR& graph) { 2350 return SourceMap<GR>(graph); 2351 } 2352 2353 /// \brief Map of the target nodes of arcs in a digraph. 2354 /// 2355 /// TargetMap provides access for the target node of each arc in a digraph, 2356 /// which is returned by the \c target() function of the digraph. 2357 /// \tparam GR The digraph type. 2303 2358 /// \see SourceMap 2304 template <typename Digraph>2359 template <typename GR> 2305 2360 class TargetMap { 2306 2361 public: 2307 2362 2308 typedef typename Digraph::Node Value; 2309 typedef typename Digraph::Arc Key; 2363 ///\e 2364 typedef typename GR::Arc Key; 2365 ///\e 2366 typedef typename GR::Node Value; 2310 2367 2311 2368 /// \brief Constructor 2312 2369 /// 2313 /// Constructor 2370 /// Constructor. 2314 2371 /// \param digraph The digraph that the map belongs to. 2315 explicit TargetMap(const Digraph& digraph) : _digraph(digraph) {} 2316 2317 /// \brief The subscript operator. 2318 /// 2319 /// The subscript operator. 2320 /// \param e The arc 2321 /// \return The target of the arc 2372 explicit TargetMap(const GR& digraph) : _graph(digraph) {} 2373 2374 /// \brief Returns the target node of the given arc. 2375 /// 2376 /// Returns the target node of the given arc. 2322 2377 Value operator[](const Key& e) const { 2323 return _ digraph.target(e);2378 return _graph.target(e); 2324 2379 } 2325 2380 2326 2381 private: 2327 const Digraph& _digraph;2382 const GR& _graph; 2328 2383 }; 2329 2384 … … 2332 2387 /// This function just returns a \c TargetMap class. 2333 2388 /// \relates TargetMap 2334 template <typename Digraph> 2335 inline TargetMap<Digraph> targetMap(const Digraph& digraph) { 2336 return TargetMap<Digraph>(digraph); 2337 } 2338 2339 /// \brief Returns the "forward" directed arc view of an edge. 2340 /// 2341 /// Returns the "forward" directed arc view of an edge. 2389 template <typename GR> 2390 inline TargetMap<GR> targetMap(const GR& graph) { 2391 return TargetMap<GR>(graph); 2392 } 2393 2394 /// \brief Map of the "forward" directed arc view of edges in a graph. 2395 /// 2396 /// ForwardMap provides access for the "forward" directed arc view of 2397 /// each edge in a graph, which is returned by the \c direct() function 2398 /// of the graph with \c true parameter. 2399 /// \tparam GR The graph type. 2342 2400 /// \see BackwardMap 2343 template <typename G raph>2401 template <typename GR> 2344 2402 class ForwardMap { 2345 2403 public: 2346 2404 2347 typedef typename G raph::Arc Value;2348 typedef typename G raph::Edge Key;2405 typedef typename GR::Arc Value; 2406 typedef typename GR::Edge Key; 2349 2407 2350 2408 /// \brief Constructor 2351 2409 /// 2352 /// Constructor 2410 /// Constructor. 2353 2411 /// \param graph The graph that the map belongs to. 2354 explicit ForwardMap(const Graph& graph) : _graph(graph) {} 2355 2356 /// \brief The subscript operator. 2357 /// 2358 /// The subscript operator. 2359 /// \param key An edge 2360 /// \return The "forward" directed arc view of edge 2412 explicit ForwardMap(const GR& graph) : _graph(graph) {} 2413 2414 /// \brief Returns the "forward" directed arc view of the given edge. 2415 /// 2416 /// Returns the "forward" directed arc view of the given edge. 2361 2417 Value operator[](const Key& key) const { 2362 2418 return _graph.direct(key, true); … … 2364 2420 2365 2421 private: 2366 const G raph& _graph;2422 const GR& _graph; 2367 2423 }; 2368 2424 … … 2371 2427 /// This function just returns an \c ForwardMap class. 2372 2428 /// \relates ForwardMap 2373 template <typename Graph> 2374 inline ForwardMap<Graph> forwardMap(const Graph& graph) { 2375 return ForwardMap<Graph>(graph); 2376 } 2377 2378 /// \brief Returns the "backward" directed arc view of an edge. 2379 /// 2380 /// Returns the "backward" directed arc view of an edge. 2429 template <typename GR> 2430 inline ForwardMap<GR> forwardMap(const GR& graph) { 2431 return ForwardMap<GR>(graph); 2432 } 2433 2434 /// \brief Map of the "backward" directed arc view of edges in a graph. 2435 /// 2436 /// BackwardMap provides access for the "backward" directed arc view of 2437 /// each edge in a graph, which is returned by the \c direct() function 2438 /// of the graph with \c false parameter. 2439 /// \tparam GR The graph type. 2381 2440 /// \see ForwardMap 2382 template <typename G raph>2441 template <typename GR> 2383 2442 class BackwardMap { 2384 2443 public: 2385 2444 2386 typedef typename G raph::Arc Value;2387 typedef typename G raph::Edge Key;2445 typedef typename GR::Arc Value; 2446 typedef typename GR::Edge Key; 2388 2447 2389 2448 /// \brief Constructor 2390 2449 /// 2391 /// Constructor 2450 /// Constructor. 2392 2451 /// \param graph The graph that the map belongs to. 2393 explicit BackwardMap(const Graph& graph) : _graph(graph) {} 2394 2395 /// \brief The subscript operator. 2396 /// 2397 /// The subscript operator. 2398 /// \param key An edge 2399 /// \return The "backward" directed arc view of edge 2452 explicit BackwardMap(const GR& graph) : _graph(graph) {} 2453 2454 /// \brief Returns the "backward" directed arc view of the given edge. 2455 /// 2456 /// Returns the "backward" directed arc view of the given edge. 2400 2457 Value operator[](const Key& key) const { 2401 2458 return _graph.direct(key, false); … … 2403 2460 2404 2461 private: 2405 const G raph& _graph;2462 const GR& _graph; 2406 2463 }; 2407 2464 … … 2410 2467 /// This function just returns a \c BackwardMap class. 2411 2468 /// \relates BackwardMap 2412 template <typename Graph> 2413 inline BackwardMap<Graph> backwardMap(const Graph& graph) { 2414 return BackwardMap<Graph>(graph); 2415 } 2416 2417 /// \brief Potential difference map 2418 /// 2419 /// If there is an potential map on the nodes then we 2420 /// can get an arc map as we get the substraction of the 2421 /// values of the target and source. 2422 template <typename Digraph, typename NodeMap> 2423 class PotentialDifferenceMap { 2424 public: 2425 typedef typename Digraph::Arc Key; 2426 typedef typename NodeMap::Value Value; 2427 2428 /// \brief Constructor 2429 /// 2430 /// Contructor of the map 2431 explicit PotentialDifferenceMap(const Digraph& digraph, 2432 const NodeMap& potential) 2433 : _digraph(digraph), _potential(potential) {} 2434 2435 /// \brief Const subscription operator 2436 /// 2437 /// Const subscription operator 2438 Value operator[](const Key& arc) const { 2439 return _potential[_digraph.target(arc)] - 2440 _potential[_digraph.source(arc)]; 2441 } 2442 2443 private: 2444 const Digraph& _digraph; 2445 const NodeMap& _potential; 2446 }; 2447 2448 /// \brief Returns a PotentialDifferenceMap. 2449 /// 2450 /// This function just returns a PotentialDifferenceMap. 2451 /// \relates PotentialDifferenceMap 2452 template <typename Digraph, typename NodeMap> 2453 PotentialDifferenceMap<Digraph, NodeMap> 2454 potentialDifferenceMap(const Digraph& digraph, const NodeMap& potential) { 2455 return PotentialDifferenceMap<Digraph, NodeMap>(digraph, potential); 2456 } 2457 2458 /// \brief Map of the node in-degrees. 2469 template <typename GR> 2470 inline BackwardMap<GR> backwardMap(const GR& graph) { 2471 return BackwardMap<GR>(graph); 2472 } 2473 2474 /// \brief Map of the in-degrees of nodes in a digraph. 2459 2475 /// 2460 2476 /// This map returns the in-degree of a node. Once it is constructed, 2461 /// the degrees are stored in a standard NodeMap, so each query is done2477 /// the degrees are stored in a standard \c NodeMap, so each query is done 2462 2478 /// in constant time. On the other hand, the values are updated automatically 2463 2479 /// whenever the digraph changes. 2464 2480 /// 2465 /// \warning Besides addNode() and addArc(), a digraph structure may provide 2466 /// alternative ways to modify the digraph. The correct behavior of InDegMap 2467 /// is not guarantied if these additional features are used. For example 2468 /// the functions \ref ListDigraph::changeSource() "changeSource()", 2481 /// \warning Besides \c addNode() and \c addArc(), a digraph structure 2482 /// may provide alternative ways to modify the digraph. 2483 /// The correct behavior of InDegMap is not guarantied if these additional 2484 /// features are used. For example the functions 2485 /// \ref ListDigraph::changeSource() "changeSource()", 2469 2486 /// \ref ListDigraph::changeTarget() "changeTarget()" and 2470 2487 /// \ref ListDigraph::reverseArc() "reverseArc()" … … 2472 2489 /// 2473 2490 /// \sa OutDegMap 2474 2475 template <typename _Digraph> 2491 template <typename GR> 2476 2492 class InDegMap 2477 : protected ItemSetTraits< _Digraph, typename _Digraph::Arc>2493 : protected ItemSetTraits<GR, typename GR::Arc> 2478 2494 ::ItemNotifier::ObserverBase { 2479 2495 2480 2496 public: 2481 2482 typedef _Digraph Digraph; 2497 2498 /// The digraph type 2499 typedef GR Digraph; 2500 /// The key type 2501 typedef typename Digraph::Node Key; 2502 /// The value type 2483 2503 typedef int Value; 2484 typedef typename Digraph::Node Key;2485 2504 2486 2505 typedef typename ItemSetTraits<Digraph, typename Digraph::Arc> … … 2524 2543 /// \brief Constructor. 2525 2544 /// 2526 /// Constructor for creating in-degree map.2527 explicit InDegMap(const Digraph& digraph)2528 : _digraph( digraph), _deg(digraph) {2545 /// Constructor for creating an in-degree map. 2546 explicit InDegMap(const Digraph& graph) 2547 : _digraph(graph), _deg(graph) { 2529 2548 Parent::attach(_digraph.notifier(typename Digraph::Arc())); 2530 2549 … … 2534 2553 } 2535 2554 2555 /// \brief Gives back the in-degree of a Node. 2556 /// 2536 2557 /// Gives back the in-degree of a Node. 2537 2558 int operator[](const Key& key) const { … … 2580 2601 }; 2581 2602 2582 /// \brief Map of the node out-degrees.2603 /// \brief Map of the out-degrees of nodes in a digraph. 2583 2604 /// 2584 2605 /// This map returns the out-degree of a node. Once it is constructed, 2585 /// the degrees are stored in a standard NodeMap, so each query is done2606 /// the degrees are stored in a standard \c NodeMap, so each query is done 2586 2607 /// in constant time. On the other hand, the values are updated automatically 2587 2608 /// whenever the digraph changes. 2588 2609 /// 2589 /// \warning Besides addNode() and addArc(), a digraph structure may provide 2590 /// alternative ways to modify the digraph. The correct behavior of OutDegMap 2591 /// is not guarantied if these additional features are used. For example 2592 /// the functions \ref ListDigraph::changeSource() "changeSource()", 2610 /// \warning Besides \c addNode() and \c addArc(), a digraph structure 2611 /// may provide alternative ways to modify the digraph. 2612 /// The correct behavior of OutDegMap is not guarantied if these additional 2613 /// features are used. For example the functions 2614 /// \ref ListDigraph::changeSource() "changeSource()", 2593 2615 /// \ref ListDigraph::changeTarget() "changeTarget()" and 2594 2616 /// \ref ListDigraph::reverseArc() "reverseArc()" … … 2596 2618 /// 2597 2619 /// \sa InDegMap 2598 2599 template <typename _Digraph> 2620 template <typename GR> 2600 2621 class OutDegMap 2601 : protected ItemSetTraits< _Digraph, typename _Digraph::Arc>2622 : protected ItemSetTraits<GR, typename GR::Arc> 2602 2623 ::ItemNotifier::ObserverBase { 2603 2624 2604 2625 public: 2605 2626 2606 typedef _Digraph Digraph; 2627 /// The digraph type 2628 typedef GR Digraph; 2629 /// The key type 2630 typedef typename Digraph::Node Key; 2631 /// The value type 2607 2632 typedef int Value; 2608 typedef typename Digraph::Node Key;2609 2633 2610 2634 typedef typename ItemSetTraits<Digraph, typename Digraph::Arc> … … 2646 2670 /// \brief Constructor. 2647 2671 /// 2648 /// Constructor for creating out-degree map.2649 explicit OutDegMap(const Digraph& digraph)2650 : _digraph( digraph), _deg(digraph) {2672 /// Constructor for creating an out-degree map. 2673 explicit OutDegMap(const Digraph& graph) 2674 : _digraph(graph), _deg(graph) { 2651 2675 Parent::attach(_digraph.notifier(typename Digraph::Arc())); 2652 2676 … … 2656 2680 } 2657 2681 2682 /// \brief Gives back the out-degree of a Node. 2683 /// 2658 2684 /// Gives back the out-degree of a Node. 2659 2685 int operator[](const Key& key) const { … … 2702 2728 }; 2703 2729 2730 /// \brief Potential difference map 2731 /// 2732 /// PotentialMap returns the difference between the potentials of the 2733 /// source and target nodes of each arc in a digraph, i.e. it returns 2734 /// \code 2735 /// potential[gr.target(arc)] - potential[gr.source(arc)]. 2736 /// \endcode 2737 /// \tparam GR The digraph type. 2738 /// \tparam POT A node map storing the potentials. 2739 template <typename GR, typename POT> 2740 class PotentialDifferenceMap { 2741 public: 2742 /// Key type 2743 typedef typename GR::Arc Key; 2744 /// Value type 2745 typedef typename POT::Value Value; 2746 2747 /// \brief Constructor 2748 /// 2749 /// Contructor of the map. 2750 explicit PotentialDifferenceMap(const GR& gr, 2751 const POT& potential) 2752 : _digraph(gr), _potential(potential) {} 2753 2754 /// \brief Returns the potential difference for the given arc. 2755 /// 2756 /// Returns the potential difference for the given arc, i.e. 2757 /// \code 2758 /// potential[gr.target(arc)] - potential[gr.source(arc)]. 2759 /// \endcode 2760 Value operator[](const Key& arc) const { 2761 return _potential[_digraph.target(arc)] - 2762 _potential[_digraph.source(arc)]; 2763 } 2764 2765 private: 2766 const GR& _digraph; 2767 const POT& _potential; 2768 }; 2769 2770 /// \brief Returns a PotentialDifferenceMap. 2771 /// 2772 /// This function just returns a PotentialDifferenceMap. 2773 /// \relates PotentialDifferenceMap 2774 template <typename GR, typename POT> 2775 PotentialDifferenceMap<GR, POT> 2776 potentialDifferenceMap(const GR& gr, const POT& potential) { 2777 return PotentialDifferenceMap<GR, POT>(gr, potential); 2778 } 2779 2704 2780 /// @} 2705 2781 }
Note: See TracChangeset
for help on using the changeset viewer.