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

📄 vertexweightpair.java

📁 Network数据结构与算法分析中 图的实现 相当全面 请需要的朋友们下载
💻 JAVA
字号:


public class VertexWeightPair implements Comparable {

    Vertex to;  // the "from" vertex is implicit

    double weight;


    // Postcondition: this VertexWeightPair has been initialized from vertex and weight.
    public VertexWeightPair (Vertex vertex, double weight) {

        to = vertex;
        this.weight = weight;

    } // default constructor


    // Postcondition: the "to" vertex in this VertexWeightPair has been returned.
    public Vertex getToVertex() {

        return to;

    } // method getToVertex


    // Postcondition: the weight in this VertexWeightPair has been returned.
    public double getWeight() {

        return weight;

    } // method getWeight


    // Postcondition: an int <, = or > 0 has been returned, depending on
    //                whether this VertexWeightPair's weight is <, = or >
    //                VertexWeightPair's weight.
    public int compareTo (Object vertexWeightPair) {

        Double thisWeight = new Double(weight);
	      Double otherWeight = new Double(((VertexWeightPair)vertexWeightPair).getWeight());
	      return thisWeight.compareTo(otherWeight);

    } // method compareTo


    // Postcondition: a String representation of this VertexWeightPair
    //                has been returned.
    public String toString() {

        return to.toString() + "  " + String.valueOf (weight);

    } // method toString

} // class VertexWeightPair

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -