Skip to main content

A Generalized Suffix Tree for any iterable, with Lowest Common Ancestor retrieval

Project description

A Generalized Suffix Tree for any Python iterable, with Lowest Common Ancestor retrieval.

pip install suffix-tree
from suffix_tree import Tree

>>> tree = Tree ({ 'A' : 'xabxac' })
>>> tree.find ('abx')
>>> tree.find ('abc')

This suffix tree:

  • works with any Python iterable, not just strings, if the items are hashable,
  • is a generalized suffix tree for sets of iterables,
  • uses Ukkonen’s algorithm to build the tree in linear time,
  • does constant-time Lowest Common Ancestor retrieval,
  • outputs the tree as GraphViz .dot file.

Three different builders have been implemented:

  • one that follows Ukkonen’s original paper ([Ukkonen1995]),
  • one that follows Gusfield’s variant ([Gusfield1997]),
  • and one simple naive algorithm.


[Ukkonen1995]Ukkonen, Esko. On-line construction of suffix trees. 1995. Algorithmica 14:249-60.
[Gusfield1997]Gusfield, Dan. Algorithms on strings, trees, and sequences. 1997. Cambridge University Press.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

suffix-tree-0.0.7.tar.gz (20.0 kB view hashes)

Uploaded source

Built Distribution

suffix_tree-0.0.7-py3-none-any.whl (37.1 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page