Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions D3128_Algorithms/src/breadth_first_search.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
template <adjacency_list G, class Visitor = empty_visitor>
template <adjacency_list G, class Visitor = empty_visitor,
class Alloc = allocator<byte>>
void breadth_first_search(
G&& g, // graph
vertex_id_t<G> source, // starting vertex\_id
Visitor&& visitor = empty_visitor())
G&& g, // graph
vertex_id_t<G> source, // starting vertex\_id
Visitor&& visitor = empty_visitor(),
const Alloc& alloc = Alloc())
6 changes: 4 additions & 2 deletions D3128_Algorithms/src/breadth_first_search_multi.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
template <adjacency_list G, input_range Sources, class Visitor = empty_visitor>
template <adjacency_list G, input_range Sources, class Visitor = empty_visitor,
class Alloc = allocator<byte>>
requires convertible_to<range_value_t<Sources>, vertex_id_t<G>>
void breadth_first_search(G&& g, // graph
const Sources& sources,
Visitor&& visitor = empty_visitor())
Visitor&& visitor = empty_visitor(),
const Alloc& alloc = Alloc())
22 changes: 12 additions & 10 deletions D3128_Algorithms/src/connected_components.hpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/*
* Hopcroft-Tarjan Articulation Points
*/
template <adjacency_list G, class Iter>
template <adjacency_list G, class Iter, class Alloc = allocator<byte>>
requires output_iterator<Iter, vertex_id_t<G>>
void articulation_points(G&& g, Iter cut_vertices);
void articulation_points(G&& g, Iter cut_vertices, const Alloc& alloc = Alloc());

/*
* Hopcroft-Tarjan Biconnected Components
*/
template <adjacency_list G, class OuterContainer>
void biconnected_components(G&& g, OuterContainer& components);
template <adjacency_list G, class OuterContainer, class Alloc = allocator<byte>>
void biconnected_components(G&& g, OuterContainer& components, const Alloc& alloc = Alloc());

/*
* Connected Components
*/
template <adjacency_list G, class ComponentFn>
template <adjacency_list G, class ComponentFn, class Alloc = allocator<byte>>
requires vertex_property_fn_for<ComponentFn, G>
size_t connected_components(G&& g, ComponentFn&& component);
size_t connected_components(G&& g, ComponentFn&& component, const Alloc& alloc = Alloc());

/*
* Afforest Connected Components
Expand All @@ -32,10 +32,12 @@ void afforest(G&& g, GT&& g_t, Component& component, const size_t neighbor_round
/*
* Kosaraju Strongly Connected Components
*/
template <adjacency_list G, adjacency_list GT, class ComponentFn>
template <adjacency_list G, adjacency_list GT, class ComponentFn,
class Alloc = allocator<byte>>
requires vertex_property_fn_for<ComponentFn, G>
void kosaraju(G&& g, GT&& g_t, ComponentFn&& component);
void kosaraju(G&& g, GT&& g_t, ComponentFn&& component, const Alloc& alloc = Alloc());

