Class Path<Vertex,Distance>

java.lang.Object
dsa.lab10.base.Path<Vertex,Distance>
Type Parameters:
Vertex - the vertex type
Distance - the distance measure type

public class Path<Vertex,Distance> extends Object
Information about a path (of zero or more edges) from some source to some target vertex.

Contains the previous vertex visited in the path from source to target, and some measure of the total distance from the source to the target.

The idea is that there will be other such Path objects giving information about any previous steps in the path (e.g. how to get to the previous vertex).

  • Constructor Details

    • Path

      public Path(Vertex previous, Distance distance)
      Construct a path step with the given information.
      Parameters:
      previous - the previous vertex in the path
      distance - the distance from the source
  • Method Details

    • previous

      public Vertex previous()
      Return the previously-visited vertex.
      Returns:
      the previous vertex
    • distance

      public Distance distance()
      Return the cumulative distance.
      Returns:
      the distance
    • 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