town.cpp

来自「使用DIJKSTAR算法解决多点最短路径,还带文字解说」· C++ 代码 · 共 54 行

CPP
54
字号
#include "town.h"


town::town()
{
	townName = " ";
	edges = NULL;
}

town::~town()
{
	delete edges;
}

void town::setTownName(string townName_Info)
{
	townName = townName_Info;
}

string town::getTownName()
{
	return townName;
}

void town::setList(list* edges_Info)
{
	edges = edges_Info;
}

list* town::getList()
{
	return edges;
}

void town::setList(double* data, int size, int townsize)
{
    edges = new list();
	int index = 0;
	for ( int j = 0; j < size; j++)
	{
		index += townsize - 1 - j;
	}
	for(int i = 0; i < townsize - size - 1; i++)
	{
		connection con;
		con.setIndex_start(size);
		con.setIndex_end(size + i +1);
		con.setKm(data[index+i]);
		edges->insert_in_order(con);
		//edges.insert_in_order(
	}
	setList(edges);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?