equal
deleted
inserted
replaced
1187 /// Build the unique map. It is called by the |
1187 /// Build the unique map. It is called by the |
1188 /// \c AlterationNotifier. |
1188 /// \c AlterationNotifier. |
1189 virtual void build() { |
1189 virtual void build() { |
1190 Map::build(); |
1190 Map::build(); |
1191 Item it; |
1191 Item it; |
1192 const typename Map::Graph* graph = Map::getGraph(); |
1192 const typename Map::Notifier* notifier = Map::getNotifier(); |
1193 for (graph->first(it); it != INVALID; graph->next(it)) { |
1193 for (notifier->first(it); it != INVALID; notifier->next(it)) { |
1194 Map::set(it, invMap.size()); |
1194 Map::set(it, invMap.size()); |
1195 invMap.push_back(it); |
1195 invMap.push_back(it); |
1196 } |
1196 } |
1197 } |
1197 } |
1198 |
1198 |
1495 /// |
1495 /// |
1496 /// \sa OutDegMap |
1496 /// \sa OutDegMap |
1497 |
1497 |
1498 template <typename _Graph> |
1498 template <typename _Graph> |
1499 class InDegMap |
1499 class InDegMap |
1500 : protected AlterationNotifier<typename _Graph::Edge>::ObserverBase { |
1500 : protected ItemSetTraits<_Graph, typename _Graph::Edge> |
|
1501 ::ItemNotifier::ObserverBase { |
1501 |
1502 |
1502 public: |
1503 public: |
1503 |
1504 |
1504 typedef _Graph Graph; |
1505 typedef _Graph Graph; |
1505 typedef int Value; |
1506 typedef int Value; |
1506 typedef typename Graph::Node Key; |
1507 typedef typename Graph::Node Key; |
|
1508 |
|
1509 typedef typename ItemSetTraits<_Graph, typename _Graph::Edge> |
|
1510 ::ItemNotifier::ObserverBase Parent; |
1507 |
1511 |
1508 private: |
1512 private: |
1509 |
1513 |
1510 class AutoNodeMap : public DefaultMap<_Graph, Key, int> { |
1514 class AutoNodeMap : public DefaultMap<_Graph, Key, int> { |
1511 public: |
1515 public: |
1531 |
1535 |
1532 /// \brief Constructor. |
1536 /// \brief Constructor. |
1533 /// |
1537 /// |
1534 /// Constructor for creating in-degree map. |
1538 /// Constructor for creating in-degree map. |
1535 InDegMap(const Graph& _graph) : graph(_graph), deg(_graph) { |
1539 InDegMap(const Graph& _graph) : graph(_graph), deg(_graph) { |
1536 AlterationNotifier<typename _Graph::Edge> |
1540 Parent::attach(graph.getNotifier(typename _Graph::Edge())); |
1537 ::ObserverBase::attach(graph.getNotifier(typename _Graph::Edge())); |
|
1538 |
1541 |
1539 for(typename _Graph::NodeIt it(graph); it != INVALID; ++it) { |
1542 for(typename _Graph::NodeIt it(graph); it != INVALID; ++it) { |
1540 deg[it] = countInEdges(graph, it); |
1543 deg[it] = countInEdges(graph, it); |
1541 } |
1544 } |
1542 } |
|
1543 |
|
1544 virtual ~InDegMap() { |
|
1545 AlterationNotifier<typename _Graph::Edge>:: |
|
1546 ObserverBase::detach(); |
|
1547 } |
1545 } |
1548 |
1546 |
1549 /// Gives back the in-degree of a Node. |
1547 /// Gives back the in-degree of a Node. |
1550 int operator[](const Key& key) const { |
1548 int operator[](const Key& key) const { |
1551 return deg[key]; |
1549 return deg[key]; |
1609 /// |
1607 /// |
1610 /// \sa InDegMap |
1608 /// \sa InDegMap |
1611 |
1609 |
1612 template <typename _Graph> |
1610 template <typename _Graph> |
1613 class OutDegMap |
1611 class OutDegMap |
1614 : protected AlterationNotifier<typename _Graph::Edge>::ObserverBase { |
1612 : protected ItemSetTraits<_Graph, typename _Graph::Edge> |
1615 |
1613 ::ItemNotifier::ObserverBase { |
1616 public: |
1614 |
|
1615 public: |
|
1616 |
|
1617 typedef typename ItemSetTraits<_Graph, typename _Graph::Edge> |
|
1618 ::ItemNotifier::ObserverBase Parent; |
1617 |
1619 |
1618 typedef _Graph Graph; |
1620 typedef _Graph Graph; |
1619 typedef int Value; |
1621 typedef int Value; |
1620 typedef typename Graph::Node Key; |
1622 typedef typename Graph::Node Key; |
1621 |
1623 |
1644 |
1646 |
1645 /// \brief Constructor. |
1647 /// \brief Constructor. |
1646 /// |
1648 /// |
1647 /// Constructor for creating out-degree map. |
1649 /// Constructor for creating out-degree map. |
1648 OutDegMap(const Graph& _graph) : graph(_graph), deg(_graph) { |
1650 OutDegMap(const Graph& _graph) : graph(_graph), deg(_graph) { |
1649 AlterationNotifier<typename _Graph::Edge> |
1651 Parent::attach(graph.getNotifier(typename _Graph::Edge())); |
1650 ::ObserverBase::attach(graph.getNotifier(typename _Graph::Edge())); |
|
1651 |
1652 |
1652 for(typename _Graph::NodeIt it(graph); it != INVALID; ++it) { |
1653 for(typename _Graph::NodeIt it(graph); it != INVALID; ++it) { |
1653 deg[it] = countOutEdges(graph, it); |
1654 deg[it] = countOutEdges(graph, it); |
1654 } |
1655 } |
1655 } |
1656 } |
1656 |
1657 |
1657 virtual ~OutDegMap() { |
|
1658 AlterationNotifier<typename _Graph::Edge>:: |
|
1659 ObserverBase::detach(); |
|
1660 } |
|
1661 |
|
1662 /// Gives back the out-degree of a Node. |
1658 /// Gives back the out-degree of a Node. |
1663 int operator[](const Key& key) const { |
1659 int operator[](const Key& key) const { |
1664 return deg[key]; |
1660 return deg[key]; |
1665 } |
1661 } |
1666 |
1662 |