Source File
hierarchy.go
Belonging Package
github.com/pancsta/d2/d2layouts/d2talalayout/internal/layoutgraph
package layoutgraph// Hierarchy records the level assigned to each member of a directed, layered// subgraph together with the discovery facts used by later layout stages.// Discovery and placement live in the sibling hierarchy package; this type// remains here because nodes own their hierarchy membership as graph state.type Hierarchy struct {level map[*Node]intLevelCount int}// NewHierarchy creates an empty hierarchy record.func () *Hierarchy {return &Hierarchy{level: make(map[*Node]int)}}// Levels returns the hierarchy's node-to-level mapping. The hierarchy// algorithms mutate this map while assigning and replacing memberships.func ( *Hierarchy) () map[*Node]int {if .level == nil {.level = make(map[*Node]int)}return .level}// ReplaceLevels atomically replaces the node-to-level mapping.func ( *Hierarchy) ( map[*Node]int) {.level =}// HierarchyLevel returns n's assigned level. Callers must only use it for a// node with non-nil Hierarchy membership.func ( *Node) () int {return .Hierarchy.level[]}
![]() |
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. |