suffix-tree Documentation — suffix-tree 0.1.1 documentation

# suffix-tree Documentation

suffix-tree is a Generalized Suffix Tree for any Python sequence, with Lowest Common Ancestor retrieval. It:

- works with any Python sequence, not just strings, if the items are hashable,

- is a generalized suffix tree for sets of sequences,

- is implemented in pure Python,

- builds the tree in time proportional to the length of the input,

- does constant-time Lowest Common Ancestor retrieval.

Three different builders have been implemented:

- one that uses McCreight’s \(\mathcal O(\lvert S\rvert)\) algorithm ([McCreight1976]),

- one that uses Ukkonen’s \(\mathcal O(\lvert S\rvert)\) algorithm ([Ukkonen1995]),

- and one that uses a naive (non linear time) algorithm.

Being implemented in Python this tree is not very fast nor memory efficient. The building of the tree takes time proportional to the length of the string of symbols. The query time is proportional to the length of the query string. You can get a rough idea of the performance under: Performance.

To get the best performance turn the python optimizer on with python -O.

Install it from PyPi: https://pypi.org/project/suffix-tree/

Contents:

- Examples
- Tree
  - `Tree`
- Node
  - `Node`
  - `Internal`
  - `Leaf`
  - `UkkonenLeaf`
- LCA Mixin
  - `uint()`
  - `nlz()`
  - `msb()`
  - `h()`
  - `Node`
  - `Leaf`
  - `Internal`
  - `Tree`
- Builders
  - McCreight Builder
  - Ukkonen Builder
  - Naive Builder
  - Base Class for Builders
- Utilities
  - `DEBUG`
  - `DEBUG_DOT`
  - `DEBUG_LABELS`
  - `UniqueEndChar`
  - `min_debug_depth`
  - `debug()`
  - `is_debug()`
  - `ukko_str()`
  - `Path`
- Performance
  - Python 3.10.7
  - PyPy 7.3.9
- References

# Indices and tables

- Index

- Module Index

- Search Page