tree

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package tree provides a struct and functions that allow for creating binary trees modifying them, and doing calculations on them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Draw

func Draw(node *Tree, imageWidth int, imageHeight int) (*image.RGBA, error)

Draw prints a tree to as an image. The function takes a pointer to the root of the tree along with the desired height and width of the output image.

func Height

func Height(node *Tree) float64

Height returns the maximum cumulative branch length from the input tree node to a leaf node.

func ToString

func ToString(node *Tree) string

ToString takes a pointer to the root of a tree and returns that tree as a text representation of the tree in newick format.

func WriteNewick

func WriteNewick(filename string, node *Tree) error

WriteNewick takes a filename and a pointer to the root of a tree. It writes the tree to the file in newick format.

Types

type Tree

type Tree struct {
	Name         string
	OnlyTopology bool
	BranchLength float64
	Left         *Tree
	Right        *Tree
}

A Tree is a node in a binary tree

func ParseDot

func ParseDot(input string, verbose bool) *Tree

ParseDot takes in the filename of a filename of a tree in "dot" format and a verbose flag that can be used to print debugging info. ParseDot returns a pointer to the root node of the tree.

func ParseNewick

func ParseNewick(input string) (*Tree, error)

ParseNewick takes a newick tree as an input string and returns a pointer to the root of the tree.

func ReadNewick

func ReadNewick(filename string) (*Tree, error)

ReadNewick takes a filename of a newick tree as input and returns a pointer to the root of the tree.

Jump to

Keyboard shortcuts

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