-
-
Notifications
You must be signed in to change notification settings - Fork 110
/
4_prims.cpp
43 lines (36 loc) · 841 Bytes
/
4_prims.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <bits/stdc++.h>
#define I INT_MAX
#define V 8
using namespace std;
void prime_mst(int cost[][V], int n)
{
int u, v, i, j, k, min = I;
vector<int> near;
for (i = 1; i <= n; i++)
{
for (j = i; j <= n; j++)
{
if (cost[i][j] < min)
{
u = i;
v = j;
}
}
}
}
int main()
{
int cost[V][V]{
{I, I, I, I, I, I, I, I},
{I, I, 25, I, I, I, 5, I},
{I, 25, I, 12, I, I, I, 10},
{I, I, 12, I, 8, I, I, I},
{I, I, I, 8, I, 16, I, 14},
{I, I, I, I, 16, I, 20, 18},
{I, 5, I, I, I, 20, I, I},
{I, I, 10, I, 14, 18, I, I},
};
int n = sizeof(cost[0]) / sizeof(cost[0][0]) - 1;
prime_mst(cost, n);
return 0;
}