template <bidirectional_adjacency_list G, class ComponentFn>
template <bidirectional_adjacency_list G, class ComponentFn,
class Alloc = allocator<byte>>
requires vertex_property_fn_for<ComponentFn, G>
void kosaraju(G&& g, ComponentFn&& component);
void kosaraju(G&& g, ComponentFn&& component, const Alloc& alloc = Alloc());
10 changes: 6 additions & 4 deletions D3128_Algorithms/src/depth_first_search.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
template <adjacency_list G, class Visitor = empty_visitor>
template <adjacency_list G, class Visitor = empty_visitor,
class Alloc = allocator<byte>>
void depth_first_search(
G&& g, // graph
vertex_id_t<G> source, // starting vertex\_id
Visitor&& visitor = empty_visitor())
G&& g, // graph
vertex_id_t<G> source, // starting vertex\_id
Visitor&& visitor = empty_visitor(),
const Alloc& alloc = Alloc())
6 changes: 4 additions & 2 deletions D3128_Algorithms/src/dijkstra_shortest_dists.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ template <adjacency_list G,
const edge_t<G>&)>,
class Visitor = empty_visitor,
class Compare = less<distance_fn_value_t<DistanceFn, G>>,
class Combine = plus<distance_fn_value_t<DistanceFn, G>>>
class Combine = plus<distance_fn_value_t<DistanceFn, G>>,
class Alloc = allocator<byte>>
requires distance_fn_for<DistanceFn, G> &&
basic_edge_weight_function<G, WF, distance_fn_value_t<DistanceFn, G>, Compare, Combine>
constexpr void dijkstra_shortest_distances(
Expand All @@ -15,4 +16,5 @@ constexpr void dijkstra_shortest_distances(
const edge_t<G>& uv) { return distance_fn_value_t<DistanceFn, G>(1); },
Visitor&& visitor = empty_visitor(),
Compare&& compare = less<distance_fn_value_t<DistanceFn, G>>(),
Combine&& combine = plus<distance_fn_value_t<DistanceFn, G>>());
Combine&& combine = plus<distance_fn_value_t<DistanceFn, G>>(),
const Alloc& alloc = Alloc());
6 changes: 4 additions & 2 deletions D3128_Algorithms/src/dijkstra_shortest_dists_multi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ template <adjacency_list G,
const edge_t<G>&)>,
class Visitor = empty_visitor,
class Compare = less<distance_fn_value_t<DistanceFn, G>>,
class Combine = plus<distance_fn_value_t<DistanceFn, G>>>
class Combine = plus<distance_fn_value_t<DistanceFn, G>>,
class Alloc = allocator<byte>>
requires distance_fn_for<DistanceFn, G> &&
convertible_to<range_value_t<Sources>, vertex_id_t<G>> &&
basic_edge_weight_function<G, WF, distance_fn_value_t<DistanceFn, G>, Compare, Combine>
Expand All @@ -17,4 +18,5 @@ constexpr void dijkstra_shortest_distances(
const edge_t<G>& uv) { return distance_fn_value_t<DistanceFn, G>(1); },
Visitor&& visitor = empty_visitor(),
Compare&& compare = less<distance_fn_value_t<DistanceFn, G>>(),
Combine&& combine = plus<distance_fn_value_t<DistanceFn, G>>());
Combine&& combine = plus<distance_fn_value_t<DistanceFn, G>>(),
const Alloc& alloc = Alloc());
6 changes: 4 additions & 2 deletions D3128_Algorithms/src/dijkstra_shortest_paths.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ template <adjacency_list G,
const edge_t<G>&)>,
class Visitor = empty_visitor,
class Compare = less<distance_fn_value_t<DistanceFn, G>>,
class Combine = plus<distance_fn_value_t<DistanceFn, G>>>
class Combine = plus<distance_fn_value_t<DistanceFn, G>>,
class Alloc = allocator<byte>>
requires distance_fn_for<DistanceFn, G> &&
predecessor_fn_for<PredecessorFn, G> &&
basic_edge_weight_function<G, WF, distance_fn_value_t<DistanceFn, G>, Compare, Combine>
Expand All @@ -18,4 +19,5 @@ constexpr void dijkstra_shortest_paths(
const edge_t<G>& uv) { return distance_fn_value_t<DistanceFn, G>(1); },
Visitor&& visitor = empty_visitor(),
Compare&& compare = less<distance_fn_value_t<DistanceFn, G>>(),
Combine&& combine = plus<distance_fn_value_t<DistanceFn, G>>());
Combine&& combine = plus<distance_fn_value_t<DistanceFn, G>>(),
const Alloc& alloc = Alloc());
18 changes: 10 additions & 8 deletions D3128_Algorithms/src/dijkstra_shortest_paths_multi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ template <adjacency_list G,
const edge_t<G>&)>,
class Visitor = empty_visitor,
class Compare = less<distance_fn_value_t<DistanceFn, G>>,
class Combine = plus<distance_fn_value_t<DistanceFn, G>>>
class Combine = plus<distance_fn_value_t<DistanceFn, G>>,
class Alloc = allocator<byte>>
requires distance_fn_for<DistanceFn, G> &&
predecessor_fn_for<PredecessorFn, G> &&
convertible_to<range_value_t<Sources>, vertex_id_t<G>> &&
basic_edge_weight_function<G, WF, distance_fn_value_t<DistanceFn, G>, Compare, Combine>
constexpr void dijkstra_shortest_paths(
G&& g,
const Sources& sources,
DistanceFn&& distance,
G&& g,
const Sources& sources,
DistanceFn&& distance,
PredecessorFn&& predecessor,
WF&& weight = [](const auto&,
WF&& weight = [](const auto&,
const edge_t<G>& uv) { return distance_fn_value_t<DistanceFn, G>(1); },
Visitor&& visitor = empty_visitor(),
Compare&& compare = less<distance_fn_value_t<DistanceFn, G>>(),
Combine&& combine = plus<distance_fn_value_t<DistanceFn, G>>());
Visitor&& visitor = empty_visitor(),
Compare&& compare = less<distance_fn_value_t<DistanceFn, G>>(),
Combine&& combine = plus<distance_fn_value_t<DistanceFn, G>>(),
const Alloc& alloc = Alloc());
26 changes: 16 additions & 10 deletions D3128_Algorithms/src/mst.hpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
/*
* Kruskal's Algorithm
*/
template <x_index_edgelist_range IELR, x_index_edgelist_range OELR>
auto kruskal(IELR&& e, OELR&& t);
template <x_index_edgelist_range IELR, x_index_edgelist_range OELR,
class Alloc = allocator<byte>>
auto kruskal(IELR&& e, OELR&& t, const Alloc& alloc = Alloc());

