您的位置:首页 > 其它

Dijkstra求最短路径

2010-05-05 20:06 357 查看
先看介绍

/content/5273273.html

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX_NAME 10
#define MAX_VERTEX_NUM 26
typedef char VertexType[MAX_NAME];
typedef int AdjMatrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM];//邻接距阵
struct MGraph//定义网
{
VertexType vexs[MAX_VERTEX_NUM];
AdjMatrix arcs;
int vexnum,arcnum;
};
int LocateVex(MGraph G,VertexType u)//定位
{
int i;
for(i=0;i<G.vexnum;++i)if(strcmp(u,G.vexs[i])==0)return i;
return -1;
}
void CreateDN(MGraph &G)//建网
{
int i,j,k,w;
VertexType va,vb;
printf("请输入有向网G的顶点数和弧数(以空格作为间隔)/n");
scanf("%d %d",&G.vexnum,&G.arcnum);
printf("请输入%d个顶点的值(


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: