hkb_editor.gui.widgets.graph_layout
¶
GraphLayout
dataclass
¶
compute_layout
¶
compute_layout(
graph: DiGraph,
nodemap: dict[str, Node],
order: list[str] = None,
) -> dict[str, tuple[float, float]]
Return {node_id: (x, y)} for all visible nodes.
order is a topological ordering of graph. Callers that already have
one should pass it: topologically sorting a large graph costs more than
the rest of the layout pass combined, and the order never changes.
HorizontalGraphLayout
dataclass
¶
Bases: GraphLayout
compute_layout
¶
compute_layout(
graph: DiGraph,
nodemap: dict[str, Node],
order: list[str] = None,
) -> dict[str, tuple[float, float]]
Place nodes left-to-right by column, top-to-bottom within each column.
Column is derived from the deepest visible parent's column + 1, so multi-parent nodes land in the correct column for the branch that revealed them rather than using a pre-assigned shortest-path depth.
next_y[col] tracks the next free y-coordinate per column so siblings from different parents never overlap.
order is a topological ordering of graph; it is computed here only
if the caller did not supply one.