PseudoScript
Module

dot

data

Box2 #

private
dot::Box2

An axis-aligned box: top-left corner and extent.

Entities Entity diagram scroll to zoom · drag to pan
RECORDBox2xnumberynumberwnumberhnumber
data

Cluster #

private
dot::Cluster

A cluster (a `subgraph cluster_*`): its id, optional parent cluster, member node ids, the margin kept outside its members, and the header band reserved on the title side.

Entities Entity diagram scroll to zoom · drag to pan
RECORDClusteridstringparentstringmembersstring[]marginnumberheadernumber
data

ClusterBox #

private
dot::ClusterBox

A laid-out cluster: its id and bounding box.

Inbound

Entities Entity diagram scroll to zoom · drag to pan
RECORDClusterBoxidstringbboxdot::Box2RECORDBox2xnumberynumberwnumberhnumber
component

Clusters #

public
dot::Clusters

Cluster framing: compute each cluster's bounding box bottom-up so a nested cluster's box encloses its children (grown by their margins) and its direct members, with header room on the title side — `dot`'s recursive `rec_bb`.

Parent

Inbound

Outbound

Scenarios

ClustersNestLikeDot

Clusters nest like `dot`: an outer box strictly contains its inner boxes.

  • given a graph with a cluster nested inside another cluster
  • when the cluster boxes are computed
  • then the outer box encloses the inner box grown by its margin
  • and each box frames its members and leaves true externals outside
Flow Flow — ClustersNestLikeDot scroll to zoom · drag to pan
FEATUREClustersNestLikeDotfor ClustersGIVENa graph with a cluster nested insideanother clusterWHENthe cluster boxes are computedTHENthe outer box encloses the inner boxgrown by its marginANDeach box frames its members and leavestrue externals outside
container

Dot #

public
dot::Dot

`crates/pseudoscript-dot`. Runs the four-pass layered pipeline over a `Graph` to produce a `Layout`; also offers the experimental grid placer. The layout authority `emit` drives for C4 diagrams.

Inbound

Outbound

Components Component diagram scroll to zoom · drag to pan
PseudoscriptDotCOMPONENTEngineThe layered engine: runs the faithfulfour-pass `dot` pipeline — rank, order,…COMPONENTRankPass 1 — rank assignment: give each node aninteger rank by network simplex, banding…COMPONENTOrderPass 2 — ordering: order nodes within eachrank to minimise edge crossings, inserting…COMPONENTPositionPass 3 — positioning: assign x-coordinatesby network simplex on an auxiliary graph…COMPONENTSplinesPass 4 — splines: route each edge as apiecewise Bézier through its virtual-node…COMPONENTClustersCluster framing: compute each cluster'sbounding box bottom-up so a nested cluster'…COMPONENTGridThe experimental grid placer: an alternativeto the layered pipeline that snaps nodes to…COMPONENTPipelineThe composable post-layout pipeline: thebase layout produces the starting…COMPONENTOptimizeThe `ShortenLongEdges` pass: a bounded,deterministic post-layout refinement.…COMPONENTOracleThe test oracle: lays the same graph outwith the real `dot` binary and compares, so…CONTAINEREmit`crates/pseudoscript-emit`. Projects a viewinto a `Scene` and renders it to SVG; C4…boxesorderassignCoordsassignRanksroute
data

Edge #

private
dot::Edge

An input edge from `tail` to `head`, with its minimum rank span, its layout weight (higher pulls the endpoints into vertical alignment harder), and an optional label size that widens the rank gap to fit.

Entities Entity diagram scroll to zoom · drag to pan
RECORDEdgetailstringheadstringminlennumberweightnumberlabeldot::SizeRECORDSizewnumberhnumber
data

EdgeRoute #

private
dot::EdgeRoute

A routed edge: the Bézier `spline` and its `polyline` approximation between `tail` and `head`, plus where its label sits.

Inbound

Entities Entity diagram scroll to zoom · drag to pan
RECORDEdgeRoutetailstringheadstringsplinedot::Pt[]polylinedot::Pt[]labelPosdot::PtRECORDPtxnumberynumber
component

Engine #

private
dot::Engine

The layered engine: runs the faithful four-pass `dot` pipeline — rank, order, position, splines — then frames the clusters and shifts the whole layout to the origin. Deterministic and panic-free.

Parent

Inbound

Outbound

Scenarios

FaithfulFourPassPipeline

The pipeline is a faithful four-pass port, run in order.

  • given an input graph of sized nodes, edges, and clusters
  • when the graph is laid out
  • then ranks are assigned, nodes ordered within ranks, x-coordinates placed, and edges routed as splines
  • and the passes run in dot's order: rank, then order, then position, then splines
