From 7bd1b3bd3a12a633ce67f179c51f4caf47233368 Mon Sep 17 00:00:00 2001 From: Nafis Ahmad <42237165+nafisahmad@users.noreply.github.com> Date: Fri, 16 Oct 2020 21:30:45 +0530 Subject: [PATCH] Prims Algorithm Prims Algorithm in C --- Prims Algorithm | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Prims Algorithm diff --git a/Prims Algorithm b/Prims Algorithm new file mode 100644 index 000000000..0b7b7eb09 --- /dev/null +++ b/Prims Algorithm @@ -0,0 +1,42 @@ +#include +#include +int a,b,u,v,n,i,j,ne=1,st,et; +int visited[10]={0},min,mincost=0,cost[10][10]; +void main() +{ + printf("Enter the number of nodes:"); + scanf("%d",&n); + printf("Enter the adjacency matrix: "); + for(i=1;i<=n;i++) + for(j=1;j<=n;j++) + { + scanf("%d",&cost[i][j]); + if(cost[i][j]==0) + cost[i][j]=999; + } + st=clock(); + visited[1]=1; + printf("n"); + while(ne