Prim算法。

/* 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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值