A command-line tool for automatically classifying binary and ternary labelling problems on bipartite rooted trees (hence BRT).
Project description
Tree classifications
This repository contains classifications of some of the problems on rooted binary trees.
Usage
To generage a new problem file:
python -m brt_classifier generate <label-count>
where "label-count" is 2 or 3 will generate problems/problems-temp.json
that contains all non-isomorphic, non-redundant problems. Moreover, it will classify some of those problems that can be automatically classified.
To classify problems in e.g. file problems/3labels.json
:
python -m brt_classifier classify problems/3labels.json
Add a flag -w
at the end, if you want the classification result's changes to persist
To find out problems's complexity e.g. for problem {121, 212}:
python -m brt_classifier find 121 212
Change the constraints at the end of the command to search for a different problem.
To print statistics on a problem file e.g. file problems/3labels.json
:
python -m brt_classifier statistics problems/3labels.json
Notation
The following notation explanation is about 2-label setting, but can be trivially extended to a setting with > 2 labels
We list the problems using sets of allowed restrictions. Since the tree is always binary, we’ll use xyz as a shorthand for “if a node has a label y, then it must have 1 child with label x and one child with label z”. E.g. { 121, 212 } means that if a node has label 2, it must have both children with label 1, and if a node has a label 1, it must have both children with label 2. Another example, {112, 212, 122} means “if a node has label 1, it can either have children with labels 1 and 2 (i.e. children with different labels) or both children with labels 2; if a node has label 2, it must have children with 2 different labels (1, 2)”
Problems
Note that we only consider problems that are non-isomorphic. E.g. { 112, 121 } and { 122, 212 } are isomorphic as we can just map ones to twos and twos to ones in the former instance to get to the latter one.
Besides, we also reduce the number of problems by eliminating redundant constraints wherever possible. E.g. {111, 112, 212} is in essence the same problem as {111} since 2s are never allowed to be a "parent" node. Similarly, {112, 212} is the same as {} (i.e. nothing is allowed) since 2 can never be used as a parent node so we can safely remove both 112 and 212.
2 labels
Most of the problems were rather trivial to classify. Lower and upper bound justifications for a not-so-trivial problem {121, 112} can be found here in the docs folder.
{112, 122} is O(1)-time solvable: each node simply tells one of its children "you will be 1" and the other one "you will be 2". Since {112, 122} is O(1)-time solvable then any problems that are relaxations of it are O(1)-time solvable too. Thus, {112, 212, 122} and {121, 112, 212, 122} were classified as O(1) solvable too.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file brt-classifier-0.1.14.tar.gz
.
File metadata
- Download URL: brt-classifier-0.1.14.tar.gz
- Upload date:
- Size: 259.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3eeccd618255a1adde1456a8cbbae797a57bcb7396cd27997a780437f4feaa85 |
|
MD5 | dc781042be8c5758357d4db8eeb845ad |
|
BLAKE2b-256 | b3d38acfd1add7e33e3349cbd53ed847f85fffcbd466d342060d67f55ea39c40 |
File details
Details for the file brt_classifier-0.1.14-py3-none-any.whl
.
File metadata
- Download URL: brt_classifier-0.1.14-py3-none-any.whl
- Upload date:
- Size: 635.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6bf8bfa0622c09bc3be528671a5ce2f287574a7e1f6424a7b9084ea3c2ebf50 |
|
MD5 | 1578082fece1e9e74dff0f9d13e034ba |
|
BLAKE2b-256 | 57359f3dfd5b9485f82cb623cba774713af87a32356ae2df884d268fedee2618 |