下载此文档

导游系统-------图的最短路径算法.doc


文档分类:IT计算机 | 页数:约7页 举报非法文档有奖
1/7
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/7 下载此文档
文档列表 文档介绍
导游系统-------图的最短路径算法导游系统算法核心部分//图的建立//和从莫一顶点到其他所有顶点的最段路径运行时输入  :边的个数:顶点的内容:----------字符串形式每条边的两个顶点和权值#include<iostream>#include<>#include<fstream>#include<>usingnamespacestd;constintMAX=30;typedefstringVT;typedefintET;constfloatBIGEST=;      classCGraph{  public:      intShortPath(intstart,boolPath[][MAX]);      voidCreateGraph();      boolIsEmpty();      voidClearGraph();      voidPrintGraph();      intGetVNum();      CGraph();      ~CGraph();    protected:        intVNum;//顶点的个数        intENum;//边数        ET  Edge[MAX*2];//边的集合        VT  Vertex[MAX];//顶点的集合        intMatrix[MAX][MAX];//顶点间的关系        };  //类的定义voidCGraph::CreateGraph(){//创建图      ifstreamInFile;    charFileName[50];    cout<<"EnterInputFileName:";    cin>>FileName;    cout<<endl;    (FileName);    if(!InFile)    {        cerr<<"canontopenfile";        return;    }    InFile>>VNum>>ENum;    cout<<"theVnumis"<<VNum<<"theEnumis"<<ENum<<endl;        for(intindex=0;index<VNum;index++)    {        InFile>>Vertex[index];        cout<<index<<"的顶点的值是"<<Vertex[index]<<endl;            }    //初始化句阵    for(inti=0;i<MAX;i++)        for(intj=0;j<MAX;j++)          Matrix[j]=0;    for(intindex=0;index<ENum;index++)    {  inta,b,c;        InFile>>a>>b>>c;        Matrix[a]=c;        Matrix[a]=c;        //显示两个定点及其权值        cout<<a<<"  "<<b<<"  "<<c<<endl;  

导游系统-------图的最短路径算法 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数7
  • 收藏数0 收藏
  • 顶次数0
  • 上传人小枷
  • 文件大小22 KB
  • 时间2019-03-25