Class Path

java.lang.Object
com.thomas.graphs.Path

public class Path extends Object
A simple class to keep the result of search algorithms on a graph
See Also:
  • Field Details

    • vertex

      public Vertex vertex
      The vertex of this path
    • dist

      public int dist
      The shortest distance
    • prev

      public Path prev
      The previous Path (Vertex)
  • Constructor Details

    • Path

      public Path(Vertex v, int dist)
      Creates a new Path
      Parameters:
      v - The vertex
      dist - The distance from the start
  • Method Details

    • getFullPath

      public List<Path> getFullPath()
      Gets the path from this path to the start
      If you have: E --> D; D --> B; B --> A
      The resulting full path will be (A,B,D,E)
      Returns:
      The full path
    • outputPath

      public String outputPath()
      Creates a String of the both from the starting point till this Vertex
      Returns:
      The full path as a string
    • toString

      public String toString()
      Overrides:
      toString in class Object