Skip to content
D
Documentation

Layout — interfaces a–h

reference
11 min readUpdated

Interfaces A–H

Import these from @grafloria/engine.

Interfaces

ApplyLayoutConfig

Configuration for applying a layout

ts
interface ApplyLayoutConfig

Properties

NameTypeDefaultDescription
adapter'dagre' | 'elk' | LayoutAdapterLayout adapter to use (name or instance)
options?Partial<LayoutOptions>Layout-specific options
animate?booleanWhether to animate to new positions
animationDuration?numberAnimation duration in milliseconds
fit?booleanWhether to fit viewport after layout
canvasDimensions?{ width: number; height: number }Canvas dimensions for viewport fitting
onProgress?(progress: number) => voidProgress callback for long-running layouts

AutoLayoutResult

Also has every member of LayoutResult, listed on its own entry.

ts
interface AutoLayoutResult extends LayoutResult

Properties

NameTypeDefaultDescription
selectionLayoutSelectionReportWhy this layout, and what the alternatives scored.

Boundary

Boundary definition for constraining node movement

ts
interface Boundary

Properties

NameTypeDefaultDescription
minX?numberMinimum X coordinate (inclusive)
maxX?numberMaximum X coordinate (inclusive)
minY?numberMinimum Y coordinate (inclusive)
maxY?numberMaximum Y coordinate (inclusive)

BundledEdgePath

Bundled edge path with control points

ts
interface BundledEdgePath

Properties

NameTypeDefaultDescription
edgeIdstringEdge ID
controlPointsPoint2D[]Control points for smooth curve
bundleId?stringBundle ID this edge belongs to
strengthnumberBundling strength applied (0-1)

CandidateScore

Every number behind one candidate's verdict.

ts
interface CandidateScore

Properties

NameTypeDefaultDescription
idstring
namestring
optionsUnifiedLayoutOptions
scorenumberFinal weighted score, 0-100.
qualityLayoutQualityResultThe classic metrics (crossings, overlap, symmetry, …).
portRespectnumberRequirement 1: do edges leave in the direction their port faces? 0-100.
labelClearancenumberRequirement 2: do edge labels stay off the nodes? 0-100.
bendsnumber | undefinedTotal bends across the engine's routes; undefined if it reported none.
areanumberBounding-box area in px².
error?stringFailed to run — kept in the report rather than hidden.

CircularLayoutOptions

Also has every member of UnifiedLayoutOptions, LayoutOptions, LayoutRunOptions, listed on their own entries.

ts
interface CircularLayoutOptions extends UnifiedLayoutOptions

Properties

NameTypeDefaultDescription
radius?numberForce a radius. By default it is derived so nodes never overlap.

CommunityLayoutOptions

Also has every member of LayoutOptions, listed on its own entry.

Community detection layout options

ts
interface CommunityLayoutOptions extends LayoutOptions

Properties

NameTypeDefaultDescription
algorithm?'louvain' | 'label-propagation'Community detection algorithm (default: 'louvain')
resolution?numberResolution parameter for community detection (default: 1.0)
separateCommunities?booleanSeparate communities visually (default: true)
communitySpacing?numberSpacing between communities (default: 200)
communityLayout?'circular' | 'grid' | 'force'Layout algorithm for communities (default: 'circular')
innerLayout?'force' | 'circular'Layout algorithm within communities (default: 'force')
forceOptions?{ iterations?: number; repulsion?: number; attraction?: number; }Force layout options for inner layout

CompoundLayoutOptions

ts
interface CompoundLayoutOptions

Properties

NameTypeDefaultDescription
defaultAlgorithm?CompoundAlgorithmDefault algorithm for groups without an explicit / 'inherit' choice.
adapters?Record<string, LayoutAdapter | undefined>Injected adapters used as black boxes, keyed by name. Unknown → grid.
defaultPadding?numberFallback padding for groups without their own padding.
gridGap?numberGap between units in the built-in grid.
layoutTopLevel?booleanAlso arrange the top level (root groups + ungrouped nodes). Default false.
layoutOptions?UnifiedLayoutOptionsBase options in the ONE unified vocabulary (direction / nodeSpacing / rankSpacing / seed), translated per level into whatever that level's engine calls them. Per-group layoutOptions are merged OVER these.
groupOverrides?Record<string, Partial<GroupInfo>>Per-group overrides keyed by group id — honors the GroupInfo contract for callers that don't want to store config on the GroupModel. Merged over the group's own subgraphLayout.

CompoundLayoutResult

ts
interface CompoundLayoutResult

Properties