Flow Flow — FaithfulFourPassPipeline scroll to zoom · drag to pan
FEATUREFaithfulFourPassPipelinefor EngineGIVENan input graph of sized nodes, edges,and clustersWHENthe graph is laid outTHENranks are assigned, nodes orderedwithin ranks, x-coordinates placed,and edges routed as splinesANDthe passes run in dot's order: rank,then order, then position, thensplines
DeterministicAndPanicFree

Layout is deterministic and never panics.

  • given the same input graph laid out twice
  • when the layouts are compared
  • then the placements are identical
  • and an empty graph yields an empty layout
  • but no input — however extreme its rank spans — panics or hangs
Flow Flow — DeterministicAndPanicFree scroll to zoom · drag to pan
FEATUREDeterministicAndPanicFreefor EngineGIVENthe same input graph laid out twiceWHENthe layouts are comparedTHENthe placements are identicalANDan empty graph yields an empty layoutBUTno input — however extreme its rankspans — panics or hangs
data

Graph #

public
dot::Graph

The input graph the engine lays out: nodes, edges, clusters, the rank and node separations, the rank direction, and any same-rank constraints.

Inbound

Entities Entity diagram scroll to zoom · drag to pan
RECORDGraphnodesdot::Node[]edgesdot::Edge[]clustersdot::Cluster[]ranksepnumbernodesepnumberrankdirdot::RankDirsameRankstring[]RECORDNodeidstringwidthnumberheightnumberRECORDEdgetailstringheadstringminlennumberweightnumberlabeldot::SizeRECORDClusteridstringparentstringmembersstring[]marginnumberheadernumberUNIONRankDirTopBottomLeftRight
component

Grid #

public
dot::Grid

The experimental grid placer: an alternative to the layered pipeline that snaps nodes to a grid, honouring drag-to-pin cells and searching for a placement that minimises crossings, distance, and against-flow edges.

Parent

Inbound

Scenarios

GridPlacerHonoursPins

The grid placer honours pinned cells while it searches.

  • given a graph and a set of drag-to-pin cells
  • when the experimental grid placer runs
  • then each pinned node stays in its cell
  • and the remaining nodes are placed to minimise crossings, distance, and against-flow edges
Flow Flow — GridPlacerHonoursPins scroll to zoom · drag to pan
FEATUREGridPlacerHonoursPinsfor GridGIVENa graph and a set of drag-to-pin cellsWHENthe experimental grid placer runsTHENeach pinned node stays in its cellANDthe remaining nodes are placed tominimise crossings, distance, andagainst-flow edges
data

GridMeta #

private
dot::GridMeta

Grid metadata carried back when the experimental grid placer ran: the grid dimensions, the cell pitch (centre-to-centre), the pixel centre of cell (0,0), and the width of the drag-room frame wrapping the grid — the geometry the IDE reads to map a drag onto a grid cell, recovering the raw cell from `origin` then subtracting `pad`.

Entities Entity diagram scroll to zoom · drag to pan
RECORDGridMetacolsnumberrowsnumbercellWnumbercellHnumberorigindot::PtpadnumberRECORDPtxnumberynumber
data

GridParams #

public
dot::GridParams

Tunable weights for the experimental grid placer: how strongly it penalises crossings, distance, and against-flow edges, the cell spacing, and how hard it searches.

Entities Entity diagram scroll to zoom · drag to pan
RECORDGridParamscrossingCostnumberdistanceCostnumberflowCostnumberspacingnumbersearchdot::SearchModeUNIONSearchModeAutoHeuristicExhaustive
data

Layout #

public
dot::Layout

The layout result: the overall bounding box, the placed nodes, the routed edges, the cluster boxes, and — only when the grid placer ran — its grid metadata.

Entities Entity diagram scroll to zoom · drag to pan
RECORDLayoutbboxdot::Box2nodesdot::NodePos[]edgesdot::EdgeRoute[]clustersdot::ClusterBox[]gridOption<dot::GridMeta>RECORDBox2xnumberynumberwnumberhnumberRECORDNodePosidstringcenterdot::PtwidthnumberheightnumberRECORDEdgeRoutetailstringheadstringsplinedot::Pt[]polylinedot::Pt[]labelPosdot::PtRECORDClusterBoxidstringbboxdot::Box2
data

LayoutState #

public
dot::LayoutState

The structure that flows through a pipeline: the (possibly pass-mutated) input graph and its current placement. A pass receives one, returns one, and the framework hands it to the next pass; a re-ranking pass may edit `graph` and re-run the base layout.

Inbound

