Class Circuit

All Implemented Interfaces:
Iterable<Integer>

public class Circuit extends Trail
A circuit is a trail whose last vertex is connected to the first one. Vertices can repeat. Edges can not repeat. The length of a circuit is the number of edges in the trail plus the one between the endpoints.
Author:
Cristian Frăsinaru
See Also:
  • Constructor Details

    • Circuit

      public Circuit(Graph graph)
    • Circuit

      public Circuit(Graph graph, int initialCapacity)
    • Circuit

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

    • isValid

      public boolean isValid()
      Overrides:
      isValid in class Trail
      Returns:
      false if the vertices do not represent the intendended structure.
    • 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.
    • join

      public Circuit join(Circuit other)
      Joins this circuit with another which has a common vertex.
      Parameters:
      other - another circuit of the graph, having a common vertex with this
      Returns:
      a circuit join this circuit and the other
    • 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