/* Prim.c Copyright (c) 2002, 2006 by ctu_85 All Rights Reserved. */ /* The impact of the situation of articulation point exists can be omitted in Prim algorithm but not in Kruskal algorithm */ #include "stdio.h" #define maxver 10 #define maxright 100 int main() { int G[maxver][maxver],in[maxver]={0},path[maxver][2]; int i,j,k,min=maxright; int v1,v2,num,temp,status=0,start=0; restart: printf("Please enter the number of vertex(s) in the graph:/n"); scanf("%d",&num); if(num>maxver||num<0) { printf("Error!Please reinput!/n"); goto restart; } for(j=0;j
=maxright||temp<-1) { printf("Invalid input!/n"); goto re; } if(temp==-1) temp=maxright; G[j][k]=G[k][j]=temp; } } for(j=0;j
num); in[start-1]=1; for(i=0;i
Prim算法。
最新推荐文章于 2024-09-04 21:39:45 发布