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
16 changes: 8 additions & 8 deletions include/graph/algorithm/bellman_ford_shortest_paths.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace graph {
*
* @param g The graph.
* @param predecessor The predecessor range.
* @param cycle_vertex_id A vertex id in the negative weight cycle. IF no negative weight cycle exists
* @param cycle_vertex_id A vertex id in the negative weight cycle. If no negative weight cycle exists
* then there will be no vertex id defined.
* @param out_cycle The output iterator that the vertex ids in the cycle are output to.
*/
Expand Down Expand Up @@ -84,9 +84,9 @@ void find_negative_cycle(G& g,
* @tparam Predecessors The predecessor random access range.
* @tparam WF Edge weight function. Defaults to a function that returns 1.
* @tparam Visitor Visitor type with functions called for different events in the algorithm.
* Function calls are removed by the optimizer if not uesd.
* Function calls are removed by the optimizer if not used.
* @tparam Compare Comparison function for Distance values. Defaults to less<DistanceValue>.
* @tparam Combine Combine function for Distance values. Defaults to plus<DistanctValue>.
* @tparam Combine Combine function for Distance values. Defaults to plus<DistanceValue>.
*
* @return optional<vertex_id_t<G>>, where no vertex id is returned if all edges were minimized.
* If an edge was not minimized, the on_edge_not_minimized event is called and a vertex id
Expand Down Expand Up @@ -120,7 +120,7 @@ requires convertible_to<range_value_t<Sources>, vertex_id_t<G>> && //
using weight_type = invoke_result_t<WF, edge_reference_t<G>>;
using return_type = optional<vertex_id_t<G>>;

// relxing the target is the function of reducing the distance from the source to the target
// relaxing the target is the function of reducing the distance from the source to the target
auto relax_target = [&g, &predecessor, &distances, &compare, &combine] //
(edge_reference_t<G> e, vertex_id_t<G> uid, const weight_type& w_e) -> bool {
id_type vid = target_id(g, e);
Expand All @@ -139,14 +139,14 @@ requires convertible_to<range_value_t<Sources>, vertex_id_t<G>> && //

if (size(distances) < size(vertices(g))) {
throw std::out_of_range(
std::format("bellman_ford_shortest_paths: size of distances is {} is less than the number of vertices {}",
std::format("bellman_ford_shortest_paths: size of distances of {} is less than the number of vertices {}",
size(distances), size(vertices(g))));
}

if constexpr (!is_same_v<Predecessors, _null_range_type>) {
if (size(predecessor) < size(vertices(g))) {
throw std::out_of_range(
std::format("bellman_ford_shortest_paths: size of predecessor is {} is less than the number of vertices {}",
std::format("bellman_ford_shortest_paths: size of predecessor of {} is less than the number of vertices {}",
size(predecessor), size(vertices(g))));
}
}
Expand Down Expand Up @@ -259,9 +259,9 @@ requires is_arithmetic_v<range_value_t<Distances>> && //
* @tparam Distances The distance random access range.
* @tparam WF Edge weight function. Defaults to a function that returns 1.
* @tparam Visitor Visitor type with functions called for different events in the algorithm.
* Function calls are removed by the optimizer if not uesd.
* Function calls are removed by the optimizer if not used.
* @tparam Compare Comparison function for Distance values. Defaults to less<DistanceValue>.
* @tparam Combine Combine function for Distance values. Defaults to plus<DistanctValue>.
* @tparam Combine Combine function for Distance values. Defaults to plus<DistanceValue>.
*
* @return optional<vertex_id_t<G>>, where no vertex id is returned if all edges were minimized.
* If an edge was not minimized, the on_edge_not_minimized event is called and a vertex id
Expand Down
11 changes: 3 additions & 8 deletions include/graph/algorithm/dijkstra_clrs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ template <class G, class F>
concept edge_weight_function = // e.g. weight(uv)
std::copy_constructible<F> && is_arithmetic_v<invoke_result_t<F, edge_reference_t<G>>>;


//edge_weight_function<G, WF> &&
//strict_weak_order<Compare, range_value_t<Distance>, range_value_t<Distance>> &&
//assignable_from <range_reference_t<Distance>, invoke_result_t <Combine, invoke_result_t<WF, edge_t<G>>,

template <class G, class WF, class Distance, class Compare, class Combine>
concept basic_edge_weight_function2 = // e.g. weight(uv)
is_arithmetic_v<range_value_t<Distance>> &&
Expand Down Expand Up @@ -67,8 +62,8 @@ constexpr auto print_types(Ts...) {
* @tparam Distance The distance range type.
* @tparam Predecessor The predecessor range type.
*
* @param graph The graph.
* @param source The source vertex.
* @param g The graph.
* @param seed The source vertex.
* @param distance The distance vector.
* @param predecessor The predecessor vector.
* @param weight The edge weight function.
Expand Down Expand Up @@ -159,7 +154,7 @@ void dijkstra_clrs(
WF&& weight = [](edge_identifier_t<G> uv) { return range_value_t<Distance>(1); }) // default weight(uv) -> 1
{
using id_type = vertex_id_t<G>;
using weight_type = invoke_result_t<WF, edge_identifer_t<G>>;
using weight_type = invoke_result_t<WF, edge_identifier_t<G>>;
const id_type seed_id = vertex_id(g, seed);

size_t N(num_vertices(g));
Expand Down
16 changes: 8 additions & 8 deletions include/graph/algorithm/dijkstra_shortest_paths.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ namespace graph {
/**
* @brief Dijkstra's single-source shortest paths algorithm with a visitor.
*
* The implementation was taken from boost::graph dijkstra_shortes_paths_no_init.
* The implementation was taken from boost::graph dijkstra_shortest_paths_no_init.
*
* Complexity: O(V * E)
* Complexity: O((V + E) log V)
*
* Pre-conditions:
* - 0 <= source < num_vertices(g)
Expand All @@ -52,9 +52,9 @@ namespace graph {
* @tparam Predecessors The predecessor random access range.
* @tparam WF Edge weight function. Defaults to a function that returns 1.
* @tparam Visitor Visitor type with functions called for different events in the algorithm.
* Function calls are removed by the optimizer if not uesd.
* Function calls are removed by the optimizer if not used.
* @tparam Compare Comparison function for Distance values. Defaults to less<distance_type>.
* @tparam Combine Combine function for Distance values. Defaults to plus<DistanctValue>.
* @tparam Combine Combine function for Distance values. Defaults to plus<DistanceValue>.
*/
template <index_adjacency_list G,
input_range Sources,
Expand Down Expand Up @@ -83,7 +83,7 @@ constexpr void dijkstra_shortest_paths(
using distance_type = range_value_t<Distances>;
using weight_type = invoke_result_t<WF, edge_reference_t<G>>;

// relxing the target is the function of reducing the distance from the source to the target
// relaxing the target is the function of reducing the distance from the source to the target
auto relax_target = [&g, &predecessor, &distances, &compare, &combine] //
(edge_reference_t<G> e, vertex_id_t<G> uid, const weight_type& w_e) -> bool {
const id_type vid = target_id(g, e);
Expand Down Expand Up @@ -233,7 +233,7 @@ constexpr void dijkstra_shortest_paths(
}

/**
* @brief Shortest distnaces from a single source using Dijkstra's single-source shortest paths algorithm
* @brief Shortest distances from a single source using Dijkstra's single-source shortest paths algorithm
* with a visitor.
*
* This is identical to dijkstra_shortest_paths() except that it does not require a predecessors range.
Expand All @@ -254,9 +254,9 @@ constexpr void dijkstra_shortest_paths(
* @tparam Distances The distance random access range.
* @tparam WF Edge weight function. Defaults to a function that returns 1.
* @tparam Visitor Visitor type with functions called for different events in the algorithm.
* Function calls are removed by the optimizer if not uesd.
* Function calls are removed by the optimizer if not used.
* @tparam Compare Comparison function for Distance values. Defaults to less<distance_type>.
* @tparam Combine Combine function for Distance values. Defaults to plus<DistanctValue>.
* @tparam Combine Combine function for Distance values. Defaults to plus<DistanceValue>.
*/
template <index_adjacency_list G,
input_range Sources,
Expand Down
12 changes: 6 additions & 6 deletions include/graph/container/compressed_graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ class compressed_graph_base

void resize_vertices(size_type count) {
row_index_.resize(count + 1); // +1 for terminating row
row_values_resize(count);
row_values_base::resize(count);
}
void resize_edges(size_type count) {
col_index_.reserve(count);
Expand Down Expand Up @@ -562,7 +562,7 @@ class compressed_graph_base
/**
* Load vertex values, callable either before or after @c load_edges(erng,eproj).
*
* If @c load_edges(vrng,vproj) has been called before this, the @c row_values_ vector will be
* If @c load_vertices(vrng,vproj) has been called before this, the @c row_values_ vector will be
* extended to match the number of @c row_index_.size()-1 to avoid out-of-bounds errors when
* accessing vertex values.
*
Expand Down Expand Up @@ -703,7 +703,7 @@ class compressed_graph_base
std::string msg = std::format(
"source id of {} on line {} of the data input is not ordered after source id of {} on the previous line",
edge.source_id, debug_count, last_uid);
std::cout << std::format("\n{}\n", msg);
//std::cout << std::format("\n{}\n", msg);
assert(false);
throw graph_error(move(msg));
}
Expand Down Expand Up @@ -736,7 +736,7 @@ class compressed_graph_base
* See @c load_edges() and @c load_vertices() for more information.
*
* @tparam EProj Edge Projection Function type
* @tparam VProj Vertex Projectiong Function type
* @tparam VProj Vertex Projection Function type
* @tparam ERng Edge Range type
* @tparam VRng Vertex Range type
* @tparam PartRng Range of starting vertex Ids for each partition
Expand Down Expand Up @@ -824,7 +824,7 @@ class compressed_graph_base
}
friend constexpr bool has_edge(const compressed_graph_base& g) { return g.col_index_.size() > 0; }

friend vertex_id_type vertex_id(const compressed_graph_base& g, const_iterator ui) {
friend constexpr vertex_id_type vertex_id(const compressed_graph_base& g, const_iterator ui) {
return static_cast<vertex_id_type>(ui - g.row_index_.begin());
}

Expand Down Expand Up @@ -881,7 +881,7 @@ class compressed_graph_base

friend constexpr auto num_vertices(const compressed_graph_base& g, partition_id_type pid) {
assert(static_cast<size_t>(pid) < g.partition_.size() - 1);
g.partition_[pid + 1] - g.partition_[pid];
return g.partition_[pid + 1] - g.partition_[pid];
}

friend constexpr auto vertices(const compressed_graph_base& g, partition_id_type pid) {
Expand Down
30 changes: 15 additions & 15 deletions include/graph/container/dynamic_graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ using dynamic_adjacency_graph = dynamic_graph<typename Traits::edge_value_type,
* This is one of three composable classes used to define properties for a @c dynamic_edge, the
* others being dynamic_edge_source for the source id and dynamic_edge_value for an edge value.
*
* Unlike the other composable edge property classes, this class doesn't have an open for not
* Unlike the other composable edge property classes, this class doesn't have an option for not
* existing. The target id always exists. It could easily be merged into the dynamic_edge class,
* but was kept separate for design symmatry with the other property classes.
* but was kept separate for design symmetry with the other property classes.
*
* @tparam EV The edge value type. If "void" is used no user value is stored on the edge and
* calls to @c edge_value(g,uv) will generate a compile error.
Expand Down Expand Up @@ -299,7 +299,7 @@ class dynamic_edge_source {
friend constexpr vertex_type& source(graph_type& g, edge_type& uv) noexcept {
return begin(vertices(g))[uv.source_id_];
}
friend constexpr const vertex_type& source_fn(const graph_type& g, const edge_type& uv) noexcept {
friend constexpr const vertex_type& source(const graph_type& g, const edge_type& uv) noexcept {
return begin(vertices(g))[uv.source_id_];
}
};
Expand Down Expand Up @@ -356,7 +356,7 @@ class dynamic_edge_value {
using value_type = EV;
using graph_type = dynamic_graph<EV, VV, GV, VId, Sourced, Traits>;
using vertex_type = dynamic_vertex<EV, VV, GV, VId, Sourced, Traits>;
using edge_type = dynamic_edge_value<EV, VV, GV, VId, Sourced, Traits>;
using edge_type = dynamic_edge<EV, VV, GV, VId, Sourced, Traits>;

public:
constexpr dynamic_edge_value(const value_type& value) : value_(value) {}
Expand Down Expand Up @@ -815,7 +815,7 @@ class dynamic_vertex<EV, void, GV, VId, Sourced, Traits>
* No additional space is used if the edge value type (EV) or vertex value type (VV) is void.
*
* The partition function is intended to determine the partition id for a vertex id on constructors.
* It has been added to assure the same interface as the compresssed_graph, but is not implemented
* It has been added to assure the same interface as the compressed_graph, but is not implemented
* at this time.
*
* @tparam EV The edge value type. If "void" is used no user value is stored on the edge and
Expand Down Expand Up @@ -1283,10 +1283,10 @@ class dynamic_graph_base {
friend constexpr vertices_type& vertices(dynamic_graph_base& g) { return g.vertices_; }
friend constexpr const vertices_type& vertices(const dynamic_graph_base& g) { return g.vertices_; }

friend auto num_edges(const dynamic_graph_base& g) { return g.edge_count_; }
friend bool has_edge(const dynamic_graph_base& g) { return g.edge_count_ > 0; }
friend constexpr auto num_edges(const dynamic_graph_base& g) { return g.edge_count_; }
friend constexpr bool has_edge(const dynamic_graph_base& g) { return g.edge_count_ > 0; }

friend vertex_id_type vertex_id(const dynamic_graph_base& g, typename vertices_type::const_iterator ui) {
friend constexpr vertex_id_type vertex_id(const dynamic_graph_base& g, typename vertices_type::const_iterator ui) {
return static_cast<vertex_id_type>(ui - g.vertices_.begin());
}

Expand All @@ -1308,7 +1308,7 @@ class dynamic_graph_base {

friend constexpr auto num_vertices(const dynamic_graph_base& g, partition_id_type pid) {
assert(static_cast<size_t>(pid) < g.partition_.size() - 1);
g.partition_[pid + 1] - g.partition_[pid];
return g.partition_[pid + 1] - g.partition_[pid];
}

friend constexpr auto vertices(const dynamic_graph_base& g, partition_id_type pid) {
Expand Down Expand Up @@ -1340,7 +1340,7 @@ class dynamic_graph_base {
* used as a key to find a vertex in the vertices container.
*
* The partition function is intended to determine the partition id for a vertex id on constructors.
* It has been added to assure the same interface as the compresssed_graph, but is not implemented
* It has been added to assure the same interface as the compressed_graph, but is not implemented
* at this time.
*
* @tparam EV @showinitializer =void The edge value type. If "void" is used no user value is stored on the edge
Expand Down Expand Up @@ -1521,14 +1521,14 @@ class dynamic_graph : public dynamic_graph_base<EV, VV, GV, VId, Sourced, Traits
*/
template <class ERng, class EProj, class VRng, forward_range PartRng, class VProj = identity>
requires convertible_to<range_value_t<PartRng>, VId>
dynamic_graph(const ERng& erng,
dynamic_graph(GV&& gv,
const ERng& erng,
const VRng& vrng,
EProj eproj,
VProj vproj,
GV&& gv,
const PartRng& partition_start_ids = std::vector<VId>(),
allocator_type alloc = allocator_type())
: base_type(erng, vrng, eproj, vproj, partition_start_ids, alloc), value_(move(gv)) {}
: base_type(erng, vrng, eproj, vproj, partition_start_ids, alloc), value_(std::move(gv)) {}


// max_vertex_id, erng, eproj, alloc
Expand All @@ -1539,7 +1539,7 @@ class dynamic_graph : public dynamic_graph_base<EV, VV, GV, VId, Sourced, Traits
* @brief Construct the graph given the maximum vertex id and edge data range.
*
* The vertices container is pre-extended to accomodate the number of vertices referenced by edges and avoids
* the need to scan the edges to determine the maximum vertex id.
* the need to scan the edges to determine the maximum vertex id.
*
* The graph value is default-constructed.
*
Expand Down Expand Up @@ -1752,7 +1752,7 @@ class dynamic_graph : public dynamic_graph_base<EV, VV, GV, VId, Sourced, Traits
* See the dynamic_graph description for more information about this class.
*
* The partition function is intended to determine the partition id for a vertex id on constructors.
* It has been added to assure the same interface as the compresssed_graph, but is not implemented
* It has been added to assure the same interface as the compressed_graph, but is not implemented
* at this time.
*
* @tparam EV @showinitializer =void The edge value type. If "void" is used no user value is stored on the edge
Expand Down
8 changes: 4 additions & 4 deletions include/graph/detail/graph_cpo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ concept _el_index_tuple_edge = _el_tuple_edge<_E> && //
integral<tuple_element_t<0, _E>>;

//
// Suport the use of edge_info for edgelist edge definitions
// Support the use of edge_info for edgelist edge definitions
// (Only types and values needed from edge_info are used and there is no
// explicit use of edge_info. This is deemed more flexible and no
// functionality is compromised for it.)
Expand Down Expand Up @@ -1319,9 +1319,9 @@ namespace _Source {
* Complexity: O(1)
*
* Default implementation: *(begin(vertices(g)) + source_id(g, uv)),
# if @source_id(g,uv) is defined for G and random_access_range<vertex_range_t<G>>
* if @source_id(g,uv) is defined for G and random_access_range<vertex_range_t<G>>
*
* Not all graphs support a source on an edge. The existance of @c source_id(g,uv) function
* Not all graphs support a source on an edge. The existence of @c source_id(g,uv) function
* for a graph type G determines if it is considered a "sourced" edge or not. If it is,
* @c source(g,uv) will also exist.
*
Expand Down Expand Up @@ -2561,7 +2561,7 @@ namespace _HasEdge {
return has_edge(__g); // intentional ADL
} else if constexpr (_Strat_id == _St_ref::_Auto_eval) {
for (auto&& u : vertices(__g))
if (empty(edges(__g, u)))
if (!empty(edges(__g, u)))
return true;
return false;
} else {
Expand Down
11 changes: 10 additions & 1 deletion include/graph/detail/graph_using.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include <tuple>
#include <functional>
#include <optional>
#include <type_traits>
#include <iterator>
#include <algorithm>
#include <memory>

namespace graph {
// Containers are not included to avoid potential conflicts: vector, list, string, etc.
Expand All @@ -19,6 +23,8 @@ using std::forward_iterator_tag;
using std::declval;
using std::allocator;
using std::allocator_traits;
using std::unique_ptr;
using std::shared_ptr;

using std::iter_difference_t;
using std::iter_value_t;
Expand All @@ -40,7 +46,6 @@ using std::is_arithmetic_v;
using std::is_convertible_v;
using std::is_same_v;
using std::is_invocable_v;
using std::is_arithmetic_v;
using std::is_void_v;
using std::is_lvalue_reference_v;
using std::is_signed_v;
Expand All @@ -52,6 +57,7 @@ using std::remove_reference_t;
using std::remove_pointer_t;
using std::remove_cvref_t;
using std::invoke_result_t;
using std::decay_t;

using std::false_type;
using std::true_type;
Expand All @@ -62,6 +68,7 @@ using std::convertible_to;
using std::integral;
using std::invocable;
using std::regular_invocable;
using std::predicate;

// range concepts
using std::ranges::range;
Expand Down Expand Up @@ -110,4 +117,6 @@ using std::ranges::empty;
using std::tuple_cat;
using std::max;
using std::min;
using std::swap;
using std::is_sorted;
} // namespace graph
Loading
Loading