1 auto g1 = Graph!(int, int)([1, 2]); 2 3 auto e1 = g1.edge(1, 2, 1); 4 auto e2 = g1.edge(1, 2, 2); 5 6 g1 ~= e1; 7 8 assertThrown!EdgeExistsException(g1.add(e2)); 9 10 with (g1.ConflictStrategy) 11 { 12 g1.add!replace(e2); 13 14 assert(g1.get(g1.edge(1, 2)) == e2); 15 16 g1.add!keep(e1); 17 18 assert(g1.get(g1.edge(1, 2)) == e2); 19 20 g1.add!sumWeights(e2); 21 22 assert(g1.get(g1.edge(1, 2)).weight == 2 * e2.weight); 23 }
Add an edge to this graph and handle existing edges with handleConflict. The handler must have this signature Edge handleConflict(Edge, Edge).