Changeset 606:c5fd2d996909 in lemon for lemon/concepts
- Timestamp:
- 03/29/09 23:08:20 (14 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- lemon/concepts
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/concepts/graph.h
r576 r606 602 602 /// \brief Opposite node on an arc 603 603 /// 604 /// \return the opposite of the given Node on the given Edge604 /// \return The opposite of the given node on the given edge. 605 605 Node oppositeNode(Node, Edge) const { return INVALID; } 606 606 607 607 /// \brief First node of the edge. 608 608 /// 609 /// \return the first node of the given Edge.609 /// \return The first node of the given edge. 610 610 /// 611 611 /// Naturally edges don't have direction and thus 612 /// don't have source and target node. But we use these two methods613 /// to query the two nodes of the arc. The direction of the arc614 /// which arises this way is called the inherent direction of the612 /// don't have source and target node. However we use \c u() and \c v() 613 /// methods to query the two nodes of the arc. The direction of the 614 /// arc which arises this way is called the inherent direction of the 615 615 /// edge, and is used to define the "default" direction 616 616 /// of the directed versions of the arcs. 617 /// \sa direction 617 /// \sa v() 618 /// \sa direction() 618 619 Node u(Edge) const { return INVALID; } 619 620 620 621 /// \brief Second node of the edge. 622 /// 623 /// \return The second node of the given edge. 624 /// 625 /// Naturally edges don't have direction and thus 626 /// don't have source and target node. However we use \c u() and \c v() 627 /// methods to query the two nodes of the arc. The direction of the 628 /// arc which arises this way is called the inherent direction of the 629 /// edge, and is used to define the "default" direction 630 /// of the directed versions of the arcs. 631 /// \sa u() 632 /// \sa direction() 621 633 Node v(Edge) const { return INVALID; } 622 634 -
lemon/concepts/graph_components.h
r581 r606 21 21 ///\brief The concept of graph components. 22 22 23 24 23 #ifndef LEMON_CONCEPTS_GRAPH_COMPONENTS_H 25 24 #define LEMON_CONCEPTS_GRAPH_COMPONENTS_H … … 45 44 46 45 #ifndef DOXYGEN 47 template <char _selector= '0'>46 template <char sel = '0'> 48 47 #endif 49 48 class GraphItem { … … 297 296 /// The most of the base digraphs should conform to this concept. 298 297 /// The id's are unique and immutable. 299 template <typename _Base= BaseDigraphComponent>300 class IDableDigraphComponent : public _Base{301 public: 302 303 typedef _BaseBase;298 template <typename BAS = BaseDigraphComponent> 299 class IDableDigraphComponent : public BAS { 300 public: 301 302 typedef BAS Base; 304 303 typedef typename Base::Node Node; 305 304 typedef typename Base::Arc Arc; … … 375 374 /// most of the base undirected graphs should conform to this 376 375 /// concept. The id's are unique and immutable. 377 template <typename _Base= BaseGraphComponent>378 class IDableGraphComponent : public IDableDigraphComponent< _Base> {379 public: 380 381 typedef _BaseBase;376 template <typename BAS = BaseGraphComponent> 377 class IDableGraphComponent : public IDableDigraphComponent<BAS> { 378 public: 379 380 typedef BAS Base; 382 381 typedef typename Base::Edge Edge; 383 382 384 using IDableDigraphComponent< _Base>::id;383 using IDableDigraphComponent<Base>::id; 385 384 386 385 /// \brief Gives back an unique integer id for the Edge. … … 426 425 /// Skeleton class for graph NodeIt and ArcIt. 427 426 /// 428 template <typename _Graph, typename _Item>429 class GraphItemIt : public _Item {427 template <typename GR, typename Item> 428 class GraphItemIt : public Item { 430 429 public: 431 430 /// \brief Default constructor. … … 443 442 /// Sets the iterator to the first item of \c the graph. 444 443 /// 445 explicit GraphItemIt(const _Graph&) {}444 explicit GraphItemIt(const GR&) {} 446 445 /// \brief Invalid constructor \& conversion. 447 446 /// … … 480 479 ++(++it1); 481 480 482 _Item bi = it1;481 Item bi = it1; 483 482 bi = it2; 484 483 } 485 _Graph& g;484 GR& g; 486 485 }; 487 486 }; … … 490 489 /// 491 490 /// \note Because InArcIt and OutArcIt may not inherit from the same 492 /// base class, the _selector is a additional template parameter. For493 /// InArcIt you should instantiate it with character 'i' and for491 /// base class, the \c sel is a additional template parameter (selector). 492 /// For InArcIt you should instantiate it with character 'i' and for 494 493 /// OutArcIt with 'o'. 495 template <typename _Graph,496 typename _Item = typename _Graph::Arc,497 typename _Base = typename _Graph::Node,498 char _selector= '0'>499 class GraphIncIt : public _Item {494 template <typename GR, 495 typename Item = typename GR::Arc, 496 typename Base = typename GR::Node, 497 char sel = '0'> 498 class GraphIncIt : public Item { 500 499 public: 501 500 /// \brief Default constructor. … … 508 507 /// Copy constructor. 509 508 /// 510 GraphIncIt(GraphIncIt const& gi) : _Item(gi) {}509 GraphIncIt(GraphIncIt const& gi) : Item(gi) {} 511 510 /// \brief Sets the iterator to the first arc incoming into or outgoing 512 511 /// from the node. … … 515 514 /// from the node. 516 515 /// 517 explicit GraphIncIt(const _Graph&, const _Base&) {}516 explicit GraphIncIt(const GR&, const Base&) {} 518 517 /// \brief Invalid constructor \& conversion. 519 518 /// … … 547 546 struct Constraints { 548 547 void constraints() { 549 checkConcept<GraphItem< _selector>, _GraphIncIt>();548 checkConcept<GraphItem<sel>, _GraphIncIt>(); 550 549 _GraphIncIt it1(graph, node); 551 550 _GraphIncIt it2; … … 554 553 ++it2 = it1; 555 554 ++(++it1); 556 _Item e = it1;555 Item e = it1; 557 556 e = it2; 558 557 559 558 } 560 559 561 _Item arc;562 _Base node;563 _Graphgraph;560 Item arc; 561 Base node; 562 GR graph; 564 563 _GraphIncIt it; 565 564 }; … … 572 571 /// iterator based iterable interface for the digraph structure. 573 572 /// This concept is part of the Digraph concept. 574 template <typename _Base= BaseDigraphComponent>575 class IterableDigraphComponent : public _Base{576 577 public: 578 579 typedef _BaseBase;573 template <typename BAS = BaseDigraphComponent> 574 class IterableDigraphComponent : public BAS { 575 576 public: 577 578 typedef BAS Base; 580 579 typedef typename Base::Node Node; 581 580 typedef typename Base::Arc Arc; … … 757 756 /// based iterable interface for the undirected graph structure. 758 757 /// This concept is part of the Graph concept. 759 template <typename _Base= BaseGraphComponent>760 class IterableGraphComponent : public IterableDigraphComponent< _Base> {761 public: 762 763 typedef _BaseBase;758 template <typename BAS = BaseGraphComponent> 759 class IterableGraphComponent : public IterableDigraphComponent<BAS> { 760 public: 761 762 typedef BAS Base; 764 763 typedef typename Base::Node Node; 765 764 typedef typename Base::Arc Arc; … … 774 773 /// @{ 775 774 776 using IterableDigraphComponent< _Base>::first;777 using IterableDigraphComponent< _Base>::next;775 using IterableDigraphComponent<Base>::first; 776 using IterableDigraphComponent<Base>::next; 778 777 779 778 /// \brief Gives back the first edge in the iterating … … 809 808 void nextInc(Edge&, bool&) const {} 810 809 811 using IterableDigraphComponent< _Base>::baseNode;812 using IterableDigraphComponent< _Base>::runningNode;810 using IterableDigraphComponent<Base>::baseNode; 811 using IterableDigraphComponent<Base>::runningNode; 813 812 814 813 /// @} … … 876 875 877 876 const _Graph& graph; 878 879 877 }; 880 878 }; … … 888 886 /// alteration occured in the digraph all the observers will 889 887 /// notified about it. 890 template <typename _Base= BaseDigraphComponent>891 class AlterableDigraphComponent : public _Base{892 public: 893 894 typedef _BaseBase;888 template <typename BAS = BaseDigraphComponent> 889 class AlterableDigraphComponent : public BAS { 890 public: 891 892 typedef BAS Base; 895 893 typedef typename Base::Node Node; 896 894 typedef typename Base::Arc Arc; … … 946 944 /// alteration occured in the graph all the observers will 947 945 /// notified about it. 948 template <typename _Base= BaseGraphComponent>949 class AlterableGraphComponent : public AlterableDigraphComponent< _Base> {950 public: 951 952 typedef _BaseBase;946 template <typename BAS = BaseGraphComponent> 947 class AlterableGraphComponent : public AlterableDigraphComponent<BAS> { 948 public: 949 950 typedef BAS Base; 953 951 typedef typename Base::Edge Edge; 954 952 … … 975 973 976 974 const _Graph& graph; 977 978 }; 979 975 }; 980 976 }; 981 977 … … 985 981 /// (NodeMap, ArcMap), that is maps that can be used to 986 982 /// associate data to graph descriptors (nodes or arcs). 987 template <typename _Graph, typename _Item, typename _Value>988 class GraphMap : public ReadWriteMap< _Item, _Value> {989 public: 990 991 typedef ReadWriteMap< _Item, _Value> Parent;983 template <typename GR, typename K, typename V> 984 class GraphMap : public ReadWriteMap<K, V> { 985 public: 986 987 typedef ReadWriteMap<K, V> Parent; 992 988 993 989 /// The graph type of the map. 994 typedef _GraphGraph;990 typedef GR Graph; 995 991 /// The key type of the map. 996 typedef _ItemKey;992 typedef K Key; 997 993 /// The value type of the map. 998 typedef _ValueValue;994 typedef V Value; 999 995 1000 996 /// \brief Construct a new map. … … 1056 1052 /// map interface for the digraph structure. 1057 1053 /// This concept is part of the Digraph concept. 1058 template <typename _Base= BaseDigraphComponent>1059 class MappableDigraphComponent : public _Base{1060 public: 1061 1062 typedef _BaseBase;1054 template <typename BAS = BaseDigraphComponent> 1055 class MappableDigraphComponent : public BAS { 1056 public: 1057 1058 typedef BAS Base; 1063 1059 typedef typename Base::Node Node; 1064 1060 typedef typename Base::Arc Arc; … … 1070 1066 /// ReadWrite map of the nodes. 1071 1067 /// 1072 template <typename _Value>1073 class NodeMap : public GraphMap<Digraph, Node, _Value> {1068 template <typename V> 1069 class NodeMap : public GraphMap<Digraph, Node, V> { 1074 1070 public: 1075 typedef GraphMap<MappableDigraphComponent, Node, _Value> Parent;1071 typedef GraphMap<MappableDigraphComponent, Node, V> Parent; 1076 1072 1077 1073 /// \brief Construct a new map. … … 1084 1080 /// 1085 1081 /// Construct a new map for the digraph and initalise the values. 1086 NodeMap(const MappableDigraphComponent& digraph, const _Value& value)1082 NodeMap(const MappableDigraphComponent& digraph, const V& value) 1087 1083 : Parent(digraph, value) {} 1088 1084 … … 1098 1094 template <typename CMap> 1099 1095 NodeMap& operator=(const CMap&) { 1100 checkConcept<ReadMap<Node, _Value>, CMap>();1096 checkConcept<ReadMap<Node, V>, CMap>(); 1101 1097 return *this; 1102 1098 } … … 1108 1104 /// ReadWrite map of the arcs. 1109 1105 /// 1110 template <typename _Value>1111 class ArcMap : public GraphMap<Digraph, Arc, _Value> {1106 template <typename V> 1107 class ArcMap : public GraphMap<Digraph, Arc, V> { 1112 1108 public: 1113 typedef GraphMap<MappableDigraphComponent, Arc, _Value> Parent;1109 typedef GraphMap<MappableDigraphComponent, Arc, V> Parent; 1114 1110 1115 1111 /// \brief Construct a new map. … … 1122 1118 /// 1123 1119 /// Construct a new map for the digraph and initalise the values. 1124 ArcMap(const MappableDigraphComponent& digraph, const _Value& value)1120 ArcMap(const MappableDigraphComponent& digraph, const V& value) 1125 1121 : Parent(digraph, value) {} 1126 1122 … … 1136 1132 template <typename CMap> 1137 1133 ArcMap& operator=(const CMap&) { 1138 checkConcept<ReadMap<Arc, _Value>, CMap>();1134 checkConcept<ReadMap<Arc, V>, CMap>(); 1139 1135 return *this; 1140 1136 } … … 1192 1188 /// map interface for the graph structure. 1193 1189 /// This concept is part of the Graph concept. 1194 template <typename _Base= BaseGraphComponent>1195 class MappableGraphComponent : public MappableDigraphComponent< _Base> {1196 public: 1197 1198 typedef _BaseBase;1190 template <typename BAS = BaseGraphComponent> 1191 class MappableGraphComponent : public MappableDigraphComponent<BAS> { 1192 public: 1193 1194 typedef BAS Base; 1199 1195 typedef typename Base::Edge Edge; 1200 1196 … … 1205 1201 /// ReadWrite map of the edges. 1206 1202 /// 1207 template <typename _Value>1208 class EdgeMap : public GraphMap<Graph, Edge, _Value> {1203 template <typename V> 1204 class EdgeMap : public GraphMap<Graph, Edge, V> { 1209 1205 public: 1210 typedef GraphMap<MappableGraphComponent, Edge, _Value> Parent;1206 typedef GraphMap<MappableGraphComponent, Edge, V> Parent; 1211 1207 1212 1208 /// \brief Construct a new map. … … 1219 1215 /// 1220 1216 /// Construct a new map for the graph and initalise the values. 1221 EdgeMap(const MappableGraphComponent& graph, const _Value& value)1217 EdgeMap(const MappableGraphComponent& graph, const V& value) 1222 1218 : Parent(graph, value) {} 1223 1219 … … 1233 1229 template <typename CMap> 1234 1230 EdgeMap& operator=(const CMap&) { 1235 checkConcept<ReadMap<Edge, _Value>, CMap>();1231 checkConcept<ReadMap<Edge, V>, CMap>(); 1236 1232 return *this; 1237 1233 } … … 1277 1273 /// difference between the base and this interface is that the 1278 1274 /// digraph alterations should handled already on this level. 1279 template <typename _Base= BaseDigraphComponent>1280 class ExtendableDigraphComponent : public _Base{1281 public: 1282 typedef _BaseBase;1283 1284 typedef typename _Base::Node Node;1285 typedef typename _Base::Arc Arc;1275 template <typename BAS = BaseDigraphComponent> 1276 class ExtendableDigraphComponent : public BAS { 1277 public: 1278 typedef BAS Base; 1279 1280 typedef typename Base::Node Node; 1281 typedef typename Base::Arc Arc; 1286 1282 1287 1283 /// \brief Adds a new node to the digraph. … … 1322 1318 /// that the graph alterations should handled already on this 1323 1319 /// level. 1324 template <typename _Base= BaseGraphComponent>1325 class ExtendableGraphComponent : public _Base{1326 public: 1327 1328 typedef _BaseBase;1329 typedef typename _Base::Node Node;1330 typedef typename _Base::Edge Edge;1320 template <typename BAS = BaseGraphComponent> 1321 class ExtendableGraphComponent : public BAS { 1322 public: 1323 1324 typedef BAS Base; 1325 typedef typename Base::Node Node; 1326 typedef typename Base::Edge Edge; 1331 1327 1332 1328 /// \brief Adds a new node to the graph. … … 1366 1362 /// the base and this interface is that the digraph alterations 1367 1363 /// should handled already on this level. 1368 template <typename _Base= BaseDigraphComponent>1369 class ErasableDigraphComponent : public _Base{1370 public: 1371 1372 typedef _BaseBase;1364 template <typename BAS = BaseDigraphComponent> 1365 class ErasableDigraphComponent : public BAS { 1366 public: 1367 1368 typedef BAS Base; 1373 1369 typedef typename Base::Node Node; 1374 1370 typedef typename Base::Arc Arc; … … 1406 1402 /// main difference between the base and this interface is that 1407 1403 /// the graph alterations should handled already on this level. 1408 template <typename _Base= BaseGraphComponent>1409 class ErasableGraphComponent : public _Base{1410 public: 1411 1412 typedef _BaseBase;1404 template <typename BAS = BaseGraphComponent> 1405 class ErasableGraphComponent : public BAS { 1406 public: 1407 1408 typedef BAS Base; 1413 1409 typedef typename Base::Node Node; 1414 1410 typedef typename Base::Edge Edge; … … 1446 1442 /// the base and this interface is that the digraph alterations 1447 1443 /// should handled already on this level. 1448 template <typename _Base= BaseDigraphComponent>1449 class ClearableDigraphComponent : public _Base{1450 public: 1451 1452 typedef _BaseBase;1444 template <typename BAS = BaseDigraphComponent> 1445 class ClearableDigraphComponent : public BAS { 1446 public: 1447 1448 typedef BAS Base; 1453 1449 1454 1450 /// \brief Erase all nodes and arcs from the digraph. … … 1475 1471 /// main difference between the base and this interface is that 1476 1472 /// the graph alterations should handled already on this level. 1477 template <typename _Base= BaseGraphComponent>1478 class ClearableGraphComponent : public ClearableDigraphComponent< _Base> {1479 public: 1480 1481 typedef _BaseBase;1473 template <typename BAS = BaseGraphComponent> 1474 class ClearableGraphComponent : public ClearableDigraphComponent<BAS> { 1475 public: 1476 1477 typedef BAS Base; 1482 1478 1483 1479 template <typename _Graph> -
lemon/concepts/heap.h
r576 r606 36 36 /// \brief The heap concept. 37 37 /// 38 /// Concept class describing the main interface of heaps. 39 template <typename Priority, typename ItemIntMap> 38 /// Concept class describing the main interface of heaps. A \e heap 39 /// is a data structure for storing items with specified values called 40 /// \e priorities in such a way that finding the item with minimum 41 /// priority is efficient. In a heap one can change the priority of an 42 /// item, add or erase an item, etc. 43 /// 44 /// \tparam PR Type of the priority of the items. 45 /// \tparam IM A read and writable item map with int values, used 46 /// internally to handle the cross references. 47 /// \tparam Comp A functor class for the ordering of the priorities. 48 /// The default is \c std::less<PR>. 49 #ifdef DOXYGEN 50 template <typename PR, typename IM, typename Comp = std::less<PR> > 51 #else 52 template <typename PR, typename IM> 53 #endif 40 54 class Heap { 41 55 public: 42 56 57 /// Type of the item-int map. 58 typedef IM ItemIntMap; 59 /// Type of the priorities. 60 typedef PR Prio; 43 61 /// Type of the items stored in the heap. 44 62 typedef typename ItemIntMap::Key Item; 45 46 /// Type of the priorities.47 typedef Priority Prio;48 63 49 64 /// \brief Type to represent the states of the items. … … 54 69 /// the user. 55 70 /// 56 /// The \c ItemIntMap must be initialized in such a way, that it57 /// assigns \c PRE_HEAP (<tt>-1</tt>) to every item.71 /// The item-int map must be initialized in such way that it assigns 72 /// \c PRE_HEAP (<tt>-1</tt>) to any element to be put in the heap. 58 73 enum State { 59 IN_HEAP = 0, 60 PRE_HEAP = -1, 61 POST_HEAP = -2 74 IN_HEAP = 0, ///< The "in heap" state constant. 75 PRE_HEAP = -1, ///< The "pre heap" state constant. 76 POST_HEAP = -2 ///< The "post heap" state constant. 62 77 }; 63 78 … … 120 135 /// 121 136 /// Returns the priority of the given item. 137 /// \param i The item. 122 138 /// \pre \c i must be in the heap. 123 /// \param i The item.124 139 Prio operator[](const Item &i) const {} 125 140 … … 138 153 /// 139 154 /// Decreases the priority of an item to the given value. 155 /// \param i The item. 156 /// \param p The priority. 140 157 /// \pre \c i must be stored in the heap with priority at least \c p. 158 void decrease(const Item &i, const Prio &p) {} 159 160 /// \brief Increases the priority of an item to the given value. 161 /// 162 /// Increases the priority of an item to the given value. 141 163 /// \param i The item. 142 164 /// \param p The priority. 143 void decrease(const Item &i, const Prio &p) {}144 145 /// \brief Increases the priority of an item to the given value.146 ///147 /// Increases the priority of an item to the given value.148 165 /// \pre \c i must be stored in the heap with priority at most \c p. 149 /// \param i The item.150 /// \param p The priority.151 166 void increase(const Item &i, const Prio &p) {} 152 167 -
lemon/concepts/path.h
r576 r606 39 39 /// A skeleton structure for representing directed paths in a 40 40 /// digraph. 41 /// \tparam _DigraphThe digraph type in which the path is.41 /// \tparam GR The digraph type in which the path is. 42 42 /// 43 43 /// In a sense, the path can be treated as a list of arcs. The … … 46 46 /// paths cannot store the source. 47 47 /// 48 template <typename _Digraph>48 template <typename GR> 49 49 class Path { 50 50 public: 51 51 52 52 /// Type of the underlying digraph. 53 typedef _DigraphDigraph;53 typedef GR Digraph; 54 54 /// Arc type of the underlying digraph. 55 55 typedef typename Digraph::Arc Arc; … … 206 206 /// assigned to a real path and the dumpers can be implemented as 207 207 /// an adaptor class to the predecessor map. 208 209 /// \tparam _DigraphThe digraph type in which the path is.208 /// 209 /// \tparam GR The digraph type in which the path is. 210 210 /// 211 211 /// The paths can be constructed from any path type by a 212 212 /// template constructor or a template assignment operator. 213 /// 214 template <typename _Digraph> 213 template <typename GR> 215 214 class PathDumper { 216 215 public: 217 216 218 217 /// Type of the underlying digraph. 219 typedef _DigraphDigraph;218 typedef GR Digraph; 220 219 /// Arc type of the underlying digraph. 221 220 typedef typename Digraph::Arc Arc;
Note: See TracChangeset
for help on using the changeset viewer.