diff --git a/bin/src/graph.dart b/bin/src/graph.dart index 8778490..8cd0c20 100644 --- a/bin/src/graph.dart +++ b/bin/src/graph.dart @@ -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? dfsIterative(int v) { + v--; + List label = []; + for (int i = 0; i < _amount; i++) { + label.add(false); + } + List stack = []; + 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; + } //************Алгоритмы************ }