com.TeamHEC.LocomotionCommotion.Goal.Graph
Class Dijkstra
java.lang.Object
com.TeamHEC.LocomotionCommotion.Goal.Graph.Dijkstra
public class Dijkstra
- extends java.lang.Object
- Author:
- sa902
Method Summary |
void |
computePaths(Node source)
Compute paths takes a source node and updates the Tentative distance of all other nodes
with the an integer value that represents the length between the source node and that
particular nodes. |
java.util.List<Node> |
getShortestPathTo(Node target)
getShortestPathTo is a function that takes in a target node and gets the shortest path to that node to another node, then returns the path in a list of nodes. |
void |
initialiseGraph()
everytime Dijkstra is called a graph is created specifically for that instance. |
Node |
lookUpNode(MapObj mapObj)
a lookup table that returns a Node instance for a given map obj, it should be noted that nodes are just extended mapobj's. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
stations
public static java.util.ArrayList<Station> stations
nodeList
public Node[] nodeList
Dijkstra
public Dijkstra()
computePaths
public void computePaths(Node source)
- Compute paths takes a source node and updates the Tentative distance of all other nodes
with the an integer value that represents the length between the source node and that
particular nodes.
- Parameters:
source
- the source node
getShortestPathTo
public java.util.List<Node> getShortestPathTo(Node target)
- getShortestPathTo is a function that takes in a target node and gets the shortest path to that node to another node, then returns the path in a list of nodes.
- Parameters:
target
-
- Returns:
- List
lookUpNode
public Node lookUpNode(MapObj mapObj)
- a lookup table that returns a Node instance for a given map obj, it should be noted that nodes are just extended mapobj's. In theory, all stations/junctions will be inside nodeList
so this should not return an illegal argument exception.
- Parameters:
mapObj
-
- Returns:
- Node
initialiseGraph
public void initialiseGraph()
- everytime Dijkstra is called a graph is created specifically for that instance. This function populates nodeList by creating as many null nodes as there are stations/junctions
it then steps through this list of null nodes and populates it with a station from the worldmap.stationList. Once done it then adds edges to each newly created node in correspondence
to the connections of that station.