| Copyright | (c) Dominik Schrempf 2019 |
|---|---|
| License | GPL-3 |
| Maintainer | dominik.schrempf@gmail.com |
| Stability | unstable |
| Portability | portable |
| Safe Haskell | None |
| Language | Haskell2010 |
ELynx.Data.Tree.Bipartition
Description
Creation date: Fri Aug 30 15:28:17 2019.
Bipartitions are weird in that
> Bipartition x y == Bipartition y x
is True.
Also,
> Bipartition x y > Bipartition y x
is False, even when x > y.
That's why we have to make sure that for
> Bipartition x y
we always have x >= y.
Synopsis
- data Bipartition a
- bps :: Bipartition a -> (Subset a, Subset a)
- bp :: Ord a => Subset a -> Subset a -> Bipartition a
- bpmap :: (Ord a, Ord b) => (a -> b) -> Bipartition a -> Bipartition b
- bphuman :: (a -> String) -> Bipartition a -> String
- bipartition :: Ord a => Tree a -> Bipartition a
- bipartitions :: Ord a => Tree a -> Set (Bipartition a)
- bipartitionToBranchLength :: (Ord a, Ord b, Monoid c) => (a -> b) -> (a -> c) -> Tree a -> Map (Bipartition b) c
- compatible :: (Show a, Ord a) => Bipartition a -> Subset a -> Bool
The Bipartition data type.
data Bipartition a Source #
Each branch of a tree partitions the leaves of the tree into two
Subsets, or a bipartition. Also the order of the two partitions of the
Bipartition is not important (see the Eq instance).
Instances
bpmap :: (Ord a, Ord b) => (a -> b) -> Bipartition a -> Bipartition b Source #
Map a function over all elements in the Bipartitions.
bphuman :: (a -> String) -> Bipartition a -> String Source #
Show a bipartition in a human readable form. Use a provided function to extract the valuable information.
Working with Bipartitions.
bipartition :: Ord a => Tree a -> Bipartition a Source #
For a bifurcating root, get the bipartition induced by the root node.
bipartitions :: Ord a => Tree a -> Set (Bipartition a) Source #
Get all bipartitions of the tree.
bipartitionToBranchLength Source #
Arguments
| :: (Ord a, Ord b, Monoid c) | |
| => (a -> b) | Convert node labels to leaves (usually leaf names) |
| -> (a -> c) | Get length of branch attached to node |
| -> Tree a | Tree to dissect |
| -> Map (Bipartition b) c |
For a given rose Tree, remove all degree two nodes and reconnect the
resulting disconnected pairs of branches and sum their branch lengths. For
this operation, a combining binary function and a unity element is required,
and so we need the Monoid type class constraint. Now, each branch on the
tree defines a unique Bipartition of leaves. Convert a tree into a Map
from each Bipartition to the length of the branch inducing the respective
Bipartition. The relevant information about the leaves is extracted from
the (leaf) nodes with a given function. Also check if leaves are unique.
compatible :: (Show a, Ord a) => Bipartition a -> Subset a -> Bool Source #
Determine compatibility between an bipartition and a subset. If both
subsets of the bipartition share elements with the given subset, the
bipartition is incompatible with this subset. If all elements of the subset
are either not in the bipartition or mapping to one of the two subsets of the
bipartition, the bipartition and the subset are compatible. See also
compatible.