github地址:Subway
结对伙伴博客:~InspAlgo~
PSP2.1 | Personal Software Process Stage | 预估耗时(分钟) | 实际耗时(分钟) |
---|---|---|---|
Planning | 计划 | ||
·Estimate | ·估计这个任务需要多长时间 | 10 | 15 |
Development | 开发 | ||
·Analysis | ·需求分析(包括学习新技术) | 60 | 120 |
·Design Spec | ·生成设计文档 | 300 | 200 |
·Design Review | ·设计复审(和同事审核设计文档) | 60 | 20 |
·Coding Standard | ·代码规范(为目前的开发制定合适的规范) | 60 | 60 |
·Design | ·具体设计 | 120 | 120 |
·Coding | ·具体编码 | 1200 | 2400 |
·Code Review | ·代码复审 | 200 | 30 |
·Test | ·测试(自我测试,修改代码,提交修改) | 300 | 100 |
Reporting | 报告 | ||
·Test Report | ·测试报告 | 60 | 30 |
·Size Measurement | ·计算工作量 | 30 | 30 |
·Postmortem & Process Improvement Plan | ·事后总结,并提出过程改进计划 | 60 | 30 |
合计 | 2460 | 3155 |
void Subway::Dijkstra()
{
int book[STATION_NUM]; // book[]节点是否被访问
int dis[STATION_NUM]; // dis[i]起始点到i的最短距离
memset(book, 0, sizeof(book)); // 一开始每个点都没被访问
for (int i = 0; i < STATION_NUM; i++)
{
dis[i] = this->station_link[this->start_station_][i].value;
if (dis[i] < INF) // start_station_到i有直接路径
{
this->station_path[i][0] = this->start_station_; // start_station_到i最短路径经过的第一个顶点
this->station_path[i][1] = i; // start_station到i最短路径经过的第二个顶点
}
}
/* 核心语句 */
for (int i = 0; i < STATION_NUM - 1; i++)
{
int min = INF; // 记录最小dis[i]
int u; // 记录小dis[i]的点
for (int j = 0; j < STATION_NUM; j++)
{
if (book[j] == 0 && dis[j] < min)
{
min = dis[j];
u = j;
}
}
book[u] = 1;
if (u == this->start_station_)
continue;
for (int v = 0; v < STATION_NUM; v++)
{
if (v == this->start_station_)
continue;
if (!book[v] && this->station_link[u][v].value < INF
&& dis[v] > dis[u] + this->station_link[u][v].value)
{
dis[v] = dis[u] + this->station_link[u][v].value;
for (int i = 0; i < STATION_NUM; i++)
{
this->station_path[v][i] = this->station_path[u][i];
if (this->station_path[v][i] == -1)
{
this->station_path[v][i] = v;
break;
}
}
/* 是否为换乘优化模式 */
if (this->transfer_par)
{
dis[u] = 0;
for (int i = 0; i < STATION_NUM; i++)
{
if (i != 0 && this->station_path[u][i - 1] > -1
&& this->station_path[u][i + 1] > -1)
{
dis[u] += this->station_link[this->station_path[u][i]][this->station_path[u][i]].value;
if (this->station_link[this->station_path[u][i - 1]]
[this->station_path[u][i]].line_name
!= this->station_link[this->station_path[u][i]]
[this->station_path[u][i + 1]].line_name)
dis[u] += this->transfer_par;
}
}
dis[v] = dis[u] + this->station_link[u][v].value;
}
}
}
}
}
///
/// 控制台使用的DLL调用函数
///
[DllImport("DLLCS.dll", EntryPoint = "ConsoleInterface")]
public static extern void InterFace();
///
/// 绘制指定颜色粗细带箭头的线
///
public static void DrawArrowLine(Graphics g, float x1, float y1, float x2, float y2, float width)
{
Pen p = new Pen(DrawTool.line_brush_color, width);
p.EndCap = LineCap.ArrowAnchor; // 定义线尾的样式为箭头
g.DrawLine(p, x1, y1, x2, y2);
}
///
/// 绘制圆心(x,y),半径r,宽度为width的空心圆
///
public static void DrawCircle(Graphics g, float x, float y, float r, float width)
{
Pen p = new Pen(DrawTool.circle_brush_color, width);
g.DrawEllipse(p, (int)(x - r), (int)(y - r), (int)(2 * r), (int)(2 * r));
}
///
/// 地图复原,使用原地图覆盖
///
public void ResetMap()
{
Bitmap bitmap = new Bitmap(Resources.subway_map);
Rectangle r = new Rectangle(0, 0,
this.pictureBox_Map.Size.Width, this.pictureBox_Map.Size.Height);
MainForm.graphics.DrawImage(bitmap, r); // 使用原地图覆盖
}
20
良乡大学城北
广阳城
篱笆房
长阳
稻田
大葆台
郭公庄 换乘9号线
丰台科技园
科怡路
丰台南路
丰台东大街
七里庄
六里桥 换乘10号线
莲花桥
公主坟 换乘1号线
军事博物馆 换乘9号线
白堆子
白石桥南
国家图书馆 换乘4号线/大兴线
魏公村
20
良乡大学城北
广阳城
篱笆房
长阳
稻田
大葆台
郭公庄 换乘9号线
丰台科技园
科怡路
丰台南路
丰台东大街
七里庄
六里桥
六里桥东
北京西站
军事博物馆
白堆子
白石桥南
国家图书馆 换乘4号线/大兴线
魏公村
正解。
Error: 站名错误!
能够正确判别站点出错。
0.
判断出距离为0,说明为相同站。
3
2号航站楼
三元桥
3号航站楼
符合实际情况,得到正确解。