TheAlgorithms-C-Plus-Plus/greedy_algorithms/kruskals_minimum_spanning_tree.cpp
Kaustubh Damania 67e26cfbae
feat: Add ncr mod p code (#1325)
* feat: Add ncr mod p code (#1323)

* Update math/ncr_modulo_p.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Added all functions inside a class + added more asserts

* updating DIRECTORY.md

* clang-format and clang-tidy fixes for f6df24a5

* Replace int64_t to uint64_t + add namespace + detailed documentation

* clang-format and clang-tidy fixes for e09a0579

* Add extra namespace + add const& in function arguments

* clang-format and clang-tidy fixes for 8111f881

* Update ncr_modulo_p.cpp

* clang-format and clang-tidy fixes for 2ad2f721

* Update math/ncr_modulo_p.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update math/ncr_modulo_p.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* Update math/ncr_modulo_p.cpp

Co-authored-by: David Leal <halfpacho@gmail.com>

* clang-format and clang-tidy fixes for 5b69ba5c

* updating DIRECTORY.md

* clang-format and clang-tidy fixes for a8401d4b

Co-authored-by: David Leal <halfpacho@gmail.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-11-22 23:05:01 +05:30

32 lines
1.0 KiB
C++

#include <array>
#include <iostream>
void findMinimumEdge(int INFINITY, std::array<std::array<int, 6>, 6> graph) {
for (int i = 0; i < graph.size(); i++) {
int min = INFINITY;
int minIndex = 0;
for (int j = 0; j < graph.size(); j++) {
if (graph[i][j] != 0 && graph[i][j] < min) {
min = graph[i][j];
minIndex = j;
}
}
std::cout << i << " - " << minIndex << "\t" << graph[i][minIndex]
<< std::endl;
}
}
int main() {
constexpr int INFINITY = 99999;
std::array<std::array<int, 6>, 6> graph{
0, 4, 1, 4, INFINITY, INFINITY,
4, 0, 3, 8, 3, INFINITY,
1, 3, 0, INFINITY, 1, INFINITY,
4, 8, INFINITY, 0, 5, 7,
INFINITY, 3, 1, 5, 0, INFINITY,
INFINITY, INFINITY, INFINITY, 7, INFINITY, 0};
findMinimumEdge(INFINITY, graph);
return 0;
}