Package org.onlab.graph
Class DefaultMutablePath<V extends Vertex,E extends Edge<V>>
- java.lang.Object
-
- org.onlab.graph.DefaultMutablePath<V,E>
-
- All Implemented Interfaces:
Edge<V>
,MutablePath<V,E>
,Path<V,E>
public class DefaultMutablePath<V extends Vertex,E extends Edge<V>> extends Object implements MutablePath<V,E>
Simple concrete implementation of a directed graph path.
-
-
Constructor Summary
Constructors Constructor Description DefaultMutablePath()
Creates a new empty path.DefaultMutablePath(Path<V,E> path)
Creates a new path as a copy of another path.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendEdge(E edge)
Appends a new edge at the end of the this path.Weight
cost()
Returns the total cost of the path as a weight object.V
dst()
Returns the edge destination vertex.List<E>
edges()
Returns the list of edges comprising the path.boolean
equals(Object obj)
int
hashCode()
void
insertEdge(E edge)
Inserts a new edge at the beginning of this path.void
removeEdge(E edge)
Removes the specified edge.void
setCost(Weight cost)
Sets the total path cost as a weight object.V
src()
Returns the edge source vertex.Path<V,E>
toImmutable()
Returns an immutable copy of this path.String
toString()
-
-
-
Method Detail
-
cost
public Weight cost()
Description copied from interface:Path
Returns the total cost of the path as a weight object.
-
edges
public List<E> edges()
Description copied from interface:Path
Returns the list of edges comprising the path. Adjacent edges will share the same vertex, meaning that a source of one edge, will be the same as the destination of the prior edge.
-
setCost
public void setCost(Weight cost)
Description copied from interface:MutablePath
Sets the total path cost as a weight object.
-
toImmutable
public Path<V,E> toImmutable()
Description copied from interface:MutablePath
Returns an immutable copy of this path.- Specified by:
toImmutable
in interfaceMutablePath<V extends Vertex,E extends Edge<V>>
- Returns:
- immutable copy
-
insertEdge
public void insertEdge(E edge)
Description copied from interface:MutablePath
Inserts a new edge at the beginning of this path. The edge must be adjacent to the prior start of the path.- Specified by:
insertEdge
in interfaceMutablePath<V extends Vertex,E extends Edge<V>>
- Parameters:
edge
- edge to be inserted
-
appendEdge
public void appendEdge(E edge)
Description copied from interface:MutablePath
Appends a new edge at the end of the this path. The edge must be adjacent to the prior end of the path.- Specified by:
appendEdge
in interfaceMutablePath<V extends Vertex,E extends Edge<V>>
- Parameters:
edge
- edge to be inserted
-
removeEdge
public void removeEdge(E edge)
Description copied from interface:MutablePath
Removes the specified edge. This edge must be either at the start or at the end of the path, or it must be a cyclic edge in order not to violate the contiguous path property.- Specified by:
removeEdge
in interfaceMutablePath<V extends Vertex,E extends Edge<V>>
- Parameters:
edge
- edge to be removed
-
-