bulkAdd

Add a set of edges to this graph and merge mutli-edges using merge.

void
bulkAdd
(
alias merge
G
R
)
(
ref G graph
,
)
if (
is(G : Graph!Params,
Params...
) &&
isForwardRange!R
&&
is(ElementType!R == G.Edge)
)

Examples

1 auto g1 = Graph!(int, int)([1, 2]);
2 
3 static g1.Edge sumWeights(g1.Edge[] multiEdge)
4 {
5     auto sumOfWeights = multiEdge.map!"a.weight".sum;
6     auto mergedEdge = multiEdge[0];
7     mergedEdge.weight = sumOfWeights;
8 
9     return mergedEdge;
10 }
11 
12 auto edges = [
13     g1.edge(1, 2, 1),
14     g1.edge(1, 2, 1),
15     g1.edge(1, 2, 1),
16     g1.edge(2, 3, 2),
17     g1.edge(2, 3, 2),
18     g1.edge(3, 4, 3),
19 ];
20 g1.bulkAdd!sumWeights(edges);
21 assert(g1.edges == [
22     g1.edge(1, 2, 3),
23     g1.edge(2, 3, 4),
24     g1.edge(3, 4, 3),
25 ]);

Meta