Skip to main content

Tree representation for fast queries of the list of IDs of any subtree

Project description

This library stores tree information in a read-only data structure which supports a fast query of the set of nodes in the subtree under a specified node.

The tree has the following structure: - each node is labeled by a unique positive integer ID - the largest node label shall not be much larger than the number of IDs

If the IDs are non-numerical or contain zero or negative numbers they must be first mapped to positive integers. Using non-unique IDs leads to undefined behaviour.

# Library API

Tree() is the main class of this package.

## Construction of the tree representation

To construct the tree representation, information about the nodes of the tree and their parent node is required.

Tree.construct_from_csv(filename, separator, elem_field_num, parent_field_num) allows to construct the Tree() object from a tabular file, with no header, fields separated by separator and the 0-based numbers of the nodes their parents in the fields specified by elem_field_num and parent_field_num.

Alternatively, an iterator or generator can be passed to Tree.construct(generator) which should yield pairs of values (ID of each node and the corresponding parent node ID).

## Saving and loading from file

The tree representations can be stored to file using the instance method tree.to_file(filename) and re-loaded from such a file using the class method Tree.from_file(filename).

## List of IDs of a subtree

The list of IDs of a subtree whose root is node n is obtained using the instance method: tree.subtree_ids(n).

The return value is an instance of array containing unsigned long long values (it can be used as a Python list for most purposes, and converted to a list if needed).

## Verbosity

The progress bars are enabled by setting fastsubtrees.PROGRESS_ENABLED to True (by default the value is False). The log messages can be activated by using fastsubtrees.enable_logger(“INFO”) and the debug messages by fastsubtrees.enable_logger(“DEBUG”) (by default the logger is disabled).

# Scripts

The script bin/fastsubtrees-construct constructs the tree representation from a tabular file.

The script bin/fastsubtrees-query loads a tree representation from file and performs a subtree IDs query.

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

fastsubtrees-0.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastsubtrees-0.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file fastsubtrees-0.1.tar.gz.

File metadata

  • Download URL: fastsubtrees-0.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.7.0 requests/2.25.1 setuptools/49.6.0.post20210108 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.7.6

File hashes

Hashes for fastsubtrees-0.1.tar.gz
Algorithm Hash digest
SHA256 5016abdc4ca82895f155916b4cc0de9cae86f1538f6c8791cc15a70b784e5fc0
MD5 9b88e0b566b0fee7e59b7b20676b6ae8
BLAKE2b-256 cfe7414e24393f2c10741657d88d84a045e0b3651e4ea6fced158fdbd0848367

See more details on using hashes here.

File details

Details for the file fastsubtrees-0.1-py3-none-any.whl.

File metadata

  • Download URL: fastsubtrees-0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.7.0 requests/2.25.1 setuptools/49.6.0.post20210108 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.7.6

File hashes

Hashes for fastsubtrees-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21d312c1867f500a14f1ca8300332c4c2e245871dbec63aa31e5a2e1ad8c6035
MD5 cd3e29eb100fc70b26e755d995aca4c1
BLAKE2b-256 2b5f62f28578bbc98d060d1dc0025e215c9dd67accafbd86b24cc65049c47307

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page