tree

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2021 License: Unlicense Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFormatter added in v1.1.0

func NewFormatter(results results) *formatter

Types

type Comparer

type Comparer interface {
	encoding.BinaryMarshaler
	Compare(element []byte) (distance float64, comparedElement string, err error)
}

Compare receives an encoded version of the element stored in the tree `distance` controls how the elements will be partitioned in the hyperplane Ideally, the method should follow the requirements of a distance function See: https://en.wikipedia.org/wiki/Metric_(mathematics)#Definition

type Tree

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

func New

func New(storage storage.Storage) *Tree

New creates a new tree It consider the root element to have ID equals 1

func (*Tree) Add

func (t *Tree) Add(comparer Comparer) error

Add recursively traversals the tree to find the correct insert position for the element

func (*Tree) Plot

func (t *Tree) Plot(writer io.Writer) error

Writes to the writer a graph following the DOT spec https://en.wikipedia.org/wiki/DOT_(graph_description_language)

func (*Tree) Search

func (t *Tree) Search(comparer Comparer, accuracy uint) (results, error)

Search recursively traversals the tree to find the elements the most ressemble the input element

Jump to

Keyboard shortcuts

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