代码拉取完成,页面将自动刷新
package week9;
import java.util.Iterator;
public class AirTraffic<T> extends NetWork<T>{
public AirTraffic()
{
super();
}
public void addCity(T city)
{
addVertex(city);
}
public void addEdge(T city1,T city2,double weight)
{
addEdge(getIndex(city1),getIndex(city2),weight);
}
public void getShortestPath(T city1,T city2)
{
int index1 = getIndex(city1);
int index2 = getIndex(city2);
if (shortestPathLength(index1,index2)==0)
System.out.println("无法连通城市:"+city1+" "+city2);
else {
System.out.println("最短路径长度为:"+shortestPathLength(index1,index2));
String result = "";
Iterator iterator = iteratorShortestPath(index1,index2);
while (iterator.hasNext())
result += iterator.next()+" ";
System.out.println("最短路径为:"+result);
}
}
public void getShortestWeightPath(T city1,T city2) {
if (shortestPathLength(city1, city2) < Double.POSITIVE_INFINITY)
System.out.println("最便宜的价格为:" + shortestPathWeight(city1, city2));
else
System.out.println("无法连通城市:" + city1 + " " + city2);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。