lemon/concepts/graph_components.h
changeset 630 936355864d6e
parent 584 33c6b6e755cd
child 666 1993af615e68
equal deleted inserted replaced
15:db14092094c7 16:7ae9bc586e4b
   178     /// It extends the interface of \ref BaseDigraphComponent with an
   178     /// It extends the interface of \ref BaseDigraphComponent with an
   179     /// \c Edge type and functions to get the end nodes of edges,
   179     /// \c Edge type and functions to get the end nodes of edges,
   180     /// to convert from arcs to edges and to get both direction of edges.
   180     /// to convert from arcs to edges and to get both direction of edges.
   181     class BaseGraphComponent : public BaseDigraphComponent {
   181     class BaseGraphComponent : public BaseDigraphComponent {
   182     public:
   182     public:
       
   183 
       
   184       typedef BaseGraphComponent Graph;
       
   185 
   183       typedef BaseDigraphComponent::Node Node;
   186       typedef BaseDigraphComponent::Node Node;
   184       typedef BaseDigraphComponent::Arc Arc;
   187       typedef BaseDigraphComponent::Arc Arc;
   185 
   188 
   186       /// \brief Undirected edge class of the graph.
   189       /// \brief Undirected edge class of the graph.
   187       ///
   190       ///
   188       /// This class represents the undirected edges of the graph.
   191       /// This class represents the undirected edges of the graph.
   189       /// Undirected graphs can be used as directed graphs, each edge is
   192       /// Undirected graphs can be used as directed graphs, each edge is
   190       /// represented by two opposite directed arcs.
   193       /// represented by two opposite directed arcs.
   191       class Edge : public GraphItem<'e'> {
   194       class Edge : public GraphItem<'e'> {
       
   195         typedef GraphItem<'e'> Parent;
       
   196 
   192       public:
   197       public:
   193         typedef GraphItem<'e'> Parent;
       
   194 
       
   195         /// \brief Default constructor.
   198         /// \brief Default constructor.
   196         ///
   199         ///
   197         /// Default constructor.
   200         /// Default constructor.
   198         /// \warning The default constructor is not required to set
   201         /// \warning The default constructor is not required to set
   199         /// the item to some well-defined value. So you should consider it
   202         /// the item to some well-defined value. So you should consider it
   989     /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and 
   992     /// 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.
   993     /// graph types, which can be used for associating data to graph items.
   991     /// The standard graph maps must conform to the ReferenceMap concept.
   994     /// The standard graph maps must conform to the ReferenceMap concept.
   992     template <typename GR, typename K, typename V>
   995     template <typename GR, typename K, typename V>
   993     class GraphMap : public ReferenceMap<K, V, V&, const V&> {
   996     class GraphMap : public ReferenceMap<K, V, V&, const V&> {
   994     public:
   997       typedef ReferenceMap<K, V, V&, const V&> Parent;
   995 
   998 
   996       typedef ReadWriteMap<K, V> Parent;
   999     public:
   997 
  1000 
   998       /// The graph type of the map.
       
   999       typedef GR Graph;
       
  1000       /// The key type of the map.
  1001       /// The key type of the map.
  1001       typedef K Key;
  1002       typedef K Key;
  1002       /// The value type of the map.
  1003       /// The value type of the map.
  1003       typedef V Value;
  1004       typedef V Value;
  1004       /// The reference type of the map.
  1005       /// The reference type of the map.
  1010       typedef True ReferenceMapTag;
  1011       typedef True ReferenceMapTag;
  1011 
  1012 
  1012       /// \brief Construct a new map.
  1013       /// \brief Construct a new map.
  1013       ///
  1014       ///
  1014       /// Construct a new map for the graph.
  1015       /// Construct a new map for the graph.
  1015       explicit GraphMap(const Graph&) {}
  1016       explicit GraphMap(const GR&) {}
  1016       /// \brief Construct a new map with default value.
  1017       /// \brief Construct a new map with default value.
  1017       ///
  1018       ///
  1018       /// Construct a new map for the graph and initalize the values.
  1019       /// Construct a new map for the graph and initalize the values.
  1019       GraphMap(const Graph&, const Value&) {}
  1020       GraphMap(const GR&, const Value&) {}
  1020 
  1021 
  1021     private:
  1022     private:
  1022       /// \brief Copy constructor.
  1023       /// \brief Copy constructor.
  1023       ///
  1024       ///
  1024       /// Copy Constructor.
  1025       /// Copy Constructor.
  1055           ignore_unused_variable_warning(m2);
  1056           ignore_unused_variable_warning(m2);
  1056           // ignore_unused_variable_warning(m3);
  1057           // ignore_unused_variable_warning(m3);
  1057         }
  1058         }
  1058 
  1059 
  1059         const _Map &m;
  1060         const _Map &m;
  1060         const Graph &g;
  1061         const GR &g;
  1061         const typename GraphMap::Value &t;
  1062         const typename GraphMap::Value &t;
  1062       };
  1063       };
  1063 
  1064 
  1064     };
  1065     };
  1065 
  1066 
  1083       ///
  1084       ///
  1084       /// Standard graph map for the nodes.
  1085       /// Standard graph map for the nodes.
  1085       /// It conforms to the ReferenceMap concept.
  1086       /// It conforms to the ReferenceMap concept.
  1086       template <typename V>
  1087       template <typename V>
  1087       class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
  1088       class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
       
  1089         typedef GraphMap<MappableDigraphComponent, Node, V> Parent;
       
  1090 
  1088       public:
  1091       public:
  1089         typedef GraphMap<MappableDigraphComponent, Node, V> Parent;
       
  1090 
       
  1091         /// \brief Construct a new map.
  1092         /// \brief Construct a new map.
  1092         ///
  1093         ///
  1093         /// Construct a new map for the digraph.
  1094         /// Construct a new map for the digraph.
  1094         explicit NodeMap(const MappableDigraphComponent& digraph)
  1095         explicit NodeMap(const MappableDigraphComponent& digraph)
  1095           : Parent(digraph) {}
  1096           : Parent(digraph) {}
  1121       ///
  1122       ///
  1122       /// Standard graph map for the arcs.
  1123       /// Standard graph map for the arcs.
  1123       /// It conforms to the ReferenceMap concept.
  1124       /// It conforms to the ReferenceMap concept.
  1124       template <typename V>
  1125       template <typename V>
  1125       class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
  1126       class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
       
  1127         typedef GraphMap<MappableDigraphComponent, Arc, V> Parent;
       
  1128 
  1126       public:
  1129       public:
  1127         typedef GraphMap<MappableDigraphComponent, Arc, V> Parent;
       
  1128 
       
  1129         /// \brief Construct a new map.
  1130         /// \brief Construct a new map.
  1130         ///
  1131         ///
  1131         /// Construct a new map for the digraph.
  1132         /// Construct a new map for the digraph.
  1132         explicit ArcMap(const MappableDigraphComponent& digraph)
  1133         explicit ArcMap(const MappableDigraphComponent& digraph)
  1133           : Parent(digraph) {}
  1134           : Parent(digraph) {}
  1219       ///
  1220       ///
  1220       /// Standard graph map for the edges.
  1221       /// Standard graph map for the edges.
  1221       /// It conforms to the ReferenceMap concept.
  1222       /// It conforms to the ReferenceMap concept.
  1222       template <typename V>
  1223       template <typename V>
  1223       class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
  1224       class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
       
  1225         typedef GraphMap<MappableGraphComponent, Edge, V> Parent;
       
  1226 
  1224       public:
  1227       public:
  1225         typedef GraphMap<MappableGraphComponent, Edge, V> Parent;
       
  1226 
       
  1227         /// \brief Construct a new map.
  1228         /// \brief Construct a new map.
  1228         ///
  1229         ///
  1229         /// Construct a new map for the graph.
  1230         /// Construct a new map for the graph.
  1230         explicit EdgeMap(const MappableGraphComponent& graph)
  1231         explicit EdgeMap(const MappableGraphComponent& graph)
  1231           : Parent(graph) {}
  1232           : Parent(graph) {}