Skip to main content

Tools around the bubble format (see https://github.com/Aluriak/PowerGrASP#bubble-formatted-file)

Project description

# bubble-tools
python routines related to bubble format, usable in CLI or as a library.

## Installation

pip install bubbletools

See below for usage.


## TODO
- [X] bubble to python
- [ ] python to bubble
- [ ] bubble to dot (via [graphviz](http://graphviz.readthedocs.io/en/latest/))
- [X] working implementation
- [ ] unit testing
- [ ] test on fully valid bubble
- [ ] test on big graphs, for benchmarking (will probably not scale)
- [ ] dot to python
- [ ] unit testing on bubble describing cliques


## CLI
`bubble-tools` is usable through CLI.

### validation
usage:

python3 bubble-tool.py validate path/to/bubble/file

Try hard to find errors and inconsistancies in the given bubble file

Spot powernode overlapping, inclusions inconsistancies
and empty or singleton powernodes.
Profiling gives general informations about the file data.

### conversion to dot
usage:

python3 bubble-tool.py dot path/to/bubble/file path/to/output/file

Convert given bubble file in dot format.
The optional `--render` flag can be used to show the graph after saving.


## python API
Submodules `validator` and `converter` provides the functionnalities described above for CLI:

from bubbletools import validate, convert

for log in validate(open('path/to/bubble.lp'), profiling=True):
print(log)
convert.to_dot(open('path/to/bubble.lp'), dotfile='path/to/dot.dot')

### python representation of the graph
A lower level interface is the `bbltree` submodule, allowing one to manipulate the graph depicted by bubble data as python object.

from bubbletools import bbltree

tree = bbltree.from_bubble_data(open('path/to/bubble.lp'))
edges, inclusions, roots = tree

`edges` is a mapping `predecessor -> set of successors`,
`inclusions` is a mapping `(power)node -> set of (power)nodes directly contained`,
and `roots` is a set of (power)nodes that are contained by nothing.

This representation holds all the data necessary for most work on the bubble.
The `bbltree.connected_components` function maps a graph with its connected components:

cc, subroots = bbltree.connected_components(tree)

Where `cc` and `subroots` are both mapping, respectively linking *the* root of a connected component with all nodes of the connected component,
and *the* root of a connected component with the other roots of the same connected component.
Thus, connected components are identified by one of their roots, which is key is both dictionaries.

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

bubbletools-0.3.1.tar.gz (9.9 kB view details)

Uploaded Source

File details

Details for the file bubbletools-0.3.1.tar.gz.

File metadata

  • Download URL: bubbletools-0.3.1.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for bubbletools-0.3.1.tar.gz
Algorithm Hash digest
SHA256 bef8b2b381cbb97689374c7fd84b1c1768d7fa37c0fc24d1f10b21bfa5c58afe
MD5 b0669d66abe4c157676d1a3be47cf196
BLAKE2b-256 d6a937ed3fd60944ac1ad02f364909d93ed26a1829aceb560c52e1e626d1acc9

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