NameTypeDefaultDescription
laidOutstring[]Groups laid out, in the order processed (deepest first).
skippedstring[]Groups skipped: fixed, collapsed, or inside a collapsed container.
collapsedstring[]Groups skipped specifically because they are collapsed (a leaf, not a container).
groupBoundsMap<string, Rect>group id → final outer bounds.
nodePositionsMap<string, { x: number; y: number }>Final node positions — the LayoutResult contract, so the registry can commit.
boundsRectBounding box of everything laid out.

DagreLayoutOptions

Also has every member of LayoutOptions, listed on its own entry.

Dagre-specific layout options

ts
interface DagreLayoutOptions extends LayoutOptions

Properties

NameTypeDefaultDescription
rankdir'TB' | 'BT' | 'LR' | 'RL'Layout direction
align?'UL' | 'UR' | 'DL' | 'DR'Alignment for rank nodes
nodesepnumberSeparation between adjacent nodes on the same rank (pixels)
edgesepnumberSeparation between adjacent edges (pixels)
ranksepnumberSeparation between ranks (pixels)
marginxnumberHorizontal margin (pixels)
marginynumberVertical margin (pixels)
acyclicer?'greedy' | undefinedAcyclic strategy for breaking cycles
ranker'network-simplex' | 'tight-tree' | 'longest-path'Algorithm for assigning ranks to nodes
deepRankThreshold?numberDEEP-GRAPH FAST PATH — rank-count threshold (default 300).

DiagramLayoutEvent

Layout event data

ts
interface DiagramLayoutEvent

Properties

NameTypeDefaultDescription
typeLayoutEventType
algorithmTypeLayoutAlgorithmType
data?any

EdgeBundlingOptions

Configuration for edge bundling

ts
interface EdgeBundlingOptions

Properties

NameTypeDefaultDescription
enabledbooleanEnable edge bundling
strategy?EdgeBundlingStrategyBundling strategy to use
strength?numberBundling strength (0 = no bundling, 1 = maximum bundling)
controlPoints?numberNumber of control points per edge
smoothness?numberSmoothness of bundled curves (0-1)
iterations?numberNumber of iterations for force-directed bundling
springConstant?numberSpring constant for force-directed bundling
compatibilityThreshold?numberCompatibility threshold (0-1) for bundling edges together
respectGroups?booleanWhether to bundle only edges in same group
minEdgeLength?numberMinimum edge length for bundling

EdgeBundlingResult

Result of edge bundling computation

ts
interface EdgeBundlingResult

Properties

NameTypeDefaultDescription
bundledPathsMap<string, BundledEdgePath>Map of edge ID to bundled path
bundleCountnumberNumber of bundles created
bundledEdgesstring[]Edges that were bundled
unbundledEdgesstring[]Edges that were not bundled
strategyEdgeBundlingStrategyStrategy used
strengthnumberActual strength applied

EdgeInfo

Edge information for bundling

ts
interface EdgeInfo

Properties

NameTypeDefaultDescription
idstringEdge unique identifier
sourceNodeIdstringSource node ID
targetNodeIdstringTarget node ID
sourcePortId?stringSource port ID (optional)
targetPortId?stringTarget port ID (optional)
weight?numberEdge weight/importance
group?stringGroup identifier for related edges

ForceDirectedOptions

Force-directed layout options (for future implementation)

ts
interface ForceDirectedOptions

Properties

