#include "iostream.h"
#include "malloc.h"
#include "conio.h"
#define MAX 100
#define MAX_INT 10000
int Shortest(int edge[][MAX],int v,int e,int st,int ed){
int weight[MAX],s[MAX];/*weight数组是记录起点到其他点的最短距离,s数组是标记集合*/
int i,j,k,mindist,u;
for(i=0;i<MAX;i++)
s[i]=0;
for(i=1;i<=v;i++){
if(edge[st][i]!=-1){
weight[i]=edge[st][i];
}
else
{
weight[i]=-1;
}
}/*赋值weight所有与起点邻接的点距离,不邻接的赋值为-1*/
s[st]=1;
weight[st]=0;/*起始点初始化*/
for(k=1;k<=v;k++){
mindist=MAX_INT;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余2页未读,立即下载