用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/06/19 04:09:45
![用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,](/uploads/image/z/10134160-16-0.jpg?t=%E7%94%A8prim%E7%AE%97%E6%B3%95%E6%B1%82%E6%9C%80%E5%B0%8F%E7%94%9F%E6%88%90%E6%A0%91%3Ac%E8%AF%AD%E8%A8%80%23include%23include%23define+VN+4%23define+Max+100typedef+struct%7Bchar+vexs%5BVN%5D%3Bdouble+arcs%5BVN%5D%5BVN%5D%3B%7DGraphMatrix%3Btypedef+struct%7Bint+start_vex%2Cstop_vex%3Bdouble+weight%3B%7DEdge%3Bvoid+prim%28GraphMatrix+graph%2CEdge+mst%5B%5D%29%7Bint+i%2Cj%2C)
用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