"use client"; import { motion } from "motion/react"; import { ChartFrame } from "@/components/charts/chart-frame"; import { circleLayout } from "@/lib/layout"; export type GraphNode = { id: string; label?: string; group?: number }; export type GraphEdge = { source: string; target: string }; type NetworkGraphProps = { nodes: GraphNode[]; edges: GraphEdge[]; width?: number; height?: number; className?: string; }; /** NetworkGraph — deterministic circular layout; edges draw (pathLength), nodes pop in. */ export function NetworkGraph({ nodes, edges, width = 520, height = 460, className }: NetworkGraphProps) { const cx = width / 2; const cy = height / 2; const pos = circleLayout(nodes.length, cx, cy, Math.min(width, height) / 2 - 56); const posOf = new Map(nodes.map((n, i) => [n.id, pos[i]])); return ( {({ inView, reduce }) => ( <> {edges.map((e, i) => { const a = posOf.get(e.source); const b = posOf.get(e.target); if (!a || !b) return null; return ( ); })} {nodes.map((n, i) => { const p = pos[i]; return ( {n.label && ( {n.label} )} ); })} )} ); }