Skip to content

Commit 2c68b68

Browse files
authored
fix: add missing namespace in Dijkstra
1 parent 17c374d commit 2c68b68

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

greedy_algorithms/dijkstra.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
*/
2626
namespace greedy_algorithms {
2727
/**
28-
* @brief
28+
* @namespace
29+
* @brief Functions for the [Dijkstra](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm) algorithm implementation
2930
*/
31+
namespace dijkstra {
3032
/**
3133
* @brief Wrapper class for storing a graph
3234
*/
@@ -112,7 +114,7 @@ void print(std::vector<int> dist, int V) {
112114
}
113115

114116
/**
115-
* @brief The main function that finds the shortest path from given source
117+
* @brief The main function that finds the shortest path from a given source
116118
* to all other vertices using Dijkstra's Algorithm.
117119
* @note This doesn't work on negative weights.
118120
* @param graph the graph to be processed
@@ -124,7 +126,7 @@ void dijkstra(Graph graph, int src) {
124126
std::vector<int> mdist{}; // Stores updated distances to the vertex
125127
std::vector<bool> vset{}; // `vset[i]` is true if the vertex `i` is included in the shortest path tree
126128

127-
// Initialize `mdist and `vset`. Set distance of source as zero
129+
// Initialize `mdist and `vset`. Set the distance of the source as zero
128130
for (int i = 0; i < V; i++) {
129131
mdist[i] = INT_MAX;
130132
vset[i] = false;
@@ -148,14 +150,15 @@ void dijkstra(Graph graph, int src) {
148150

149151
print(mdist, V);
150152
}
153+
} // namespace dijkstra
151154
} // namespace greedy_algorithms
152155

153156
/**
154157
* @brief Self-test implementations
155158
* @returns void
156159
*/
157160
static void tests() {
158-
greedy_algorithms::Graph graph(8);
161+
greedy_algorithms::dijkstra::Graph graph(8);
159162

160163
// 1st test.
161164
graph.add_edge(6, 2, 4);

0 commit comments

Comments
 (0)