This commit is contained in:
Морозов Андрей 2021-10-26 11:49:01 +00:00
parent 03599e5d6f
commit f00d27589b
1 changed files with 23 additions and 1 deletions

View File

@ -478,8 +478,30 @@ class Graphs {
path = path.reversed.toList();
//print("Shortest path between vertices ${startDot+1} and ${goalDot+1} is: $path");
if (path[0]==startDot && path[1]==goalDot && !_dots[startDot].hasConnection(goalDot+1)) return null;
if (path[0] == (startDot+1) &&
path[1] == (goalDot+1) &&
!_dots[startDot].hasConnection(goalDot + 1)) return null;
return path;
}
List<bool>? dfsIterative(int v) {
v--;
List<bool> label = <bool>[];
for (int i = 0; i < _amount; i++) {
label.add(false);
}
List<int> stack = <int>[];
stack.add(v);
while (stack.isNotEmpty) {
v = stack.removeLast();
if (!label[v]) {
label[v] = true;
for (int i in _dots[v].getL().keys) {
stack.add(i-1);
}
}
}
return label;
}
//************Алгоритмы************
}