Practical-10: Implementation of Prim's Algorithm:-: Ada-Lab Poradhiya Chirag I en - No:180280107082
Practical-10: Implementation of Prim's Algorithm:-: Ada-Lab Poradhiya Chirag I en - No:180280107082
En.no:180280107082
Input code:
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#define V 5
return min_index;
int parent[V];
int key[V];
bool mstSet[V];
Computer Engineering
L D College of Engineering Page 1
ADA-LAB Poradhiya Chirag I
En.no:180280107082
key[i] = INT_MAX, mstSet[i] = false;
key[0] = 0;
parent[0] = -1;
mstSet[u] = true;
printf("Edge \tWeight\n");
void main()
int graph[V][V] = { { 0, 3, 1, 7, 4 },
{ 3, 0, 4, 8, 5 },
{ 1, 4, 0, 6, 7 },
{ 7, 8, 6, 0, 9 },
Computer Engineering
L D College of Engineering Page 2
ADA-LAB Poradhiya Chirag I
En.no:180280107082
{ 4, 5, 7, 9, 0 } };
primMST(graph);
Output snapshot:
*****
Computer Engineering
L D College of Engineering Page 3
ADA-LAB Poradhiya Chirag I
En.no:180280107082
Computer Engineering
L D College of Engineering Page 4
ADA-LAB Poradhiya Chirag I
En.no:180280107082
Computer Department
L D College of Engineering Page 5