Class Edge

java.lang.Object
me.nabdev.pathfinding.structures.Edge

public class Edge extends Object
Edge class, used to represent an edge between two vertices.
  • Constructor Details

    • Edge

      public Edge(int vertexOne, int vertexTwo, ModifierCollection modifiers)
      Constructor for the Edge class.
      Parameters:
      vertexOne - The index of the first vertex in the obstacleVertices array.
      vertexTwo - The index of the second vertex in the obstacleVertices array.
      modifiers - The modifiers on this edge.
    • Edge

      public Edge(int vertexOne, int vertexTwo)
      Constructor for the Edge class.
      Parameters:
      vertexOne - The index of the first vertex in the obstacleVertices array.
      vertexTwo - The index of the second vertex in the obstacleVertices array.
  • Method Details

    • equals

      public boolean equals(Object o)
      Overridden equals method, used to check if two edges are equal.
      Overrides:
      equals in class Object
      Parameters:
      o - The object to compare to.
      Returns:
      Whether the two edges are equal.
    • containsVertex

      public int containsVertex(int vertex)
      Check if an index is contained in the edge.
      Parameters:
      vertex - The index to check.
      Returns:
      The index of the other vertex if the index is contained in the edge, otherwise -1.
    • containsVertex

      public int containsVertex(Vertex vertex, ArrayList<Vertex> vertices)
      Check if a vertex is contained in the edge, used when the index is not known.
      Parameters:
      vertex - The vertex to check.
      vertices - The list of vertices to check against.
      Returns:
      The index of the other vertex if the vertex is contained in the edge, otherwise -1.
    • getVertexOne

      public int getVertexOne()
      Get the index in the obstacleVertices list of the first vertex.
      Returns:
      The index of the first vertex.
    • getVertexTwo

      public int getVertexTwo()
      Get the index in the obstacleVertices list of the second vertex.
      Returns:
      The index of the second vertex.
    • getVertexOne

      public Vertex getVertexOne(ArrayList<Vertex> vertices)
      Get the first vertex.
      Parameters:
      vertices - The list of vertices to get the vertex from.
      Returns:
      The first vertex.
    • getVertexTwo

      public Vertex getVertexTwo(ArrayList<Vertex> vertices)
      Get the second vertex.
      Parameters:
      vertices - The list of vertices to get the vertex from.
      Returns:
      The second vertex.
    • isActive

      public boolean isActive()
      Whether or not the edge is active right now based on the modifiers
      Returns:
      true if the edge is active (or has no modifiers)