Class Edge<Vertex,Weight>

java.lang.Object
dsa.lab10.base.Edge<Vertex,Weight>
Type Parameters:
Vertex - the vertex type
Weight - the weight type

public class Edge<Vertex,Weight> extends Object
An edge in a directed graph.
  • Constructor Details

    • Edge

      public Edge(Vertex source, Vertex target)
      Construct an edge between the given vertices with no weight data.
      Parameters:
      source - the source vertex
      target - the target vertex
    • Edge

      public Edge(Vertex source, Vertex target, Weight weight)
      Construct an edge between the given vertices with the given weight.
      Parameters:
      source - the source vertex
      target - the target vertex
      weight - the weight data
  • Method Details

    • source

      public Vertex source()
      Get the source vertex.
      Returns:
      the source vertex
    • target

      public Vertex target()
      Get the target vertex.
      Returns:
      the target vertex
    • weight

      public Weight weight()
      Get the weight data (null if there is none).
      Returns:
      the weight data
    • equals

      public boolean equals(Object that)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object