ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
Parallel.h File Reference

The algorithms of LEMON on the threads of ADS, beyond the book (see Interoperation with LEMON): More...

#include "ADS/graph/ShortestPaths.h"
#include "ADS/interop/lemon/Heaps.h"
#include "ADS/interop/lemon/Maps.h"
#include "ADS/parallel/Executor.h"
#include "ADS/parallel/ParallelSort.h"
#include <lemon/bits/traits.h>
#include <lemon/core.h>
#include <lemon/dijkstra.h>
#include <cstddef>
#include <type_traits>
#include <utility>
#include <vector>

Go to the source code of this file.

Namespaces

namespace  ADS
namespace  ADS::lemon_interop

Functions

template<class H = void, Executor E, class GR, class LM>
std::vector< std::vector< typename LM::Value > > ADS::lemon_interop::dijkstraFrom (E &ex, const GR &g, const LM &l, const std::vector< typename GR::Node > &S)
 the distances from each node of \( S \) in the digraph \( g \) of the lengths \( l \), by one run of the Dijkstra of LEMON per source on the threads of \( \mathit{ex} \): the vector of each source, by the ids of the nodes, infinity() for those not reached [see ShortestPaths.h]
template<Executor E, class GR, class CM, class Item = typename CM::Key>
std::vector< std::pair< Item, typename CM::Value > > ADS::lemon_interop::sortedArcs (E &ex, const GR &g, const CM &c)
 the pairs ( item , cost ) of the items Item of \( g \), the edges of a graph by default, in the order of the costs of \( c \), sorted on the threads of \( \mathit{ex} \), for lemon::kruskal( g , S , t )

Detailed description

The algorithms of LEMON on the threads of ADS, beyond the book (see Interoperation with LEMON):

  • dijkstraFrom( ex , g , l , S ), the shortest distances from each source of \( S \) by \( |S| \) runs of the Dijkstra of LEMON on the threads of the executor \( \mathit{ex} \) [see Executor.h], all on the one digraph \( g \), which nobody changes meanwhile: each run takes its distances, its predecessors and its cross references in a DenseMap [see Maps.h] and its heap from H, DaryHeap of ADS by default [see Heaps.h], so that no run attaches a map to the notifier of the graph, whose lock would serialize them, and the runs share no mutable state; the work is that of the \( |S| \) runs, the time that of the longest share of them on each thread. It is, e.g., the pricing of a generation of columns by one shortest path per commodity;
  • sortedArcs( ex , g , c ), the pairs ( item , cost ) of the edges (or of the arcs) of \( g \) in the order of their costs, sorted by the parallel sort of ADS [see ParallelSort.h], which lemon::kruskal() takes as already sorted (it sorts a map by std::sort, a sequence not), so that the sort, which dominates Kruskal's algorithm on a sparse graph, runs on the threads of the executor.

The contracts [see Contract.h]: the graph does not change while the runs read it; the lengths are not negative. The functions are defined in this file.

See also
E. W. Dijkstra, A note on two problems in connexion with graphs, Numerische Mathematik 1, 269-271, 1959, doi:10.1007/BF01386390
J. B. Kruskal, On the shortest spanning subtree of a graph and the traveling salesman problem, Proceedings of the American Mathematical Society 7(1), 48-50, 1956, doi:10.1090/S0002-9939-1956-0078686-7
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa