lemon/concepts/graph_components.h
changeset 580 2313edd0db0b
parent 579 d11bf7998905
child 584 33c6b6e755cd
equal deleted inserted replaced
13:990865220ca6 14:7ea888c03671
   986     /// \brief Concept class for standard graph maps.
   986     /// \brief Concept class for standard graph maps.
   987     ///
   987     ///
   988     /// This class describes the concept of standard graph maps, i.e.
   988     /// This class describes the concept of standard graph maps, i.e.
   989     /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and 
   989     /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and 
   990     /// graph types, which can be used for associating data to graph items.
   990     /// graph types, which can be used for associating data to graph items.
       
   991     /// The standard graph maps must conform to the ReferenceMap concept.
   991     template <typename GR, typename K, typename V>
   992     template <typename GR, typename K, typename V>
   992     class GraphMap : public ReadWriteMap<K, V> {
   993     class GraphMap : public ReferenceMap<K, V, V&, const V&> {
   993     public:
   994     public:
   994 
   995 
   995       typedef ReadWriteMap<K, V> Parent;
   996       typedef ReadWriteMap<K, V> Parent;
   996 
   997 
   997       /// The graph type of the map.
   998       /// The graph type of the map.
   998       typedef GR Graph;
   999       typedef GR Graph;
   999       /// The key type of the map.
  1000       /// The key type of the map.
  1000       typedef K Key;
  1001       typedef K Key;
  1001       /// The value type of the map.
  1002       /// The value type of the map.
  1002       typedef V Value;
  1003       typedef V Value;
       
  1004       /// The reference type of the map.
       
  1005       typedef Value& Reference;
       
  1006       /// The const reference type of the map.
       
  1007       typedef const Value& ConstReference;
       
  1008 
       
  1009       // The reference map tag.
       
  1010       typedef True ReferenceMapTag;
  1003 
  1011 
  1004       /// \brief Construct a new map.
  1012       /// \brief Construct a new map.
  1005       ///
  1013       ///
  1006       /// Construct a new map for the graph.
  1014       /// Construct a new map for the graph.
  1007       explicit GraphMap(const Graph&) {}
  1015       explicit GraphMap(const Graph&) {}
  1029 
  1037 
  1030     public:
  1038     public:
  1031       template<typename _Map>
  1039       template<typename _Map>
  1032       struct Constraints {
  1040       struct Constraints {
  1033         void constraints() {
  1041         void constraints() {
  1034           checkConcept<ReadWriteMap<Key, Value>, _Map >();
  1042           checkConcept
       
  1043             <ReferenceMap<Key, Value, Value&, const Value&>, _Map>();
  1035           _Map m1(g);
  1044           _Map m1(g);
  1036           _Map m2(g,t);
  1045           _Map m2(g,t);
  1037           
  1046           
  1038           // Copy constructor
  1047           // Copy constructor
  1039           // _Map m3(m);
  1048           // _Map m3(m);
  1071       typedef MappableDigraphComponent Digraph;
  1080       typedef MappableDigraphComponent Digraph;
  1072 
  1081 
  1073       /// \brief Standard graph map for the nodes.
  1082       /// \brief Standard graph map for the nodes.
  1074       ///
  1083       ///
  1075       /// Standard graph map for the nodes.
  1084       /// Standard graph map for the nodes.
       
  1085       /// It conforms to the ReferenceMap concept.
  1076       template <typename V>
  1086       template <typename V>
  1077       class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
  1087       class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
  1078       public:
  1088       public:
  1079         typedef GraphMap<MappableDigraphComponent, Node, V> Parent;
  1089         typedef GraphMap<MappableDigraphComponent, Node, V> Parent;
  1080 
  1090 
  1108       };
  1118       };
  1109 
  1119 
  1110       /// \brief Standard graph map for the arcs.
  1120       /// \brief Standard graph map for the arcs.
  1111       ///
  1121       ///
  1112       /// Standard graph map for the arcs.
  1122       /// Standard graph map for the arcs.
       
  1123       /// It conforms to the ReferenceMap concept.
  1113       template <typename V>
  1124       template <typename V>
  1114       class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
  1125       class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
  1115       public:
  1126       public:
  1116         typedef GraphMap<MappableDigraphComponent, Arc, V> Parent;
  1127         typedef GraphMap<MappableDigraphComponent, Arc, V> Parent;
  1117 
  1128 
  1205       typedef MappableGraphComponent Graph;
  1216       typedef MappableGraphComponent Graph;
  1206 
  1217 
  1207       /// \brief Standard graph map for the edges.
  1218       /// \brief Standard graph map for the edges.
  1208       ///
  1219       ///
  1209       /// Standard graph map for the edges.
  1220       /// Standard graph map for the edges.
       
  1221       /// It conforms to the ReferenceMap concept.
  1210       template <typename V>
  1222       template <typename V>
  1211       class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
  1223       class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
  1212       public:
  1224       public:
  1213         typedef GraphMap<MappableGraphComponent, Edge, V> Parent;
  1225         typedef GraphMap<MappableGraphComponent, Edge, V> Parent;
  1214 
  1226