template <x_index_edgelist_range IELR, x_index_edgelist_range OELR, class CompareOp>
auto kruskal(IELR&& e, OELR&& t, CompareOp compare);
template <x_index_edgelist_range IELR, x_index_edgelist_range OELR, class CompareOp,
class Alloc = allocator<byte>>
auto kruskal(IELR&& e, OELR&& t, CompareOp compare, const Alloc& alloc = Alloc());

/*
* Inplace Kruskal's Algorithm
*/
template <x_index_edgelist_range IELR, x_index_edgelist_range OELR>
template <x_index_edgelist_range IELR, x_index_edgelist_range OELR,
class Alloc = allocator<byte>>
requires permutable<iterator_t<IELR>>
auto inplace_kruskal(IELR&& e, OELR&& t);
auto inplace_kruskal(IELR&& e, OELR&& t, const Alloc& alloc = Alloc());

template <x_index_edgelist_range IELR, x_index_edgelist_range OELR, class CompareOp>
template <x_index_edgelist_range IELR, x_index_edgelist_range OELR, class CompareOp,
class Alloc = allocator<byte>>
requires permutable<iterator_t<IELR>>
auto inplace_kruskal(IELR&& e, OELR&& t, CompareOp compare);
auto inplace_kruskal(IELR&& e, OELR&& t, CompareOp compare, const Alloc& alloc = Alloc());

/*
* Prim's Algorithm
Expand All @@ -26,7 +30,8 @@ template <adjacency_list G,
class PredecessorFn,
class WF = function<distance_fn_value_t<WeightFn, G>(const remove_reference_t<G>&,
const edge_t<G>&)>,
class CompareOp = less<distance_fn_value_t<WeightFn, G>>>
class CompareOp = less<distance_fn_value_t<WeightFn, G>>,
class Alloc = allocator<byte>>
requires distance_fn_for<WeightFn, G> &&
is_arithmetic_v<distance_fn_value_t<WeightFn, G>> &&
predecessor_fn_for<PredecessorFn, G> &&
Expand All @@ -37,4 +42,5 @@ auto prim(G&& g,
WeightFn&& weight,
PredecessorFn&& predecessor,
WF&& weight_fn = [](const auto& gr, const edge_t<G>& uv) { return edge_value(gr, uv); },
CompareOp compare = less<distance_fn_value_t<WeightFn, G>>());
CompareOp compare = less<distance_fn_value_t<WeightFn, G>>(),
const Alloc& alloc = Alloc());
4 changes: 2 additions & 2 deletions D3128_Algorithms/src/tarjan_scc.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Tarjan's Strongly Connected Components
*/
template <adjacency_list G, class ComponentFn>
template <adjacency_list G, class ComponentFn, class Alloc = allocator<byte>>
requires vertex_property_fn_for<ComponentFn, G>
size_t tarjan_scc(G&& g, ComponentFn&& component);
size_t tarjan_scc(G&& g, ComponentFn&& component, const Alloc& alloc = Alloc());
10 changes: 6 additions & 4 deletions D3128_Algorithms/src/topological_sort.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Single-source topological sort
template <adjacency_list G, class OutputIterator>
template <adjacency_list G, class OutputIterator, class Alloc = allocator<byte>>
requires output_iterator<OutputIterator, vertex_id_t<G>>
[[nodiscard]] bool
topological_sort(const G& g, const vertex_id_t<G>& source, OutputIterator result);
topological_sort(const G& g, const vertex_id_t<G>& source, OutputIterator result,
const Alloc& alloc = Alloc());

// Full-graph topological sort
template <adjacency_list G, class OutputIterator>
template <adjacency_list G, class OutputIterator, class Alloc = allocator<byte>>
requires output_iterator<OutputIterator, vertex_id_t<G>>
[[nodiscard]] bool topological_sort(const G& g, OutputIterator result);
[[nodiscard]] bool topological_sort(const G& g, OutputIterator result,
const Alloc& alloc = Alloc());
6 changes: 4 additions & 2 deletions D3128_Algorithms/src/topological_sort_multi.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
template <adjacency_list G, input_range Sources, class OutputIterator>
template <adjacency_list G, input_range Sources, class OutputIterator,
class Alloc = allocator<byte>>
requires convertible_to<range_value_t<Sources>, vertex_id_t<G>> &&
output_iterator<OutputIterator, vertex_id_t<G>>
[[nodiscard]] bool topological_sort(const G& g, const Sources& sources, OutputIterator result);
[[nodiscard]] bool topological_sort(const G& g, const Sources& sources, OutputIterator result,
const Alloc& alloc = Alloc());
Loading
Loading