资源简介
Dijkstra 迪杰斯特拉算法的 JAVA实现

代码片段和文件信息
package homework2;
public class Find {
MapArray map;
int startPoint;
int endPoint;
NowShortest nowShortest;
int nowPoint;
public Find(MapArray mapint startPointint endPoint){
this.map=map;
this.startPoint=startPoint;
this.endPoint=endPoint;
this.nowShortest=new NowShortest(map.pointNum);
nowPoint=startPoint;
}
public void FindShortest(){
//标记该点已选
nowShortest.shortestLinesValue[1][nowPoint]=0;
//初始化起始节点
nowShortest.firstShortestLine[nowPoint].next=new Node(map.pointNum);
nowShortest.firstShortestLine[nowPoint].next.pre=nowShortest.firstShortestLine[nowPoint].next;
nowShortest.firstShortestLine[nowPoint].next.array[0]=nowPoint;
nowShortest.firstShortestLine[nowPoint].isTheEnd=false;
for(int i=0;i
nowShortest.shortestLinesValue[0][nowPoint]=1;
for(int j=0;j int theValue;
if(map.theMap[nowPoint][j]!=0){
theValue=map.theMap[nowPoint][j];
}
else {
theValue=300;//大于预设的200
}
if(nowShortest.shortestLinesValue[1][nowPoint]+theValue
SetTheLine(nowShortest.firstShortestLine[nowPoint].next
nowShortest.firstShortestLine[j]j);
nowShortest.shortestLinesValue[1][j]=
nowShortest.shortestLinesValue[1][nowPoint]+theValue;
}
else if(nowShortest.shortestLinesValue[1][nowPoint]+theValue
==nowShortest.shortestLinesValue[1][j]){
//找出原链表最后一个节点
Node currentNode=nowShortest.firstShortestLine[j];
while(currentNode.isTheEnd==false){
currentNode=currentNode.next;
}
SetTheLine(nowShortest.firstShortestLine[nowPoint].nextcurrentNodej);
}
else{
}
}
int MinValue=200;
int MinPoint=0;
for(int k=0;k if(nowShortest.shortestLinesValue[0][k]==0){
if(nowShortest.shortestLinesValue[1][k] MinValue=nowShortest.shortestLinesValue[1][k];
MinPoint=k;
}
else{
}
}
else{
}
}
nowPoint=MinPoint;
}
Print();
}
//currentNode为当前节点的最短路径链表第一个有效节点
//newLinePreNode为更新节点的最短路径链表的首节点
public void SetTheLine(Node currentNodeNode newLinePreNodeint pointNum){
Node newLineCurrentNode;
//将更新的值保存在链表中
while(currentNode.isTheEnd==false){
Node node=new Node(map.pointNum);
for(int k=0;k if(currentNode.array[k]!=-1){
node.array[k]=currentNode.array[k];
}
else{
node.array[k]=pointNum;
break;
}
}
newLineCurrentNode=node;
newLineCurrentNode.pre=newLinePreNode;
newLinePreNode.next=newLineCurrentNode;
newLinePreNode.isTheEnd=false;
newLinePreNode=newLineCurrentNode;
currentNode=currentNode.next;
}
Node node=new Node(map.pointNum);
for(int k=0;k if(currentNode.array[k]!=-1){
node.array[k]=c
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6921 2013-04-15 14:20 Dijkstra迪杰斯特拉算法JAVA\Find.java
文件 1606 2013-04-16 09:39 Dijkstra迪杰斯特拉算法JAVA\Main.java
文件 415 2013-04-11 17:56 Dijkstra迪杰斯特拉算法JAVA\MapArray.java
文件 230 2013-04-13 11:57 Dijkstra迪杰斯特拉算法JAVA\Node.java
文件 419 2013-04-12 19:09 Dijkstra迪杰斯特拉算法JAVA\NowShortest.java
目录 0 2013-04-22 17:06 Dijkstra迪杰斯特拉算法JAVA
----------- --------- ---------- ----- ----
9591 6
- 上一篇:Java实现推箱子游戏
- 下一篇:运用java图形界面编写的学生信息管理系统
相关资源
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
- 基于jsp的bbs论坛 非常详细
- [免费]java实现有障碍物的贪吃蛇游戏
- java Servlet投票实例
评论
共有 条评论