#Help with modified Dijkstra's algorithm
1 messages · Page 1 of 1 (latest)
Methods that didn't make the cut due to max chars in post:
public boolean hasPathTo(SeaPoint v) {
return distTo.get(v) != Double.POSITIVE_INFINITY;
}
public double distTo(SeaPoint v) {
if (!hasPathTo(v))
throw new UnsupportedOperationException("No path to " + v + "!");
return distTo.get(v);
}
public Iterable<Edge> pathTo(SeaPoint v) {
LinkedList<Edge> path = new LinkedList<>();
if (!hasPathTo(v))
return path;
Edge e = edgeTo.get(v);
while (e != null) {
path.addFirst(e);
e = edgeTo.get(e.getV());
}
return path;
}
Please use this format for posting code:
```java
// Example java program
int value = 5;
System.out.println(value);
```
Which results in:
// Example java program
int value = 5;
System.out.println(value);
For syntax highlighting, you have to add the name of the language after the three backticks, like ```java. Please make sure to use exactly this format, so no space between the backticks and the language name, and a newline before the code starts. If done right, the syntax highlighting will even be applied to your text as you type, before sending.
zabuzard • used /tag id: code
·