2021-05-21 21:59:51 +00:00
|
|
|
#!/usr/bin/env -S node --experimental-json-modules
|
|
|
|
|
|
|
|
import network from "../src/tam/network.json";
|
|
|
|
|
|
|
|
console.log("digraph {");
|
2021-05-21 22:21:26 +00:00
|
|
|
console.log("graph[layout=neato, overlap=scalexy, splines=true, outputorder=nodesfirst]");
|
2021-05-21 21:59:51 +00:00
|
|
|
|
|
|
|
for (const [stopId, stop] of Object.entries(network.stops)) {
|
2021-05-21 22:21:26 +00:00
|
|
|
console.log(`${stopId}[label="${stop.properties.name}", shape=box]`);
|
2021-05-21 21:59:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const junctions = new Set();
|
|
|
|
|
|
|
|
for (const [beginId, begin] of Object.entries(network.navigation)) {
|
|
|
|
if (!(beginId in network.stops)) {
|
|
|
|
junctions.add(beginId);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const endId in begin) {
|
|
|
|
if (!(endId in network.stops)) {
|
|
|
|
junctions.add(endId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const junction of junctions) {
|
|
|
|
console.log(`${junction}[label="", shape=point]`);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const [beginId, begin] of Object.entries(network.navigation)) {
|
2021-05-21 22:21:26 +00:00
|
|
|
for (const endId in begin) {
|
|
|
|
console.log(`${beginId} -> ${endId}`);
|
2021-05-21 21:59:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log("}");
|