buildWeightedGraph function
Builds WeightedAdjacency from edges; nodeCount = max node index + 1.
Implementation
WeightedAdjacency buildWeightedGraph(List<GraphUtils> edges, int nodeCount) {
final WeightedAdjacency adj = List.generate(nodeCount, (_) => <(int, double)>[]);
for (final GraphUtils e in edges) {
if (e.from >= 0 && e.from < nodeCount && e.to >= 0 && e.to < nodeCount) {
adj[e.from].add((e.to, e.weight));
}
}
return adj;
}