图最短路径问题
#include<iostream>#include<stdio.h>
#include<string>
using namespace std;
const int MaxWeight=10000;
const int MaxGraphSize=256; //定义的顶点最多值
void Menu(void);
struct scenery
{
char name[20];
int num;
char Introduction[200];
};
class Graph_Matrix
{
private:
int edge[MaxGraphSize][MaxGraphSize];
int graphsize; //图中顶点个数。
scenery sce[20]; //景点
public:
Graph_Matrix()
{
for(int i=0;i<10;i++)
{
sce[i].num=i;
}
strcpy(sce[0].name,"2");
strcpy(sce[0].Introduction,"3");
strcpy(sce[1].name,"4");
strcpy(sce[1].Introduction,"5");
strcpy(sce[2].name,"2");
strcpy(sce[2].Introduction,"4");
strcpy(sce[3].name,"5");
strcpy(sce[3].Introduction,"3");
strcpy(sce[4].name,"3");
strcpy(sce[4].Introduction,"3");
strcpy(sce[5].name,"3");
strcpy(sce[5].Introduction,"3");
strcpy(sce[6].name,"3");
strcpy(sce[6].Introduction,"3");
strcpy(sce[7].name,"3");
strcpy(sce[7].Introduction,"3");
strcpy(sce[8].name,"3");
strcpy(sce[8].Introduction,"3
strcpy(sce[9].name,"3");
strcpy(sce[9].Introduction,"3");
graphsize=10;
for(int m=0;m<graphsize;m++)
for(int n=0;n<graphsize;n++)
edge[m][n]=MaxWeight;
edge[0][1]=100;
edge[0][2]=200;
edge[0][6]=400;
edge[1][7]=300;
edge[2][3]=120;
edge[3][6]=220;
edge[3][4]=100;
edge[4][5]=300;
edge[4][9]=250;
edge[5][9]=350;
edge[6][7]=60;
edge[6][9]=200;
edge[7][8]=50;
edge[8][9]=20;
for(int m1=0;m1<graphsize;m1++)
for(int n1=0;n1<graphsize;n1++)
edge[m1][n1]=edge[n1][m1];
}
void ShortestPath(void)
printf("请输入出发点和目的地的编号:");
//大家帮我补充下这个函数吧。谢谢了。输入出发点 和目的点 的编号 。输出最短路径,eg:a->b->c->d->e;
类我定义好了。就是最短路径的函数不会。