haccepted-0.1.0.0: Data structures and algorithms
Safe HaskellNone
LanguageHaskell2010

CentroidDecomp

Description

Centroid decomposition

A recursive decomposition (divide-and-conquer) of a tree into multiple subtrees. This allows performing certain operations involving paths on the original tree effectively, by taking every path on the tree into account exactly once when it passes through the root of a decomposed subtree. The roots of the subtrees are chosen to be centroids so that the recursive decomposition has logarithmic depth.

Sources:

Synopsis

Documentation

centroidDecompose :: Tree a -> Tree (Tree a) Source #

Performs centroid decomposition on a tree of n nodes, returning the decomposition as a tree of n trees. O(n log n).

centroidDecomposeL :: LTree b a -> Tree (LTree b a) Source #

Same as centroidDecompose, for edge-labelled graphs. O(n log n).