[Lemon-commits] Alpar Juttner: Merge
Lemon HG
hg at lemon.cs.elte.hu
Mon Aug 4 22:03:28 CEST 2008
details: http://lemon.cs.elte.hu/hg/lemon/rev/f1158744a112
changeset: 247:f1158744a112
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Mon Aug 04 22:00:36 2008 +0200
description:
Merge
diffstat:
3 files changed, 1578 insertions(+), 1312 deletions(-)
lemon/bfs.h | 1042 +++++++++++++++++++++++++++++-----------------------
lemon/dfs.h | 1073 ++++++++++++++++++++++++++++--------------------------
lemon/dijkstra.h | 775 +++++++++++++++++++++------------------
diffs (truncated from 4970 to 300 lines):
diff -r 7c67988fca07 -r f1158744a112 lemon/bfs.h
--- a/lemon/bfs.h Wed Jul 30 12:07:48 2008 +0100
+++ b/lemon/bfs.h Mon Aug 04 22:00:36 2008 +0200
@@ -21,7 +21,7 @@
///\ingroup search
///\file
-///\brief Bfs algorithm.
+///\brief BFS algorithm.
#include <lemon/list_graph.h>
#include <lemon/bits/path_dump.h>
@@ -31,8 +31,6 @@
namespace lemon {
-
-
///Default traits class of Bfs class.
///Default traits class of Bfs class.
@@ -40,73 +38,75 @@
template<class GR>
struct BfsDefaultTraits
{
- ///The digraph type the algorithm runs on.
+ ///The type of the digraph the algorithm runs on.
typedef GR Digraph;
- ///\brief The type of the map that stores the last
+
+ ///\brief The type of the map that stores the predecessor
///arcs of the shortest paths.
///
- ///The type of the map that stores the last
+ ///The type of the map that stores the predecessor
///arcs of the shortest paths.
///It must meet the \ref concepts::WriteMap "WriteMap" concept.
- ///
- typedef typename Digraph::template NodeMap<typename GR::Arc> PredMap;
- ///Instantiates a PredMap.
+ typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
+ ///Instantiates a \ref PredMap.
///This function instantiates a \ref PredMap.
- ///\param G is the digraph, to which we would like to define the PredMap.
+ ///\param g is the digraph, to which we would like to define the
+ ///\ref PredMap.
///\todo The digraph alone may be insufficient to initialize
- static PredMap *createPredMap(const GR &G)
+ static PredMap *createPredMap(const Digraph &g)
{
- return new PredMap(G);
+ return new PredMap(g);
}
+
///The type of the map that indicates which nodes are processed.
///The type of the map that indicates which nodes are processed.
///It must meet the \ref concepts::WriteMap "WriteMap" concept.
- ///\todo named parameter to set this type, function to read and write.
+ ///By default it is a NullMap.
typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
- ///Instantiates a ProcessedMap.
+ ///Instantiates a \ref ProcessedMap.
///This function instantiates a \ref ProcessedMap.
///\param g is the digraph, to which
///we would like to define the \ref ProcessedMap
#ifdef DOXYGEN
- static ProcessedMap *createProcessedMap(const GR &g)
+ static ProcessedMap *createProcessedMap(const Digraph &g)
#else
- static ProcessedMap *createProcessedMap(const GR &)
+ static ProcessedMap *createProcessedMap(const Digraph &)
#endif
{
return new ProcessedMap();
}
+
///The type of the map that indicates which nodes are reached.
///The type of the map that indicates which nodes are reached.
- ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
- ///\todo named parameter to set this type, function to read and write.
+ ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
typedef typename Digraph::template NodeMap<bool> ReachedMap;
- ///Instantiates a ReachedMap.
+ ///Instantiates a \ref ReachedMap.
///This function instantiates a \ref ReachedMap.
- ///\param G is the digraph, to which
+ ///\param g is the digraph, to which
///we would like to define the \ref ReachedMap.
- static ReachedMap *createReachedMap(const GR &G)
+ static ReachedMap *createReachedMap(const Digraph &g)
{
- return new ReachedMap(G);
+ return new ReachedMap(g);
}
- ///The type of the map that stores the dists of the nodes.
- ///The type of the map that stores the dists of the nodes.
+ ///The type of the map that stores the distances of the nodes.
+
+ ///The type of the map that stores the distances of the nodes.
///It must meet the \ref concepts::WriteMap "WriteMap" concept.
- ///
typedef typename Digraph::template NodeMap<int> DistMap;
- ///Instantiates a DistMap.
+ ///Instantiates a \ref DistMap.
///This function instantiates a \ref DistMap.
- ///\param G is the digraph, to which we would like to define
- ///the \ref DistMap
- static DistMap *createDistMap(const GR &G)
+ ///\param g is the digraph, to which we would like to define the
+ ///\ref DistMap.
+ static DistMap *createDistMap(const Digraph &g)
{
- return new DistMap(G);
+ return new DistMap(g);
}
};
@@ -115,15 +115,18 @@
///\ingroup search
///This class provides an efficient implementation of the %BFS algorithm.
///
- ///\tparam GR The digraph type the algorithm runs on. The default value is
- ///\ref ListDigraph. The value of GR is not used directly by Bfs, it
- ///is only passed to \ref BfsDefaultTraits.
+ ///There is also a \ref bfs() "function type interface" for the BFS
+ ///algorithm, which is convenient in the simplier cases and it can be
+ ///used easier.
+ ///
+ ///\tparam GR The type of the digraph the algorithm runs on.
+ ///The default value is \ref ListDigraph. The value of GR is not used
+ ///directly by \ref Bfs, it is only passed to \ref BfsDefaultTraits.
///\tparam TR Traits class to set various data types used by the algorithm.
///The default traits class is
///\ref BfsDefaultTraits "BfsDefaultTraits<GR>".
///See \ref BfsDefaultTraits for the documentation of
///a Bfs traits class.
-
#ifdef DOXYGEN
template <typename GR,
typename TR>
@@ -133,12 +136,10 @@
#endif
class Bfs {
public:
- /**
- * \brief \ref Exception for uninitialized parameters.
- *
- * This error represents problems in the initialization
- * of the parameters of the algorithms.
- */
+ ///\ref Exception for uninitialized parameters.
+
+ ///This error represents problems in the initialization of the
+ ///parameters of the algorithm.
class UninitializedParameter : public lemon::UninitializedParameter {
public:
virtual const char* what() const throw() {
@@ -146,19 +147,24 @@
}
};
- typedef TR Traits;
- ///The type of the underlying digraph.
+ ///The type of the digraph the algorithm runs on.
typedef typename TR::Digraph Digraph;
- ///\brief The type of the map that stores the last
- ///arcs of the shortest paths.
+ ///\brief The type of the map that stores the predecessor arcs of the
+ ///shortest paths.
typedef typename TR::PredMap PredMap;
- ///The type of the map indicating which nodes are reached.
+ ///The type of the map that stores the distances of the nodes.
+ typedef typename TR::DistMap DistMap;
+ ///The type of the map that indicates which nodes are reached.
typedef typename TR::ReachedMap ReachedMap;
- ///The type of the map indicating which nodes are processed.
+ ///The type of the map that indicates which nodes are processed.
typedef typename TR::ProcessedMap ProcessedMap;
- ///The type of the map that stores the dists of the nodes.
- typedef typename TR::DistMap DistMap;
+ ///The type of the paths.
+ typedef PredMapPath<Digraph, PredMap> Path;
+
+ ///The traits class.
+ typedef TR Traits;
+
private:
typedef typename Digraph::Node Node;
@@ -166,23 +172,23 @@
typedef typename Digraph::Arc Arc;
typedef typename Digraph::OutArcIt OutArcIt;
- /// Pointer to the underlying digraph.
+ //Pointer to the underlying digraph.
const Digraph *G;
- ///Pointer to the map of predecessors arcs.
+ //Pointer to the map of predecessor arcs.
PredMap *_pred;
- ///Indicates if \ref _pred is locally allocated (\c true) or not.
+ //Indicates if _pred is locally allocated (true) or not.
bool local_pred;
- ///Pointer to the map of distances.
+ //Pointer to the map of distances.
DistMap *_dist;
- ///Indicates if \ref _dist is locally allocated (\c true) or not.
+ //Indicates if _dist is locally allocated (true) or not.
bool local_dist;
- ///Pointer to the map of reached status of the nodes.
+ //Pointer to the map of reached status of the nodes.
ReachedMap *_reached;
- ///Indicates if \ref _reached is locally allocated (\c true) or not.
+ //Indicates if _reached is locally allocated (true) or not.
bool local_reached;
- ///Pointer to the map of processed status of the nodes.
+ //Pointer to the map of processed status of the nodes.
ProcessedMap *_processed;
- ///Indicates if \ref _processed is locally allocated (\c true) or not.
+ //Indicates if _processed is locally allocated (true) or not.
bool local_processed;
std::vector<typename Digraph::Node> _queue;
@@ -190,7 +196,6 @@
int _curr_dist;
///Creates the maps if necessary.
-
///\todo Better memory allocation (instead of new).
void create_maps()
{
@@ -233,10 +238,10 @@
}
};
///\brief \ref named-templ-param "Named parameter" for setting
- ///PredMap type
+ ///\ref PredMap type.
///
- ///\ref named-templ-param "Named parameter" for setting PredMap type
- ///
+ ///\ref named-templ-param "Named parameter" for setting
+ ///\ref PredMap type.
template <class T>
struct DefPredMap : public Bfs< Digraph, DefPredMapTraits<T> > {
typedef Bfs< Digraph, DefPredMapTraits<T> > Create;
@@ -251,10 +256,10 @@
}
};
///\brief \ref named-templ-param "Named parameter" for setting
- ///DistMap type
+ ///\ref DistMap type.
///
- ///\ref named-templ-param "Named parameter" for setting DistMap type
- ///
+ ///\ref named-templ-param "Named parameter" for setting
+ ///\ref DistMap type.
template <class T>
struct DefDistMap : public Bfs< Digraph, DefDistMapTraits<T> > {
typedef Bfs< Digraph, DefDistMapTraits<T> > Create;
@@ -269,10 +274,10 @@
}
};
///\brief \ref named-templ-param "Named parameter" for setting
- ///ReachedMap type
+ ///\ref ReachedMap type.
///
- ///\ref named-templ-param "Named parameter" for setting ReachedMap type
- ///
+ ///\ref named-templ-param "Named parameter" for setting
+ ///\ref ReachedMap type.
template <class T>
struct DefReachedMap : public Bfs< Digraph, DefReachedMapTraits<T> > {
typedef Bfs< Digraph, DefReachedMapTraits<T> > Create;
@@ -287,10 +292,10 @@
}
};
///\brief \ref named-templ-param "Named parameter" for setting
- ///ProcessedMap type
+ ///\ref ProcessedMap type.
///
- ///\ref named-templ-param "Named parameter" for setting ProcessedMap type
- ///
+ ///\ref named-templ-param "Named parameter" for setting
+ ///\ref ProcessedMap type.
template <class T>
struct DefProcessedMap : public Bfs< Digraph, DefProcessedMapTraits<T> > {
typedef Bfs< Digraph, DefProcessedMapTraits<T> > Create;
@@ -298,16 +303,16 @@
struct DefDigraphProcessedMapTraits : public Traits {
typedef typename Digraph::template NodeMap<bool> ProcessedMap;
- static ProcessedMap *createProcessedMap(const Digraph &G)
+ static ProcessedMap *createProcessedMap(const Digraph &g)
More information about the Lemon-commits
mailing list