lemon/graph_utils.h
changeset 2288 ef8af928c54e
parent 2286 1ef281b2b10e
child 2290 f30867b359a8
equal deleted inserted replaced
56:d4f1db41e646 57:005459e3ef69
  1130   /// \param _Graph The graph type.
  1130   /// \param _Graph The graph type.
  1131   /// \param _Item The item type of the graph.
  1131   /// \param _Item The item type of the graph.
  1132   /// \param _Value The value type of the map.
  1132   /// \param _Value The value type of the map.
  1133   ///
  1133   ///
  1134   /// \see IterableValueMap
  1134   /// \see IterableValueMap
  1135 #ifndef DOXYGEN
       
  1136   /// \param _Map A ReadWriteMap mapping from the item type to integer.
       
  1137   template <
       
  1138     typename _Graph, typename _Item, typename _Value, 
       
  1139     typename _Map = DefaultMap<_Graph, _Item, _Value>
       
  1140   >
       
  1141 #else
       
  1142   template <typename _Graph, typename _Item, typename _Value>
  1135   template <typename _Graph, typename _Item, typename _Value>
  1143 #endif
  1136   class InvertableMap : protected DefaultMap<_Graph, _Item, _Value> {
  1144   class InvertableMap : protected _Map {
       
  1145   public:
       
  1146 
       
  1147     /// The key type of InvertableMap (Node, Edge, UEdge).
       
  1148     typedef typename _Map::Key Key;
       
  1149     /// The value type of the InvertableMap.
       
  1150     typedef typename _Map::Value Value;
       
  1151 
       
  1152   private:
  1137   private:
  1153     
  1138     
  1154     typedef _Map Map;
  1139     typedef DefaultMap<_Graph, _Item, _Value> Map;
  1155     typedef _Graph Graph;
  1140     typedef _Graph Graph;
  1156 
  1141 
  1157     typedef std::map<Value, Key> Container;
  1142     typedef std::map<_Value, _Item> Container;
  1158     Container invMap;    
  1143     Container invMap;    
  1159 
  1144 
  1160   public:
  1145   public:
  1161  
  1146  
       
  1147     /// The key type of InvertableMap (Node, Edge, UEdge).
       
  1148     typedef typename Map::Key Key;
       
  1149     /// The value type of the InvertableMap.
       
  1150     typedef typename Map::Value Value;
       
  1151 
  1162 
  1152 
  1163 
  1153 
  1164     /// \brief Constructor.
  1154     /// \brief Constructor.
  1165     ///
  1155     ///
  1166     /// Construct a new InvertableMap for the graph.
  1156     /// Construct a new InvertableMap for the graph.
  1336   /// with its member class \c InverseMap.
  1326   /// with its member class \c InverseMap.
  1337   ///
  1327   ///
  1338   /// \param _Graph The graph class the \c DescriptorMap belongs to.
  1328   /// \param _Graph The graph class the \c DescriptorMap belongs to.
  1339   /// \param _Item The Item is the Key of the Map. It may be Node, Edge or 
  1329   /// \param _Item The Item is the Key of the Map. It may be Node, Edge or 
  1340   /// UEdge.
  1330   /// UEdge.
  1341 #ifndef DOXYGEN
       
  1342   /// \param _Map A ReadWriteMap mapping from the item type to integer.
       
  1343   template <
       
  1344     typename _Graph, typename _Item,
       
  1345     typename _Map = DefaultMap<_Graph, _Item, int>
       
  1346   >
       
  1347 #else
       
  1348   template <typename _Graph, typename _Item>
  1331   template <typename _Graph, typename _Item>
  1349 #endif
  1332   class DescriptorMap : protected DefaultMap<_Graph, _Item, int> {
  1350   class DescriptorMap : protected _Map {
       
  1351 
  1333 
  1352     typedef _Item Item;
  1334     typedef _Item Item;
  1353     typedef _Map Map;
  1335     typedef DefaultMap<_Graph, _Item, int> Map;
  1354 
  1336 
  1355   public:
  1337   public:
  1356     /// The graph class of DescriptorMap.
  1338     /// The graph class of DescriptorMap.
  1357     typedef _Graph Graph;
  1339     typedef _Graph Graph;
  1358 
  1340 
  1359     /// The key type of DescriptorMap (Node, Edge, UEdge).
  1341     /// The key type of DescriptorMap (Node, Edge, UEdge).
  1360     typedef typename _Map::Key Key;
  1342     typedef typename Map::Key Key;
  1361     /// The value type of DescriptorMap.
  1343     /// The value type of DescriptorMap.
  1362     typedef typename _Map::Value Value;
  1344     typedef typename Map::Value Value;
  1363 
  1345 
  1364     /// \brief Constructor.
  1346     /// \brief Constructor.
  1365     ///
  1347     ///
  1366     /// Constructor for descriptor map.
  1348     /// Constructor for descriptor map.
  1367     explicit DescriptorMap(const Graph& _graph) : Map(_graph) {
  1349     explicit DescriptorMap(const Graph& _graph) : Map(_graph) {
  1370       for (notifier->first(it); it != INVALID; notifier->next(it)) {
  1352       for (notifier->first(it); it != INVALID; notifier->next(it)) {
  1371 	Map::set(it, invMap.size());
  1353 	Map::set(it, invMap.size());
  1372 	invMap.push_back(it);	
  1354 	invMap.push_back(it);	
  1373       }      
  1355       }      
  1374     }
  1356     }
  1375 
       
  1376 
  1357 
  1377   protected:
  1358   protected:
  1378 
  1359 
  1379     /// \brief Add a new key to the map.
  1360     /// \brief Add a new key to the map.
  1380     ///
  1361     ///