tree-fun-0.8.1.0: Library for functions pertaining to tree exploration and manipulation

Safe HaskellSafe
LanguageHaskell2010

Math.TreeFun.Tree

Description

Collects all functions pertaining to trees

Synopsis

Documentation

boolToInt :: Bool -> Int Source #

Convert a bool to an integer

isLeaf :: Tree a -> Bool Source #

Find out if a node is a leaf or not

leaves :: Tree a -> [a] Source #

Return the labels of the leaves of the tree

leavesHeight :: Ord a => Int -> Tree a -> Map a Int Source #

Return the labels of the leaves of the tree with their relative heights from the root (the input number you give determines how many steps away the leaves are, should almost always start at 0)

leavesCommonHeight :: Ord a => Int -> Tree a -> Map a (Int, Int) Source #

Return the labels of the leaves of the tree with their relative heights from the root (the input number you give determines how many steps away the leaves are, should almost always start at 0). Also, here we give leaves that share a parent a separate label.

leavesParentMult :: Ord a => Double -> Double -> Tree a -> Map a (Double, Double) Source #

Return the labels of the leaves of the tree with their weights determined by the product of the number of children of their parents all the way up to the root, along with their distance. Returns Double for more precision.

leavesCommonParentMult :: Ord a => Int -> Tree a -> Map a (Int, Int) Source #

Return the labels of the leaves of the tree with their weights determined by the product of the number of children of their parents all the way up to the root. Also, here we give leaves that share a parent a separate label.

leavesHeightList :: Int -> Tree a -> [(a, Int)] Source #

Return the labels of the leaves of the tree with their relative heights from the root (the input number you give determines how many steps away the leaves are, should almost always start at 0), slower version not requiring Ord but no Maps

innerNodes :: Tree a -> [a] Source #

Return the inner nodes of the tree

numLeaves :: Num b => Tree a -> b Source #

Return the number of leaves in a tree

numInner :: Num b => Tree a -> b Source #

Return the number of inner nodes of a tree

hasRootLeaf :: Tree a -> Bool Source #

Return True if a tree has a leaf connected to the root of the given tree

getRootLeaves :: Tree a -> [a] Source #

Return the list of root leaves

getProperties :: Eq b => PropertyMap a b -> [b] Source #

Return the list of properties in a property map for a tree

filterLeaves :: Tree a -> Tree a Source #

Remove leaves from a tree

filterRootLeaves :: Tree a -> Tree a Source #

Remove leaves attached to the root of the tree

getDistanceMap :: (Eq a, Ord a) => Tree a -> DistanceMap a Source #

Return the map of distances from each leaf to another leaf

getDistance :: Eq a => Tree a -> a -> a -> Int Source #

Find the distance between two leaves in a tree.

getDistanceMapSuperNode :: (Eq a, Ord a) => Tree (SuperNode a) -> DistanceMap a Source #

Return the map of distances from each leaf to another leaf

getDistanceSuperNode :: (Eq a, Ord a) => Tree (SuperNode a) -> a -> a -> Int Source #

Find the distance between two leaves in a leafNode tree. Begin recording distances when record is True (should have height starting at 0)

sumTree :: Num a => Tree a -> a Source #

Get the sum of a tree for a tree with numbered labels

toSuperNodeTree :: Ord a => SuperNode a -> Tree a -> Tree (SuperNode a) Source #

Convert a tree to the LeafNode tree data structure (the leaves are in the nodes)