V
- the type of the verticespublic class TrailByID<V extends Vertex> extends WalkByID<V>
Graph
using the identifiers of the vertices.
WalkByID
that does not pass over the same edge twice. A trail might visit the same vertex twice, but only if it
comes and goes from a different edge each time.
TrailByID
to serialize a Trail
. If you deserialize a TrailByID
keep in mind to set the associated graph with
WalkByID.setGraph(Graph)
otherwise the trail is not functioning any more.
cast()
to convert this trail using vertex identifiers in a Trail
using concrete Vertex
s.WalkByID
,
PathByID
,
Serialized FormConstructor and Description |
---|
TrailByID(Graph<V,? extends Edge> graph)
Creates an empty trail.
|
TrailByID(Graph<V,? extends Edge> graph,
java.lang.Integer[] trail)
Creates a trail based on a predefined trail.
|
TrailByID(Graph<V,? extends Edge> graph,
java.util.List<java.lang.Integer> trail)
Creates a trail based on a predefined trail.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int vertexID)
Adds a new vertex to the path.
|
void |
add(int vertexID,
int edgeID)
Adds a new vertex to the path.
|
Trail<V> |
cast()
|
TrailByID<V> |
clone()
Gets a shallow copy of this trail (the identifiers of the vertices in the trail are not cloned).
|
boolean |
contains(Edge e)
Indicates whether the trail contains the specified edge.
|
boolean |
equals(java.lang.Object o)
Indicates whether this trail equals the specified one.
|
boolean |
equals(TrailByID<V> t)
Indicates whether this trail equals the specified one.
|
boolean |
isClosed()
Indicates whether this trail is a circuit meaning that the trail begins and ends on the same vertex.
|
void |
removeLast()
Removes the last vertex of the trail.
|
public TrailByID(Graph<V,? extends Edge> graph) throws java.lang.IllegalArgumentException
graph
- the graph its vertices can be part of this trailjava.lang.IllegalArgumentException
- public TrailByID(Graph<V,? extends Edge> graph, java.lang.Integer[] trail) throws java.lang.IllegalArgumentException
graph
- the graph its vertices can be part of this trailtrail
- the predefined trail or null
java.lang.IllegalArgumentException
- public TrailByID(Graph<V,? extends Edge> graph, java.util.List<java.lang.Integer> trail) throws java.lang.IllegalArgumentException
graph
- the graph its vertices can be part of this trailtrail
- the predefined trail or null
java.lang.IllegalArgumentException
- public void add(int vertexID) throws java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
add
in class WalkByID<V extends Vertex>
vertexID
- the id of the vertexjava.lang.UnsupportedOperationException
- WalkByID.setGraph(Graph)
)java.lang.IllegalArgumentException
- TrailByID
)public void add(int vertexID, int edgeID) throws java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
vertexID
- the id of the vertexedgeID
- the id of the edge the trail should take when traversing from the last vertex of the trail to the new one or < 1
to take an edge that is currently not visitedjava.lang.UnsupportedOperationException
- WalkByID.setGraph(Graph)
)java.lang.IllegalArgumentException
- edgeID
is not incident to the vertexTrailByID
)public void removeLast() throws java.lang.UnsupportedOperationException
removeLast
in class WalkByID<V extends Vertex>
java.lang.UnsupportedOperationException
- WalkByID.setGraph(Graph)
)public boolean contains(Edge e)
public boolean isClosed()
public Trail<V> cast() throws java.lang.UnsupportedOperationException, java.lang.IllegalArgumentException
cast
in class WalkByID<V extends Vertex>
java.lang.UnsupportedOperationException
- WalkByID.setGraph(Graph)
)java.lang.IllegalArgumentException
- public boolean equals(java.lang.Object o)
public boolean equals(TrailByID<V> t)
t
- another trail that should be compared with this trailtrue
if the trails are equal otherwise false