/usr/include/boost/graph/distributed
Edit: /usr/include/boost/graph/distributed/dijkstra_shortest_paths.hpp (8719B)
// Copyright (C) 2004-2006 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Authors: Douglas Gregor
// Andrew Lumsdaine
#ifndef BOOST_GRAPH_PARALLEL_DIJKSTRA_HPP
#define BOOST_GRAPH_PARALLEL_DIJKSTRA_HPP
#ifndef BOOST_GRAPH_USE_MPI
#error "Parallel BGL files should not be included unless
has been included"
#endif
#include
#include
#include
#include
#include
#include
namespace boost {
namespace graph { namespace detail {
template
struct parallel_dijkstra_impl2
{
template
static void
run(const DistributedGraph& g,
typename graph_traits::vertex_descriptor s,
PredecessorMap predecessor, DistanceMap distance,
typename property_traits::value_type lookahead,
WeightMap weight, IndexMap index_map, ColorMap color_map,
Compare compare, Combine combine, DistInf inf, DistZero zero,
DijkstraVisitor vis)
{
eager_dijkstra_shortest_paths(g, s, predecessor, distance, lookahead,
weight, index_map, color_map, compare,
combine, inf, zero, vis);
}
};
template<>
struct parallel_dijkstra_impl2< ::boost::param_not_found >
{
template
static void
run(const DistributedGraph& g,
typename graph_traits::vertex_descriptor s,
PredecessorMap predecessor, DistanceMap distance,
::boost::param_not_found,
WeightMap weight, IndexMap index_map, ColorMap color_map,
Compare compare, Combine combine, DistInf inf, DistZero zero,
DijkstraVisitor vis)
{
crauser_et_al_shortest_paths(g, s, predecessor, distance, weight,
index_map, color_map, compare, combine,
inf, zero, vis);
}
};
template
struct parallel_dijkstra_impl
{
template
static void
run(const DistributedGraph& g,
typename graph_traits::vertex_descriptor s,
PredecessorMap predecessor, DistanceMap distance,
Lookahead lookahead,
WeightMap weight, IndexMap index_map, ColorMap color_map,
Compare compare, Combine combine, DistInf inf, DistZero zero,
DijkstraVisitor vis)
{
graph::detail::parallel_dijkstra_impl2
::run(g, s, predecessor, distance, lookahead, weight, index_map,
color_map, compare, combine, inf, zero, vis);
}
};
template<>
struct parallel_dijkstra_impl< ::boost::param_not_found >
{
private:
template
static void
run_impl(const DistributedGraph& g,
typename graph_traits::vertex_descriptor s,
PredecessorMap predecessor, DistanceMap distance,
Lookahead lookahead, WeightMap weight, IndexMap index_map,
ColorMap color_map, Compare compare, Combine combine,
DistInf inf, DistZero zero, DijkstraVisitor vis)
{
BGL_FORALL_VERTICES_T(u, g, DistributedGraph)
BGL_FORALL_OUTEDGES_T(u, e, g, DistributedGraph)
local_put(color_map, target(e, g), white_color);
graph::detail::parallel_dijkstra_impl2
::run(g, s, predecessor, distance, lookahead, weight, index_map,
color_map, compare, combine, inf, zero, vis);
}
public:
template
static void
run(const DistributedGraph& g,
typename graph_traits::vertex_descriptor s,
PredecessorMap predecessor, DistanceMap distance,
Lookahead lookahead, WeightMap weight, IndexMap index_map,
::boost::param_not_found,
Compare compare, Combine combine, DistInf inf, DistZero zero,
DijkstraVisitor vis)
{
typedef typename graph_traits::vertices_size_type
vertices_size_type;
vertices_size_type n = num_vertices(g);
std::vector colors(n, white_color);
run_impl(g, s, predecessor, distance, lookahead, weight, index_map,
make_iterator_property_map(colors.begin(), index_map),
compare, combine, inf, zero, vis);
}
};
} } // end namespace graph::detail
/** Dijkstra's single-source shortest paths algorithm for distributed
* graphs.
*
* Also implements the heuristics of:
*
* Andreas Crauser, Kurt Mehlhorn, Ulrich Meyer, and Peter
* Sanders. A Parallelization of Dijkstra's Shortest Path
* Algorithm. In Lubos Brim, Jozef Gruska, and Jiri Zlatuska,
* editors, Mathematical Foundations of Computer Science (MFCS),
* volume 1450 of Lecture Notes in Computer Science, pages
* 722--731, 1998. Springer.
*/
template
inline
void
dijkstra_shortest_paths
(const DistributedGraph& g,
typename graph_traits::vertex_descriptor s,
PredecessorMap predecessor, DistanceMap distance, WeightMap weight,
IndexMap index_map,
Compare compare, Combine combine, DistInf inf, DistZero zero,
DijkstraVisitor vis,
const bgl_named_params& params
BOOST_GRAPH_ENABLE_IF_MODELS_PARM(DistributedGraph,distributed_graph_tag))
{
typedef typename graph_traits::vertices_size_type
vertices_size_type;
// Build a distributed property map for vertex colors, if we need it
bool use_default_color_map
= is_default_param(get_param(params, vertex_color));
vertices_size_type n = use_default_color_map? num_vertices(g) : 1;
std::vector color(n, white_color);
typedef iterator_property_map::iterator,
IndexMap> DefColorMap;
DefColorMap color_map(color.begin(), index_map);
typedef typename get_param_type< vertex_color_t, bgl_named_params >::type color_map_type;
graph::detail::parallel_dijkstra_impl
::run(g, s, predecessor, distance,
get_param(params, lookahead_t()),
weight, index_map,
get_param(params, vertex_color),
compare, combine, inf, zero, vis);
}
} // end namespace boost
#endif // BOOST_GRAPH_PARALLEL_DIJKSTRA_HPP