⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 minipass.java

📁 自己上学编的基于Dijkstra的最短路径&最大流量java源码
💻 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 + -