类 DirectedEdge


  • public class DirectedEdge
    extends java.lang.Object
    The DirectedEdge class represents a weighted edge in an EdgeWeightedDigraph. Each edge consists of two integers (naming the two vertices) and a real-value weight. The data type provides methods for accessing the two endpoints of the directed edge and the weight.

    For additional documentation, see Section 4.4 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

    • 构造器概要

      构造器 
      构造器 说明
      DirectedEdge​(int v, int w, double weight)
      Initializes a directed edge from vertex v to vertex w with the given weight.
    • 方法概要

      修饰符和类型 方法 说明
      int from()
      Returns the tail vertex of the directed edge.
      static void main​(java.lang.String[] args)
      Unit tests the DirectedEdge data type.
      int to()
      Returns the head vertex of the directed edge.
      java.lang.String toString()
      Returns a string representation of the directed edge.
      double weight()
      Returns the weight of the directed edge.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 构造器详细资料

      • DirectedEdge

        public DirectedEdge​(int v,
                            int w,
                            double weight)
        Initializes a directed edge from vertex v to vertex w with the given weight.
        参数:
        v - the tail vertex
        w - the head vertex
        weight - the weight of the directed edge
        抛出:
        java.lang.IllegalArgumentException - if either v or w is a negative integer
        java.lang.IllegalArgumentException - if weight is NaN
    • 方法详细资料

      • from

        public int from()
        Returns the tail vertex of the directed edge.
        返回:
        the tail vertex of the directed edge
      • to

        public int to()
        Returns the head vertex of the directed edge.
        返回:
        the head vertex of the directed edge
      • weight

        public double weight()
        Returns the weight of the directed edge.
        返回:
        the weight of the directed edge
      • toString

        public java.lang.String toString()
        Returns a string representation of the directed edge.
        覆盖:
        toString 在类中 java.lang.Object
        返回:
        a string representation of the directed edge
      • main

        public static void main​(java.lang.String[] args)
        Unit tests the DirectedEdge data type.
        参数:
        args - the command-line arguments