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
7 changes: 4 additions & 3 deletions include/graaflib/algorithm/shortest_path/a_star.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ std::optional<graph_path<WEIGHT_T>> a_star_search(

// A* search does not work on negative edge weights.
if (edge_weight < 0) {
throw std::invalid_argument{fmt::format(
"Negative edge weight [{}] between vertices [{}] -> [{}].",
edge_weight, current.id, neighbor)};
throw std::invalid_argument{
"Negative edge weight [" + std::to_string(edge_weight) +
"] between vertices [" + std::to_string(current.id) + "] -> [" +
std::to_string(neighbor) + "]."};
}

// tentative_g_score is the distance from start to the neighbor through
Expand Down
2 changes: 1 addition & 1 deletion test/graaflib/algorithm/shortest_path/a_star_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ TYPED_TEST(AStarShortestPathSignedTypesTest, AStarNegativeWeight) {
ex.what(),
fmt::format(
"Negative edge weight [{}] between vertices [{}] -> [{}].",
-1, vertex_id_1, vertex_id_2));
std::to_string(weight_t{-1}), vertex_id_1, vertex_id_2));
throw;
}
},
Expand Down
Loading