You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
3.9 KiB

#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].no=i;
}
strcpy(G.vexs[1].sight,"烟台市");
strcpy(G.vexs[1].introduction,"山东省沿海城市,位于山东半岛中部");
strcpy(G.vexs[2].sight,"青岛市");
strcpy(G.vexs[2].introduction,"山东省沿海城市,位于山东半岛南部,有崂山风景区等众多景点");
strcpy(G.vexs[3].sight,"潍坊市");
strcpy(G.vexs[3].introduction,"景色优美,气候宜人,经济发达");
strcpy(G.vexs[4].sight,"威海市");
strcpy(G.vexs[4].introduction,"山东省辖地级市,位于山东半岛东端,北,东,南三面濒临 黄海");
strcpy(G.vexs[5].sight,"东营市");
strcpy(G.vexs[5].introduction,"山东省辖地级市,位于山东省东北部,黄河入海口的三角洲地带");
strcpy(G.vexs[6].sight,"滨州市");
strcpy(G.vexs[6].introduction,"山东省辖地级市,位于山东省北部、鲁北平原、黄河三角洲腹地");
strcpy(G.vexs[7].sight,"德州市");
strcpy(G.vexs[7].introduction,"山东省辖地级市,位于山东省西北部,北以新河为界,");
strcpy(G.vexs[8].sight,"聊城市");
strcpy(G.vexs[8].introduction,"山东省辖地级市,位于山东省西部,西部靠漳卫河与河 ");
strcpy(G.vexs[9].sight,"菏泽市");
strcpy(G.vexs[9].introduction,"位于山东西南部,鲁苏豫皖交界地带,东与济宁市相邻");
strcpy(G.vexs[10].sight,"泰安市");
strcpy(G.vexs[10].introduction,"位于山东省中部,是鲁中地区中心城,国家历史文化名城");
for(i=0;i<G.vexnum;i++)
{
for(j=0;j<G.vexnum;j++)
{
G.arc[i][j].length=INF;
G.arc[i][j].money=INF;
}
}
G.arc[1][3].length=G.arc[3][1].length=500;
G.arc[1][4].length=G.arc[4][1].length=200;
G.arc[3][5].length=G.arc[5][3].length=100;
G.arc[10][3].length=G.arc[3][10].length=800;
G.arc[6][4].length=G.arc[4][6].length=200;
G.arc[5][2].length=G.arc[2][5].length=200;
G.arc[2][4].length=G.arc[4][2].length=800;
G.arc[5][7].length=G.arc[7][5].length=500;
G.arc[2][4].length=G.arc[4][2].length=400;
G.arc[4][7].length=G.arc[7][4].length=600;
G.arc[6][8].length=G.arc[8][6].length=500;
G.arc[8][7].length=G.arc[7][8].length=300;
G.arc[6][9].length=G.arc[9][6].length=500;
G.arc[10][3].length=G.arc[3][10].length=600;
G.arc[1][3].money=G.arc[3][1].money=100;
G.arc[1][4].money=G.arc[4][1].money=250;
G.arc[3][5].money=G.arc[5][3].money=360;
G.arc[10][3].money=G.arc[3][10].money=5000;
G.arc[6][4].money=G.arc[4][6].money=200;
G.arc[5][2].money=G.arc[2][5].money=100;
G.arc[2][4].money=G.arc[4][2].money=450;
G.arc[5][7].money=G.arc[7][5].money=600;
G.arc[6][4].money=G.arc[4][6].money=120;
G.arc[4][7].money=G.arc[7][4].money=300;
G.arc[6][8].money=G.arc[8][6].money=460;
G.arc[8][7].money=G.arc[7][8].money=100;
G.arc[6][9].money=G.arc[9][6].money=640;
G.arc[10][3].money=G.arc[3][10].money=230;
return 1;
}