91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-05-17
  • 語(yǔ)言: Java
  • 標(biāo)簽: Dijkstra??JAVA??

資源簡(jiǎn)介

Dijkstra 迪杰斯特拉算法的 JAVA實(shí)現(xiàn)

資源截圖

代碼片段和文件信息

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(){
//標(biāo)記該點(diǎn)已選
nowShortest.shortestLinesValue[1][nowPoint]=0;
//初始化起始節(jié)點(diǎn)
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;//大于預(yù)設(shè)的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]){
//找出原鏈表最后一個(gè)節(jié)點(diǎn)
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為當(dāng)前節(jié)點(diǎn)的最短路徑鏈表第一個(gè)有效節(jié)點(diǎn)
//newLinePreNode為更新節(jié)點(diǎn)的最短路徑鏈表的首節(jié)點(diǎn)
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

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件???????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


評(píng)論

共有 條評(píng)論

相關(guān)資源