Skip to content

Commit

Permalink
Remove max iterations limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Lempiy committed Apr 27, 2023
1 parent 1259d59 commit 51b03c6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@
* Removed `contentWrapperBuilder` since `InteractiveViewer` is no longer used.
* Changed `onCanvasTap` callback to provide tap details and trigger only if tapped out of other widgets and figures.

## [1.1.1] - April 27, 2023


* Removed max iterations limitation for graph.
14 changes: 4 additions & 10 deletions lib/core/graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import 'package:graphite/core/matrix.dart';
import 'package:graphite/core/traverse_queue.dart';
import 'package:graphite/core/typings.dart';

const MaxIterations = 1000;

class Graph extends GraphMatrix {
Graph({required List<NodeInput> list, required bool centred})
: super(list: list, centred: centred);
Expand Down Expand Up @@ -86,24 +84,20 @@ class Graph extends GraphMatrix {
}
}

int traverseLevel(int iterations, State state) {
void traverseLevel(State state) {
var queue = state.queue;
var levelQueue = queue.drain();
while (levelQueue.length() != 0) {
iterations++;
state.iterations++;
NodeOutput item = levelQueue.shift();
traverseItem(item, state, levelQueue);
if (iterations > MaxIterations) {
throw "max iterations reached";
}
}
return iterations;
}

Matrix traverseList(State state) {
var safe = 0, mtx = state.mtx, queue = state.queue;
var mtx = state.mtx, queue = state.queue;
while (queue.length() != 0) {
safe = traverseLevel(safe, state);
traverseLevel(state);
state.x++;
}
return mtx;
Expand Down
2 changes: 2 additions & 0 deletions lib/core/graph_matrix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ class State {
TraverseQueue queue;
int x;
int y;
int iterations;
State({
required this.mtx,
required this.queue,
this.x = 0,
this.y = 0,
this.iterations = 0,
});
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: graphite
description: Flutter widget to easily draw direct graphs, trees, flowcharts. Includes gesture API to create graphs interactions.
version: 1.1.0
version: 1.1.1
homepage: https://github.com/lempiy/flutter_graphite

environment:
Expand Down

0 comments on commit 51b03c6

Please sign in to comment.