You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
633 B
26 lines
633 B
import {Graph} from "./pslg";
|
|
import {Plot, plot} from "nodeplotlib";
|
|
|
|
export function plotGraph(graph: Graph) {
|
|
const segmentTraces = graph.segments.map((segment): Plot => {
|
|
return {
|
|
x: [segment.from.x, segment.to.x],
|
|
y: [segment.from.y, segment.to.y],
|
|
type: 'scatter',
|
|
}
|
|
})
|
|
|
|
const traces = segmentTraces.concat(
|
|
graph.getFreePoints()
|
|
.map((point): Plot => {
|
|
return {
|
|
x: [point.x],
|
|
y: [point.y],
|
|
type: 'scatter',
|
|
}
|
|
})
|
|
)
|
|
|
|
plot(traces)
|
|
}
|