# HG changeset patch # User Alpar Juttner # Date 1221127844 -3600 # Node ID c691064dfd4f2e3d4e230a1fd9845a1d96de2a5d # Parent 362415050b29c0c5c089847b2985595d373b33e2# Parent 0310c8984732b7dcf2afaa6eecdb74f936b550e8 Merge diff -r 362415050b29 -r c691064dfd4f lemon/bfs.h --- a/lemon/bfs.h Wed Sep 10 11:23:41 2008 +0100 +++ b/lemon/bfs.h Thu Sep 11 11:10:44 2008 +0100 @@ -230,7 +230,7 @@ ///@{ template - struct DefPredMapTraits : public Traits { + struct SetPredMapTraits : public Traits { typedef T PredMap; static PredMap *createPredMap(const Digraph &) { @@ -243,12 +243,12 @@ ///\ref named-templ-param "Named parameter" for setting ///\ref PredMap type. template - struct DefPredMap : public Bfs< Digraph, DefPredMapTraits > { - typedef Bfs< Digraph, DefPredMapTraits > Create; + struct SetPredMap : public Bfs< Digraph, SetPredMapTraits > { + typedef Bfs< Digraph, SetPredMapTraits > Create; }; template - struct DefDistMapTraits : public Traits { + struct SetDistMapTraits : public Traits { typedef T DistMap; static DistMap *createDistMap(const Digraph &) { @@ -261,12 +261,12 @@ ///\ref named-templ-param "Named parameter" for setting ///\ref DistMap type. template - struct DefDistMap : public Bfs< Digraph, DefDistMapTraits > { - typedef Bfs< Digraph, DefDistMapTraits > Create; + struct SetDistMap : public Bfs< Digraph, SetDistMapTraits > { + typedef Bfs< Digraph, SetDistMapTraits > Create; }; template - struct DefReachedMapTraits : public Traits { + struct SetReachedMapTraits : public Traits { typedef T ReachedMap; static ReachedMap *createReachedMap(const Digraph &) { @@ -279,12 +279,12 @@ ///\ref named-templ-param "Named parameter" for setting ///\ref ReachedMap type. template - struct DefReachedMap : public Bfs< Digraph, DefReachedMapTraits > { - typedef Bfs< Digraph, DefReachedMapTraits > Create; + struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits > { + typedef Bfs< Digraph, SetReachedMapTraits > Create; }; template - struct DefProcessedMapTraits : public Traits { + struct SetProcessedMapTraits : public Traits { typedef T ProcessedMap; static ProcessedMap *createProcessedMap(const Digraph &) { @@ -297,11 +297,11 @@ ///\ref named-templ-param "Named parameter" for setting ///\ref ProcessedMap type. template - struct DefProcessedMap : public Bfs< Digraph, DefProcessedMapTraits > { - typedef Bfs< Digraph, DefProcessedMapTraits > Create; + struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits > { + typedef Bfs< Digraph, SetProcessedMapTraits > Create; }; - struct DefDigraphProcessedMapTraits : public Traits { + struct SetStandardProcessedMapTraits : public Traits { typedef typename Digraph::template NodeMap ProcessedMap; static ProcessedMap *createProcessedMap(const Digraph &g) { @@ -314,10 +314,9 @@ ///\ref named-templ-param "Named parameter" for setting ///\ref ProcessedMap type to be Digraph::NodeMap. ///If you don't set it explicitly, it will be automatically allocated. - template - struct DefProcessedMapToBeDefaultMap : - public Bfs< Digraph, DefDigraphProcessedMapTraits> { - typedef Bfs< Digraph, DefDigraphProcessedMapTraits> Create; + struct SetStandardProcessedMap : + public Bfs< Digraph, SetStandardProcessedMapTraits > { + typedef Bfs< Digraph, SetStandardProcessedMapTraits > Create; }; ///@} @@ -1065,10 +1064,10 @@ } template - struct DefPredMapBase : public Base { + struct SetPredMapBase : public Base { typedef T PredMap; static PredMap *createPredMap(const Digraph &) { return 0; }; - DefPredMapBase(const TR &b) : TR(b) {} + SetPredMapBase(const TR &b) : TR(b) {} }; ///\brief \ref named-templ-param "Named parameter" ///for setting \ref PredMap object. @@ -1076,17 +1075,17 @@ /// \ref named-templ-param "Named parameter" ///for setting \ref PredMap object. template - BfsWizard > predMap(const T &t) + BfsWizard > predMap(const T &t) { Base::_pred=reinterpret_cast(const_cast(&t)); - return BfsWizard >(*this); + return BfsWizard >(*this); } template - struct DefReachedMapBase : public Base { + struct SetReachedMapBase : public Base { typedef T ReachedMap; static ReachedMap *createReachedMap(const Digraph &) { return 0; }; - DefReachedMapBase(const TR &b) : TR(b) {} + SetReachedMapBase(const TR &b) : TR(b) {} }; ///\brief \ref named-templ-param "Named parameter" ///for setting \ref ReachedMap object. @@ -1094,17 +1093,17 @@ /// \ref named-templ-param "Named parameter" ///for setting \ref ReachedMap object. template - BfsWizard > reachedMap(const T &t) + BfsWizard > reachedMap(const T &t) { Base::_reached=reinterpret_cast(const_cast(&t)); - return BfsWizard >(*this); + return BfsWizard >(*this); } template - struct DefProcessedMapBase : public Base { + struct SetProcessedMapBase : public Base { typedef T ProcessedMap; static ProcessedMap *createProcessedMap(const Digraph &) { return 0; }; - DefProcessedMapBase(const TR &b) : TR(b) {} + SetProcessedMapBase(const TR &b) : TR(b) {} }; ///\brief \ref named-templ-param "Named parameter" ///for setting \ref ProcessedMap object. @@ -1112,17 +1111,17 @@ /// \ref named-templ-param "Named parameter" ///for setting \ref ProcessedMap object. template - BfsWizard > processedMap(const T &t) + BfsWizard > processedMap(const T &t) { Base::_processed=reinterpret_cast(const_cast(&t)); - return BfsWizard >(*this); + return BfsWizard >(*this); } template - struct DefDistMapBase : public Base { + struct SetDistMapBase : public Base { typedef T DistMap; static DistMap *createDistMap(const Digraph &) { return 0; }; - DefDistMapBase(const TR &b) : TR(b) {} + SetDistMapBase(const TR &b) : TR(b) {} }; ///\brief \ref named-templ-param "Named parameter" ///for setting \ref DistMap object. @@ -1130,10 +1129,10 @@ /// \ref named-templ-param "Named parameter" ///for setting \ref DistMap object. template - BfsWizard > distMap(const T &t) + BfsWizard > distMap(const T &t) { Base::_dist=reinterpret_cast(const_cast(&t)); - return BfsWizard >(*this); + return BfsWizard >(*this); } }; @@ -1354,7 +1353,7 @@ ///@{ template - struct DefReachedMapTraits : public Traits { + struct SetReachedMapTraits : public Traits { typedef T ReachedMap; static ReachedMap *createReachedMap(const Digraph &digraph) { throw UninitializedParameter(); @@ -1365,9 +1364,9 @@ /// /// \ref named-templ-param "Named parameter" for setting ReachedMap type. template - struct DefReachedMap : public BfsVisit< Digraph, Visitor, - DefReachedMapTraits > { - typedef BfsVisit< Digraph, Visitor, DefReachedMapTraits > Create; + struct SetReachedMap : public BfsVisit< Digraph, Visitor, + SetReachedMapTraits > { + typedef BfsVisit< Digraph, Visitor, SetReachedMapTraits > Create; }; ///@} diff -r 362415050b29 -r c691064dfd4f lemon/bits/base_extender.h --- a/lemon/bits/base_extender.h Wed Sep 10 11:23:41 2008 +0100 +++ b/lemon/bits/base_extender.h Thu Sep 11 11:10:44 2008 +0100 @@ -59,7 +59,7 @@ public: Arc() {} - /// Invalid arc constructor + // Invalid arc constructor Arc(Invalid i) : Edge(i), forward(true) {} bool operator==(const Arc &that) const { @@ -74,38 +74,41 @@ } }; + /// First node of the edge + Node u(const Edge &e) const { + return Parent::source(e); + } - - using Parent::source; - - /// Source of the given Arc. + /// Source of the given arc Node source(const Arc &e) const { return e.forward ? Parent::source(e) : Parent::target(e); } - using Parent::target; + /// Second node of the edge + Node v(const Edge &e) const { + return Parent::target(e); + } - /// Target of the given Arc. + /// Target of the given arc Node target(const Arc &e) const { return e.forward ? Parent::target(e) : Parent::source(e); } /// \brief Directed arc from an edge. /// - /// Returns a directed arc corresponding to the specified Edge. - /// If the given bool is true the given edge and the - /// returned arc have the same source node. - static Arc direct(const Edge &ue, bool d) { - return Arc(ue, d); + /// Returns a directed arc corresponding to the specified edge. + /// If the given bool is true, the first node of the given edge and + /// the source node of the returned arc are the same. + static Arc direct(const Edge &e, bool d) { + return Arc(e, d); } - /// Returns whether the given directed arc is same orientation as the - /// corresponding edge. + /// Returns whether the given directed arc has the same orientation + /// as the corresponding edge. /// /// \todo reference to the corresponding point of the undirected digraph /// concept. "What does the direction of an edge mean?" - static bool direction(const Arc &e) { return e.forward; } - + static bool direction(const Arc &a) { return a.forward; } using Parent::first; using Parent::next; @@ -229,7 +232,6 @@ return Parent::maxArcId(); } - int arcNum() const { return 2 * Parent::arcNum(); } diff -r 362415050b29 -r c691064dfd4f lemon/dfs.h --- a/lemon/dfs.h Wed Sep 10 11:23:41 2008 +0100 +++ b/lemon/dfs.h Thu Sep 11 11:10:44 2008 +0100 @@ -230,7 +230,7 @@ ///@{ template - struct DefPredMapTraits : public Traits { + struct SetPredMapTraits : public Traits { typedef T PredMap; static PredMap *createPredMap(const Digraph &) { @@ -243,12 +243,12 @@ ///\ref named-templ-param "Named parameter" for setting ///\ref PredMap type. template - struct DefPredMap : public Dfs > { - typedef Dfs > Create; + struct SetPredMap : public Dfs > { + typedef Dfs > Create; }; template - struct DefDistMapTraits : public Traits { + struct SetDistMapTraits : public Traits { typedef T DistMap; static DistMap *createDistMap(const Digraph &) { @@ -261,12 +261,12 @@ ///\ref named-templ-param "Named parameter" for setting ///\ref DistMap type. template - struct DefDistMap : public Dfs< Digraph, DefDistMapTraits > { - typedef Dfs > Create; + struct SetDistMap : public Dfs< Digraph, SetDistMapTraits > { + typedef Dfs > Create; }; template - struct DefReachedMapTraits : public Traits { + struct SetReachedMapTraits : public Traits { typedef T ReachedMap; static ReachedMap *createReachedMap(const Digraph &) { @@ -279,12 +279,12 @@ ///\ref named-templ-param "Named parameter" for setting ///\ref ReachedMap type. template - struct DefReachedMap : public Dfs< Digraph, DefReachedMapTraits > { - typedef Dfs< Digraph, DefReachedMapTraits > Create; + struct SetReachedMap : public Dfs< Digraph, SetReachedMapTraits > { + typedef Dfs< Digraph, SetReachedMapTraits > Create; }; template - struct DefProcessedMapTraits : public Traits { + struct SetProcessedMapTraits : public Traits { typedef T ProcessedMap; static ProcessedMap *createProcessedMap(const Digraph &) { @@ -297,11 +297,11 @@ ///\ref named-templ-param "Named parameter" for setting ///\ref ProcessedMap type. template - struct DefProcessedMap : public Dfs< Digraph, DefProcessedMapTraits > { - typedef Dfs< Digraph, DefProcessedMapTraits > Create; + struct SetProcessedMap : public Dfs< Digraph, SetProcessedMapTraits > { + typedef Dfs< Digraph, SetProcessedMapTraits > Create; }; - struct DefDigraphProcessedMapTraits : public Traits { + struct SetStandardProcessedMapTraits : public Traits { typedef typename Digraph::template NodeMap ProcessedMap; static ProcessedMap *createProcessedMap(const Digraph &g) { @@ -314,10 +314,9 @@ ///\ref named-templ-param "Named parameter" for setting ///\ref ProcessedMap type to be Digraph::NodeMap. ///If you don't set it explicitly, it will be automatically allocated. - template - struct DefProcessedMapToBeDefaultMap : - public Dfs< Digraph, DefDigraphProcessedMapTraits> { - typedef Dfs< Digraph, DefDigraphProcessedMapTraits> Create; + struct SetStandardProcessedMap : + public Dfs< Digraph, SetStandardProcessedMapTraits > { + typedef Dfs< Digraph, SetStandardProcessedMapTraits > Create; }; ///@} @@ -1000,10 +999,10 @@ } template - struct DefPredMapBase : public Base { + struct SetPredMapBase : public Base { typedef T PredMap; static PredMap *createPredMap(const Digraph &) { return 0; }; - DefPredMapBase(const TR &b) : TR(b) {} + SetPredMapBase(const TR &b) : TR(b) {} }; ///\brief \ref named-templ-param "Named parameter" ///for setting \ref PredMap object. @@ -1011,17 +1010,17 @@ ///\ref named-templ-param "Named parameter" ///for setting \ref PredMap object. template - DfsWizard > predMap(const T &t) + DfsWizard > predMap(const T &t) { Base::_pred=reinterpret_cast(const_cast(&t)); - return DfsWizard >(*this); + return DfsWizard >(*this); } template - struct DefReachedMapBase : public Base { + struct SetReachedMapBase : public Base { typedef T ReachedMap; static ReachedMap *createReachedMap(const Digraph &) { return 0; }; - DefReachedMapBase(const TR &b) : TR(b) {} + SetReachedMapBase(const TR &b) : TR(b) {} }; ///\brief \ref named-templ-param "Named parameter" ///for setting \ref ReachedMap object. @@ -1029,17 +1028,17 @@ /// \ref named-templ-param "Named parameter" ///for setting \ref ReachedMap object. template - DfsWizard > reachedMap(const T &t) + DfsWizard > reachedMap(const T &t) { Base::_reached=reinterpret_cast(const_cast(&t)); - return DfsWizard >(*this); + return DfsWizard >(*this); } template - struct DefProcessedMapBase : public Base { + struct SetProcessedMapBase : public Base { typedef T ProcessedMap; static ProcessedMap *createProcessedMap(const Digraph &) { return 0; }; - DefProcessedMapBase(const TR &b) : TR(b) {} + SetProcessedMapBase(const TR &b) : TR(b) {} }; ///\brief \ref named-templ-param "Named parameter" ///for setting \ref ProcessedMap object. @@ -1047,17 +1046,17 @@ /// \ref named-templ-param "Named parameter" ///for setting \ref ProcessedMap object. template - DfsWizard > processedMap(const T &t) + DfsWizard > processedMap(const T &t) { Base::_processed=reinterpret_cast(const_cast(&t)); - return DfsWizard >(*this); + return DfsWizard >(*this); } template - struct DefDistMapBase : public Base { + struct SetDistMapBase : public Base { typedef T DistMap; static DistMap *createDistMap(const Digraph &) { return 0; }; - DefDistMapBase(const TR &b) : TR(b) {} + SetDistMapBase(const TR &b) : TR(b) {} }; ///\brief \ref named-templ-param "Named parameter" ///for setting \ref DistMap object. @@ -1065,10 +1064,10 @@ ///\ref named-templ-param "Named parameter" ///for setting \ref DistMap object. template - DfsWizard > distMap(const T &t) + DfsWizard > distMap(const T &t) { Base::_dist=reinterpret_cast(const_cast(&t)); - return DfsWizard >(*this); + return DfsWizard >(*this); } }; @@ -1301,7 +1300,7 @@ ///@{ template - struct DefReachedMapTraits : public Traits { + struct SetReachedMapTraits : public Traits { typedef T ReachedMap; static ReachedMap *createReachedMap(const Digraph &digraph) { throw UninitializedParameter(); @@ -1312,9 +1311,9 @@ /// /// \ref named-templ-param "Named parameter" for setting ReachedMap type. template - struct DefReachedMap : public DfsVisit< Digraph, Visitor, - DefReachedMapTraits > { - typedef DfsVisit< Digraph, Visitor, DefReachedMapTraits > Create; + struct SetReachedMap : public DfsVisit< Digraph, Visitor, + SetReachedMapTraits > { + typedef DfsVisit< Digraph, Visitor, SetReachedMapTraits > Create; }; ///@} diff -r 362415050b29 -r c691064dfd4f lemon/dijkstra.h --- a/lemon/dijkstra.h Wed Sep 10 11:23:41 2008 +0100 +++ b/lemon/dijkstra.h Thu Sep 11 11:10:44 2008 +0100 @@ -331,7 +331,7 @@ ///@{ template - struct DefPredMapTraits : public Traits { + struct SetPredMapTraits : public Traits { typedef T PredMap; static PredMap *createPredMap(const Digraph &) { @@ -344,13 +344,13 @@ ///\ref named-templ-param "Named parameter" for setting ///\ref PredMap type. template - struct DefPredMap - : public Dijkstra< Digraph, LengthMap, DefPredMapTraits > { - typedef Dijkstra< Digraph, LengthMap, DefPredMapTraits > Create; + struct SetPredMap + : public Dijkstra< Digraph, LengthMap, SetPredMapTraits > { + typedef Dijkstra< Digraph, LengthMap, SetPredMapTraits > Create; }; template - struct DefDistMapTraits : public Traits { + struct SetDistMapTraits : public Traits { typedef T DistMap; static DistMap *createDistMap(const Digraph &) { @@ -363,13 +363,13 @@ ///\ref named-templ-param "Named parameter" for setting ///\ref DistMap type. template - struct DefDistMap - : public Dijkstra< Digraph, LengthMap, DefDistMapTraits > { - typedef Dijkstra< Digraph, LengthMap, DefDistMapTraits > Create; + struct SetDistMap + : public Dijkstra< Digraph, LengthMap, SetDistMapTraits > { + typedef Dijkstra< Digraph, LengthMap, SetDistMapTraits > Create; }; template - struct DefProcessedMapTraits : public Traits { + struct SetProcessedMapTraits : public Traits { typedef T ProcessedMap; static ProcessedMap *createProcessedMap(const Digraph &) { @@ -382,12 +382,12 @@ ///\ref named-templ-param "Named parameter" for setting ///\ref ProcessedMap type. template - struct DefProcessedMap - : public Dijkstra< Digraph, LengthMap, DefProcessedMapTraits > { - typedef Dijkstra< Digraph, LengthMap, DefProcessedMapTraits > Create; + struct SetProcessedMap + : public Dijkstra< Digraph, LengthMap, SetProcessedMapTraits > { + typedef Dijkstra< Digraph, LengthMap, SetProcessedMapTraits > Create; }; - struct DefDigraphProcessedMapTraits : public Traits { + struct SetStandardProcessedMapTraits : public Traits { typedef typename Digraph::template NodeMap ProcessedMap; static ProcessedMap *createProcessedMap(const Digraph &g) { @@ -400,15 +400,14 @@ ///\ref named-templ-param "Named parameter" for setting ///\ref ProcessedMap type to be Digraph::NodeMap. ///If you don't set it explicitly, it will be automatically allocated. - template - struct DefProcessedMapToBeDefaultMap - : public Dijkstra< Digraph, LengthMap, DefDigraphProcessedMapTraits> { - typedef Dijkstra< Digraph, LengthMap, DefDigraphProcessedMapTraits> + struct SetStandardProcessedMap + : public Dijkstra< Digraph, LengthMap, SetStandardProcessedMapTraits > { + typedef Dijkstra< Digraph, LengthMap, SetStandardProcessedMapTraits > Create; }; template - struct DefHeapTraits : public Traits { + struct SetHeapTraits : public Traits { typedef CR HeapCrossRef; typedef H Heap; static HeapCrossRef *createHeapCrossRef(const Digraph &) { @@ -425,13 +424,13 @@ ///\ref named-templ-param "Named parameter" for setting heap and cross ///reference type. template > - struct DefHeap - : public Dijkstra< Digraph, LengthMap, DefHeapTraits > { - typedef Dijkstra< Digraph, LengthMap, DefHeapTraits > Create; + struct SetHeap + : public Dijkstra< Digraph, LengthMap, SetHeapTraits > { + typedef Dijkstra< Digraph, LengthMap, SetHeapTraits > Create; }; template - struct DefStandardHeapTraits : public Traits { + struct SetStandardHeapTraits : public Traits { typedef CR HeapCrossRef; typedef H Heap; static HeapCrossRef *createHeapCrossRef(const Digraph &G) { @@ -450,14 +449,14 @@ ///object if the cross reference's constructor waits for the digraph as ///parameter and the heap's constructor waits for the cross reference. template > - struct DefStandardHeap - : public Dijkstra< Digraph, LengthMap, DefStandardHeapTraits > { - typedef Dijkstra< Digraph, LengthMap, DefStandardHeapTraits > + struct SetStandardHeap + : public Dijkstra< Digraph, LengthMap, SetStandardHeapTraits > { + typedef Dijkstra< Digraph, LengthMap, SetStandardHeapTraits > Create; }; template - struct DefOperationTraitsTraits : public Traits { + struct SetOperationTraitsTraits : public Traits { typedef T OperationTraits; }; @@ -467,9 +466,9 @@ ///\ref named-templ-param "Named parameter" for setting ///\ref OperationTraits type. template - struct DefOperationTraits - : public Dijkstra > { - typedef Dijkstra > + struct SetOperationTraits + : public Dijkstra > { + typedef Dijkstra > Create; }; @@ -1205,10 +1204,10 @@ } template - struct DefPredMapBase : public Base { + struct SetPredMapBase : public Base { typedef T PredMap; static PredMap *createPredMap(const Digraph &) { return 0; }; - DefPredMapBase(const TR &b) : TR(b) {} + SetPredMapBase(const TR &b) : TR(b) {} }; ///\brief \ref named-templ-param "Named parameter" ///for setting \ref PredMap object. @@ -1216,17 +1215,17 @@ ///\ref named-templ-param "Named parameter" ///for setting \ref PredMap object. template - DijkstraWizard > predMap(const T &t) + DijkstraWizard > predMap(const T &t) { Base::_pred=reinterpret_cast(const_cast(&t)); - return DijkstraWizard >(*this); + return DijkstraWizard >(*this); } template - struct DefProcessedMapBase : public Base { + struct SetProcessedMapBase : public Base { typedef T ProcessedMap; static ProcessedMap *createProcessedMap(const Digraph &) { return 0; }; - DefProcessedMapBase(const TR &b) : TR(b) {} + SetProcessedMapBase(const TR &b) : TR(b) {} }; ///\brief \ref named-templ-param "Named parameter" ///for setting \ref ProcessedMap object. @@ -1234,17 +1233,17 @@ /// \ref named-templ-param "Named parameter" ///for setting \ref ProcessedMap object. template - DijkstraWizard > processedMap(const T &t) + DijkstraWizard > processedMap(const T &t) { Base::_processed=reinterpret_cast(const_cast(&t)); - return DijkstraWizard >(*this); + return DijkstraWizard >(*this); } template - struct DefDistMapBase : public Base { + struct SetDistMapBase : public Base { typedef T DistMap; static DistMap *createDistMap(const Digraph &) { return 0; }; - DefDistMapBase(const TR &b) : TR(b) {} + SetDistMapBase(const TR &b) : TR(b) {} }; ///\brief \ref named-templ-param "Named parameter" ///for setting \ref DistMap object. @@ -1252,10 +1251,10 @@ ///\ref named-templ-param "Named parameter" ///for setting \ref DistMap object. template - DijkstraWizard > distMap(const T &t) + DijkstraWizard > distMap(const T &t) { Base::_dist=reinterpret_cast(const_cast(&t)); - return DijkstraWizard >(*this); + return DijkstraWizard >(*this); } }; diff -r 362415050b29 -r c691064dfd4f test/heap_test.cc --- a/test/heap_test.cc Wed Sep 10 11:23:41 2008 +0100 +++ b/test/heap_test.cc Thu Sep 11 11:10:44 2008 +0100 @@ -131,7 +131,7 @@ void dijkstraHeapTest(const Digraph& digraph, const IntArcMap& length, Node source) { - typename Dijkstra::template DefStandardHeap:: + typename Dijkstra::template SetStandardHeap:: Create dijkstra(digraph, length); dijkstra.run(source);