Untitled
unknown
java
2 years ago
788 B
3
Indexable
Never
/** * Returns a list of edges for a path from city s to city t. This will be the * shortest path from s to t as prescribed by Dijkstra's algorithm * * @param s * (String) starting city name * @param t * (String) ending city name * @return (List<Edge>) list of edges from s to t */ public List<Edge> getDijkstraPath(String s, String t) { LinkedList<Edge> ret = new LinkedList<Edge>(); Vertex current = getVertex(t); do { for (Edge e : current.adjacentEdges) { if (e.target == current.prev) { ret.add(e); break; } } current = current.prev; } while (current != null); // TODO return ret; // Replace this }