TreeDecomp
TreeDecomp is a simple python package for storing and manipulating tree decompositions.
It was originally written as part of infrared, a generic C++/Python hybrid library for efficient (fixed-parameter tractable) Boltzmann sampling.
By default, TreeDecomp runs treewidth_min_fill_in from networkx $20$ times on randomized input and returns the one with the smallest treewidth as treedecomp.TreeDecomposition.
Simple Usage
The class TreeDecompositionFactory creates a tree decomposition for a given hypergraph. The result is stored in TreeDecomposition.
A hypergraph is a pair of integer and a list of lists, where the former one is the number of nodes and the later one is the list of hyperedges.
>>> import treedecomp as td
>>> nb_nodes = 6
>>> hyperedges = [[0,1,5], [2,4], [2,5], [3,4,5]]
>>> tree = treedecomp.TreeDecompositionFactory().create(nb_nodes, hyperedges)
>>> tree.get_bags()
[[4, 5, 3], [4, 5, 2], [5, 1], [5, 0, 1]]
>>> tree.get_edges()
[(0, 1), (0, 2), (2, 3)]
>>> tree.toposorted_bag_indices()
[0, 2, 3, 1]
>>> with open('tree.dot', 'w') as output:
... td.writeTD(output)
Future Work
One can notice TreeDecomp offers two other tree decompoistion factories HTDTreeDecompositionFactory and TDLibTreeDecompositionFactory.
These two are for supporting tree decompoitions using libhtd (via python wrapper) or calling TDlib (written in java) that will be included in the future
Metadata
Release files for treedecomp 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| treedecomp-1.2.0.tar.gz | 21.4 kB | Without provenance | Details for treedecomp-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| treedecomp-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for treedecomp-1.2.0-py3-none-any.whl |
Total release size: 42.5 kB
Release files / treedecomp-1.2.0.tar.gz
| Download URL | treedecomp-1.2.0.tar.gz |
|---|---|
| Size | 21.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a64c5cf5005ab2f4950eeef806e337049ac56f5908917e0849de884833669234
|
|
BLAKE2b-256 checksum How to use checksums |
bd1a819e503679bbfeb3090e3494c24d8be51b254b79c68fddd5b1a1f63841e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / treedecomp-1.2.0-py3-none-any.whl
| Download URL | treedecomp-1.2.0-py3-none-any.whl |
|---|---|
| Size | 21.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c560a8f1f1e44298b2336dc68aa902dce82152c1369d1e1bb73e0c8eba76401
|
|
BLAKE2b-256 checksum How to use checksums |
9c4a36566492bef33dfcef83cf94fd8d486521b41f66f0ead2654799963d4126
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for treedecomp 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.