用prim算法求最小生成树:c语言#include#include#define VN 4#define Max 100typedef struct{char vexs[VN];double arcs[VN][VN];}GraphMatrix;typedef struct{int start_vex,stop_vex;double weight;}Edge;void prim(GraphMatrix graph,Edge mst[]){int i,j,

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/17 01:55:06
用prim算法求最小生成树:c语言#include#include#define VN 4#define Max 100typedef struct{char vexs[VN];double arcs[VN][VN];}GraphMatrix;typedef struct{int start_vex,stop_vex;double weight;}Edge;void prim(GraphMatrix graph,Edge mst[]){int i,j,

用prim算法求最小生成树:c语言#include#include#define VN 4#define Max 100typedef struct{char vexs[VN];double arcs[VN][VN];}GraphMatrix;typedef struct{int start_vex,stop_vex;double weight;}Edge;void prim(GraphMatrix graph,Edge mst[]){int i,j,
用prim算法求最小生成树:c语言
#include
#include
#define VN 4
#define Max 100
typedef struct{
char vexs[VN];
double arcs[VN][VN];
}GraphMatrix;
typedef struct{
int start_vex,stop_vex;
double weight;
}Edge;
void prim(GraphMatrix graph,Edge mst[])
{
int i,j,min,vx,vy;
double weight;
Edge edge;
for(i=0;i

用prim算法求最小生成树:c语言#include#include#define VN 4#define Max 100typedef struct{char vexs[VN];double arcs[VN][VN];}GraphMatrix;typedef struct{int start_vex,stop_vex;double weight;}Edge;void prim(GraphMatrix graph,Edge mst[]){int i,j,
把main函数改成:
main(){
GraphMatrix graph = {
"abcd",
{{7,8,Max,15},{12,100,6,20},{Max,100,4,13},{Max,4,8,10}},
};
Edge mst[Max];
int i,j;
prim(graph,mst);
for(j=0;j