Documentation of 'edu.princeton.cs.algs4.DirectedEdge' Java class
DirectedEdge
edu.princeton.cs.algs4

Class 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.

    • Constructor Summary

      Constructors 
      Constructor and Description
      DirectedEdge(int v, int w, double weight)
      Initializes a directed edge from vertex v to vertex w with the given weight.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      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.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DirectedEdge

        public DirectedEdge(int v,
                            int w,
                            double weight)
        Initializes a directed edge from vertex v to vertex w with the given weight.
        Parameters:
        v - the tail vertex
        w - the head vertex
        weight - the weight of the directed edge
        Throws:
        java.lang.IllegalArgumentException - if either v or w is a negative integer
        java.lang.IllegalArgumentException - if weight is NaN
    • Method Detail

      • from

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

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

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

        public java.lang.String toString()
        Returns a string representation of the directed edge.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of the directed edge
      • main

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

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.