Skip to content

Commit c4eb279

Browse files
authored
Update kruskals_minimum_spanning_tree.cpp
unit-32 test case added
1 parent 5b88f0e commit c4eb279

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

greedy_algorithms/kruskals_minimum_spanning_tree.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <array> /// for array
2222
#include <iostream> /// for IO operations
2323
#include <limits> /// for numeric limits
24+
#include <cstdint> /// for uint32_t
2425

2526
/**
2627
* @namespace
@@ -60,10 +61,12 @@ void findMinimumEdge(const T &infinity,
6061
* define a large constant value for int
6162
* define a large constant value for float
6263
* define a large constant value for double
64+
* define infinity for uint32_t
6365
*/
6466
constexpr int INFINITY_INT = std::numeric_limits<int>::max();
6567
constexpr float INFINITY_FLOAT = std::numeric_limits<float>::max();
6668
constexpr double INFINITY_DOUBLE = std::numeric_limits<double>::max();
69+
constexpr uint32_t INFINITY_UINT32 = UINT32_MAX;
6770

6871
/**
6972
* @brief Self-test implementations
@@ -161,6 +164,15 @@ static void test() {
161164
5, 5, 5, 5, 0};
162165
greedy_algorithms::findMinimumEdge(INFINITY_INT, graph10);
163166

167+
// Test Case with uint32_t values
168+
std::cout << "\nTest Case 11 :\n";
169+
std::array<std::array<uint32_t, 4>, 4> graph_uint32{
170+
0, 5, INFINITY_UINT32, 9,
171+
5, 0, 2, INFINITY_UINT32,
172+
INFINITY_UINT32, 2, 0, 6,
173+
9, INFINITY_UINT32, 6, 0};
174+
greedy_algorithms::findMinimumEdge(INFINITY_UINT32, graph_uint32);
175+
164176
std::cout << "\nAll tests have successfully passed!\n";
165177
}
166178

0 commit comments

Comments
 (0)