Self-test implementations.
define a large value for int define a large value for float define a large value for double define a large value for uint32_t
64 {
71 constexpr int INFINITY_INT = std::numeric_limits<int>::max();
72 constexpr float INFINITY_FLOAT = std::numeric_limits<float>::max();
73 constexpr double INFINITY_DOUBLE = std::numeric_limits<double>::max();
74 constexpr uint32_t INFINITY_UINT32 = UINT32_MAX;
75
76
77 std::cout << "\nTest Case 1 :\n";
78 std::array<std::array<int, 6>, 6> graph1{
79 0, 4, 1, 4, INFINITY_INT, INFINITY_INT,
80 4, 0, 3, 8, 3, INFINITY_INT,
81 1, 3, 0, INFINITY_INT, 1, INFINITY_INT,
82 4, 8, INFINITY_INT, 0, 5, 7,
83 INFINITY_INT, 3, 1, 5, 0, INFINITY_INT,
84 INFINITY_INT, INFINITY_INT, INFINITY_INT, 7, INFINITY_INT, 0};
86
87
88 std::cout << "\nTest Case 2 :\n";
89 std::array<std::array<float, 3>, 3> graph2{
90 0.0f, 2.5f, INFINITY_FLOAT,
91 2.5f, 0.0f, 3.2f,
92 INFINITY_FLOAT, 3.2f, 0.0f};
94
95
96 std::cout << "\nTest Case 3 :\n";
97 std::array<std::array<double, 5>, 5> graph3{
98 0.0, 10.5, INFINITY_DOUBLE, 6.7, 3.3,
99 10.5, 0.0, 8.1, 15.4, INFINITY_DOUBLE,
100 INFINITY_DOUBLE, 8.1, 0.0, INFINITY_DOUBLE, 7.8,
101 6.7, 15.4, INFINITY_DOUBLE, 0.0, 9.9,
102 3.3, INFINITY_DOUBLE, 7.8, 9.9, 0.0};
104
105
106 std::cout << "\nTest Case 4 :\n";
107 std::array<std::array<int, 3>, 3> graph_neg{
108 0, -2, 4,
109 -2, 0, 3,
110 4, 3, 0};
112
113
114 std::cout << "\nTest Case 5 :\n";
115 std::array<std::array<int, 3>, 3> graph_self_loop{
116 2, 1, INFINITY_INT,
117 INFINITY_INT, 0, 4,
118 INFINITY_INT, 4, 0};
120
121
122 std::cout << "\nTest Case 6 :\n";
123 std::array<std::array<int, 4>, 4> no_edges{
124 0, INFINITY_INT, INFINITY_INT, INFINITY_INT,
125 INFINITY_INT, 0, INFINITY_INT, INFINITY_INT,
126 INFINITY_INT, INFINITY_INT, 0, INFINITY_INT,
127 INFINITY_INT, INFINITY_INT, INFINITY_INT, 0};
129
130
131 std::cout << "\nTest Case 7:\n";
132 std::array<std::array<int, 4>, 4> partial_graph{
133 0, 2, INFINITY_INT, 6,
134 2, 0, 3, INFINITY_INT,
135 INFINITY_INT, 3, 0, 4,
136 6, INFINITY_INT, 4, 0};
138
139
140
141 std::cout << "\nTest Case 8:\n";
142 std::array<std::array<int, 4>, 4> directed_graph{
143 0, 3, 7, INFINITY_INT,
144 INFINITY_INT, 0, 2, 5,
145 INFINITY_INT, INFINITY_INT, 0, 1,
146 INFINITY_INT, INFINITY_INT, INFINITY_INT, 0};
148
149
150 std::cout << "\nTest Case 9:\n";
151 std::array<std::array<int, 4>, 3> graph9{
152 0, 5, 5, 5,
153 5, 0, 5, 5,
154 5, 5, 5, 5};
156
157
158 std::cout << "\nTest Case 10:\n";
159 std::array<std::array<int, 5>, 5> graph10{
160 0, 5, 5, 5, 5,
161 5, 0, 5, 5, 5,
162 5, 5, 0, 5, 5,
163 5, 5, 5, 0, 5,
164 5, 5, 5, 5, 0};
166
167
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};
175
176 std::cout << "\nAll tests have successfully passed!\n";
177}
void findMinimumEdge(const T &infinity, const std::array< std::array< T, N >, M > &graph)
Finds the minimum edge of the given graph.