Class Cycle

All Implemented Interfaces:
Iterable<Integer>

public class Cycle extends Path
A cycle is a closed path, meaning that the last vertex of the path is connected to the first one. Vertices can not repeat. Edges can not repeat. The length of a cycle is the number of edges in the path plus the one between the endpoints.
Author:
Cristian Frăsinaru
See Also:
  • Constructor Details

    • Cycle

      public Cycle(Graph graph)
    • Cycle

      public Cycle(Graph graph, int initialCapacity)
    • Cycle

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

    • isValid

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

      public boolean isInduced()
      Description copied from class: Path
      Checks if the path is induced (there is no chord).
      Overrides:
      isInduced in class Path
      Returns:
      true if the cycle is induced (there is no chord).
    • isClosed

      public boolean isClosed()
      Overrides:
      isClosed in class Walk
      Returns:
      true, if the first vertex equals the last one.
    • length

      public int length()
      Description copied from class: Walk
      The length of the walk, trail, path or cycle (number of edges).
      Overrides:
      length in class Walk
      Returns:
      the number of edges.
    • computeEdgesWeight

      public double computeEdgesWeight()
      Overrides:
      computeEdgesWeight in class Walk
      Returns:
      the sum of the edge weights.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Walk
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Walk
    • toString

      public String toString()
      Overrides:
      toString in class Walk