package intermediate
Import Path
github.com/d2lang/elk-go/internal/layered/intermediate (on go.dev)
Dependency Relation
imports 16 packages, and imported by 3 packages
Involved Source Files
comments.go
edge_constraint_reverser.go
end_labels.go
graph_transformer.go
hierarchical_port_router.go
hierarchical_ports.go
high_degree_nodes.go
hyperedge_dummy_merger.go
hypernodes.go
in_layer_constraints.go
innermost_node_margin.go
interactive_external_ports.go
inverted_port.go
label_and_node_size.go
label_dummy_inserter.go
label_dummy_remover.go
label_dummy_switcher.go
label_side_selector.go
layer_constraint_postprocessor.go
layer_constraint_preprocessor.go
layer_size.go
long_edge.go
node_placement_repeater.go
node_promotion.go
north_south_port.go
north_south_port_postprocessor.go
partition.go
Package intermediate contains the processors run between ELK Layered's five
main phases.
ports.go
post_compaction.go
reversed_edge_restorer.go
selfloop_port_restorer.go
selfloop_postprocessor.go
selfloop_preprocessor.go
selfloop_router.go
semi_interactive.go
sort_by_input_model.go
Package-Level Type Names (total 4)
GraphTransformMode selects one of GraphTransformer's two passes.
func TransformGraph(arena *layered.LGraphArena, graphID layered.LGraphID, mode GraphTransformMode)
const ToInputDirection
const ToInternalLTR
HyperedgeDummyMerger joins adjacent long-edge dummies that belong to the
same hyperedge, subject to the source/target label-dummy restrictions from
ELK 0.8.1.
(*HyperedgeDummyMerger) Process(arena *layered.LGraphArena, graphID layered.LGraphID) error
*HyperedgeDummyMerger : github.com/d2lang/elk-go/internal/layered.LayoutProcessor
LayerConstraintPostprocessor moves FIRST and LAST nodes to their boundary
layers and restores the separate-layer nodes hidden before phase 2.
(*LayerConstraintPostprocessor) Process(arena *layered.LGraphArena, graphID layered.LGraphID) error
*LayerConstraintPostprocessor : github.com/d2lang/elk-go/internal/layered.LayoutProcessor
LayerConstraintPreprocessor hides FIRST_SEPARATE and LAST_SEPARATE nodes
before layering. It is the arena-backed counterpart of ELK 0.8.1's
intermediate processor of the same name.
(*LayerConstraintPreprocessor) Process(arena *layered.LGraphArena, graphID layered.LGraphID) error
*LayerConstraintPreprocessor : github.com/d2lang/elk-go/internal/layered.LayoutProcessor
Package-Level Functions (total 54)
CalculateCommentNodeMargins reserves the exact top, bottom, and horizontal
protrusion required by comments extracted during preprocessing.
CalculateInnermostNodeMargins ports ELK 0.8.1's
InnermostNodeMarginCalculator. In particular, it deliberately excludes edge
head and tail labels: EndLabelPreprocessor places those precisely after this
baseline margin has been recomputed.
CalculateLayerSizesAndGraphHeight sets every layer's bounding size and the
graph's vertical size and offset after node placement.
CompactHorizontally is the arena-backed port of ELK 0.8.1's
HorizontalGraphCompactor and its one-dimensional constraint graph.
InsertLabelDummies replaces center labels on non-self-loop edges with one
label dummy per edge. New dummies are appended only after the original
layerless-node traversal, as in ELK's implementation.
JoinLongEdgeAt joins matching west-incoming and east-outgoing edges.
JoinLongEdges removes long-edge dummies after routing. The dummy's Layer
pointer intentionally remains set, matching ELK's postcondition.
LongEdgeTargetNode follows a proper long-edge dummy chain to its normal
target. A dummy's LONG_EDGE_TARGET shortcut takes precedence, exactly as in
SortByInputModelProcessor.getTargetNode.
LongEdgeTargetNodePreprocessing calculates each outgoing port's ultimate
target and caches the minimum non-reversed edge order per target node.
ManageEndNodePortLabels corresponds to LabelManagementProcessor(false).
JSON ELK graphs cannot carry Java's ILabelManager callback, so the exact
elkjs/D2-active behavior is an intentional no-op.
MergeHyperedgeDummies is the function-shaped API used by the intermediate
processor dispatcher.
PositionHierarchicalPorts fixes east/west dummy y coordinates for fixed
ratio and fixed-position external ports.
PositionInteractiveExternalPorts assigns previous-layout coordinates to
external-port dummies before the interactive Layered phases run.
PostprocessComments reconnects extracted comment edges and puts the comment
boxes back into their connected node's layer.
PostprocessEndLabels offsets all cells by their final node positions and
applies the LabelCell layout to the individual labels.
PostprocessNorthSouthPorts ports ELK 0.8.1's
NorthSouthPortPostprocessor. It removes the temporary in-layer dummies,
reconnects their edges to the original ports, and adds the vertical routing
segments (or records the dummy y coordinate for spline routing).
PostprocessPartitions detaches the disposable partition ports after
layering. Their incident constraint edges consequently disappear from the
graph topology, exactly as when ELK removes the ports from each node.
PostprocessSelfLoops reattaches the routed edges and translates node-local
bend points and labels into graph coordinates.
PrepareNodePlacementRepeat fixes the node sizes produced by network-simplex
flexibility, disables flexibility for the second run, and recomputes ports,
labels, and margins for those fixed sizes. The selected phase-4 placer is
invoked by layeredlayout to keep the phase packages acyclic.
PreprocessComments removes singly connected comment boxes from the normal
layered pipeline and attaches them to the connected node for later placement.
PreprocessEndLabels is the exact ELK 0.8.1 EndLabelPreprocessor pipeline for
the arena graph. It gathers HEAD and TAIL labels into per-port cells, places
those cells relative to their nodes, removes strip overlaps, and extends the
node margins to cover the result.
PreprocessNorthSouthPorts ports ELK 0.8.1's NorthSouthPortPreprocessor.
Every connected north/south port of a side-fixed normal node is represented
by an in-layer dummy whose west/east ports carry the original edges through
crossing minimization and routing.
PreprocessPartitions reverses edges from higher-indexed to lower-indexed
partitions before cycle breaking. The elevated direction priority mirrors
ELK's safeguard against the cycle breaker reversing the edge again.
PreprocessSelfLoops installs ELK's temporary self-loop model and hides
self-loop edges and freely orderable pure self-loop ports from phases 1-3.
ProcessConstraints stores final layer and position identifiers on normal
nodes for interactive-layout and generated-constraint output.
ProcessHierarchicalPortConstraints imposes fixed-order constraints on
east/west external-port dummies and replaces fixed-side north/south dummies
with the per-layer representatives expected by the later router.
ProcessHighDegreeNodes is the arena-backed port of ELK 0.8.1's
HighDegreeNodeLayeringProcessor. It isolates bounded-height trees adjacent
to high-degree nodes in newly introduced layers.
ProcessHypernodes moves simple hypernodes onto the first orthogonal join
point of their outgoing hyperedge, matching HypernodesProcessor.
ProcessInLayerConstraints moves TOP nodes before ordinary nodes and BOTTOM
nodes to the end while preserving the encounter order within each group.
ProcessInvertedPorts inserts same-layer long-edge dummies for input ports on
the east side and output ports on the west side.
ProcessLabelAndNodeSizes performs the post-ordering part of ELK 0.8.1's
LabelAndNodeSizeProcessor for normal layered nodes. Original node and label
sizing has already run on the imported ELK graph; the important second pass
fixes the positions of ports whose order was chosen during phase 3.
D2 either supplies FIXED_POS ports or zero-sized implicit ports. The latter
use ELK's default DISTRIBUTED alignment. The implementation below also keeps
the source algorithm's size, margin, spacing, border-offset, and alignment
arithmetic for non-zero ports.
ProcessLayerConstraintsAfterLayering is the function-shaped API used by the
layered pipeline's intermediate-processor dispatcher.
ProcessLayerConstraintsBeforeLayering is the function-shaped API used by
the layered pipeline's intermediate-processor dispatcher.
ProcessPartitionsBeforeLayering connects every node in a partition to every
node in the next partition through disposable constraint ports and edges.
ProcessPortSides makes every port side-fixed. It is the direct counterpart
of ELK 0.8.1's PortSideProcessor and deliberately visits layerless nodes
before layered nodes.
ProcessSemiInteractiveCrossing derives pairwise in-layer constraints from
explicitly supplied node positions while leaving dummy nodes unconstrained.
PromoteNodes is the arena-backed port of ELK 0.8.1's NodePromotion
intermediate processor (Nikolov and Tarassov's dummy-reduction heuristic).
RemoveLabelDummies places represented center labels, rejoins their edges,
and removes label dummies from their layers.
ResizeHierarchicalNode finishes a child graph and transfers its actual size
and external-port positions to the compound node that owns it.
RestoreReversedEdges restores every cycle-breaking reversal. Iteration uses
a copy of each outgoing-edge list because ReverseEdge mutates adjacency.
RestoreSelfLoopPorts restores hidden self-loop ports and computes the loop
types needed by routing.
ReverseConstraintEdges enforces ELK's outer-layer constraints and the
fixed-side feedback-node rule before cycle breaking.
RouteHierarchicalPorts restores north/south external-port dummies, routes
their temporary connections, and fixes every external dummy to the graph
border. It is ELK's HierarchicalPortOrthogonalEdgeRouter.
RouteSelfLoops runs ELK's routing-director, label-placement, slot-assignment,
and orthogonal routing chain for every normal self-loop node.
SelectLabelSides annotates edge labels and label dummies with the side on
which they must be placed.
SetPortSide places input ports west and output ports east. A port connected
to an external-port dummy inherits that dummy's side instead.
SizeHierarchicalPortDummies gives north/south representatives the staggered
widths required to separate their vertical edge segments.
SortByInputModel ports ELK 0.8.1's SortByInputModelProcessor. It must run
after long-edge splitting and before north/south port dummy insertion.
SortEndLabels ports ELK 0.8.1's EndLabelSorter. Groups of labels belonging
to one edge retain their input order; groups are ordered by the opposite
endpoint's final layer/port order.
SortPortLists puts ports into clockwise order starting with the leftmost
northern port. Sort stability intentionally preserves model order on ties.
SplitEdgeAtDummy reroutes edge into dummy and returns the new outgoing edge.
SplitLongEdges makes the layering proper by inserting one dummy into each
intervening layer of every long edge.
SwitchLabelDummies moves center-label dummies to the layer selected by the
configured ELK strategy while preserving each layer's crossing-minimized
node position.
TransformGraph applies ELK Layered's direction normalization. The internal
layered phases always operate left-to-right; the second pass restores the
input direction after routing.
Package-Level Constants (total 2)
const ToInputDirection GraphTransformMode = 1 const ToInternalLTR GraphTransformMode = 0
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |