Class DijkstraAlgorithm


  • public class DijkstraAlgorithm
    extends java.lang.Object
    Find the shortest path from a source to a destination. For this purpose each edge has a weight. If the destination of this edge is a stormy track the weight is 6. If it is an occupy track, the weight is 5 and if has both conditions, weight is 11. Else the weight of the edge is 1;
    Since:
    Ptolemy II 11.0
    Version:
    $Id$
    Author:
    Maryam Bagheri
    • Constructor Summary

      Constructors 
      Constructor Description
      DijkstraAlgorithm()
      Instantiate.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Token[] callDijkstra​(java.util.Map<java.lang.Integer,​ArrayToken> neighbors, java.util.ArrayList<java.lang.Integer> airportsId, int source, int destination, java.util.Map<java.lang.Integer,​Token> stormyTracks, java.util.Map<java.lang.Integer,​java.lang.Boolean> inTransit)
      Call the Dijkstra algorithm.
      void execute​(Vertex source)
      Execute the Dijkstra algorithm.
      java.util.LinkedList<Vertex> getPath​(Vertex target)
      Return the path from the source to the selected target.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DijkstraAlgorithm

        public DijkstraAlgorithm()
        Instantiate.
    • Method Detail

      • execute

        public void execute​(Vertex source)
        Execute the Dijkstra algorithm.
        Parameters:
        source - The source id.
      • callDijkstra

        public Token[] callDijkstra​(java.util.Map<java.lang.Integer,​ArrayToken> neighbors,
                                    java.util.ArrayList<java.lang.Integer> airportsId,
                                    int source,
                                    int destination,
                                    java.util.Map<java.lang.Integer,​Token> stormyTracks,
                                    java.util.Map<java.lang.Integer,​java.lang.Boolean> inTransit)
        Call the Dijkstra algorithm.
        Parameters:
        neighbors - The map of neighbors.
        airportsId - The airports
        source - The source
        destination - The destination
        stormyTracks - The map of storm tracks.
        inTransit - the map of in transit objects.
        Returns:
        an array of tokens
      • getPath

        public java.util.LinkedList<Vertex> getPath​(Vertex target)
        Return the path from the source to the selected target. Return null if no path exists.
        Parameters:
        target - The target.
        Returns:
        the path to the target or null.