Package me.nabdev.pathfinding.structures
Class Edge
java.lang.Object
me.nabdev.pathfinding.structures.Edge
Edge class, used to represent an edge between two vertices.
-
Constructor Summary
ConstructorsConstructorDescriptionEdge
(int vertexOne, int vertexTwo) Constructor for the Edge class.Edge
(int vertexOne, int vertexTwo, ModifierCollection modifiers) Constructor for the Edge class. -
Method Summary
Modifier and TypeMethodDescriptionint
containsVertex
(int vertex) Check if an index is contained in the edge.int
containsVertex
(Vertex vertex, ArrayList<Vertex> vertices) Check if a vertex is contained in the edge, used when the index is not known.boolean
Overridden equals method, used to check if two edges are equal.int
Get the index in the obstacleVertices list of the first vertex.getVertexOne
(ArrayList<Vertex> vertices) Get the first vertex.int
Get the index in the obstacleVertices list of the second vertex.getVertexTwo
(ArrayList<Vertex> vertices) Get the second vertex.boolean
isActive()
Whether or not the edge is active right now based on the modifiers
-
Constructor Details
-
Edge
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
Overridden equals method, used to check if 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
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
Get the first vertex.- Parameters:
vertices
- The list of vertices to get the vertex from.- Returns:
- The first vertex.
-
getVertexTwo
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)
-