Skip to content

Commit

Permalink
Fixed minor bug with graph class
Browse files Browse the repository at this point in the history
  • Loading branch information
spirosmaggioros committed Aug 3, 2024
1 parent 79821e3 commit efe2c7f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/classes/graph/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ template <typename T> std::vector<T> weighted_graph<T>::bfs(T start) {
T current = q.front();
path.push_back(current);
q.pop();
for (std::pair<T, int64_t> &x : adj[current]) {
for (std::pair<T, double> &x : adj[current]) {
if (visited.find(x.first) == visited.end()) {
q.push(x.first);
visited[x.first] = true;
Expand Down
1 change: 1 addition & 0 deletions tests/graph/weighted_graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ TEST_CASE("Testing clear function for weighted graph class") {
g.add_edge(1, 2, 5);
g.add_edge(2, 3, 6);
g.add_edge(3, 4, 11);
g.clear();
std::vector<int> bfs_path = g.bfs(0);
REQUIRE(bfs_path.size() == 0);
}

0 comments on commit efe2c7f

Please sign in to comment.