equal
deleted
inserted
replaced
26 |
26 |
27 #include <lemon/invalid.h> |
27 #include <lemon/invalid.h> |
28 #include <lemon/utility.h> |
28 #include <lemon/utility.h> |
29 #include <lemon/maps.h> |
29 #include <lemon/maps.h> |
30 #include <lemon/traits.h> |
30 #include <lemon/traits.h> |
|
31 |
31 #include <lemon/bits/alteration_notifier.h> |
32 #include <lemon/bits/alteration_notifier.h> |
|
33 #include <lemon/bits/default_map.h> |
32 |
34 |
33 ///\ingroup gutils |
35 ///\ingroup gutils |
34 ///\file |
36 ///\file |
35 ///\brief Graph utilities. |
37 ///\brief Graph utilities. |
36 /// |
38 /// |
898 /// |
900 /// |
899 /// \see IterableValueMap |
901 /// \see IterableValueMap |
900 #ifndef DOXYGEN |
902 #ifndef DOXYGEN |
901 /// \param _Map A ReadWriteMap mapping from the item type to integer. |
903 /// \param _Map A ReadWriteMap mapping from the item type to integer. |
902 template < |
904 template < |
903 typename _Graph, typename _Item, typename _Value, typename _Map |
905 typename _Graph, typename _Item, typename _Value, |
904 = typename ItemSetTraits<_Graph, _Item>::template Map<_Value>::Parent |
906 typename _Map = DefaultMap<_Graph, _Item, _Value> |
905 > |
907 > |
906 #else |
908 #else |
907 template <typename _Graph, typename _Item, typename _Value> |
909 template <typename _Graph, typename _Item, typename _Value> |
908 #endif |
910 #endif |
909 class InvertableMap : protected _Map { |
911 class InvertableMap : protected _Map { |
1103 /// \param _Item The Item is the Key of the Map. It may be Node, Edge or |
1105 /// \param _Item The Item is the Key of the Map. It may be Node, Edge or |
1104 /// UEdge. |
1106 /// UEdge. |
1105 #ifndef DOXYGEN |
1107 #ifndef DOXYGEN |
1106 /// \param _Map A ReadWriteMap mapping from the item type to integer. |
1108 /// \param _Map A ReadWriteMap mapping from the item type to integer. |
1107 template < |
1109 template < |
1108 typename _Graph, typename _Item, typename _Map |
1110 typename _Graph, typename _Item, |
1109 = typename ItemSetTraits<_Graph, _Item>::template Map<int>::Parent |
1111 typename _Map = DefaultMap<_Graph, _Item, int> |
1110 > |
1112 > |
1111 #else |
1113 #else |
1112 template <typename _Graph, typename _Item> |
1114 template <typename _Graph, typename _Item> |
1113 #endif |
1115 #endif |
1114 class DescriptorMap : protected _Map { |
1116 class DescriptorMap : protected _Map { |
1503 typedef int Value; |
1505 typedef int Value; |
1504 typedef typename Graph::Node Key; |
1506 typedef typename Graph::Node Key; |
1505 |
1507 |
1506 private: |
1508 private: |
1507 |
1509 |
1508 class AutoNodeMap : public Graph::template NodeMap<int> { |
1510 class AutoNodeMap : public DefaultMap<_Graph, Key, int> { |
1509 public: |
1511 public: |
1510 |
1512 |
1511 typedef typename Graph::template NodeMap<int> Parent; |
1513 typedef DefaultMap<_Graph, Key, int> Parent; |
1512 |
1514 |
1513 typedef typename Parent::Key Key; |
|
1514 typedef typename Parent::Value Value; |
|
1515 |
|
1516 AutoNodeMap(const Graph& graph) : Parent(graph, 0) {} |
1515 AutoNodeMap(const Graph& graph) : Parent(graph, 0) {} |
1517 |
1516 |
1518 virtual void add(const Key& key) { |
1517 virtual void add(const Key& key) { |
1519 Parent::add(key); |
1518 Parent::add(key); |
1520 Parent::set(key, 0); |
1519 Parent::set(key, 0); |
1620 typedef int Value; |
1619 typedef int Value; |
1621 typedef typename Graph::Node Key; |
1620 typedef typename Graph::Node Key; |
1622 |
1621 |
1623 private: |
1622 private: |
1624 |
1623 |
1625 class AutoNodeMap : public Graph::template NodeMap<int> { |
1624 class AutoNodeMap : public DefaultMap<_Graph, Key, int> { |
1626 public: |
1625 public: |
1627 |
1626 |
1628 typedef typename Graph::template NodeMap<int> Parent; |
1627 typedef DefaultMap<_Graph, Key, int> Parent; |
1629 |
1628 |
1630 typedef typename Parent::Key Key; |
|
1631 typedef typename Parent::Value Value; |
|
1632 |
|
1633 AutoNodeMap(const Graph& graph) : Parent(graph, 0) {} |
1629 AutoNodeMap(const Graph& graph) : Parent(graph, 0) {} |
1634 |
1630 |
1635 virtual void add(const Key& key) { |
1631 virtual void add(const Key& key) { |
1636 Parent::add(key); |
1632 Parent::add(key); |
1637 Parent::set(key, 0); |
1633 Parent::set(key, 0); |
1661 virtual ~OutDegMap() { |
1657 virtual ~OutDegMap() { |
1662 AlterationNotifier<typename _Graph::Edge>:: |
1658 AlterationNotifier<typename _Graph::Edge>:: |
1663 ObserverBase::detach(); |
1659 ObserverBase::detach(); |
1664 } |
1660 } |
1665 |
1661 |
1666 /// Gives back the in-degree of a Node. |
1662 /// Gives back the out-degree of a Node. |
1667 int operator[](const Key& key) const { |
1663 int operator[](const Key& key) const { |
1668 return deg[key]; |
1664 return deg[key]; |
1669 } |
1665 } |
1670 |
1666 |
1671 protected: |
1667 protected: |