@@ -348,14 +348,10 @@ a [comparator] function is provided
348348or if ` T ` implements [ ` Comparator ` ] [ Comparator ] .
349349
350350``` Dart
351-
352351import 'package:directed_graph/directed_graph.dart';
353352
354353void main(List<String> args) {
355- int comparator(
356- String s1,
357- String s2,
358- ) {
354+ int comparator(String s1, String s2) {
359355 return s1.compareTo(s2);
360356 }
361357
@@ -375,15 +371,15 @@ void main(List<String> args) {
375371
376372 var graph = WeightedDirectedGraph<String, int>(
377373 {
378- a: {b: 1, h: 7, c: 2, e: 40, g:7},
374+ a: {b: 1, h: 7, c: 2, e: 40, g: 7},
379375 b: {h: 6},
380376 c: {h: 5, g: 4},
381377 d: {e: 1, f: 2},
382378 e: {g: 2},
383379 f: {i: 3},
384380 i: {l: 3, k: 2},
385381 k: {g: 4, f: 5},
386- l: {l: 0}
382+ l: {l: 0},
387383 },
388384 summation: sum,
389385 zero: 0,
@@ -407,6 +403,19 @@ void main(List<String> args) {
407403 final shortestPath = graph.shortestPath(a, g);
408404 print('\nShortest path a -> g');
409405 print('$shortestPath weight: ${graph.weightAlong(shortestPath)}');
406+
407+ print('\nTransitive Closure');
408+ print(WeightedDirectedGraph.transitiveClosure(graph));
409+
410+ print('\nTransitive Weighted Edges:');
411+ print(graph.transitiveWeightedEdges);
412+
413+ print('\nVertices reachable from d:');
414+ print(graph.reachableVertices(d));
415+
416+ print('\nUpdate weight of edge (a,b) with value 101:');
417+ graph.updateEdgeWeight(vertex: a, connectedVertex: b, weight: 101);
418+ print('graph.weightedEdges(a): ${graph.weightedEdges(a)}');
410419}
411420```
412421
@@ -429,7 +438,7 @@ Weighted Graph:
429438 'l': {'l': 0},
430439}
431440
432- Neighbouring vertices sorted by weight
441+ Neighbouring vertices sorted by weight:
433442{
434443 'a': {'b': 1, 'c': 2, 'h': 7, 'g': 7, 'e': 40},
435444 'b': {'h': 6},
@@ -452,6 +461,30 @@ Heaviest path a -> g
452461
453462Shortest path a -> g
454463[a, g] weight: 7
464+
465+ Transitive Closure
466+ {
467+ 'a': {'b': 1, 'c': 2, 'h': 7, 'g': 6, 'e': 40},
468+ 'b': {'h': 6},
469+ 'c': {'g': 4, 'h': 5},
470+ 'd': {'e': 1, 'f': 2, 'g': 3, 'i': 5, 'k': 7, 'l': 8},
471+ 'e': {'g': 2},
472+ 'f': {'i': 3, 'k': 5, 'l': 6, 'g': 9, 'f': 10},
473+ 'g': {},
474+ 'h': {},
475+ 'i': {'k': 2, 'l': 3, 'g': 6, 'f': 7, 'i': 10},
476+ 'k': {'g': 4, 'f': 5, 'i': 8, 'k': 10, 'l': 11},
477+ 'l': {'l': 0},
478+ }
479+
480+ Transitive Weighted Edges:
481+ {a: {b: 1, c: 2, h: 7, g: 6, e: 40}, b: {h: 6}, c: {g: 4, h: 5}, d: {e: 1, f: 2, g: 3, i: 5, k: 7, l: 8}, e: {g: 2}, f: {i: 3, k: 5, l: 6, g: 9, f: 10}, g: {}, h: {}, i: {k: 2, l: 3, g: 6, f: 7, i: 10}, k: {g: 4, f: 5, i: 8, k: 10, l: 11}, l: {l: 0}}
482+
483+ Vertices reachable from d:
484+ {e, g, f, i, k, l}
485+
486+ Update weight of edge (a,b) with value 101:
487+ graph.weightedEdges(a): {b: 101, c: 2, h: 7, g: 7, e: 40}
455488```
456489</details >
457490
0 commit comments