pub fn to_graph_data(sheet: &Sheet, labels: &Labels) -> GraphDataExpand description
Serializes sheet and labels into a GraphData snapshot for D3.
Constraint links: when sheet.selected_method supplies a relationship method,
its links are directed (inputs → relationship → outputs, LinkData::directed
true). Otherwise all cells adjacent to that relationship are emitted as undirected
source→relationship edges (directed false) — this is decided per relationship, so one
relationship having a plan never marks another relationship’s links as directed.
Conditional nodes: for each conditional, emits one Conditional node, one always-directed
Constraint link from the match cell to the conditional node, and one Control link per
relationship in each branch/default. When a branch (or the default) holds more than one
relationship, its control links route through an intermediate Branch junction node
(conditional → branch → relationship) instead of a direct edge, so the branch’s relationships visually group
together; branches with 0 or 1 relationships keep a direct edge. Control links carry
branch_index and branch_active for rendering, shared identically across both hops of a
junction-routed branch.
- Complexity: O(c + r + e + t) traversal/copy work for cells, relationships, emitted links, and copied text; cell formatting, conditional matching/evaluation, and sheet classification queries add their own costs.
§Examples
let sheet = adam_rs::Sheet::new();
let data = adam_web_ui::to_graph_data(&sheet, &adam_web_ui::Labels::new());
assert!(data.nodes.is_empty());