depthtree

package module
v0.0.0-...-c5373b1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2019 License: GPL-3.0 Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const EXTENSION = ".bin"

Variables

This section is empty.

Functions

func BytesToInt64

func BytesToInt64(b []byte) (int64, error)

func Int64ToBytes

func Int64ToBytes(i int64) ([]byte, error)

Types

type ChildrenCountClusterPoint

type ChildrenCountClusterPoint struct {
	Node  *Node
	Depth int
}

func (ChildrenCountClusterPoint) Coordinates

func (ChildrenCountClusterPoint) Data

func (c ChildrenCountClusterPoint) Data() interface{}

func (ChildrenCountClusterPoint) Distance

Distance returns the euclidean distance between two coordinates

type ChildrenCountNodeSlice

type ChildrenCountNodeSlice struct {
	// contains filtered or unexported fields
}

func NewChildrenCountNodeSlice

func NewChildrenCountNodeSlice(nodes []*Node, depth int) ChildrenCountNodeSlice

func (ChildrenCountNodeSlice) Len

func (c ChildrenCountNodeSlice) Len() int

func (ChildrenCountNodeSlice) Less

func (c ChildrenCountNodeSlice) Less(i, j int) bool

func (ChildrenCountNodeSlice) Nodes

func (c ChildrenCountNodeSlice) Nodes() []*Node

func (ChildrenCountNodeSlice) Swap

func (c ChildrenCountNodeSlice) Swap(i, j int)

type Cluster

type Cluster struct {
	Center clusters.Coordinates `json:"center"`
	Range  []int                `json:"range"`
	Count  int                  `json:"count"`
	Nodes  []*Node              `json:"nodes,omitempty"`
	Roots  []*Node              `json:"roots,omitempty"`
}

func NewCluster

func NewCluster(cluster clusters.Cluster, depth int) *Cluster

type Database

type Database struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewDatabase

func NewDatabase(dbPath string) *Database

func (*Database) Flush

func (this *Database) Flush()

func (*Database) List

func (this *Database) List() []string

func (*Database) NewTree

func (this *Database) NewTree(name string) *Tree

func (*Database) Open

func (this *Database) Open() error

func (*Database) Truncate

func (this *Database) Truncate(name string)

func (*Database) Use

func (this *Database) Use(name string) *Tree

type DepthClusterPoint

type DepthClusterPoint struct {
	Node *Node
}

func (DepthClusterPoint) Coordinates

func (c DepthClusterPoint) Coordinates() clusters.Coordinates

func (DepthClusterPoint) Data

func (c DepthClusterPoint) Data() interface{}

func (DepthClusterPoint) Distance

Distance returns the euclidean distance between two coordinates

type DepthNodeSlice

type DepthNodeSlice []*Node

func (DepthNodeSlice) Len

func (c DepthNodeSlice) Len() int

func (DepthNodeSlice) Less

func (c DepthNodeSlice) Less(i, j int) bool

func (DepthNodeSlice) Swap

func (c DepthNodeSlice) Swap(i, j int)

type Node

type Node struct {
	Id int64 `json:"i"`

	Children []*Node `json:"c,omitempty"`
	MaxDepth int32   `json:"mxd,omitempty"`
	MinDepth int32   `json:"mnd,omitempty"`

	ChildrenCount int32 `json:"n,omitempty"`

	Meta NodeMeta `json:"meta,omitempty"`
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewNode

func NewNode(id int64) *Node

func (*Node) AddChild

func (this *Node) AddChild(node *Node)

func (*Node) AddChildren

func (this *Node) AddChildren(nodes []*Node)

func (*Node) AddParent

func (this *Node) AddParent(node *Node)

func (*Node) ChildrenCountInDepth

func (this *Node) ChildrenCountInDepth(depth int) int

func (*Node) ChildrenIds

func (this *Node) ChildrenIds() []int64

func (*Node) Copy

func (this *Node) Copy(children []*Node) *Node

func (*Node) CountChildren

func (this *Node) CountChildren(depth int) int

func (*Node) Depth

func (this *Node) Depth() (int, int)

func (*Node) GetChildren

func (this *Node) GetChildren(depth int) ([]*Node, int)

func (*Node) HasChildren

func (this *Node) HasChildren() bool

func (*Node) HasParent

func (this *Node) HasParent() bool

func (*Node) Parents

func (this *Node) Parents() []*Node

func (*Node) PrintTree

func (this *Node) PrintTree(depth int) string

func (*Node) RemoveChild

func (this *Node) RemoveChild(nodeId int64)

func (*Node) RemoveFromChildren

func (this *Node) RemoveFromChildren()

func (*Node) RemoveParent

func (this *Node) RemoveParent(nodeId int64)

func (*Node) String

func (this *Node) String() string

type NodeChildrenDepthCount

type NodeChildrenDepthCount struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewNodeChildrenDepthCount

func NewNodeChildrenDepthCount() *NodeChildrenDepthCount

func (*NodeChildrenDepthCount) Get

func (this *NodeChildrenDepthCount) Get(depth int) int

func (*NodeChildrenDepthCount) Set

func (this *NodeChildrenDepthCount) Set(depth int, count int)

type NodeMeta

type NodeMeta interface {
	String() string
}

type Tree

type Tree struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewTree

func NewTree(name string) *Tree

func (*Tree) AddNode

func (this *Tree) AddNode(from int64, to int64)

func (*Tree) AddRoot

func (this *Tree) AddRoot(id int64)

func (*Tree) ChildrenCountInDepthCluster

func (this *Tree) ChildrenCountInDepthCluster(depth int, k int) []*Cluster

func (*Tree) DepthCluster

func (this *Tree) DepthCluster(k int) []*Cluster

func (*Tree) Find

func (this *Tree) Find(nodeId int64) *Node

func (*Tree) Flush

func (this *Tree) Flush(filePath string) error

func (*Tree) Name

func (this *Tree) Name() string

func (*Tree) Reload

func (this *Tree) Reload(filePath string) error

func (*Tree) RemoveNode

func (this *Tree) RemoveNode(nodeId int64) bool

func (*Tree) RootNodes

func (this *Tree) RootNodes() []*Node

func (*Tree) TopChildrenCounts

func (this *Tree) TopChildrenCounts(depth int, limit int) []*Node

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址