public class DefaultPath extends Object implements MutablePath
Modifier and Type | Field and Description |
---|---|
protected double |
cost |
protected Vertex |
dst |
protected List<Edge> |
edges |
protected Vertex |
src |
Constructor and Description |
---|
DefaultPath(Path path)
Creates a new path as a copy of another path.
|
DefaultPath(Vertex src,
Vertex dst)
Creates a new path from source to destination.
|
Modifier and Type | Method and Description |
---|---|
void |
appendEdge(Edge edge)
Appends the given edge to the end of the path.
|
double |
cost()
Get the total cost of the path.
|
Vertex |
dst()
Get the target vertex.
|
List<Edge> |
edges()
Gets the list of all edges that form the path.
|
boolean |
equals(Object obj) |
int |
hashCode() |
void |
insertEdge(Edge edge)
Inserts the given edge to the start of the path.
|
void |
insertEdges(List<Edge> list) |
void |
removeEdge(Edge edge)
Removes the given edge from the path.
|
void |
setCost(double cost)
Sets the new path cost.
|
Vertex |
src()
Get the source vertex.
|
String |
toString() |
protected final Vertex src
protected final Vertex dst
protected double cost
public DefaultPath(Vertex src, Vertex dst)
src
- source vertexdst
- destination/target vertexpublic DefaultPath(Path path)
path
- path to be copiedpublic double cost()
Path
public List<Edge> edges()
Path
public void setCost(double cost)
MutablePath
setCost
in interface MutablePath
cost
- new path costpublic void appendEdge(Edge edge)
MutablePath
appendEdge
in interface MutablePath
edge
- edge to be appendedpublic void insertEdge(Edge edge)
MutablePath
insertEdge
in interface MutablePath
edge
- edge to be insertedpublic void removeEdge(Edge edge)
MutablePath
removeEdge
in interface MutablePath
edge
- edge to be removedCopyright © 2016. All Rights Reserved.