|
|
|
|
#include"type.h"
|
|
|
|
|
#include <string.h>
|
|
|
|
|
/***********************
|
|
|
|
|
功能:创建图结构
|
|
|
|
|
输入:给图中的点赋予该点的编号,名称以及简介
|
|
|
|
|
输出:无
|
|
|
|
|
***********************/
|
|
|
|
|
int CreatGrath(MatGrath &G)//进行图的创建
|
|
|
|
|
{
|
|
|
|
|
int i,j;
|
|
|
|
|
G.vexnum=10; //说明图的顶点的数目
|
|
|
|
|
G.arcnum=14; //说明图的边的数目
|
|
|
|
|
for(i=1;i<=G.vexnum;i++)
|
|
|
|
|
{
|
|
|
|
|
G.vexs[i].bianhao=i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strcpy(G.vexs[1].sight,"济南市");
|
|
|
|
|
strcpy(G.vexs[2].sight,"德州市");
|
|
|
|
|
strcpy(G.vexs[3].sight,"淄博市");
|
|
|
|
|
strcpy(G.vexs[4].sight,"潍坊市");
|
|
|
|
|
strcpy(G.vexs[5].sight,"烟台市");
|
|
|
|
|
strcpy(G.vexs[6].sight,"威海市");
|
|
|
|
|
strcpy(G.vexs[7].sight,"青岛市");
|
|
|
|
|
strcpy(G.vexs[8].sight,"日照市");
|
|
|
|
|
strcpy(G.vexs[9].sight,"临沂市");
|
|
|
|
|
strcpy(G.vexs[10].sight,"济宁市");
|
|
|
|
|
strcpy(G.vexs[11].sight,"泰安市");
|
|
|
|
|
strcpy(G.vexs[12].sight,"滨州市");
|
|
|
|
|
strcpy(G.vexs[13].sight,"菏泽市");
|
|
|
|
|
strcpy(G.vexs[14].sight,"即墨市");
|
|
|
|
|
strcpy(G.vexs[15].sight,"胶州市");
|
|
|
|
|
strcpy(G.vexs[16].sight,"胶南市");
|
|
|
|
|
strcpy(G.vexs[17].sight,"诸城市");
|
|
|
|
|
strcpy(G.vexs[18].sight,"高密市");
|
|
|
|
|
strcpy(G.vexs[19].sight,"安丘市");
|
|
|
|
|
strcpy(G.vexs[20].sight,"莒县");
|
|
|
|
|
strcpy(G.vexs[21].sight,"平度市");
|
|
|
|
|
strcpy(G.vexs[22].sight,"莱西市");
|
|
|
|
|
strcpy(G.vexs[23].sight,"莱阳市");
|
|
|
|
|
strcpy(G.vexs[24].sight,"海阳市");
|
|
|
|
|
strcpy(G.vexs[25].sight,"乳山市");
|
|
|
|
|
strcpy(G.vexs[26].sight,"文登市");
|
|
|
|
|
strcpy(G.vexs[27].sight,"荣成市");
|
|
|
|
|
strcpy(G.vexs[28].sight,"牟平区");
|
|
|
|
|
strcpy(G.vexs[29].sight,"蓬莱市");
|
|
|
|
|
strcpy(G.vexs[30].sight,"栖霞市");
|
|
|
|
|
strcpy(G.vexs[31].sight,"莱州市");
|
|
|
|
|
strcpy(G.vexs[32].sight,"招远市");
|
|
|
|
|
strcpy(G.vexs[33].sight,"龙口市");
|
|
|
|
|
strcpy(G.vexs[34].sight,"昌邑市");
|
|
|
|
|
strcpy(G.vexs[35].sight,"昌乐");
|
|
|
|
|
strcpy(G.vexs[36].sight,"孝光市");
|
|
|
|
|
strcpy(G.vexs[37].sight,"青州市");
|
|
|
|
|
strcpy(G.vexs[38].sight,"临朐");
|
|
|
|
|
strcpy(G.vexs[39].sight,"沂水");
|
|
|
|
|
strcpy(G.vexs[40].sight,"广饶");
|
|
|
|
|
strcpy(G.vexs[41].sight,"东营市");
|
|
|
|
|
strcpy(G.vexs[42].sight,"沂源");
|
|
|
|
|
strcpy(G.vexs[43].sight,"恒台");
|
|
|
|
|
strcpy(G.vexs[44].sight,"博兴");
|
|
|
|
|
strcpy(G.vexs[45].sight,"博山");
|
|
|
|
|
strcpy(G.vexs[46].sight,"沂南");
|
|
|
|
|
strcpy(G.vexs[47].sight,"蒙阴");
|
|
|
|
|
strcpy(G.vexs[48].sight,"莱芜市");
|
|
|
|
|
|
|
|
|
|
for(i=0;i<G.vexnum;i++)
|
|
|
|
|
{
|
|
|
|
|
for(j=0;j<G.vexnum;j++)
|
|
|
|
|
{
|
|
|
|
|
G.arc[i][j].length=INF;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
G.arc[7][14].length=G.arc[14][7].length=51;
|
|
|
|
|
G.arc[7][15].length=G.arc[15][7].length=41;
|
|
|
|
|
G.arc[15][16].length=G.arc[16][15].length=47;
|
|
|
|
|
G.arc[15][17].length=G.arc[17][15].length=65;
|
|
|
|
|
G.arc[16][17].length=G.arc[17][16].length=70;
|
|
|
|
|
G.arc[17][18].length=G.arc[18][17].length=56;
|
|
|
|
|
G.arc[17][19].length=G.arc[19][17].length=139;
|
|
|
|
|
G.arc[17][20].length=G.arc[20][7].length=200;
|
|
|
|
|
G.arc[15][21].length=G.arc[21][15].length=52;
|
|
|
|
|
G.arc[18][21].length=G.arc[21][18].length=54;
|
|
|
|
|
G.arc[14][22].length=G.arc[22][14].length=83;
|
|
|
|
|
G.arc[21][22].length=G.arc[22][21].length=48;
|
|
|
|
|
G.arc[22][23].length=G.arc[23][22].length=19;
|
|
|
|
|
G.arc[23][25].length=G.arc[25][23].length=104;
|
|
|
|
|
G.arc[24][25].length=G.arc[25][24].length=39;
|
|
|
|
|
G.arc[14][24].length=G.arc[24][14].length=96;
|
|
|
|
|
G.arc[25][26].length=G.arc[26][25].length=59;
|
|
|
|
|
G.arc[26][27].length=G.arc[27][26].length=35;
|
|
|
|
|
G.arc[25][28].length=G.arc[28][25].length=71;
|
|
|
|
|
G.arc[6][28].length=G.arc[28][6].length=52;
|
|
|
|
|
G.arc[5][28].length=G.arc[28][5].length=30;
|
|
|
|
|
G.arc[6][26].length=G.arc[26][6].length=45;
|
|
|
|
|
G.arc[5][23].length=G.arc[23][5].length=115;
|
|
|
|
|
G.arc[23][30].length=G.arc[30][23].length=43;
|
|
|
|
|
G.arc[23][31].length=G.arc[31][23].length=35;
|
|
|
|
|
G.arc[29][30].length=G.arc[30][29].length=64;
|
|
|
|
|
G.arc[5][29].length=G.arc[29][5].length=78;
|
|
|
|
|
G.arc[29][33].length=G.arc[33][29].length=61;
|
|
|
|
|
G.arc[29][32].length=G.arc[32][29].length=67;
|
|
|
|
|
G.arc[30][32].length=G.arc[32][30].length=42;
|
|
|
|
|
G.arc[22][32].length=G.arc[32][22].length=41;
|
|
|
|
|
G.arc[31][33].length=G.arc[33][31].length=68;
|
|
|
|
|
G.arc[31][34].length=G.arc[34][31].length=70;
|
|
|
|
|
G.arc[19][34].length=G.arc[34][19].length=79;
|
|
|
|
|
G.arc[4][34].length=G.arc[34][4].length=33;
|
|
|
|
|
G.arc[4][19].length=G.arc[19][4].length=27;
|
|
|
|
|
G.arc[8][17].length=G.arc[17][8].length=70;
|
|
|
|
|
G.arc[8][16].length=G.arc[16][8].length=94;
|
|
|
|
|
G.arc[8][20].length=G.arc[20][8].length=50;
|
|
|
|
|
G.arc[4][35].length=G.arc[35][4].length=40;
|
|
|
|
|
G.arc[4][36].length=G.arc[36][4].length=40;
|
|
|
|
|
G.arc[36][37].length=G.arc[37][36].length=28;
|
|
|
|
|
G.arc[36][41].length=G.arc[41][36].length=47;
|
|
|
|
|
G.arc[36][40].length=G.arc[40][36].length=36;
|
|
|
|
|
G.arc[40][44].length=G.arc[44][40].length=28;
|
|
|
|
|
G.arc[43][44].length=G.arc[44][43].length=33;
|
|
|
|
|
G.arc[44][12].length=G.arc[12][44].length=34;
|
|
|
|
|
G.arc[3][43].length=G.arc[43][3].length=43;
|
|
|
|
|
G.arc[12][44].length=G.arc[44][12].length=34;
|
|
|
|
|
G.arc[12][41].length=G.arc[41][12].length=66;
|
|
|
|
|
G.arc[3][37].length=G.arc[37][3].length=50;
|
|
|
|
|
G.arc[35][37].length=G.arc[37][35].length=49;
|
|
|
|
|
G.arc[38][37].length=G.arc[37][38].length=23;
|
|
|
|
|
G.arc[4][39].length=G.arc[39][4].length=89;
|
|
|
|
|
G.arc[39][46].length=G.arc[46][39].length=25;
|
|
|
|
|
G.arc[39][42].length=G.arc[42][39].length=86;
|
|
|
|
|
G.arc[42][45].length=G.arc[45][42].length=53;
|
|
|
|
|
G.arc[42][48].length=G.arc[48][42].length=43;
|
|
|
|
|
G.arc[3][45].length=G.arc[45][3].length=84;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|