V
- the type of the verticespublic class Path<V extends Vertex> extends Walk<V>
Graph
.
Walk
that does not include any vertex twice, except that its first vertex might be the same as its last.
cast()
to convert this path using concrete Vertex
s in a PathByID
using vertex identifiers.
PathByID
.Constructor and Description |
---|
Path(Graph<V,? extends Edge> graph)
Creates an empty path.
|
Path(Graph<V,? extends Edge> graph,
java.util.List<V> path)
Creates a path based on a predefined path.
|
Path(Graph<V,? extends Edge> graph,
V[] path)
Creates a path based on a predefined path.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
V vertex)
Adds a new vertex to the path.
|
void |
add(V vertex)
Adds a new vertex to the path.
|
protected void |
addImpl(int index,
V vertex)
Adds a new vertex to the path at a specified index.
|
PathByID<V> |
cast()
|
Path<V> |
clone()
Gets a shallow copy of this path (the vertices in the path are not cloned).
|
boolean |
equals(java.lang.Object o)
Indicates whether this path equals the specified one.
|
boolean |
equals(Path<V> p)
Indicates whether this path equals the specified one.
|
void |
insert(Walk<V> w,
boolean back)
It is not possible to insert another path!
|
void |
insert(Walk<V> w,
int index)
It is not possible to insert another path!
|
boolean |
isClosed()
Indicates whether the path is a cycle meaning that the path begins and ends on the same vertex.
|
void |
removeLast()
Removes the last vertex of the path.
|
public Path(Graph<V,? extends Edge> graph) throws java.lang.IllegalArgumentException
graph
- the graph its vertices can be part of this pathjava.lang.IllegalArgumentException
- public Path(Graph<V,? extends Edge> graph, V[] path) throws java.lang.IllegalArgumentException
graph
- the graph its vertices can be part of this pathpath
- the predefined path or null
java.lang.IllegalArgumentException
- public Path(Graph<V,? extends Edge> graph, java.util.List<V> path) throws java.lang.IllegalArgumentException
graph
- the graph its vertices can be part of this pathpath
- the predefined path or null
java.lang.IllegalArgumentException
- public void add(V vertex) throws java.lang.IllegalArgumentException
add
in class Walk<V extends Vertex>
vertex
- the vertexjava.lang.IllegalArgumentException
- Path
)Path
)Path
)public void add(int index, V vertex) throws java.lang.IllegalArgumentException, java.lang.IndexOutOfBoundsException
add
in class Walk<V extends Vertex>
index
- the index at which the vertex should be insertedvertex
- the vertexjava.lang.IllegalArgumentException
- Path
)Path
)Path
)java.lang.IndexOutOfBoundsException
- public void insert(Walk<V> w, boolean back) throws java.lang.UnsupportedOperationException
public void insert(Walk<V> w, int index) throws java.lang.UnsupportedOperationException
insert
in class Walk<V extends Vertex>
w
- the pathindex
- the index of the starting vertex of w in this path at which the path w should be inserted (example this = v1,v2,v3,v2,v4,v1
, w = v2,v5,v2
, so w can be inserted at occurrence 1 or 2 of v2)java.lang.UnsupportedOperationException
- public void removeLast()
removeLast
in class Walk<V extends Vertex>
public boolean isClosed()
public boolean equals(java.lang.Object o)
public boolean equals(Path<V> p)
p
- another path that should be compared with this pathtrue
if the paths are equal otherwise false
public Path<V> clone()
protected void addImpl(int index, V vertex) throws java.lang.IllegalArgumentException
addImpl
in class Walk<V extends Vertex>
index
- the index at which the vertex should be addedvertex
- the vertexjava.lang.IllegalArgumentException
- Path
)Path
)Path
)