Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gblelloch committed Feb 29, 2024
1 parent f265fa1 commit 242b3aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 2 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The examples are as follows, broken down into categories.
- ldd_connectivity : graph connectivity using low diameter decomposition
- le_list : Least elements lists for vertices of a graph.
- low_diameter_decomposition : returns a decomposition of a graph such that beta*m edges cross between components, and each component has radius log(n)/beta.
- lubys : luby's algorithm for maximal independent set (MIS)
- maximal_independent_set : greedy (lexicographically first) MIS on random permutation of vertices
- maximal_matching : greedy (lexicographically first) maximal matching on random permutation of edges
- pagerank : Page and Brin's algorithm for ranking pages in the web graph
Expand Down Expand Up @@ -89,6 +90,7 @@ The examples are as follows, broken down into categories.
## Sorting etc.

- counting_sort : parallel counting sort for a smallish number of buckets
- integer_sort : a radix-based integer sort
- kth_smallest : randomized algorithm to report the kth smallest element of an unsorted sequence
- mergesort : merge sort
- quicksort : quick sort
Expand Down
10 changes: 4 additions & 6 deletions examples/lubys.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <parlay/delayed.h>
#include <parlay/random.h>
#include <parlay/monoid.h>
#include <parlay/internal/get_time.h>

// **************************************************************
// Luby's algorithm for Maximal Independent Set (MIS). From:
Expand All @@ -19,14 +18,14 @@

// Note graph is copied since it is mutated internally
template <typename graph>
parlay::sequence<bool> MIS(graph& G_in) {
parlay::sequence<bool> MIS(const graph& G_in) {
using vertex = typename graph::value_type::value_type;
long n = G_in.size();
parlay::random_generator gen(0);
std::uniform_int_distribution<int> dis(0,1000000000);

// first round uses G_in then uses G_nxt
graph* G = &G_in;
const graph* G = &G_in;
graph G_nxt(n);

// Each vertex is either in the set, out of the set, or unknown (initially)
Expand Down Expand Up @@ -63,13 +62,12 @@ parlay::sequence<bool> MIS(graph& G_in) {
// only keep edges for which both endpoints are unknown
for_each(V, [&] (vertex u) {
G_nxt[u] = parlay::filter((*G)[u], [&] (vertex v) {
return states[v] == Unknown;});});
return states[v] == Unknown;});});

// advanced state of random number generator
gen = gen[n];
G = &G_nxt;
}

return parlay::map(states, [] (auto& s) {
return s.load() == InSet;});
return parlay::map(states, [] (auto& s) {return s.load() == InSet;});
}

0 comments on commit 242b3aa

Please sign in to comment.