package routing
Import Path
github.com/pancsta/d2/d2layouts/d2talalayout/internal/routing (on go.dev)
Dependency Relation
imports 25 packages, and imported by 2 packages
Involved Source Files
balance_crossings.go
balance_route_guard.go
cluster_route_guard.go
coordinator.go
cost.go
Package routing builds orthogonal visibility graphs, searches them for edge
routes, and applies the routing post-processing stages.
edge_simplify.go
filter.go
geometry.go
graph_stage.go
loop_router.go
nudge_channels.go
ovg.go
ovg_edge.go
ovg_edge_router.go
ovg_edge_set.go
ovg_hierarchy.go
ovg_node.go
ovg_resource.go
port_interior_balance.go
postprocess.go
priority_queue.go
route.go
route_search_guard.go
route_stage_guard.go
shortcut_routes.go
slingshot.go
snapshot.go
standalone_route_guard.go
standalone_router.go
swap_ports.go
trace.go
tree_routes.go
tuning.go
tunnel.go
turns.go
work.go
Package-Level Type Names (total 15)
GraphRouteOptions describes the route state owned by the pipeline around a
whole-graph routing pass.
CompletionObserver RouteCompletionObserver
ForceReroute bool
Observer SubgraphRouteObserver
RoutesPreviouslyCompleted bool
func RouteGraph(ctx context.Context, graph *layoutgraph.Graph, options GraphRouteOptions) (bool, error)
func RouteGraphWithWorkLimit(ctx context.Context, graph *layoutgraph.Graph, options GraphRouteOptions, workLimit uint64) (routingComplete bool, err error)
Orthogonal Visibility Graph
Centers map[*layoutgraph.Node]*OVGNode
Edges []*OVGEdge
HorizontalEdges map[float64][]*OVGEdge
Nodes []*OVGNode
NodesInsideBoundingBox []*layoutgraph.Node
OccupiedPoints map[geo.Point]*OVGNode
Ports map[*layoutgraph.Node][]*OVGNode
VerticalEdges map[float64][]*OVGEdge
(*OVG) AddNode(node *OVGNode) *OVGNode
(*OVG) AddNodeUnchecked(node *OVGNode)
(*OVG) Connect(nodeA, nodeB *OVGNode) *OVGEdge
(*OVG) MarshalJSON() ([]byte, error)
(*OVG) UnmarshalJSON(content []byte) error
*OVG : github.com/goccy/go-json.Marshaler
*OVG : github.com/goccy/go-json.Unmarshaler
*OVG : encoding/json/v2.Marshaler
*OVG : encoding/json/v2.Unmarshaler
func NewOVG(nodesInsideBoundingBox []*layoutgraph.Node) *OVG
func SubgraphRouteObserver.SubgraphRouted(*OVG) error
Distance float64
From *OVGNode
To *OVGNode
func NewOVGEdge(from, to *OVGNode) *OVGEdge
func (*OVG).Connect(nodeA, nodeB *OVGNode) *OVGEdge
func (*OVGNode).Adjacent(edge *OVGEdge) *OVGNode
Container *layoutgraph.Node
// 24 bytes
// 8 bytes
// 8 bytes
// 1 byte
// 1 byte
// 8 bytes
Point.X float64
Point.Y float64
Moves the given point by Vector
(*OVGNode) Adjacent(edge *OVGEdge) *OVGNode
( OVGNode) Compare(p2 *geo.Point) int
( OVGNode) Copy() *geo.Point
https://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment
( OVGNode) Equals(p2 *geo.Point) bool
( OVGNode) FormattedCoordinates() string
GetOrientation gets orientation of pFrom to pTo
E.g. pFrom ---> pTo, here, pFrom is to the left of pTo, so Left would be returned
point t% of the way between a and b
returns true if point p is on orthogonal segment between points a and b
( OVGNode) ToString() string
Creates a Vector pointing to point
( OVGNode) Transpose()
( OVGNode) TruncateDecimals()
( OVGNode) TruncateFloat32()
Creates a Vector of the size between start and endpoint, pointing to endpoint
func NewOVGNode(p *geo.Point) *OVGNode
func (*OVG).AddNode(node *OVGNode) *OVGNode
func (*OVGNode).Adjacent(edge *OVGEdge) *OVGNode
func NewOVGEdge(from, to *OVGNode) *OVGEdge
func NewTunnelEntry(node *layoutgraph.Node, ovgNode *OVGNode) *TunnelEntry
func (*OVG).AddNode(node *OVGNode) *OVGNode
func (*OVG).AddNodeUnchecked(node *OVGNode)
func (*OVG).Connect(nodeA, nodeB *OVGNode) *OVGEdge
type Range (struct) type RouteChecker (struct)
RouteCompletionObserver observes the route-complete transition inside the
atomic routing stage. The engine retains pipeline-status ownership while the
routing guard can still observe cancellation before commit.
( RouteCompletionObserver) RoutingCompleted()
const Default
const LongestToShortest
const ShortestToLongest
const TopDownLeftRight
SearchTelemetry collects per-flavor work samples for routing diagnostics
and calibration. It is safe to share across concurrent route workers.
WorkSamples returns a stable copy of the recorded per-flavor work totals.
func WithSearchTelemetry(ctx context.Context, telemetry *SearchTelemetry) context.Context
SubgraphRouteObserver observes each completed subgraph route at the exact
point where its OVG and the graph's current route state agree. Snapshot
serialization belongs to the engine orchestrator and can be implemented by
this optional observer without making routing depend on engine.
( SubgraphRouteObserver) SubgraphRouted(*OVG) error
SourceMidpoint *geo.Point
SourceOrientationToTarget geo.Orientation
SourcePortNode *OVGNode
TargetMidpoint *geo.Point
TargetPortNode *OVGNode
EntryA *TunnelEntry
EntryB *TunnelEntry
func NewTunnel(entryA, entryB *TunnelEntry) *Tunnel
Node *layoutgraph.Node
OVGNode *OVGNode
func NewTunnelEntry(node *layoutgraph.Node, ovgNode *OVGNode) *TunnelEntry
func NewTunnel(entryA, entryB *TunnelEntry) *Tunnel
Package-Level Functions (total 19)
func BalanceEdgeSegments(ctx context.Context, g *layoutgraph.Graph) error func Crosshatch(ctx context.Context, g *layoutgraph.Graph) error
FixClusterEdgeBranching resolves route branching at cluster boundaries.
func NewOVG(nodesInsideBoundingBox []*layoutgraph.Node) *OVG func NewOVGEdge(from, to *OVGNode) *OVGEdge func NewOVGNode(p *geo.Point) *OVGNode func NewTunnel(entryA, entryB *TunnelEntry) *Tunnel func NewTunnelEntry(node *layoutgraph.Node, ovgNode *OVGNode) *TunnelEntry func NudgeEdgeChannels(ctx context.Context, g *layoutgraph.Graph) error func ReorderDuplicates(ctx context.Context, g *layoutgraph.Graph) error func RouteEdges(ctx context.Context, g *layoutgraph.Graph, edges []*layoutgraph.Edge) error
RouteGraph runs the complete graph-routing stage. The returned boolean is
the updated value of RoutesPreviouslyCompleted; on error the caller must
retain its prior value.
RouteGraphWithWorkLimit is RouteGraph with an explicit aggregate budget.
It exists for deterministic resource-boundary testing inside TALA.
ShortcutEdgeRoutes is a bounded bend-reduction postpass with fixed boxes and
ports. WueOrtho's routing step chooses bend-minimal shortest paths
(https://arxiv.org/html/2309.01671v2#S2), motivating this local adaptation:
replace a subchain by either rectilinear L, retaining only strict bend wins.
It is not a shortest-path solver and does not change the routing grid.
simplifyEdgeRoutes post-processes edge routes to remove unnecessary bending caused by the constraint that routes have to go through OVG nodes
It identifies unnecessary bends in routes and eliminates them when possible.
func StraightEdgesFallback(ctx context.Context, g *layoutgraph.Graph) error
SwapAllEdgePorts applies port swapping to every node under one atomic
route-stage budget and rollback boundary.
TraceEdgesToShapeBorder trims every route endpoint to the rendered shape.
WithSearchTelemetry attaches route-search diagnostics to a routing context.
Package-Level Constants (total 5)
const Default RouteGenerationFlavor = "Default" const LongestToShortest RouteGenerationFlavor = "LongestToShortest"
MaxSearchWorkUnits is the calibrated per-flavor route-search budget.
const ShortestToLongest RouteGenerationFlavor = "ShortestToLongest" const TopDownLeftRight RouteGenerationFlavor = "TopDownLeftRight"
![]() |
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. |