add

Add an edge to this graph and handle existing edges with handleConflict. The handler must have this signature Edge handleConflict(Edge, Edge).

G.Edge
add
(
alias handleConflict = 1337
G
)
(
ref G graph
,
G.Edge edge
)
if (
is(G : Graph!Params,
Params...
)
)

Examples

auto g1 = Graph!(int, int)([1, 2]);

auto e1 = g1.edge(1, 2, 1);
auto e2 = g1.edge(1, 2, 2);

g1 ~= e1;

assertThrown!EdgeExistsException(g1.add(e2));

with (g1.ConflictStrategy)
{
    g1.add!replace(e2);

    assert(g1.get(g1.edge(1, 2)) == e2);

    g1.add!keep(e1);

    assert(g1.get(g1.edge(1, 2)) == e2);

    g1.add!sumWeights(e2);

    assert(g1.get(g1.edge(1, 2)).weight == 2 * e2.weight);
}

Meta