lemon/concepts/graph_components.h
changeset 1026 699c7eac2c6d
parent 1025 c8fa41fcc4a7
child 1027 8b2b9e61d8ce
equal deleted inserted replaced
30:cab561a86a73 31:0e0cce39f604
  1204       /// @{
  1204       /// @{
  1205 
  1205 
  1206       /// \brief This iterator goes through each red node.
  1206       /// \brief This iterator goes through each red node.
  1207       ///
  1207       ///
  1208       /// This iterator goes through each red node.
  1208       /// This iterator goes through each red node.
  1209       typedef GraphItemIt<BpGraph, RedNode> RedIt;
  1209       typedef GraphItemIt<BpGraph, RedNode> RedNodeIt;
  1210 
  1210 
  1211       /// \brief This iterator goes through each blue node.
  1211       /// \brief This iterator goes through each blue node.
  1212       ///
  1212       ///
  1213       /// This iterator goes through each blue node.
  1213       /// This iterator goes through each blue node.
  1214       typedef GraphItemIt<BpGraph, BlueNode> BlueIt;
  1214       typedef GraphItemIt<BpGraph, BlueNode> BlueNodeIt;
  1215 
  1215 
  1216       /// @}
  1216       /// @}
  1217 
  1217 
  1218       template <typename _BpGraph>
  1218       template <typename _BpGraph>
  1219       struct Constraints {
  1219       struct Constraints {
  1226           typename _BpGraph::BlueNode bn(INVALID);
  1226           typename _BpGraph::BlueNode bn(INVALID);
  1227           bpgraph.first(bn);
  1227           bpgraph.first(bn);
  1228           bpgraph.next(bn);
  1228           bpgraph.next(bn);
  1229 
  1229 
  1230           checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::RedNode>,
  1230           checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::RedNode>,
  1231             typename _BpGraph::RedIt>();
  1231             typename _BpGraph::RedNodeIt>();
  1232           checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::BlueNode>,
  1232           checkConcept<GraphItemIt<_BpGraph, typename _BpGraph::BlueNode>,
  1233             typename _BpGraph::BlueIt>();
  1233             typename _BpGraph::BlueNodeIt>();
  1234         }
  1234         }
  1235 
  1235 
  1236         const _BpGraph& bpgraph;
  1236         const _BpGraph& bpgraph;
  1237       };
  1237       };
  1238     };
  1238     };
  1713     /// \brief Skeleton class for mappable undirected bipartite graphs.
  1713     /// \brief Skeleton class for mappable undirected bipartite graphs.
  1714     ///
  1714     ///
  1715     /// This class describes the interface of mappable undirected
  1715     /// This class describes the interface of mappable undirected
  1716     /// bipartite graphs.  It extends \ref MappableGraphComponent with
  1716     /// bipartite graphs.  It extends \ref MappableGraphComponent with
  1717     /// the standard graph map class for red and blue nodes (\c
  1717     /// the standard graph map class for red and blue nodes (\c
  1718     /// RedMap and BlueMap). This concept is part of the BpGraph concept.
  1718     /// RedNodeMap and BlueNodeMap). This concept is part of the
       
  1719     /// BpGraph concept.
  1719     template <typename BAS = BaseBpGraphComponent>
  1720     template <typename BAS = BaseBpGraphComponent>
  1720     class MappableBpGraphComponent : public MappableGraphComponent<BAS>  {
  1721     class MappableBpGraphComponent : public MappableGraphComponent<BAS>  {
  1721     public:
  1722     public:
  1722 
  1723 
  1723       typedef BAS Base;
  1724       typedef BAS Base;
  1728       /// \brief Standard graph map for the red nodes.
  1729       /// \brief Standard graph map for the red nodes.
  1729       ///
  1730       ///
  1730       /// Standard graph map for the red nodes.
  1731       /// Standard graph map for the red nodes.
  1731       /// It conforms to the ReferenceMap concept.
  1732       /// It conforms to the ReferenceMap concept.
  1732       template <typename V>
  1733       template <typename V>
  1733       class RedMap : public GraphMap<MappableBpGraphComponent, Node, V> {
  1734       class RedNodeMap : public GraphMap<MappableBpGraphComponent, Node, V> {
  1734         typedef GraphMap<MappableBpGraphComponent, Node, V> Parent;
  1735         typedef GraphMap<MappableBpGraphComponent, Node, V> Parent;
  1735 
  1736 
  1736       public:
  1737       public:
  1737         /// \brief Construct a new map.
  1738         /// \brief Construct a new map.
  1738         ///
  1739         ///
  1739         /// Construct a new map for the graph.
  1740         /// Construct a new map for the graph.
  1740         explicit RedMap(const MappableBpGraphComponent& graph)
  1741         explicit RedNodeMap(const MappableBpGraphComponent& graph)
  1741           : Parent(graph) {}
  1742           : Parent(graph) {}
  1742 
  1743 
  1743         /// \brief Construct a new map with default value.
  1744         /// \brief Construct a new map with default value.
  1744         ///
  1745         ///
  1745         /// Construct a new map for the graph and initalize the values.
  1746         /// Construct a new map for the graph and initalize the values.
  1746         RedMap(const MappableBpGraphComponent& graph, const V& value)
  1747         RedNodeMap(const MappableBpGraphComponent& graph, const V& value)
  1747           : Parent(graph, value) {}
  1748           : Parent(graph, value) {}
  1748 
  1749 
  1749       private:
  1750       private:
  1750         /// \brief Copy constructor.
  1751         /// \brief Copy constructor.
  1751         ///
  1752         ///
  1752         /// Copy Constructor.
  1753         /// Copy Constructor.
  1753         RedMap(const RedMap& nm) : Parent(nm) {}
  1754         RedNodeMap(const RedNodeMap& nm) : Parent(nm) {}
  1754 
  1755 
  1755         /// \brief Assignment operator.
  1756         /// \brief Assignment operator.
  1756         ///
  1757         ///
  1757         /// Assignment operator.
  1758         /// Assignment operator.
  1758         template <typename CMap>
  1759         template <typename CMap>
  1759         RedMap& operator=(const CMap&) {
  1760         RedNodeMap& operator=(const CMap&) {
  1760           checkConcept<ReadMap<Node, V>, CMap>();
  1761           checkConcept<ReadMap<Node, V>, CMap>();
  1761           return *this;
  1762           return *this;
  1762         }
  1763         }
  1763 
  1764 
  1764       };
  1765       };
  1766       /// \brief Standard graph map for the blue nodes.
  1767       /// \brief Standard graph map for the blue nodes.
  1767       ///
  1768       ///
  1768       /// Standard graph map for the blue nodes.
  1769       /// Standard graph map for the blue nodes.
  1769       /// It conforms to the ReferenceMap concept.
  1770       /// It conforms to the ReferenceMap concept.
  1770       template <typename V>
  1771       template <typename V>
  1771       class BlueMap : public GraphMap<MappableBpGraphComponent, Node, V> {
  1772       class BlueNodeMap : public GraphMap<MappableBpGraphComponent, Node, V> {
  1772         typedef GraphMap<MappableBpGraphComponent, Node, V> Parent;
  1773         typedef GraphMap<MappableBpGraphComponent, Node, V> Parent;
  1773 
  1774 
  1774       public:
  1775       public:
  1775         /// \brief Construct a new map.
  1776         /// \brief Construct a new map.
  1776         ///
  1777         ///
  1777         /// Construct a new map for the graph.
  1778         /// Construct a new map for the graph.
  1778         explicit BlueMap(const MappableBpGraphComponent& graph)
  1779         explicit BlueNodeMap(const MappableBpGraphComponent& graph)
  1779           : Parent(graph) {}
  1780           : Parent(graph) {}
  1780 
  1781 
  1781         /// \brief Construct a new map with default value.
  1782         /// \brief Construct a new map with default value.
  1782         ///
  1783         ///
  1783         /// Construct a new map for the graph and initalize the values.
  1784         /// Construct a new map for the graph and initalize the values.
  1784         BlueMap(const MappableBpGraphComponent& graph, const V& value)
  1785         BlueNodeMap(const MappableBpGraphComponent& graph, const V& value)
  1785           : Parent(graph, value) {}
  1786           : Parent(graph, value) {}
  1786 
  1787 
  1787       private:
  1788       private:
  1788         /// \brief Copy constructor.
  1789         /// \brief Copy constructor.
  1789         ///
  1790         ///
  1790         /// Copy Constructor.
  1791         /// Copy Constructor.
  1791         BlueMap(const BlueMap& nm) : Parent(nm) {}
  1792         BlueNodeMap(const BlueNodeMap& nm) : Parent(nm) {}
  1792 
  1793 
  1793         /// \brief Assignment operator.
  1794         /// \brief Assignment operator.
  1794         ///
  1795         ///
  1795         /// Assignment operator.
  1796         /// Assignment operator.
  1796         template <typename CMap>
  1797         template <typename CMap>
  1797         BlueMap& operator=(const CMap&) {
  1798         BlueNodeMap& operator=(const CMap&) {
  1798           checkConcept<ReadMap<Node, V>, CMap>();
  1799           checkConcept<ReadMap<Node, V>, CMap>();
  1799           return *this;
  1800           return *this;
  1800         }
  1801         }
  1801 
  1802 
  1802       };
  1803       };
  1813 
  1814 
  1814         void constraints() {
  1815         void constraints() {
  1815           checkConcept<MappableGraphComponent<Base>, _BpGraph>();
  1816           checkConcept<MappableGraphComponent<Base>, _BpGraph>();
  1816 
  1817 
  1817           { // int map test
  1818           { // int map test
  1818             typedef typename _BpGraph::template RedMap<int> IntRedMap;
  1819             typedef typename _BpGraph::template RedNodeMap<int>
       
  1820               IntRedNodeMap;
  1819             checkConcept<GraphMap<_BpGraph, typename _BpGraph::RedNode, int>,
  1821             checkConcept<GraphMap<_BpGraph, typename _BpGraph::RedNode, int>,
  1820               IntRedMap >();
  1822               IntRedNodeMap >();
  1821           } { // bool map test
  1823           } { // bool map test
  1822             typedef typename _BpGraph::template RedMap<bool> BoolRedMap;
  1824             typedef typename _BpGraph::template RedNodeMap<bool>
       
  1825               BoolRedNodeMap;
  1823             checkConcept<GraphMap<_BpGraph, typename _BpGraph::RedNode, bool>,
  1826             checkConcept<GraphMap<_BpGraph, typename _BpGraph::RedNode, bool>,
  1824               BoolRedMap >();
  1827               BoolRedNodeMap >();
  1825           } { // Dummy map test
  1828           } { // Dummy map test
  1826             typedef typename _BpGraph::template RedMap<Dummy> DummyRedMap;
  1829             typedef typename _BpGraph::template RedNodeMap<Dummy>
       
  1830               DummyRedNodeMap;
  1827             checkConcept<GraphMap<_BpGraph, typename _BpGraph::RedNode, Dummy>,
  1831             checkConcept<GraphMap<_BpGraph, typename _BpGraph::RedNode, Dummy>,
  1828               DummyRedMap >();
  1832               DummyRedNodeMap >();
  1829           }
  1833           }
  1830 
  1834 
  1831           { // int map test
  1835           { // int map test
  1832             typedef typename _BpGraph::template BlueMap<int> IntBlueMap;
  1836             typedef typename _BpGraph::template BlueNodeMap<int>
       
  1837               IntBlueNodeMap;
  1833             checkConcept<GraphMap<_BpGraph, typename _BpGraph::BlueNode, int>,
  1838             checkConcept<GraphMap<_BpGraph, typename _BpGraph::BlueNode, int>,
  1834               IntBlueMap >();
  1839               IntBlueNodeMap >();
  1835           } { // bool map test
  1840           } { // bool map test
  1836             typedef typename _BpGraph::template BlueMap<bool> BoolBlueMap;
  1841             typedef typename _BpGraph::template BlueNodeMap<bool>
       
  1842               BoolBlueNodeMap;
  1837             checkConcept<GraphMap<_BpGraph, typename _BpGraph::BlueNode, bool>,
  1843             checkConcept<GraphMap<_BpGraph, typename _BpGraph::BlueNode, bool>,
  1838               BoolBlueMap >();
  1844               BoolBlueNodeMap >();
  1839           } { // Dummy map test
  1845           } { // Dummy map test
  1840             typedef typename _BpGraph::template BlueMap<Dummy> DummyBlueMap;
  1846             typedef typename _BpGraph::template BlueNodeMap<Dummy>
       
  1847               DummyBlueNodeMap;
  1841             checkConcept<GraphMap<_BpGraph, typename _BpGraph::BlueNode, Dummy>,
  1848             checkConcept<GraphMap<_BpGraph, typename _BpGraph::BlueNode, Dummy>,
  1842               DummyBlueMap >();
  1849               DummyBlueNodeMap >();
  1843           }
  1850           }
  1844         }
  1851         }
  1845 
  1852 
  1846         const _BpGraph& bpgraph;
  1853         const _BpGraph& bpgraph;
  1847       };
  1854       };