Class AgentGraphPath<N extends AgentGraphNode,A extends AgentGraphArc>
java.lang.Object
com.amalgamasimulation.graph.GraphPath<N,A>
com.amalgamasimulation.graphagent.GeometricGraphPath<N,A>
com.amalgamasimulation.graphagent.AgentGraphPath<N,A>
- Type Parameters:
N- type of graph node valuesA- type of graph arc values
public class AgentGraphPath<N extends AgentGraphNode,A extends AgentGraphArc>
extends GeometricGraphPath<N,A>
Path of a
GraphAgent from some GeometricGraphPosition to some
other, probably equal or adjacent GeometricGraphPosition.
Extends from GeometricGraphPath. In addition to that type, contains
the agent's initial source position getInitialSourcePosition() and
final destination position getFinalDestPosition(), that determine
whether the agent must turn around in the beginning or in the end of its
movement.
- Author:
- Andrey Malykhanov
-
Constructor Summary
ConstructorsConstructorDescriptionAgentGraphPath(AgentGraphPath<N, A> otherAgentGraphPath) AgentGraphPath(GeometricGraphPath<N, A> geometricGraphPath) AgentGraphPath(GeometricGraphPath<N, A> geometricGraphPath, boolean requiresTurnAtSource, boolean requiresTurnDestSource, Graph<N, A> graph) -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the position representing the final destination position of an agent moving along this path, i.e.Returns the position representing the initial source position of an agent moving along this path, i.e.getReversePath(Graph<N, A> graph) Returns a reverse path of this path, i.e.Returns thePolylinerepresenting the trajectory of this path.doubleReturns the weight of this path as calculated at the moment of its creation.inthashCode()booleanChecks whether turning around is required at the destination position of this path i.e.booleanChecks whether turning around is required at the source position of this path, i.e.voidsetWeight(double weight) Methods inherited from class com.amalgamasimulation.graphagent.GeometricGraphPath
addNode, append, appendArc, containsNode, containsPosition, containsPositionOrReverse, getArcRecords, getDestPosition, getIntersection, getIntersectionIgnoreDirection, getIntersectionOffsets, getIntersectionOffsetsIgnoreDirection, getLength, getLengthAlongArc, getPolyline, getPositionAtOffset, getSourcePosition, getSubPath, getSubPathBetweenOffsets, getSubPaths, hasNonZeroIntersection, hasNonZeroIntersectionIgnoreDirection, of, of, of, of, prepend, prependArc, toStringMethods inherited from class com.amalgamasimulation.graph.GraphPath
containsArc, emptyPath, getArc, getArcs, getArcsCount, getCopy, getFirstArc, getFirstNode, getLastArc, getLastNode, getNextArc, getNode, getNodes, getNodesCount, getPrevArc, getSubPath, getSubPathFrom, getSubPathTo, isEmpty
-
Constructor Details
-
AgentGraphPath
-
AgentGraphPath
-
AgentGraphPath
-
-
Method Details
-
setWeight
public void setWeight(double weight) -
getTrajectory
Returns thePolylinerepresenting the trajectory of this path.- Returns:
Polylinerepresenting the trajectory of this path
-
getWeight
public double getWeight()Returns the weight of this path as calculated at the moment of its creation.- Returns:
- weight of this path
-
requiresTurnAtSource
public boolean requiresTurnAtSource()Checks whether turning around is required at the source position of this path, i.e.GeometricGraphPath.getSourcePosition()is not equal togetInitialSourcePosition().- Returns:
trueif turning around is required at the source position of this path,falseotherwise- See Also:
-
requiresTurnAtDest
public boolean requiresTurnAtDest()Checks whether turning around is required at the destination position of this path i.e.GeometricGraphPath.getDestPosition()is not equal togetFinalDestPosition().- Returns:
trueif turning around is required at the destination position of this path,falseotherwise- See Also:
-
getInitialSourcePosition
Returns the position representing the initial source position of an agent moving along this path, i.e. the position before possible turning around. Two cases are possible:- If an agent can start moving along this path without turning around, then
getInitialSourcePosition()is equal toGeometricGraphPath.getSourcePosition() - If the path starts on an arc that has a reverse arc, and an agent must
turn around to the reverse arc before starting to move along this path, then
getInitialSourcePosition()is equal to reverse ofGeometricGraphPath.getSourcePosition()
- Returns:
- initial source position of an agent moving along this path
- See Also:
- If an agent can start moving along this path without turning around, then
-
getFinalDestPosition
Returns the position representing the final destination position of an agent moving along this path, i.e. the position after possible turning around at the very end of agent's movement. Two cases are possible:- If an agent does not need to turn around to reach its destination
position, then
getFinalDestPosition()is equal toGeometricGraphPath.getDestPosition() - If the path ends on an arc that has a reverse arc, and an agent must turn
around just before reaching its destination, then
getFinalDestPosition()is equal to reverse ofGeometricGraphPath.getDestPosition()
- Returns:
- final destination position of an agent moving along this path
- See Also:
- If an agent does not need to turn around to reach its destination
position, then
-
equals
- Overrides:
equalsin classGeometricGraphPath<N extends AgentGraphNode,A extends AgentGraphArc>
-
hashCode
public int hashCode()- Overrides:
hashCodein classGeometricGraphPath<N extends AgentGraphNode,A extends AgentGraphArc>
-
getReversePath
Description copied from class:GeometricGraphPathReturns a reverse path of this path, i.e. the path along all the opposite arcs in the reversed order.If this path contains at least one arc that does not have a reverse arc, a
IllegalStateExceptionwill be thrownIf this path is a zero-length path, the returned path will also be a zero-length path
- Overrides:
getReversePathin classGeometricGraphPath<N extends AgentGraphNode,A extends AgentGraphArc> - Returns:
- a new instance of
GeometricGraphPath()that is reverse path of this one
-