package gps;
import java.util.*;
import java.awt.*;
import java.io.*;
import javax.swing.JOptionPane;
//类Path
//包含输入文本信息后的实现相关操作的方法
public class Path {
//
获得图g,对应列表l中,从start到end的最短路径,并在a中返回前继地点
// 方法返回最短路径长度
public double getPath(String start, String end,
ArrayList a,
Graph g, List
l) {
int s = 0, e = 0;
try {
if
(l.contains(start))// 若图中不存在地点start,抛出异常
s
= l.indexOf(start);
else
throw
new Exception();
} catch (Exception x) {
JOptionPane.showMessageDialog(null,
"起始地点不存在", "error",
JOptionPane.ERROR_MESSAGE);
return
0;
}
try {
if
(l.contains(end))// 若图中不存在地点end,抛出异常
e
= l.