• 大小: 4KB
    文件类型: .cpp
    金币: 1
    下载: 0 次
    发布日期: 2021-05-21
  • 语言: C/C++
  • 标签: 源代码  

资源简介

这个是我们做课程设计时做的,感觉是自己做的比较好的一次,所以上传来给大家分享一下,有点献丑了

资源截图

代码片段和文件信息

#include
#include
#include

#define MAX_VERTEX_NUM  100        /*最大顶点数为100*/
typedef int VertexType;
/*表结点*/
typedef struct ArcNode
{
int adjvex; 
int lon;
struct ArcNode  * nextarc;     
}ArcNode;
/*头结点*/
typedef struct VNode
{             
VertexType data; 
ArcNode  * firstarc;          
}VNodeAdjList[MAX_VERTEX_NUM];
typedef struct
{
AdjList vertices;              
int vexnumarcnum;              
}ALGraph;
//地名
typedef struct Place
{             
char name[20];          
}PlacePL[20];


int daohang(ALGraph Gint nint qint Lj[20]int M)//导航函数(图,起点,终点,路径数组,范围)
{
ArcNode *s*d*e;
int l=0x;
s=G.vertices[n-1].firstarc;
if(!s) //死路,返回无限远
l=1000;
else
{
Lj[0]=G.vertices[n-1].data;
while(s) //孤立起始点
{
x=s->adjvex;
if(x==q)
{
Lj[1]=q;
l=s->lon;
return l;
}
d=G.vertices[x-1].firstarc;
if(d->adjvex==n)
G.vertices[x-1].firstarc=d->nextarc;
else
{

while(d->nextarc)
{
if(d->nextarc->adjvex==n)
{
d->nextarc=d->nextarc->nextarc;
break;
}
d=d->nextarc;
}
}
s=s->nextarc;
}
int L[20]={0}i=0z;
e=G.vertices[n-1].firstarc;
while(e)
{
if(Mlon)
e=e->nextarc;
else
break;
}
if(e)
{
l=daohang(Ge->adjvexqLM-e->lon)+e->lon;
for(int j=0;j<20;j++)
Lj[j+1]=L[j];
e=e->nextarc;
}
while(e)
{
if(M>=e->lon)
{
if((z=daohang(Ge->adjvexqLM-e->lon)+e->lon) {
l=z;
for(int j=0;j<20;j++)
Lj[j+1]=L[j];
}
}
e=e->nextarc;
}


}
if(l==0)
l=1000;
return l;
}



void get(ALGraph &Gint BC[400])//获得地图(无向图)
{
ArcNode *s;
FILE *fp;
if((fp=fopen(“file““rb“))==NULL)
{
printf(“can not open file\n“);
return ;
}


fread(BC

评论

共有 条评论