aryagraph.layout.base.Layout#
- class aryagraph.layout.base.Layout(nodes: list[~typing.Hashable], xy: ~numpy.ndarray, routes: dict[tuple[~typing.Hashable, ~typing.Hashable], ~numpy.ndarray] = <factory>, method: str = 'custom', metric: bool = False, meta: dict[str, ~typing.Any] = <factory>)[source]#
Bases:
objectNode positions, optional edge routes, and provenance.
- Variables:
nodes (list[Hashable]) – Node order; row i of
xybelongs tonodes[i].xy (numpy.ndarray) –
(n, 2)float array of positions (screen coordinates, y down).routes (dict[tuple[Hashable, Hashable], numpy.ndarray]) – Interior bend points of routed edges,
{(u, v): (k, 2) array}, excluding the endpoints themselves. Edges absent here are drawn directly between their endpoints.method (str) – Name of the algorithm that produced the layout.
metric (bool) – True when coordinates are pixels that respect node sizes.
meta (dict[str, Any]) – Algorithm-specific extras, e.g.
{"orientation": "TB", "layers": {...}}.
- classmethod from_positions(positions: Mapping[Hashable, Sequence[float]], nodes: Iterable[Hashable] | None = None, **kwargs: Any) Layout[source]#
Build from
{node: (x, y)}; nodes fixes the order (defaults to mapping order).
- property positions: dict[Hashable, tuple[float, float]]#
{node: (x, y)}as plain floats.
- to_dict() dict[str, Any][source]#
JSON-friendly representation (positions, routes, method, metric, meta).
- bounds(include_routes: bool = True) tuple[float, float, float, float][source]#
(xmin, ymin, xmax, ymax)of all positions (and route points).
- transformed(matrix: ndarray, offset: Sequence[float] = (0.0, 0.0)) Layout[source]#
Apply
p ↦ M·p + offsetto positions and routes.
- scaled(sx: float, sy: float | None = None) Layout[source]#
Scale about the origin (uniformly when sy is omitted).
- rotated(degrees: float, center: Sequence[float] | None = None) Layout[source]#
Rotate clockwise on screen (y down) by degrees about center (default: centroid).
- flipped(axis: str = 'x') Layout[source]#
Mirror horizontally (
axis='x'negates x) or vertically ('y') about the centroid.
- normalized() Layout[source]#
Centered on the origin with the larger half-extent equal to 1 (abstract layouts).
- fit(width: float, height: float, padding: float = 0.0) Layout[source]#
Uniformly scale and center into the box
[padding, width-padding] × [padding, height-padding].