Entities Entity diagram scroll to zoom · drag to pan
RECORDLayoutStategraphdot::Graphlayoutdot::LayoutRECORDGraphnodesdot::Node[]edgesdot::Edge[]clustersdot::Cluster[]ranksepnumbernodesepnumberrankdirdot::RankDirsameRankstring[]RECORDLayoutbboxdot::Box2nodesdot::NodePos[]edgesdot::EdgeRoute[]clustersdot::ClusterBox[]gridOption<dot::GridMeta>
data

Node #

private
dot::Node

An input node: its id and its rendered size (the placer reserves this box).

Entities Entity diagram scroll to zoom · drag to pan
RECORDNodeidstringwidthnumberheightnumber
data

NodePos #

private
dot::NodePos

A placed node: its id, centre point, and reserved size.

Inbound

Entities Entity diagram scroll to zoom · drag to pan
RECORDNodePosidstringcenterdot::PtwidthnumberheightnumberRECORDPtxnumberynumber
component

Optimize #

public
dot::Optimize

The `ShortenLongEdges` pass: a bounded, deterministic post-layout refinement. Greedily search for same-rank moves that reduce the sum of squared edge lengths (never merging across a cluster boundary), then re-lay-out with the improving moves applied.

Parent

component

Oracle #

private
dot::Oracle

The test oracle: lays the same graph out with the real `dot` binary and compares, so the port stays faithful rather than approximate. Skipped when `dot` is not installed.

Parent

Scenarios

OracleCheckedAgainstDot

Fidelity is checked against the real `dot` binary.

  • given the reference dot binary is installed
  • when a graph is laid out by both this engine and dot
  • then the cluster nesting and placements match dot's
  • but the oracle comparison is skipped when dot is not installed
Flow Flow — OracleCheckedAgainstDot scroll to zoom · drag to pan
FEATUREOracleCheckedAgainstDotfor OracleGIVENthe reference dot binary is installedWHENa graph is laid out by both thisengine and dotTHENthe cluster nesting and placementsmatch dot'sBUTthe oracle comparison is skipped whendot is not installed
component

Order #

public
dot::Order

Pass 2 — ordering: order nodes within each rank to minimise edge crossings, inserting virtual nodes for long edges so they route through thin lanes.

Parent

Inbound

Outbound

  • from dot::string
data

Pass #

public
dot::Pass

One stage of the composable post-layout pipeline: same structure in, same structure out, so passes fold freely. `ShortenLongEdges` is the long-edge optimiser; `GridPlacement` wraps the grid placer so it drops into a pipeline. New behaviour is added by writing a pass, not by threading flags through the engine.

Entities Entity diagram scroll to zoom · drag to pan
UNIONPassShortenLongEdgesGridPlacement
data

Pin #

public
dot::Pin

A pin fixing a node to a grid cell: the node's index into `graph.nodes` (the caller resolves the FQN) at a row and column. The IDE's drag-to-pin.

Entities Entity diagram scroll to zoom · drag to pan
RECORDPinnodenumberrownumbercolnumber
component

Pipeline #

public
dot::Pipeline

The composable post-layout pipeline: the base layout produces the starting `LayoutState`; each `Pass` folds it into the next. A pass adjusts geometry directly or edits the input graph (e.g. adds same-rank hints) and re-runs the base layout.

Parent

Inbound

Outbound

component

Position #

public
dot::Position

Pass 3 — positioning: assign x-coordinates by network simplex on an auxiliary graph (aligning nodes and straightening long edges), and y-coordinates per rank stacked with `ranksep` plus any label and cluster-header room.

Parent

Inbound

Outbound

data

Pt #

private
dot::Pt

A point in layout coordinates.

Entities Entity diagram scroll to zoom · drag to pan
RECORDPtxnumberynumber
component

Rank #

public
dot::Rank

Pass 1 — rank assignment: give each node an integer rank by network simplex, banding each cluster onto contiguous ranks and honouring same-rank constraints.

Parent

Inbound

Outbound

  • from dot::string
data

RankDir #

private
dot::RankDir

The rank direction: top-to-bottom (the C4 default) or left-to-right.

Entities Entity diagram scroll to zoom · drag to pan
UNIONRankDirTopBottomLeftRight
data

SearchMode #

private
dot::SearchMode

How the experimental grid placer searches for a placement: pick automatically by size, always the bounded heuristic, or brute-force exhaustive (tiny graphs only).

Entities Entity diagram scroll to zoom · drag to pan
UNIONSearchModeAutoHeuristicExhaustive
data

Size #

private
dot::Size

A width/height extent.

Entities Entity diagram scroll to zoom · drag to pan
RECORDSizewnumberhnumber
component

Splines #

public
dot::Splines

Pass 4 — splines: route each edge as a piecewise Bézier through its virtual-node corridor, clipped to the endpoint borders, with a label point at the polyline midpoint.

Parent

Inbound

Outbound

Generated by pds doc.