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

  • All Implemented Interfaces:
    Edge<V>, Path<V,​E>

    public class DefaultPath<V extends Vertex,​E extends Edge<V>>
    extends Object
    implements Path<V,​E>
    Simple concrete implementation of a directed graph path.
    • Constructor Detail

      • DefaultPath

        public DefaultPath​(List<E> edges,
                           Weight cost)
        Creates a new path from the specified list of edges and cost.
        Parameters:
        edges - list of path edges
        cost - path cost as a weight object
    • 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object