"""Force-directed network graph template — network family. Adapted from d3-graph-gallery.com (Yan Holtz) — https://d3-graph-gallery.com/graph/network_basic.html (d3 v6 version: d3.forceSimulation() with forceLink/forceManyBody/forceCenter, driven by data_network.json loaded via d3.json()). Here the JSON is injected inline as GraphData; nodes are additionally colored by `group` via an ordinal color scale, ticking uses the "tick" event (not "end") so the simulation animates into place, and a drag behavior is added so nodes can be repositioned. """ from __future__ import annotations from app.agents.d3.registry import D3Template, register from app.agents.d3.templates._graph import GraphData, GraphNode, GraphLink _HTML = """
""" golden_sample = GraphData( title="Demo", nodes=[ GraphNode(id="A", group="x"), GraphNode(id="B", group="x"), GraphNode(id="C", group="y"), ], links=[ GraphLink(source="A", target="B", value=2), GraphLink(source="B", target="C", value=1), ], ) register( D3Template( id="network_force_graph", family="network", title="Force-directed network graph", when_to_use="Show relationships between named entities as a connected node-link network.", data_requirements="A list of nodes (id, optional group) and links (source id, target id, optional weight).", schema=GraphData, html_template=_HTML, golden_sample=golden_sample, ) )