Class DefaultMutablePath<V extends Vertex,​E extends Edge<V>>

  • 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 Detail

      • DefaultMutablePath

        public DefaultMutablePath()
        Creates a new empty path.
      • DefaultMutablePath

        public DefaultMutablePath​(Path<V,​E> path)
        Creates a new path as a copy of another path.
        Parameters:
        path - path to be copied
    • Method Detail

      • src

        public V src()
        Description copied from interface: Edge
        Returns the edge source vertex.
        Specified by:
        src in interface Edge<V extends Vertex>
        Returns:
        source vertex
      • dst

        public V dst()
        Description copied from interface: Edge
        Returns the edge destination vertex.
        Specified by:
        dst in interface Edge<V extends Vertex>
        Returns:
        destination vertex
      • cost

        public Weight cost()
        Description copied from interface: Path
        Returns the total cost of the path as a weight object.
        Specified by:
        cost in interface Path<V extends Vertex,​E extends Edge<V>>
        Returns:
        path cost 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.
        Specified by:
        edges in interface Path<V extends Vertex,​E extends Edge<V>>
        Returns:
        list of path edges
      • setCost

        public void setCost​(Weight cost)
        Description copied from interface: MutablePath
        Sets the total path cost as a weight object.
        Specified by:
        setCost in interface MutablePath<V extends Vertex,​E extends Edge<V>>
        Parameters:
        cost - new path cost
      • 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 interface MutablePath<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 interface MutablePath<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 interface MutablePath<V extends Vertex,​E extends Edge<V>>
        Parameters:
        edge - edge to be removed
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object