This commit is contained in:
Ari Sosnovsky committed 2021-11-08 19:46:06 -05:00
1 parent a8c83afaff
commit 8b4c8aec22
6 files changed
+104 -56

No files matched your search

+8 -5
View File
@@ -1,6 +1,6 @@
import { GRAPH_HEIGHT, GRAPH_WIDTH, NODE_HEIGHT, NODE_WIDTH } from "./constants";
import {DAG, Point} from "./types";
import {DAG, Node, Point} from "./types";
export const clip = (p: Point) : Point => {
@@ -12,10 +12,13 @@ export interface NormalizedDag extends DAG {
}
export const normalizeDAG = (dag: DAG): NormalizedDag => {
// let overflow: bo
const nodes = dag.nodes.map(n => ({
...n,
loc: clip(n.loc),
}));
const nodes = Object.keys(dag.nodes).map<[string, Node]>(nodeId => [nodeId, {
...dag.nodes[nodeId],
loc: clip(dag.nodes[nodeId].loc),
}]).reduce((all, [nodeId, next]) => ({
[nodeId]: next,
...all,
}),{});
// dag.edges.forEach(edge => {
// const n1 = nodes[edge.from];
// const n2 = nodes[edge.to];