Download src/components/mindmap/MindMapLayout.js from UnDaoDu/aimindmap: direct link, hf CLI and curl.
- Browser
- Download file 798 Bytes
-
https://huggingface.co/spaces/UnDaoDu/aimindmap/resolve/main/src/components/mindmap/MindMapLayout.js
- Command line
-
hf download hf://spaces/UnDaoDu/aimindmap/src/components/mindmap/MindMapLayout.js
-
curl -L -o MindMapLayout.js https://huggingface.co/spaces/UnDaoDu/aimindmap/resolve/main/src/components/mindmap/MindMapLayout.js
798 Bytes
| export const SPACING = { | |
| X: 250, // Horizontal spacing between nodes | |
| Y: 100, // Vertical spacing between siblings | |
| }; | |
| export const SNAP_GRID = [20, 20]; | |
| export const calculateNodePosition = (level, index, totalAtLevel) => { | |
| const x = level * SPACING.X; | |
| const totalHeight = (totalAtLevel - 1) * SPACING.Y; | |
| const y = (index * SPACING.Y) - (totalHeight / 2); | |
| return { x, y }; | |
| }; | |
| export const getDescendants = (nodeId, edges) => { | |
| const descendants = new Set(); | |
| const stack = [nodeId]; | |
| while (stack.length > 0) { | |
| const current = stack.pop(); | |
| descendants.add(current); | |
| // Find all edges where this node is the source | |
| edges.forEach(edge => { | |
| if (edge.source === current) { | |
| stack.push(edge.target); | |
| } | |
| }); | |
| } | |
| return descendants; | |
| }; |