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 #

Convert a bool to an integer

isLeaf :: Tree a -> Bool #

Find out if a node is a leaf or not

leaves :: Tree a -> [a] #

Return the labels of the leaves of the tree

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

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) #

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) #

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) #

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)] #

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] #

Return the inner nodes of the tree

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

Return the number of leaves in a tree

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

Return the number of inner nodes of a tree

hasRootLeaf :: Tree a -> Bool #

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

getRootLeaves :: Tree a -> [a] #

Return the list of root leaves

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

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

filterLeaves :: Tree a -> Tree a #

Remove leaves from a tree

filterRootLeaves :: Tree a -> Tree a #

Remove leaves attached to the root of the tree

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

Return the map of distances from each leaf to another leaf

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

Find the distance between two leaves in a tree.

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

Return the map of distances from each leaf to another leaf

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

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 #

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

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

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