NameTypeDefaultDescription
iterations?numberNumber of simulation iterations (default: 100)
repulsionStrength?numberStrength of repulsive force between nodes (default: 5000)
attractionStrength?numberStrength of attraction between connected nodes (default: 0.01)
damping?numberVelocity damping factor (0-1, default: 0.9)
temperature?numberInitial temperature for simulation (default: 100)
coolingFactor?numberCooling factor per iteration (default: 0.95)
minDistance?numberMinimum distance between nodes (default: 50)
maxDistance?numberMaximum distance for force calculation (default: 500)
centerGravity?numberCenter gravity strength (pulls towards center, default: 0.1)
pinExistingNodes?booleanPin existing nodes (don't move them)

ForceLayoutOptions

Also has every member of LayoutOptions, listed on its own entry.

Force-directed layout options

ts
interface ForceLayoutOptions extends LayoutOptions

Properties

NameTypeDefaultDescription
repulsion?numberRepulsion strength between nodes (default: 100)
attraction?numberAttraction strength along edges (default: 0.2)
gravity?numberGravity pulling nodes to center (default: 0.1)
temperature?numberInitial temperature (default: 100)
cooling?numberCooling factor per iteration (default: 0.95)
iterations?numberNumber of iterations (default: 300)
threshold?numberMinimum movement to continue (default: 0.1)
useBarnesHut?booleanUse Barnes-Hut approximation for large graphs (default: true)
theta?numberBarnes-Hut theta parameter (default: 0.9)
linkDistance?numberEdge length (default: 100)
randomize?booleanRandomize initial positions (default: true)
removeOverlaps?booleanThe engine-wide "give me the algorithm's raw output" escape hatch (see UnifiedLayoutOptions in layout-registry.ts). false skips the adapter's snapshot-time residual-overlap cleanup too, so what comes back is literally the simulation state — same meaning as everywhere else.

GraphComponent

One connected component: its nodes, and the links that live entirely inside it.

ts
interface GraphComponent

Properties

NameTypeDefaultDescription
nodesNodeModel[]
linksLinkModel[]

GraphShape

What kind of graph is this? Used to pick which candidates are worth RUNNING (a bake-off over five algorithms on a 5,000-node graph is not free) — never to pick the winner. The winner is always decided by measurement.

ts
interface GraphShape

Properties

NameTypeDefaultDescription
nodeCountnumber
linkCountnumber
densitynumberlinks / max-possible-links.
isTreebooleanNo cycles, and every node has at most one parent.
isDAGbooleanDirected, acyclic.
componentsnumberNumber of connected components.
hasDeclaredPortsbooleanAny node carries author-declared ports.
hasEdgeLabelsbooleanAny link carries a label.

GridLayoutOptions

Grid layout options

ts
interface GridLayoutOptions

Properties

NameTypeDefaultDescription
columns?number | 'auto'Number of columns (auto-calculated if not specified)
startPosition?PointStarting position
horizontalSpacing?numberHorizontal spacing between nodes
verticalSpacing?numberVertical spacing between nodes
nodeSize?SizeNode size for calculations (uses actual size if not specified)
alignment?'start' | 'center' | 'end'Alignment within grid cells
direction?'row' | 'column'Direction of grid filling

GridLayoutPortfolioOptions

Also has every member of UnifiedLayoutOptions, LayoutOptions, LayoutRunOptions, listed on their own entries.

ts
interface GridLayoutPortfolioOptions extends UnifiedLayoutOptions

Properties

NameTypeDefaultDescription
columns?numberColumns in the grid. Defaults to ceil(sqrt(n)) — a roughly square block.

GroupInfo

Group/container information for layout

ts
interface GroupInfo

Properties

NameTypeDefaultDescription
idstringUnique group identifier
parentId?stringParent group ID (if nested)
memberNodeIdsstring[]Node IDs that belong to this group
childGroupIds?string[]Child group IDs (if this group contains other groups)
padding?{ top?: number; right?: number; bottom?: number; left?: number; }Padding inside the group container
minSize?{ width: number; height: number; }Minimum size for the group
maxSize?{ width: number; height: number; }Maximum size for the group
fixed?booleanFixed position (group doesn't move during layout)
fixedSize?booleanFixed size (group size doesn't change to fit content)
layoutAlgorithm?'dagre' | 'elk' | 'inherit'Layout algorithm to use for this group's contents
layoutOptions?anyLayout options specific to this group
collapsed?booleanWhether this group should collapse its members visually

HierarchicalOptions

Hierarchical layout options (for future implementation)

ts
interface HierarchicalOptions

Properties

NameTypeDefaultDescription
direction?'TB' | 'BT' | 'LR' | 'RL'Direction of hierarchy
nodeSpacing?numberSpacing between nodes in same rank
rankSpacing?numberSpacing between ranks/levels
rankAlgorithm?'longest-path' | 'coffman-graham'Algorithm for rank assignment
minimizeCrossings?booleanWhether to minimize edge crossings
preserveMentalMap?booleanPreserve mental map when re-layouting

HostLayoutResult

Also has every member of LayoutResult, listed on its own entry.

ts
interface HostLayoutResult extends LayoutResult

Properties

NameTypeDefaultDescription
algorithmstring
nodePositionsMap<string, { x: number; y: number }>Map of node IDs to their new positions
bounds{ x: number; y: number; width: number; height: number }Bounding box of the laid-out graph
partialbooleanTrue when this is a best-so-far answer rather than a finished one.
reason?LayoutStopReason
iterationnumber
totalIterationsnumber

HybridOptions

Hybrid layout options

ts
interface HybridOptions

Properties

NameTypeDefaultDescription
fallbackAlgorithm?'grid' | 'force-directed' | 'hierarchical'Fallback algorithm if pattern detection fails or confidence is low
enableAutoSwitch?booleanEnable automatic algorithm switching based on pattern detection (default: true)
analysisThreshold?numberConfidence threshold for pattern detection (0-1, default: 0.7) If confidence is below this, fallback algorithm is used
gridOptions?GridLayoutOptionsOptions for each sub-algorithm
forceDirectedOptions?ForceDirectedOptions
hierarchicalOptions?HierarchicalOptions

Was this page helpful?

Layout — interfaces a–h — Grafloria