package networksimplex
Import Path
github.com/d2lang/elk-go/internal/common/networksimplex (on go.dev)
Dependency Relation
imports 2 packages, and imported by 3 packages
Involved Source Files
adapter.go
Package networksimplex implements ELK's deterministic network-simplex
layering primitive. The implementation is a direct port of ELK v0.8.1's
org.eclipse.elk.alg.common.networksimplex package.
network_simplex.go
Package-Level Type Names (total 8)
Type Parameters:
N: comparable
E: comparable
Adapter lets a caller retain its own node and edge arena IDs while using
the common network-simplex implementation. Nodes and outgoing edges must be
supplied in their Java iteration order.
MinLength func(E) int
Nodes []N
Outgoing func(N) []E
Source func(E) N
Target func(E) N
Weight func(E) float64
func Layer[N, E](adapter Adapter[N, E], options Options) map[N]int
Edge is the Go counterpart of NEdge.
Delta int
ID int
Origin any
Source NodeID
Target NodeID
Weight float64
Other returns the opposite endpoint of edge.
func (*Graph).Edge(id EdgeID) *Edge
func (*Graph).AddEdge(source, target NodeID, weight float64, delta int) EdgeID
func (*Node).ConnectedEdges() []EdgeID
func (*Graph).Edge(id EdgeID) *Edge
func (*Graph).ReverseEdge(id EdgeID)
Graph stores network-simplex nodes and edges in deterministic arenas.
Nodes is the mutable list ELK removes from and appends to while pruning
subtrees. It intentionally differs from the immutable node arena.
AddEdge creates an NEdge and registers it with both endpoints.
AddNode creates and appends an NNode.
(*Graph) Edge(id EdgeID) *Edge
(*Graph) EdgeCount() int
IsAcyclic creates the same topological numbering as NGraph.isAcyclic and
reports whether every edge points forward in it.
MakeConnected adds one artificial root for a disconnected graph and joins
each connected component to it with zero-weight, zero-delta edges. The
second return value reports whether a root was created.
(*Graph) Node(id NodeID) *Node
ReverseEdge reverses edge and updates endpoint incidence lists in the same
order as NGraph.reverseEdge.
func NewGraph() *Graph
func ForGraph(graph *Graph) *NetworkSimplex
NetworkSimplex determines an optimal weighted layering of an acyclic graph.
Execute computes the layering and stores each result in Node.Layer.
(*NetworkSimplex) WithBalancing(balance bool) *NetworkSimplex
(*NetworkSimplex) WithIterationLimit(limit int) *NetworkSimplex
(*NetworkSimplex) WithPreviousLayering(nodeCounts []int) *NetworkSimplex
func ForGraph(graph *Graph) *NetworkSimplex
func (*NetworkSimplex).WithBalancing(balance bool) *NetworkSimplex
func (*NetworkSimplex).WithIterationLimit(limit int) *NetworkSimplex
func (*NetworkSimplex).WithPreviousLayering(nodeCounts []int) *NetworkSimplex
Node is the Go counterpart of NNode.
ID int
IncomingEdges []EdgeID
Layer int
Origin any
OutgoingEdges []EdgeID
ConnectedEdges returns incoming edges followed by outgoing edges, matching
NNode.getConnectedEdges' iteration order.
func (*Graph).Node(id NodeID) *Node
NodeID and EdgeID are stable arena handles. Arena order is Java object
creation order; Nodes separately preserves NGraph's mutable list order.
func (*Edge).Other(node NodeID) NodeID
func (*Graph).AddNode() NodeID
func (*Graph).MakeConnected() (NodeID, bool)
func (*Edge).Other(node NodeID) NodeID
func (*Graph).AddEdge(source, target NodeID, weight float64, delta int) EdgeID
func (*Graph).Node(id NodeID) *Node
Options configures the callback-based Layer entry point.
Balance bool
IterationLimit int
PreviousLayeringNodeCounts []int
func Layer[N, E](adapter Adapter[N, E], options Options) map[N]int
Package-Level Functions (total 3)
func ForGraph(graph *Graph) *NetworkSimplex
Type Parameters:
N: comparable
E: comparable
Layer maps a caller-owned acyclic graph into ELK's common graph, executes
network simplex, and returns layers keyed by the original node IDs.
![]() |
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. |