File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 25
25
*/
26
26
namespace greedy_algorithms {
27
27
/* *
28
- * @brief
28
+ * @namespace
29
+ * @brief Functions for the [Dijkstra](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm) algorithm implementation
29
30
*/
31
+ namespace dijkstra {
30
32
/* *
31
33
* @brief Wrapper class for storing a graph
32
34
*/
@@ -112,7 +114,7 @@ void print(std::vector<int> dist, int V) {
112
114
}
113
115
114
116
/* *
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
116
118
* to all other vertices using Dijkstra's Algorithm.
117
119
* @note This doesn't work on negative weights.
118
120
* @param graph the graph to be processed
@@ -124,7 +126,7 @@ void dijkstra(Graph graph, int src) {
124
126
std::vector<int > mdist{}; // Stores updated distances to the vertex
125
127
std::vector<bool > vset{}; // `vset[i]` is true if the vertex `i` is included in the shortest path tree
126
128
127
- // Initialize `mdist and `vset`. Set distance of source as zero
129
+ // Initialize `mdist and `vset`. Set the distance of the source as zero
128
130
for (int i = 0 ; i < V; i++) {
129
131
mdist[i] = INT_MAX;
130
132
vset[i] = false ;
@@ -148,14 +150,15 @@ void dijkstra(Graph graph, int src) {
148
150
149
151
print (mdist, V);
150
152
}
153
+ } // namespace dijkstra
151
154
} // namespace greedy_algorithms
152
155
153
156
/* *
154
157
* @brief Self-test implementations
155
158
* @returns void
156
159
*/
157
160
static void tests () {
158
- greedy_algorithms::Graph graph (8 );
161
+ greedy_algorithms::dijkstra:: Graph graph (8 );
159
162
160
163
// 1st test.
161
164
graph.add_edge (6 , 2 , 4 );
You can’t perform that action at this time.
0 commit comments