Open
Conversation
aobolensk
requested changes
Jan 29, 2025
src/graph/graph.cpp
Outdated
Comment on lines
+94
to
+111
| bool Graph::hasPath(int u, int v) { | ||
| if (vertices.find(u) != vertices.end() && vertices.find(v) != vertices.end()) { | ||
| std::unordered_map <int, bool> visited; | ||
| std::queue<int> queue; | ||
| queue.push(u); | ||
|
|
||
| while (!queue.empty()) { | ||
| int current = queue.front(); | ||
| queue.pop(); | ||
| if (current == v) { return true; } | ||
| visited[current] = true; | ||
|
|
||
| for (const int& neighbor : vertices[current]->getNeighbors()) | ||
| if (!visited[neighbor]) | ||
| queue.push(neighbor); | ||
|
|
||
| } | ||
| return false; |
Member
There was a problem hiding this comment.
Can we reuse the code in hasPath and BFS?
src/graph/graph.cpp
Outdated
Comment on lines
+137
to
+138
| //for (int i : traversal_order) | ||
| // std::cout << i << " "; |
Member
There was a problem hiding this comment.
Please, remove all commented out code in the final version
CMakeLists.txt
Outdated
| @@ -1,15 +1,19 @@ | |||
| cmake_minimum_required(VERSION 3.20) | |||
| cmake_minimum_required(VERSION 3.15) | |||
added 10 commits
February 25, 2025 17:47
aobolensk
requested changes
Mar 30, 2025
src/graph/graph.cpp
Outdated
Comment on lines
+39
to
+46
| void Graph::getVertex() const { | ||
| if (!this->empty()) { | ||
| for (const auto& vertice : vertices_) { | ||
| std::cout << vertice.first << " "; | ||
| } | ||
| std::cout << '\n'; | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
It seems this function does not give a vertex, it only prints some messages
include/graph/graph.h
Outdated
Comment on lines
+33
to
+34
| int vertexCount() const; | ||
| int edgeCount() const; |
Member
There was a problem hiding this comment.
I think it makes sense to name them as "get"
|
|
||
| #include "graph/graph.h" | ||
| #include "gtest/gtest.h" | ||
|
|
Member
There was a problem hiding this comment.
As for ASSERT_NO_THROW:
It seems you're generally not using exceptions. I think it is better to check some data about the graph in the assertion part. For example, if you have added one vertex, you can check that amount of vertices in the graph is 1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.