Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
Loading...
Searching...
No Matches
greedy_algorithms Namespace Reference

for std::vector More...

Functions

template<typename T >
void findMinimumEdge (const int &infinity, const std::array< std::array< T, 6 >, 6 > &graph)
 Finds the minimum edge of the given graph.
 

Detailed Description

for std::vector

for assert for INT_MAX for IO operations

Greedy Algorithms

Function Documentation

◆ findMinimumEdge()

template<typename T >
void greedy_algorithms::findMinimumEdge ( const int & infinity,
const std::array< std::array< T, 6 >, 6 > & graph )

Finds the minimum edge of the given graph.

Parameters
infinityDefines the infinity of the graph
graphThe graph that will be used to find the edge
Returns
void
37 {
38 for (int i = 0; i < graph.size(); i++) {
39 int min = infinity;
40 int minIndex = 0;
41 for (int j = 0; j < graph.size(); j++) {
42 if (graph[i][j] != 0 && graph[i][j] < min) {
43 min = graph[i][j];
44 minIndex = j;
45 }
46 }
47 std::cout << i << " - " << minIndex << "\t" << graph[i][minIndex]
48 << "\n";
49 }
50}
Graph Algorithms.