Improved docs.
1.1 --- a/doc/named-param.dox Mon Nov 01 17:57:19 2004 +0000
1.2 +++ b/doc/named-param.dox Mon Nov 01 19:00:19 2004 +0000
1.3 @@ -1,5 +1,19 @@
1.4 /*!
1.5 +
1.6 \page named-param Named Parameters
1.7
1.8 +\section named-templ-param Named Template Parameters
1.9 +
1.10 +Instead of creating a new traits class you can also use this adaptor class
1.11 +like this
1.12 +\code
1.13 +Dijkstra<>::SetPredNodeMap<NullMap<Node,Node> >
1.14 +\endcode
1.15 +It can also be used in conjunction with other named template
1.16 +parameters in arbitrary order.
1.17 +\code
1.18 +Dijkstra<>::SetDistMap<MyMap>::SetPredMap<NullMap<Node,Edge> >
1.19 +\endcode
1.20 +
1.21
1.22 */
2.1 --- a/src/work/alpar/dijkstra.h Mon Nov 01 17:57:19 2004 +0000
2.2 +++ b/src/work/alpar/dijkstra.h Mon Nov 01 19:00:19 2004 +0000
2.3 @@ -30,23 +30,24 @@
2.4 /// \addtogroup flowalgs
2.5 /// @{
2.6
2.7 + ///Default traits class of Dijkstra class.
2.8 +
2.9 + ///Default traits class of Dijkstra class.
2.10 + ///\param GR Graph type.
2.11 + ///\param LM Type of length map.
2.12 template<class GR, class LM>
2.13 struct DijkstraDefaultTraits
2.14 {
2.15 - ///\e
2.16 + ///The graph type the algorithm runs on.
2.17 typedef GR Graph;
2.18 - ///\e
2.19 - typedef typename Graph::Node Node;
2.20 - ///\e
2.21 - typedef typename Graph::Edge Edge;
2.22 ///The type of the map that stores the edge lengths.
2.23
2.24 ///It must meet the \ref ReadMap concept.
2.25 ///
2.26 typedef LM LengthMap;
2.27 - ///The type of the length of the edges.
2.28 + //The type of the length of the edges.
2.29 typedef typename LM::ValueType ValueType;
2.30 - ///The heap type used by the dijkstra algorithm.
2.31 + ///The heap type used by Dijkstra algorithm.
2.32 typedef BinHeap<typename Graph::Node,
2.33 typename LM::ValueType,
2.34 typename GR::template NodeMap<int>,
2.35 @@ -57,12 +58,12 @@
2.36 ///
2.37 ///It must meet the \ref WriteMap concept.
2.38 ///
2.39 - typedef typename Graph::template NodeMap<Edge> PredMap;
2.40 - ///
2.41 + typedef typename Graph::template NodeMap<typename GR::Edge> PredMap;
2.42 + ///Instantiates a PredMap.
2.43
2.44 ///\todo Please document...
2.45 ///
2.46 - static PredMap *createPredMap(const Graph &G)
2.47 + static PredMap *createPredMap(const GR &G)
2.48 {
2.49 return new PredMap(G);
2.50 }
2.51 @@ -71,12 +72,12 @@
2.52 ///
2.53 ///It must meet the \ref WriteMap concept.
2.54 ///
2.55 - typedef typename Graph::template NodeMap<Node> PredNodeMap;
2.56 - ///
2.57 + typedef typename Graph::template NodeMap<typename GR::Node> PredNodeMap;
2.58 + ///Instantiates a PredNodeMap.
2.59
2.60 ///\todo Please document...
2.61 ///
2.62 - static PredNodeMap *createPredNodeMap(const Graph &G)
2.63 + static PredNodeMap *createPredNodeMap(const GR &G)
2.64 {
2.65 return new PredNodeMap(G);
2.66 }
2.67 @@ -84,12 +85,12 @@
2.68
2.69 ///It must meet the \ref WriteMap concept.
2.70 ///
2.71 - typedef typename Graph::template NodeMap<ValueType> DistMap;
2.72 - ///
2.73 + typedef typename Graph::template NodeMap<typename LM::ValueType> DistMap;
2.74 + ///Instantiates a DistMap.
2.75
2.76 ///\todo Please document...
2.77 ///
2.78 - static DistMap *createDistMap(const Graph &G)
2.79 + static DistMap *createDistMap(const GR &G)
2.80 {
2.81 return new DistMap(G);
2.82 }
2.83 @@ -108,22 +109,25 @@
2.84 ///It is also possible to change the underlying priority heap.
2.85 ///
2.86 ///\param GR The graph type the algorithm runs on. The default value is
2.87 - ///\ref ListGraph
2.88 + ///\ref ListGraph. The value of GR is not used directly by %Dijsktra, it
2.89 + ///is only passed to \ref DijkstraDefaultTraits.
2.90 ///\param LM This read-only
2.91 ///EdgeMap
2.92 ///determines the
2.93 ///lengths of the edges. It is read once for each edge, so the map
2.94 ///may involve in relatively time consuming process to compute the edge
2.95 ///length if it is necessary. The default map type is
2.96 - ///\ref skeleton::StaticGraph::EdgeMap "Graph::EdgeMap<int>"
2.97 - ///\param Heap The heap type used by the %Dijkstra
2.98 - ///algorithm. The default
2.99 - ///is using \ref BinHeap "binary heap".
2.100 + ///\ref skeleton::StaticGraph::EdgeMap "Graph::EdgeMap<int>".
2.101 + ///The value of LM is not used directly by %Dijsktra, it
2.102 + ///is only passed to \ref DijkstraDefaultTraits.
2.103 + ///\param TR Traits class to set various data types used by the algorithm.
2.104 + ///The default traits class is
2.105 + ///\ref DijkstraDefaultTraits<GR,LM> "DijkstraDefaultTraits<GR,LM>".
2.106 + ///See \ref DijkstraDefaultTraits for the documentation of
2.107 + ///a Dijkstra traits class.
2.108 ///
2.109 ///\author Jacint Szabo and Alpar Juttner
2.110 ///\todo We need a typedef-names should be standardized. (-:
2.111 - ///\todo Type of \c PredMap, \c PredNodeMap and \c DistMap
2.112 - ///should not be fixed. (Problematic to solve).
2.113
2.114 #ifdef DOXYGEN
2.115 template <typename GR,
2.116 @@ -138,7 +142,7 @@
2.117 public:
2.118 typedef TR Traits;
2.119 ///The type of the underlying graph.
2.120 - typedef GR Graph;
2.121 + typedef typename TR::Graph Graph;
2.122 ///\e
2.123 typedef typename Graph::Node Node;
2.124 ///\e
2.125 @@ -149,9 +153,9 @@
2.126 typedef typename Graph::OutEdgeIt OutEdgeIt;
2.127
2.128 ///The type of the length of the edges.
2.129 - typedef typename LM::ValueType ValueType;
2.130 + typedef typename TR::LengthMap::ValueType ValueType;
2.131 ///The type of the map that stores the edge lengths.
2.132 - typedef LM LengthMap;
2.133 + typedef typename TR::LengthMap LengthMap;
2.134 ///\brief The type of the map that stores the last
2.135 ///edges of the shortest paths.
2.136 typedef typename TR::PredMap PredMap;
2.137 @@ -160,7 +164,6 @@
2.138 typedef typename TR::PredNodeMap PredNodeMap;
2.139 ///The type of the map that stores the dists of the nodes.
2.140 typedef typename TR::DistMap DistMap;
2.141 -
2.142 ///The heap type used by the dijkstra algorithm.
2.143 typedef typename TR::Heap Heap;
2.144
2.145 @@ -168,7 +171,7 @@
2.146 /// Pointer to the underlying graph.
2.147 const Graph *G;
2.148 /// Pointer to the length map
2.149 - const LM *length;
2.150 + const LengthMap *length;
2.151 ///Pointer to the map of predecessors edges.
2.152 PredMap *predecessor;
2.153 ///Indicates if \ref predecessor is locally allocated (\c true) or not.
2.154 @@ -219,7 +222,10 @@
2.155 exit(1);
2.156 }
2.157 };
2.158 - ///\ref named-templ-param "Named parameter" for setting PredMap's type
2.159 + ///\ref named-templ-param "Named parameter" for setting PredMap type
2.160 +
2.161 + ///\ingroup flowalgs
2.162 + ///\ref named-templ-param "Named parameter" for setting PredMap type
2.163 template <class T>
2.164 class SetPredMap : public Dijkstra< Graph,
2.165 LengthMap,
2.166 @@ -237,7 +243,10 @@
2.167 exit(1);
2.168 }
2.169 };
2.170 - ///\ref named-templ-param "Named parameter" for setting PredNodeMap's type
2.171 + ///\ref named-templ-param "Named parameter" for setting PredNodeMap type
2.172 +
2.173 + ///\ingroup flowalgs
2.174 + ///\ref named-templ-param "Named parameter" for setting PredNodeMap type
2.175 template <class T>
2.176 class SetPredNodeMap : public Dijkstra< Graph,
2.177 LengthMap,
2.178 @@ -255,7 +264,10 @@
2.179 exit(1);
2.180 }
2.181 };
2.182 - ///\ref named-templ-param "Named parameter" for setting DistMap's type
2.183 + ///\ref named-templ-param "Named parameter" for setting DistMap type
2.184 +
2.185 + ///\ingroup flowalgs
2.186 + ///\ref named-templ-param "Named parameter" for setting DistMap type
2.187 template <class T>
2.188 class SetDistMap : public Dijkstra< Graph,
2.189 LengthMap,
2.190 @@ -265,7 +277,7 @@
2.191
2.192 ///\param _G the graph the algorithm will run on.
2.193 ///\param _length the length map used by the algorithm.
2.194 - Dijkstra(const Graph& _G, const LM& _length) :
2.195 + Dijkstra(const Graph& _G, const LengthMap& _length) :
2.196 G(&_G), length(&_length),
2.197 predecessor(NULL), local_predecessor(false),
2.198 pred_node(NULL), local_pred_node(false),
2.199 @@ -284,7 +296,7 @@
2.200
2.201 ///Sets the length map.
2.202 ///\return <tt> (*this) </tt>
2.203 - Dijkstra &setLengthMap(const LM &m)
2.204 + Dijkstra &setLengthMap(const LengthMap &m)
2.205 {
2.206 length = &m;
2.207 return *this;
2.208 @@ -349,7 +361,7 @@
2.209 ///shortest path to each node. The algorithm computes
2.210 ///- The shortest path tree.
2.211 ///- The distance of each node from the root.
2.212 -
2.213 + ///\todo heap_map's type could also be in the traits class.
2.214 void run(Node s) {
2.215
2.216 init_maps();
2.217 @@ -361,7 +373,7 @@
2.218 pred_node->set(u,INVALID);
2.219 }
2.220
2.221 - typename GR::template NodeMap<int> heap_map(*G,-1);
2.222 + typename Graph::template NodeMap<int> heap_map(*G,-1);
2.223
2.224 Heap heap(heap_map);
2.225
2.226 @@ -583,7 +595,7 @@
2.227
2.228 ///\e
2.229
2.230 - ///\e
2.231 + ///\todo Please document...
2.232 ///
2.233 template<class GR, class LM>
2.234 _Dijkstra<DijkstraDefaultTraits<GR,LM> >