Skip to content

Commit 3cb2e95

Browse files
authored
Update deps in package:graphs (#2318)
1 parent ddb0ca4 commit 3cb2e95

17 files changed

Lines changed: 264 additions & 287 deletions

pkgs/graphs/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## 2.3.3-wip
1+
## 2.4.0-wip
22

33
- Add an example usage to the README.
4+
- Update dependencies and minimum SDK version.
45

56
## 2.3.2
67

pkgs/graphs/analysis_options.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,5 @@ linter:
3030
- require_trailing_commas
3131
- unnecessary_await_in_return
3232
- unnecessary_raw_strings
33-
- use_if_null_to_convert_nulls_to_bools
3433
- use_raw_strings
3534
- use_string_buffers

pkgs/graphs/benchmark/connected_components_benchmark.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ void main() {
2626

2727
const duration = Duration(milliseconds: 100);
2828

29-
for (var i = 1;; i++) {
29+
for (var i = 1; ; i++) {
3030
var count = 0;
3131
final watch = Stopwatch()..start();
3232
while (watch.elapsed < duration) {
3333
count++;
34-
final length =
35-
stronglyConnectedComponents(graph.keys, (e) => graph[e] ?? <Never>[])
36-
.length;
34+
final length = stronglyConnectedComponents(
35+
graph.keys,
36+
(e) => graph[e] ?? <Never>[],
37+
).length;
3738
assert(length == 244, '$length');
3839
}
3940

@@ -43,8 +44,10 @@ void main() {
4344
}
4445

4546
if (maxIteration == i || (i - maxIteration) % 20 == 0) {
46-
print('max iterations in ${duration.inMilliseconds}ms: $maxCount\t'
47-
'after $maxIteration of $i iterations');
47+
print(
48+
'max iterations in ${duration.inMilliseconds}ms: $maxCount\t'
49+
'after $maxIteration of $i iterations',
50+
);
4851
}
4952
}
5053
}

pkgs/graphs/benchmark/shortest_path_benchmark.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ void main() {
2424
int? minTicks;
2525
var maxIteration = 0;
2626

27-
final testOutput =
28-
shortestPath(0, size - 1, (e) => graph[e] ?? <Never>[]).toString();
27+
final testOutput = shortestPath(
28+
0,
29+
size - 1,
30+
(e) => graph[e] ?? <Never>[],
31+
).toString();
2932
print(testOutput);
3033
assert(testOutput == '(258, 252, 819, 999)', testOutput);
3134

3235
final watch = Stopwatch();
33-
for (var i = 1;; i++) {
36+
for (var i = 1; ; i++) {
3437
watch
3538
..reset()
3639
..start();
@@ -47,8 +50,10 @@ void main() {
4750
}
4851

4952
if (maxIteration == i || (i - maxIteration) % 100000 == 0) {
50-
print('min ticks for one run: $minTicks\t'
51-
'after $maxIteration of $i iterations');
53+
print(
54+
'min ticks for one run: $minTicks\t'
55+
'after $maxIteration of $i iterations',
56+
);
5257
}
5358
}
5459
}

pkgs/graphs/benchmark/shortest_path_worst_case_benchmark.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,19 @@ void main() {
2525
int? minTicks;
2626
var maxIteration = 0;
2727

28-
final testOutput =
29-
shortestPath(0, size - 1, (e) => graph[e] ?? <Never>[]).toString();
28+
final testOutput = shortestPath(
29+
0,
30+
size - 1,
31+
(e) => graph[e] ?? <Never>[],
32+
).toString();
3033
print(testOutput);
3134
assert(
3235
testOutput == Iterable.generate(size - 1, (i) => i + 1).toString(),
3336
testOutput,
3437
);
3538

3639
final watch = Stopwatch();
37-
for (var i = 1;; i++) {
40+
for (var i = 1; ; i++) {
3841
watch
3942
..reset()
4043
..start();
@@ -51,8 +54,10 @@ void main() {
5154
}
5255

5356
if (maxIteration == i || (i - maxIteration) % 100000 == 0) {
54-
print('min ticks for one run: $minTicks\t'
55-
'after $maxIteration of $i iterations');
57+
print(
58+
'min ticks for one run: $minTicks\t'
59+
'after $maxIteration of $i iterations',
60+
);
5661
}
5762
}
5863
}

pkgs/graphs/example/crawl_async_example.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ Future<AnalysisContextCollection> get analysisContextCollection async {
4242
return collection;
4343
}
4444

45-
Future<Iterable<Uri>> findImports(Uri from, Source source) async =>
46-
source.unit.directives
47-
.whereType<UriBasedDirective>()
48-
.map((d) => d.uri.stringValue!)
49-
.where((uri) => !uri.startsWith('dart:'))
50-
.map((import) => resolveImport(import, from));
45+
Future<Iterable<Uri>> findImports(Uri from, Source source) async => source
46+
.unit
47+
.directives
48+
.whereType<UriBasedDirective>()
49+
.map((d) => d.uri.stringValue!)
50+
.where((uri) => !uri.startsWith('dart:'))
51+
.map((import) => resolveImport(import, from));
5152

5253
Future<CompilationUnit> parseUri(Uri uri) async {
5354
final path = await pathForUri(uri);

pkgs/graphs/lib/src/cycle_exception.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class CycleException<T> implements Exception {
1414
CycleException(Iterable<T> cycle) : cycle = List.unmodifiable(cycle);
1515

1616
@override
17-
String toString() => 'A cycle was detected in a graph that must be acyclic:\n'
17+
String toString() =>
18+
'A cycle was detected in a graph that must be acyclic:\n'
1819
'${cycle.map((node) => '* $node').join('\n')}';
1920
}

pkgs/graphs/lib/src/shortest_path.dart

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ Iterable<T>? shortestPath<T extends Object>(
2525
Iterable<T> Function(T) edges, {
2626
bool Function(T, T)? equals,
2727
int Function(T)? hashCode,
28-
}) =>
29-
_shortestPaths<T>(
30-
start,
31-
edges,
32-
target: target,
33-
equals: equals,
34-
hashCode: hashCode,
35-
)[target];
28+
}) => _shortestPaths<T>(
29+
start,
30+
edges,
31+
target: target,
32+
equals: equals,
33+
hashCode: hashCode,
34+
)[target];
3635

3736
/// Returns a [Map] of the shortest paths from [start] to all of the nodes in
3837
/// the directed graph defined by [edges].
@@ -58,13 +57,7 @@ Map<T, Iterable<T>> shortestPaths<T extends Object>(
5857
Iterable<T> Function(T) edges, {
5958
bool Function(T, T)? equals,
6059
int Function(T)? hashCode,
61-
}) =>
62-
_shortestPaths<T>(
63-
start,
64-
edges,
65-
equals: equals,
66-
hashCode: hashCode,
67-
);
60+
}) => _shortestPaths<T>(start, edges, equals: equals, hashCode: hashCode);
6861

6962
Map<T, Iterable<T>> _shortestPaths<T extends Object>(
7063
T start,
@@ -77,8 +70,9 @@ Map<T, Iterable<T>> _shortestPaths<T extends Object>(
7770
distances[start] = _Tail<T>();
7871

7972
final nonNullEquals = equals ??= _defaultEquals;
80-
final isTarget =
81-
target == null ? _neverTarget : (T node) => nonNullEquals(node, target);
73+
final isTarget = target == null
74+
? _neverTarget
75+
: (T node) => nonNullEquals(node, target);
8276
if (isTarget(start)) {
8377
return distances;
8478
}
@@ -122,10 +116,7 @@ class _Tail<T extends Object> extends Iterable<T> {
122116
final _Tail<T>? head;
123117
@override
124118
final int length;
125-
_Tail()
126-
: tail = null,
127-
head = null,
128-
length = 0;
119+
_Tail() : tail = null, head = null, length = 0;
129120
_Tail._(this.tail, this.head, this.length);
130121
_Tail<T> append(T value) => _Tail._(value, this, length + 1);
131122

pkgs/graphs/lib/src/transitive_closure.dart

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ Map<T, Set<T>> transitiveClosure<T extends Object>(
4646
);
4747
}
4848

49-
final topologicalOrder =
50-
topologicalSort(nodes, edges, equals: equals, hashCode: hashCode);
49+
final topologicalOrder = topologicalSort(
50+
nodes,
51+
edges,
52+
equals: equals,
53+
hashCode: hashCode,
54+
);
5155
final result = LinkedHashMap<T, Set<T>>(equals: equals, hashCode: hashCode);
5256
for (final node in topologicalOrder.reversed) {
5357
final closure = LinkedHashSet<T>(equals: equals, hashCode: hashCode);
@@ -81,8 +85,10 @@ Map<T, Set<T>> _cyclicTransitiveClosure<T extends Object>(
8185
equals: equals,
8286
hashCode: hashCode,
8387
);
84-
final nodesToComponents =
85-
HashMap<T, List<T>>(equals: equals, hashCode: hashCode);
88+
final nodesToComponents = HashMap<T, List<T>>(
89+
equals: equals,
90+
hashCode: hashCode,
91+
);
8692
for (final component in components) {
8793
for (final node in component) {
8894
nodesToComponents[node] = component;
@@ -138,6 +144,7 @@ bool _componentIncludesCycle<T>(
138144
// A component with only a single node only contains a cycle if that node has
139145
// an edge to itself.
140146
final node = component.single;
141-
return edges(node)
142-
.any((edge) => equals == null ? edge == node : equals(edge, node));
147+
return edges(
148+
node,
149+
).any((edge) => equals == null ? edge == node : equals(edge, node));
143150
}

pkgs/graphs/pubspec.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
name: graphs
2-
version: 2.3.3-wip
2+
version: 2.4.0-wip
33
description: Graph algorithms that operate on graphs in any representation.
44
repository: https://github.com/dart-lang/tools/tree/main/pkgs/graphs
55
issue_tracker: https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Agraphs
66

77
environment:
8-
sdk: ^3.4.0
8+
sdk: ^3.10.0
99

1010
dependencies:
11-
collection: ^1.15.0
11+
collection: ^1.19.1
1212

1313
dev_dependencies:
14-
dart_flutter_team_lints: ^3.0.0
15-
test: ^1.21.6
14+
dart_flutter_team_lints: ^3.5.2
15+
test: ^1.29.0
1616

1717
# For examples
18-
analyzer: '>=5.2.0 <9.0.0'
19-
path: ^1.8.0
20-
pool: ^1.5.0
18+
analyzer: ^10.0.2
19+
path: ^1.9.1
20+
pool: ^1.5.2

0 commit comments

Comments
 (0)