List dijkstra(int from) { List d = List.filled(_amount, intMax); List p = List.filled(_amount, -1); d[from - 1] = 0; List u = List.filled(_amount, false); for (int i = 0; i < _amount; ++i) { int v = -1; for (int j = 0; j < _amount; ++j) { if (!u[j] && (v == -1 || d[j]! < d[v]!)) { v = j; } } if (d[v] == intMax) break; u[v] = true; for (int to in _dots[v].getL().keys) { int len = _dots[v].getL()[to]!; if (!_useLength && len == 0) len = 1; if (d[v]! + len < d[to - 1]!) { d[to - 1] = d[v]! + len; p[to - 1] = v; } } } for (int i = 0; i < d.length; i++) { if (d[i] == intMax) d[i] = null; } return d; }