@@ -96,12 +96,30 @@ void main() {
9696 expect (graph.vertices.contains (l), false );
9797 // Restore graph:
9898 });
99+ test ('addEdge' , () {
100+ final graph = WeightedDirectedGraph .of (graph0);
101+ graph.addEdge (g, h, 1 );
102+ expect (graph.edges (g), {h});
103+ expect (graph.weightAlong ([g, h]), 1 );
104+ });
105+
99106 test ('addEdges(\' g\' ,{\' h\' : 1}):' , () {
100107 final graph = WeightedDirectedGraph .of (graph0);
101- graph.addEdges ('g' , {'h' : 1 });
102- expect (graph.edges ('g' ), {'h' });
103- expect (graph.data['g' ]? ['h' ], 1 );
108+ graph.addEdges (g, {h: 1 });
109+ expect (graph.edges (g), {h});
110+ expect (graph.weightAlong ([g, h]), 1 );
111+ });
112+ test ('removeEdge' , () {
113+ final graph = WeightedDirectedGraph .of (graph0);
114+ graph.removeEdge (a, b);
115+ expect (graph.edges (a), {h, c, e});
116+ });
117+ test ('removeEdges' , () {
118+ final graph = WeightedDirectedGraph .of (graph0);
119+ graph.removeEdges (a, {b, h, c});
120+ expect (graph.edges (a), {e});
104121 });
122+
105123 test ('clear' , () {
106124 final graph = WeightedDirectedGraph .of (graph0);
107125 expect (graph.sortedVertices, graph0.sortedVertices);
@@ -301,17 +319,17 @@ void main() {
301319 expect (
302320 WeightedDirectedGraph .transitiveClosure (graph).data,
303321 < String , Map <String , int >> {
304- 'a' : {'b' : 1 , 'h' : 7 , 'c' : 2 , 'g' : 6 , 'e' : 4 },
305- 'b' : {'h' : 6 },
306- 'c' : {'h' : 5 , 'g' : 4 },
307- 'd' : {'e' : 1 , 'g' : 3 , 'f' : 2 , 'i' : 5 , 'l' : 8 },
308- 'e' : {'g' : 2 },
309- 'f' : {'i' : 3 , 'l' : 6 },
310- 'g' : {},
311- 'h' : {},
312- 'i' : {'l' : 3 },
313- 'k' : {'g' : 4 , 'f' : 5 , 'i' : 8 , 'l' : 11 },
314- 'l' : {},
322+ a : {b : 1 , h : 7 , c : 2 , g : 6 , e : 4 },
323+ b : {h : 6 },
324+ c : {h : 5 , g : 4 },
325+ d : {e : 1 , g : 3 , f : 2 , i : 5 , l : 8 },
326+ e : {g : 2 },
327+ f : {i : 3 , l : 6 },
328+ g : {},
329+ h : {},
330+ i : {l : 3 },
331+ k : {g : 4 , f : 5 , i : 8 , l : 11 },
332+ l : {},
315333 },
316334 );
317335 });
@@ -320,7 +338,7 @@ void main() {
320338 group ('path:' , () {
321339 test ('min. weight' , () {
322340 final graph = WeightedDirectedGraph .of (graph0);
323- expect (graph.lightestPath ('a' , 'g' ), [a, c, g]);
341+ expect (graph.lightestPath (a, g ), [a, c, g]);
324342 expect (graph.weightAlong ([a, c, g]), 6 );
325343 });
326344 test ('max. weight' , () {
@@ -351,17 +369,17 @@ void main() {
351369 vertex = '${vertex }1' ;
352370 }
353371 expect (graph.sortedVertices, {
354- 'a' ,
355- 'b' ,
356- 'c' ,
357- 'd' ,
358- 'e' ,
359- 'f' ,
360- 'g' ,
361- 'h' ,
362- 'i' ,
363- 'k' ,
364- 'l' ,
372+ a ,
373+ b ,
374+ c ,
375+ d ,
376+ e ,
377+ f ,
378+ g ,
379+ h ,
380+ i ,
381+ k ,
382+ l ,
365383 });
366384 });
367385 });
0 commit comments