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

The greedy algorithms on graphs in parallel, beyond the book, by the deterministic reservations of speculativeFor() [see SpeculativeFor.h] on the threads of an executor [see Executor.h]: each gives exactly the result of the sequential greedy algorithm on the same order of the edges or of the nodes, on every executor and whatever the number of its threads (see Deterministic reservations, greedy algorithms). More...

#include "ADS/Contract.h"
#include "ADS/graph/MinimumSpanningTree.h"
#include "ADS/graph/StaticGraph.h"
#include "ADS/parallel/Executor.h"
#include "ADS/parallel/ParallelSort.h"
#include "ADS/parallel/SpeculativeFor.h"
#include <cstddef>
#include <utility>
#include <vector>
#include "ADS/parallel/impl/ParallelGreedy.tpp"

Go to the source code of this file.

Namespaces

namespace  ADS

Functions

std::vector< int > ADS::randomOrder (int n, unsigned long long seed)
 a random permutation of \( [ 0 , n ) \) from the seed, the same on every machine (the shuffle of Fisher and Yates on a SplitMix64 generator)
template<Executor E, class W>
std::vector< int > ADS::parallelKruskal (E &ex, int n, const std::vector< WeightedEdge< W > > &A)
 the places in \( A \) of the edges of the minimum spanning forest that Kruskal gives on the order \( ( w , \mathit{place} ) \), in that order
template<Executor E, class W>
std::vector< int > ADS::filterKruskal (E &ex, int n, const std::vector< WeightedEdge< W > > &A)
 the forest of parallelKruskal() above, by filter-Kruskal
template<Executor E>
std::vector< int > ADS::spanningForest (E &ex, int n, const std::vector< std::pair< int, int > > &A)
 the places in \( A \) of the edges of the spanning forest of the greedy algorithm in the order of \( A \), increasing
template<Executor E, class W, ArcLayout AL>
std::vector< int > ADS::maximalIndependentSet (E &ex, const StaticGraph< W, AL > &g, const std::vector< int > &pi)
 the nodes of the greedy maximal independent set of \( g \) in the order \( \pi \) (the node \( \pi[ 0 ] \) first), increasing
template<Executor E>
std::vector< int > ADS::maximalMatching (E &ex, int n, const std::vector< std::pair< int, int > > &A, const std::vector< int > &pi)
 the places in \( A \) of the edges of the greedy maximal matching in the order \( \pi \) of the edges (the edge \( A[ \pi[ 0 ] ] \) first), increasing

Detailed description

The greedy algorithms on graphs in parallel, beyond the book, by the deterministic reservations of speculativeFor() [see SpeculativeFor.h] on the threads of an executor [see Executor.h]: each gives exactly the result of the sequential greedy algorithm on the same order of the edges or of the nodes, on every executor and whatever the number of its threads (see Deterministic reservations, greedy algorithms).

They are the algorithm of Kruskal (parallelKruskal(), section 14.3 of the book) and its filter-Kruskal variant (filterKruskal()), the spanning forest in the order of the edges (spanningForest(), by the union-find of section 10.2), and the greedy maximal independent set and maximal matching in a given order (maximalIndependentSet(), maximalMatching()); on a random order (randomOrder()) the iterations that wait for each other form short chains, and the rounds are few.

The union-find of the forests links the roots with no rank, and its find() halves the paths (a write of a node to its grandparent, which a concurrent find() reads either way, since no link happens while the finds run). On one thread, or on fewer than 4096 items, the sequential greedy algorithm runs instead.

The contracts [see Contract.h]: \( n \ge 0 \), the ends of the edges in \( [ 0 , n ) \) (a loop \( [ u , u ] \) joins nothing and matches nothing; parallel edges are allowed); the graph is unoriented; an order is a permutation. At the level of the audits each result is checked against the sequential greedy algorithm.

See also
A. Montresor, Algoritmi e Strutture Dati, 2025, sections 10.2 and 14.3, https://algoritmicamente.it/materiali/libro/capitoli/cap14.pdf
G. E. Blelloch, J. T. Fineman, P. B. Gibbons, J. Shun, Internally deterministic parallel algorithms can be fast, Proceedings of PPoPP, 181-192, 2012, doi:10.1145/2145816.2145840
G. E. Blelloch, J. T. Fineman, J. Shun, Greedy sequential maximal independent set and matching are parallel on average, Proceedings of SPAA, 308-317, 2012, doi:10.1145/2312005.2312058
M. Fischer, A. Noever, Tight analysis of parallel randomized greedy MIS, Proceedings of SODA, 2152-2160, 2018, doi:10.1137/1.9781611975031.140
V. Osipov, P. Sanders, J. Singler, The filter-Kruskal minimum spanning tree algorithm, Proceedings of ALENEX, 52-61, 2009, doi:10.1137/1.9781611972894.5
J. Shun, Y. Gu, G. E. Blelloch, J. T. Fineman, P. B. Gibbons, Sequential random permutation, list contraction and tree contraction are highly parallel, Proceedings of SODA, 431-448, 2015, doi:10.1137/1.9781611973730.30
L. Dhulipala, G. E. Blelloch, J. Shun, Theoretically efficient parallel graph algorithms can be fast and scalable, ACM Transactions on Parallel Computing 8(1), 1-70, 2021, doi:10.1145/3434393
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa