function createGraph(edges) {
const graph = { sources: [], targets: [], costs: [] };
edges.forEach(({ u, v, length }, i) => {
const cost = length;
graph.sources.push(u);
graph.targets.push(v);
graph.costs.push(cost);
graph.sources.push(v);
graph.targets.push(u);
graph.costs.push(cost);
});
return graph;
}