I have some edges in a graph, which I get with:
const edges = getEdges();
Each edge has an array of labels, which I get with:
const edges = getEdges().map(function (edge, i) {
return (i + 1) + '-' + getLabels(edge).sort().join('-');
});
So if I have 2 edges, each with two labels, I get an array
[
'1-label1-label2',
'2-label1-label2'
]
But what I want is
[
'1-label1',
'2-label2',
'3-label1',
'4-label2'
]
So I guess I need to use Array.reduce().