lca

O(log n) persistent online lowest common ancestor search without preprocessing

http://github.com/ekmett/lca/

LTS Haskell 23.1:0.4
Stackage Nightly 2024-12-27:0.4
Latest on Hackage:0.4

See all snapshots lca appears in

BSD-3-Clause licensed by Edward A. Kmett
Maintained by Edward A. Kmett
This version can be pinned in stack with:lca-0.4@sha256:164b1ed37d5a297a8e5a8493891e579db654deff547514a060d96a181dee5939,2349

Module documentation for 0.4

Depends on 1 package(full list with versions):

lca: O(log h) Online Lowest Common Ancestor Search

Hackage Build Status

This package provides a reference implementation of my skew binary random access algorithm for performing an online lowest common ancestor in logarithmic time without preprocessing. This improves the previous known asymptotic bound for this problem from O(h) to O(log h), where h is the height of the tree. Mostly importantly this bound is completely independent of the width or overall size of the tree, enabling you to calculate lowest common ancestors in a distributed fashion with good locality.

While algorithms exist that that provide O(1) query time, they all require O(n) preprocessing, where n is the size of the entire tree, and so are less suitable for LCA search in areas such as revision control where the tree is constantly updated, or distributed computing where the tree may be too large to fit in any one computer’s memory.

Slides are available as Purely Functional Data Structures for On-Line LCA

Contact Information

Contributions and bug reports are welcome!

Please feel free to contact me through github or on the #haskell IRC channel on irc.freenode.net.

-Edward Kmett

Changes

0.4 [2021.02.17]

  • lca now always exports null and length functions that are always specialized to Path, i.e.,

    length :: Path a -> Int
    null :: Path a -> Bool
    

    Previously, these specialized versions of null and length were only exported with GHC 7.8 or older, and for more recent GHCs, the Data.Foldable versions were exported instead. The exported API is now uniform across all supported versions of GHC.

  • The build-type has been changed from Custom to Simple. To achieve this, the doctests test suite has been removed in favor of using cabal-docspec to run the doctests.

0.3.1 [2018.02.06]

  • Fix the build with GHC 8.4.
  • Use cabal-doctest for the test suite.

0.3

  • Updated to build without warnings in the wake of GHC 7.10.
  • Use (and re-export) the new overloaded null and length from Prelude on GHC 7.10+
  • Modified mkeep, mdrop and mlca to parameterize them by monoid homomorphisms. This permits cheaper summaries to be calculated over the dropped path, when only a portion of the information in the path is required.

0.2.4

  • Fixed a bug in path reconstruction

0.2.3

  • Improved documentation to also note that this package also provides an improvement in the online version of the level ancestor problem.

0.2.2

  • Added README
  • Better haddock coverage
  • Added links to documentation