Source File
tree.go
Belonging Package
github.com/pancsta/d2/d2layouts/d2talalayout/internal/layoutgraph
package layoutgraphimporttype Tree struct {Node *NodeParent *TreeChildren []*TreeSentinelEdge *EdgeOrientation geo.Orientation}type Trees []*Treefunc ( *Node) *Tree {:= new(Tree).Node =.Children = make([]*Tree, 0)return}func ( *Tree) ( map[*Edge]bool) {if .Parent != nil && .SentinelEdge != nil {[.SentinelEdge] = true}for , := range .Children {.()}}func ( *Graph) () map[*Edge]bool {// Note: this only includes internal tree edges. It doesn't include the edge between the tree root and the rootSentinel:= make(map[*Edge]bool)for , := range .TreeOrder() {for , := range .Trees[] {.recordInternalTreeEdges()}}return}func ( *Graph) ( *Node) bool {if .isContainer {return false}// it is an isolated tree if all edges are to treesfor , := range .Edges {:= falsefor , := range .Trees[] {if == .SentinelEdge {= truebreak}}if ! {return false}}return true}func ( *Graph) ( map[*Edge]bool) {for , := range .TreeOrder() {if .isIsolatedTree() {for , := range .Trees[] {if .SentinelEdge != nil {[.SentinelEdge] = true}}}}}// tree is either the source or target of its sentinel edge, return true if it is the sourcefunc ( *Tree) () bool {return .SentinelEdge.From == .Node}// return the node this tree is connected to via its sentinel edgefunc ( *Tree) () *Node {if .isSentinelEdgeSource() {return .SentinelEdge.To}return .SentinelEdge.From}func ( *Tree) () *Tree {if .Parent == nil {return}return .Parent.()}
![]() |
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. |