mohini ghosh
mohini ghosh

Reputation: 1

Explain what is the logic behind this code

#define MAX 100

int n, x = 1;

int min, mincost = 0, graph[MAX][MAX], parent[MAX];

int i, j, k, a, b, u, v;

int set_union(int i, int j)

{

if (i != j)

{

    parent[j] = i;

    return 1;

}

return 0;

}

int find_node(int i)

{

while (parent[i])

    i = parent[i];

return i;

}

void takeInput(){

printf("\nEnter the no. of vertices:");

scanf("%d", &n);

printf("\nEnter the cost adjacency matrix:\n");

for (i = 1; i <= n; i++)

{

    for (j = 1; j <= n; j++)

    {

        scanf("%d", &graph[i][j]);

        if (graph[i][j] == 0)

            graph[i][j] = 999;

    }

}

Upvotes: 0

Views: 15

Answers (0)

Related Questions