JAlgoArena
JAlgoArena copied to clipboard
Shortest Path in a Graph - specification incomplete
In the problem "Shortest Path in a Graph" it would be advisible to state explicitly:
a) the weights of the edges are necessarily positive, b) if the graph is directed or not (the class WeightedGraphEdge suggests a directed graph, but it would be good to confirm it; + the "example" does not really present any input data, nor any "arrows" (as for directed graphs), so it remains unspecified), c) we are not given any info on if the graph is supposed to be connected; even if it is, the statement should specify what should be returned if no path exists between "start" and "target" (if the graph is directed),
These have essential influence on the type of algorithm that can be correctly applied to the problem.
a) yes, they are positive b) graph is not directed, it's like map where you have connected two cities, but it's weighted c) it's by design, you get head of graph (WeightedGraph) from where you can find all nodes, which can be connected but not necessarily are
let me know if that helps