"""Adjacency matrix template — network family. d3-graph-gallery.com has no dedicated adjacency-matrix example (no `/graph/matrix_basic.html` or sibling page — confirmed 404, and the site's network/arc/chord section pages link only to force graphs, arc diagrams, and chord diagrams). The closest real sibling on that site for a grid of colored cells is the general heatmap example — https://d3-graph-gallery.com/graph/heatmap_style.html (d3 v4: d3.scaleBand() row/column axes, d3.scaleSequential(d3.interpolateInferno) cell coloring, cells loaded from a remote CSV via d3.csv()). Here the row/column bands are keyed by `data.nodes` ids (not a remote CSV), and cell values come from an NxN matrix built dynamically from `data.links` (same source/target-id lookup approach as network_chord.py) rather than a hardcoded/loaded table. """ 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_adjacency_matrix", family="network", title="Adjacency matrix", when_to_use="Show which named entities connect to which, and how strongly, as a grid of colored cells.", data_requirements="A list of nodes (id, optional group) and weighted links (source id, target id, value).", schema=GraphData, html_template=_HTML, golden_sample=golden_sample, ) )