When a graph/geometry algorithm is used recursively (or downstream computations depend on its shape/metrics), don’t patch symptoms. Preserve invariants end-to-end:
Map over plain objects for wrapper/global state (descendants/parents/cluster DB) to avoid key collisions and make updates predictable.Example (subgraph config propagation):
// In recursive render for subgraphs
const { ranksep, nodesep } = graph.graph();
node.graph.setGraph({
...node.graph.graph(),
ranksep,
nodesep,
});
Example (wrapper state as Map):
export let clusterDb = new Map();
let descendants = new Map();
let parents = new Map();
export const clear = () => {
clusterDb = new Map();
descendants = new Map();
parents = new Map();
};
Enter the URL of a public GitHub repository