Class Path

All Implemented Interfaces:
Iterable<Integer>
Direct Known Subclasses:
Cycle

public class Path extends Trail
A path is a trail with no duplicate vertices. Vertices can not repeat. Edges can not repeat. The length of a walk is its number of edges.
Author:
Cristian Frăsinaru
See Also:
  • Constructor Details

    • Path

      public Path(Graph graph)
    • Path

      public Path(Graph graph, int initialCapacity)
    • Path

      public Path(Graph graph, int[] vertices)
  • Method Details

    • firstVertex

      public int firstVertex()
    • lastVertex

      public int lastVertex()
    • isValid

      public boolean isValid()
      Overrides:
      isValid in class Trail
      Returns:
      false if the vertices do not represent the intendended structure.
    • isInduced

      public boolean isInduced()
      Checks if the path is induced (there is no chord).
      Returns:
      true if the path is induced, false otherwise.
    • isHamiltonian

      public boolean isHamiltonian()
      A Hamiltonian path contains all vertices in the graph.
      Returns:
      true if the path is Hamiltonian.