📄 minipass.java
字号:
import java.util.Vector;
/**
* The class MiniPass store the shortest (and/or) path and weight between points
* on a map using the Dijkstra algorithm
*/
public class MiniPass {
//name collection of vertices in shortest path
private Vector<String> nodeList;
//weight(distance or time)
private float weight;
public MiniPass(String nodename) {
nodeList = new Vector<String>();
nodeList.add(nodename);
weight = -1;
}
public Vector<String> getNodeList() {
return nodeList;
}
public void setNodeList(Vector<String> nodeList) {
this.nodeList = nodeList;
}
public void addNode(String nodename) {
if (nodeList == null)
nodeList = new Vector<String>();
nodeList.add(0, nodename);
}
public String getLastNode() {
int size = nodeList.size();
return nodeList.elementAt(size - 1);
}
public float getWeight() {
return weight;
}
public void setWeight(float weight) {
this.weight = weight;
}
public void addWeight(float w) {
if (weight == -1)
weight = w;
else
weight += w;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -