edge.java
来自「java版的数据结构的完全代码 免费提供了 学习数据结构的请下载」· Java 代码 · 共 47 行
JAVA
47 行
// Introduced in Chapter 15/** An edge connecting two vertices in a graph. */public class Edge implements Comparable<Edge> { /** Index of the destination vertex. */ private int dest; /** Index of the source vertex. */ private int source; /** Weight associated with this Edge. */ private double weight; /** Store the given values. */ public Edge(int source, int dest, double weight) { this.source = source; this.dest = dest; this.weight = weight; } public int compareTo(Edge that) { if (weight > that.weight) { return 1; } if (weight == that.weight) { return 0; } return -1; } /** Return the destination vertex of this Edge. */ public int getDest() { return dest; } /** Return the source vertex of this Edge. */ public int getSource() { return source; } /** Return the weight of this Edge. */ public double getWeight() { return weight; } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?