Step3_025_Hub2Hub = {
const graph = _Imports.Graph.ngraph.fromdot.default(Step3_02_Hubs.graph);
const HubsRTG = new Map();
const connections = new Map();
const ConnectionsReplacement = new Map();
for (const hub of [...Step3_02_Hubs.hubs.entries()]) {
for (const link of [...hub[1].values()].map((link) =>
[link[0].fromId, link[0].toId].filter((v) => v !== hub[0])
)) {
if (HubsRTG.has(hub[0])) {
HubsRTG.set(hub[0], [...HubsRTG.get(hub[0]), link[0]]);
} else {
HubsRTG.set(hub[0], [link[0]]);
}
}
}
for (const hub of [...HubsRTG.entries()]) {
const connection = hub[1]
.map((v) => HubsRTG.has(v))
.map((v, i) => (v ? hub[1][i] : null))
.filter((v) => v !== null);
if (connection.length > 0) {
connections.set(hub[0], connection[0]);
graph.removeNode(connection[0]);
}
}
for (const connection of [...connections.entries()]) {
ConnectionsReplacement.set(
connection[0],
_Imports.Geospatial.turf.midpoint(
Step3_01_CoordMapping.coordUnmapping.get(connection[0]),
Step3_01_CoordMapping.coordUnmapping.get(connection[1])
).geometry.coordinates
);
}
console.log("Finished Step3_025_Hub2Hub");
return {
ConnectionsReplacement,
graph: _Imports.Graph.ngraph.todot.default(graph)
};
}