tests/weghting_n_cutting_the_tree/func_models.go

31 lines
489 B
Go

package main
import "encoding/json"
type Node struct {
ID string `json:"id"`
Name string `json:"name"`
Children []*Node `json:"children"`
}
type WeightedNode struct {
node *Node
parent *Node
children []*Node
weight uint16
}
type SubTree struct {
path string
tree *Node
}
func (root *Node) getNodeWeight() uint16 {
nodeBytes, _ := json.Marshal(&Node{
ID: root.ID,
Name: root.Name,
Children: []*Node{},
})
return uint16(len(nodeBytes))
}