heaviestPath method
Returns the path connecting start
and target
with
the largest summed edge-weight.
Note: Returns an empty list if no path could be found.
Implementation
List<T> heaviestPath(T start, T target) {
final paths = crawler.paths(start, target);
if (paths.isEmpty) return [];
var maxWeight = zero;
var result = <T>[];
for (final path in paths) {
final currentWeight = weightAlong(path);
if (currentWeight.compareTo(maxWeight) > 0) {
// Reset maximum weight.
maxWeight = currentWeight;
result = path;
}
}
return result;
}