# TdVisu
![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)
[![PyPI license](https://img.shields.io/pypi/l/tdvisu.svg)](https://pypi.python.org/pypi/tdvisu/)
![Tests](https://github.com/VaeterchenFrost/tdvisu/workflows/Tests/badge.svg)
[![codecov](https://codecov.io/gh/VaeterchenFrost/tdvisu/branch/main/graph/badge.svg)](https://codecov.io/gh/VaeterchenFrost/tdvisu)
![GitHub release (latest SemVer including pre-releases)](https://img.shields.io/github/v/release/vaeterchenfrost/tdvisu?include_prereleases)
[![PyPI version fury.io](https://badge.fury.io/py/tdvisu.svg)](https://pypi.python.org/pypi/tdvisu/)
![GitHub commits since latest release (by SemVer)](https://img.shields.io/github/commits-since/VaeterchenFrost/tdvisu/latest)
[![PyPI status](https://img.shields.io/pypi/status/tdvisu.svg)](https://pypi.python.org/pypi/tdvisu/)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/tdvisu.svg)](https://pypi.python.org/pypi/tdvisu/)
![PyPI - Wheel](https://img.shields.io/pypi/wheel/tdvisu)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/VaeterchenFrost/tdvisu)
---
Visualization for [dynamic programming](https://en.wikipedia.org/wiki/Dynamic_programming) on [tree decompositions](https://en.wikipedia.org/wiki/Tree_decomposition).
Create a graph object for each given graph that is of interest for the dynamic programming.
The visualization generates highlights and adds solution-tables for user defined time steps.
These snapshot of the graphs will be written in a graphviz-supported file-format to a folder of your choosing.
For the portable and light weight '.svg' format, all graphs for a timestep can be joined together to provide a thoroughly view on the process of dynamic programming.
With the '.svg' format the images are highly customizable, and even combining several timesteps together using svg [animate](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/animate) would be an option in the future.
---
# Using
> Note: see also the steps prepared in the CI/CD [.github/workflows/python-app.yml](https://github.com/VaeterchenFrost/tdvisu/actions/workflows/python-app.yml):
[Graphviz (>=2.38)](https://graphviz.gitlab.io/download/). Be aware of changes in default layouts over different major versions of Graphviz. The project currently tests with `graphviz-version: "12.2.1"`.
[python-benedict[xml]](https://pypi.org/project/python-benedict/)
PostgreSQL adapter for Python: [psycopg (3)](https://www.psycopg.org/docs/index.html)
---
# To register the graphviz plugins
https://gitlab.com/graphviz/graphviz/-/issues/1352
```shell
dot.exe -c
```
# To install
In a command prompt with pip (to get _pip_ see: https://pip.pypa.io/en/stable/) installed:
Just run
```shell
pip install -h (for more information on install options)
pip install tdvisu
```
To download the latest version from the default branch:
```shell
git clone --depth 1 --single https://github.com/VaeterchenFrost/tdvisu
```
# To isolate the dependencies
With [virtualenv](https://virtualenv.pypa.io/en/latest/installation.html) on the system installed you can isolate the environment, for example
```shell
virtualenv tdvisu_dir -p 3.12
cd tdvisu_dir/bin/
source activate
# Windows: ./tdvisu_dir/Scripts/activate
```
With [Conda](https://docs.conda.io/en/latest/) on the system installed the dependencies for this project can be automatically installed in a new environment:
Go to the projects base directory.
Open a _conda-command-prompt_ with admin privileges and run the commands from the project folder
- to create a new environment with basic dependencies:
```shell
conda env create -f ./environment.yml
```
- to activate the environment:
```shell
conda activate tdvisu
```
# Install from source
To clone the complete repository:
```shell
git clone https://github.com/VaeterchenFrost/tdvisu
```
To download only the latest version from the default branch:
```shell
git clone --depth 1 --single https://github.com/VaeterchenFrost/tdvisu
```
To install the project from the source folder:
```shell
pip install -h (for more information on install options)
pip install .
```
to confirm that the visualization finds all dependencies:
```shell
python ./tdvisu/visualization.py -h
```
to run all tests:
```shell
pip install .[test]
pytest ./test/
```
---
# How to use
The visualization needs input in the form of the [Json API](https://github.com/VaeterchenFrost/gpusat-VISU/blob/main/JsonAPI_v1.3.md).
The creation of this file is exemplary implemented in _construct_dpdb_visu.py_ or the fork [GPUSAT](https://github.com/VaeterchenFrost/GPUSAT) and _--visufile filename_ (optionally disabling preprocessing with _-p_).
Run the python file with the above dependencies installed:
[visualization.py](https://github.com/VaeterchenFrost/gpusat-VISU/blob/main/satvisualization_repo/satvisu/visualization.py)
**visualization.py** takes two parameters, the json-**infile** to read from, and optionally one **outputfolder**.
With both arguments a run might look like this:
```shell
python tdvisu/visualization.py visugpusat.json examplefolder
```
For #SAT it produces for example three different graphs suffixed with a running integer to represent timesteps:
- _TDStep_ the tree decomposition with solved nodes
- _PrimalGraphStep_ the primal graph with currently active variables highlighted
- _IncidenceGraphStep_ the bipartite incidence graph with active clauses/variables highlighted
The graphs are images encoded in resolution independent **.svg files** (see https://www.lifewire.com/svg-file-4120603)
<p align="center"><img src="https://raw.githubusercontent.com/VaeterchenFrost/tdvisu/main/doc/images/combined6DA4.svg?sanitize=true" width="70%"/></p>
## How to use construct_dpdb_visu.py
After installing the project [dp_on_dbs](https://github.com/hmarkus/dp_on_dbs) with the there listed [requirements](https://github.com/hmarkus/dp_on_dbs#requirements), we need to
- edit the [database.ini](https://github.com/VaeterchenFrost/tdvisu/blob/main/tdvisu/database.ini) with our password to [postgresql](https://www.postgresql.org/)
- Solve a problem with `python dpdb.py [GENERAL-OPTIONS] -f <INPUT-FILE> <PROBLEM> [PROBLEM-SPECIFIC-OPTIONS]`
- for the problem **VertexCover**
- with flag `--gr-file` to store the htd Input (if the input was in a different format)
- for the problem **SharpSat**
- with flag `--store-formula` to store the formula in the database
- Run
- **Sat** / **SharpSat**: `python construct_dpdb_visu.py [PROBLEMNUMBER]`
- **VertexCover**: `python construct_dpdb_visu.py [PROBLEMNUMBER] --twfile [TWFILE]`
with the file in DIMACS tw-format containing the edges of the graph.
# Installation of the psycopg package
See https://www.psycopg.org/psycopg3/docs/basic/install.html
**Note** Whatever version of `libpq` psycopg is compiled with, it will be possible to connect to PostgreSQL servers of any [supported version](https://www.psycopg.org/docs/install.html#prerequisites): just install the most recent libpq version or the most practical, without trying to match it to the version of the PostgreSQL server you will have to connect to.
---
# New Release
## Version
- Bump `/version.py` according to the changes made
- Change date to the release day, keep format
## Requirements
In case dependencies have changed, or just to update some, check
- _requirements.txt_
- _stable-requirements.txt_ (using `pip freeze`)
- _setup.py_
## Write Changelog.md
- Add tag with link (see bottom for linking examples)
- Add changes, maybe some are already in _Unreleased_
- Update _Unreleased_ with **(No) unreleased changes**
## Review code
- Run tests (pytest)
- Check codestyle (pylint)
## Push
- Push changes to main
- Wait for all automated checks! (All checks have passed...)
## Create Release
- On the GitHub page go to: Release, **[Draft a new release](https://github.com/VaeterchenFrost/tdvisu/releases/new)**
- Enter v'YOUR VERSION NUMBER' as the tag.
- Add a **Release Title** (could be just the version)
- Add some description (like in the CHANGELOG.md)
- Click on **Publish release** on the bottom
## Should automatically release to [PyPI](https://pypi.org/project/tdvisu/)
- For details see: [Upload Python Package](https://github.com/VaeterchenFrost/tdvisu/blob/main/.github/workflows/python-publish.yml)
**Now you are set for the new release :tada:**
---
Raw data
{
"_id": null,
"home_page": "https://github.com/VaeterchenFrost/tdvisu",
"name": "tdvisu",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "graph visualization dynamic-programming msol-solver",
"author": "Martin R\u00f6bke",
"author_email": "martin.roebke@web.de",
"download_url": "https://files.pythonhosted.org/packages/7e/be/ce36e6a7644c35925aa1d8b1e3e68642557172bfed14847fa78a8b615bcb/tdvisu-1.2.0.tar.gz",
"platform": "any",
"description": "# TdVisu\n\n![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)\n[![PyPI license](https://img.shields.io/pypi/l/tdvisu.svg)](https://pypi.python.org/pypi/tdvisu/)\n![Tests](https://github.com/VaeterchenFrost/tdvisu/workflows/Tests/badge.svg)\n[![codecov](https://codecov.io/gh/VaeterchenFrost/tdvisu/branch/main/graph/badge.svg)](https://codecov.io/gh/VaeterchenFrost/tdvisu)\n\n![GitHub release (latest SemVer including pre-releases)](https://img.shields.io/github/v/release/vaeterchenfrost/tdvisu?include_prereleases)\n[![PyPI version fury.io](https://badge.fury.io/py/tdvisu.svg)](https://pypi.python.org/pypi/tdvisu/)\n![GitHub commits since latest release (by SemVer)](https://img.shields.io/github/commits-since/VaeterchenFrost/tdvisu/latest)\n[![PyPI status](https://img.shields.io/pypi/status/tdvisu.svg)](https://pypi.python.org/pypi/tdvisu/)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/tdvisu.svg)](https://pypi.python.org/pypi/tdvisu/)\n![PyPI - Wheel](https://img.shields.io/pypi/wheel/tdvisu)\n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/VaeterchenFrost/tdvisu)\n\n---\n\nVisualization for [dynamic programming](https://en.wikipedia.org/wiki/Dynamic_programming) on [tree decompositions](https://en.wikipedia.org/wiki/Tree_decomposition).\n\nCreate a graph object for each given graph that is of interest for the dynamic programming.\n\nThe visualization generates highlights and adds solution-tables for user defined time steps.\n\nThese snapshot of the graphs will be written in a graphviz-supported file-format to a folder of your choosing.\n\nFor the portable and light weight '.svg' format, all graphs for a timestep can be joined together to provide a thoroughly view on the process of dynamic programming.\n\nWith the '.svg' format the images are highly customizable, and even combining several timesteps together using svg [animate](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/animate) would be an option in the future.\n\n---\n\n# Using\n\n> Note: see also the steps prepared in the CI/CD [.github/workflows/python-app.yml](https://github.com/VaeterchenFrost/tdvisu/actions/workflows/python-app.yml):\n\n[Graphviz (>=2.38)](https://graphviz.gitlab.io/download/). Be aware of changes in default layouts over different major versions of Graphviz. The project currently tests with `graphviz-version: \"12.2.1\"`.\n\n[python-benedict[xml]](https://pypi.org/project/python-benedict/)\n\nPostgreSQL adapter for Python: [psycopg (3)](https://www.psycopg.org/docs/index.html)\n\n---\n\n# To register the graphviz plugins\n\nhttps://gitlab.com/graphviz/graphviz/-/issues/1352\n\n```shell\ndot.exe -c\n```\n\n# To install\n\nIn a command prompt with pip (to get _pip_ see: https://pip.pypa.io/en/stable/) installed:\nJust run\n\n```shell\npip install -h (for more information on install options)\npip install tdvisu\n```\n\nTo download the latest version from the default branch:\n\n```shell\ngit clone --depth 1 --single https://github.com/VaeterchenFrost/tdvisu\n```\n\n# To isolate the dependencies\n\nWith [virtualenv](https://virtualenv.pypa.io/en/latest/installation.html) on the system installed you can isolate the environment, for example\n\n```shell\nvirtualenv tdvisu_dir -p 3.12\ncd tdvisu_dir/bin/\nsource activate\n# Windows: ./tdvisu_dir/Scripts/activate\n```\n\nWith [Conda](https://docs.conda.io/en/latest/) on the system installed the dependencies for this project can be automatically installed in a new environment:\n\nGo to the projects base directory.\n\nOpen a _conda-command-prompt_ with admin privileges and run the commands from the project folder\n\n- to create a new environment with basic dependencies:\n\n```shell\nconda env create -f ./environment.yml\n```\n\n- to activate the environment:\n\n```shell\nconda activate tdvisu\n```\n\n# Install from source\n\nTo clone the complete repository:\n\n```shell\ngit clone https://github.com/VaeterchenFrost/tdvisu\n```\n\nTo download only the latest version from the default branch:\n\n```shell\ngit clone --depth 1 --single https://github.com/VaeterchenFrost/tdvisu\n```\n\nTo install the project from the source folder:\n\n```shell\npip install -h (for more information on install options)\npip install .\n```\n\nto confirm that the visualization finds all dependencies:\n\n```shell\npython ./tdvisu/visualization.py -h\n```\n\nto run all tests:\n\n```shell\npip install .[test]\npytest ./test/\n```\n\n---\n\n# How to use\n\nThe visualization needs input in the form of the [Json API](https://github.com/VaeterchenFrost/gpusat-VISU/blob/main/JsonAPI_v1.3.md).\nThe creation of this file is exemplary implemented in _construct_dpdb_visu.py_ or the fork [GPUSAT](https://github.com/VaeterchenFrost/GPUSAT) and _--visufile filename_ (optionally disabling preprocessing with _-p_).\n\nRun the python file with the above dependencies installed:\n[visualization.py](https://github.com/VaeterchenFrost/gpusat-VISU/blob/main/satvisualization_repo/satvisu/visualization.py)\n\n**visualization.py** takes two parameters, the json-**infile** to read from, and optionally one **outputfolder**.\nWith both arguments a run might look like this:\n\n```shell\npython tdvisu/visualization.py visugpusat.json examplefolder\n```\n\nFor #SAT it produces for example three different graphs suffixed with a running integer to represent timesteps:\n\n- _TDStep_ the tree decomposition with solved nodes\n- _PrimalGraphStep_ the primal graph with currently active variables highlighted\n- _IncidenceGraphStep_ the bipartite incidence graph with active clauses/variables highlighted\n\nThe graphs are images encoded in resolution independent **.svg files** (see https://www.lifewire.com/svg-file-4120603)\n\n<p align=\"center\"><img src=\"https://raw.githubusercontent.com/VaeterchenFrost/tdvisu/main/doc/images/combined6DA4.svg?sanitize=true\" width=\"70%\"/></p>\n\n## How to use construct_dpdb_visu.py\n\nAfter installing the project [dp_on_dbs](https://github.com/hmarkus/dp_on_dbs) with the there listed [requirements](https://github.com/hmarkus/dp_on_dbs#requirements), we need to\n\n- edit the [database.ini](https://github.com/VaeterchenFrost/tdvisu/blob/main/tdvisu/database.ini) with our password to [postgresql](https://www.postgresql.org/)\n- Solve a problem with `python dpdb.py [GENERAL-OPTIONS] -f <INPUT-FILE> <PROBLEM> [PROBLEM-SPECIFIC-OPTIONS]`\n - for the problem **VertexCover**\n - with flag `--gr-file` to store the htd Input (if the input was in a different format)\n - for the problem **SharpSat**\n - with flag `--store-formula` to store the formula in the database\n- Run\n - **Sat** / **SharpSat**: `python construct_dpdb_visu.py [PROBLEMNUMBER]`\n - **VertexCover**: `python construct_dpdb_visu.py [PROBLEMNUMBER] --twfile [TWFILE]`\n with the file in DIMACS tw-format containing the edges of the graph.\n\n# Installation of the psycopg package \n\nSee https://www.psycopg.org/psycopg3/docs/basic/install.html\n\n**Note** Whatever version of `libpq` psycopg is compiled with, it will be possible to connect to PostgreSQL servers of any [supported version](https://www.psycopg.org/docs/install.html#prerequisites): just install the most recent libpq version or the most practical, without trying to match it to the version of the PostgreSQL server you will have to connect to.\n\n---\n\n# New Release\n\n## Version\n\n- Bump `/version.py` according to the changes made\n- Change date to the release day, keep format\n\n## Requirements\n\nIn case dependencies have changed, or just to update some, check\n\n- _requirements.txt_\n- _stable-requirements.txt_ (using `pip freeze`)\n- _setup.py_\n\n## Write Changelog.md\n\n- Add tag with link (see bottom for linking examples)\n- Add changes, maybe some are already in _Unreleased_\n- Update _Unreleased_ with **(No) unreleased changes**\n\n## Review code\n\n- Run tests (pytest)\n- Check codestyle (pylint)\n\n## Push\n\n- Push changes to main\n- Wait for all automated checks! (All checks have passed...)\n\n## Create Release\n\n- On the GitHub page go to: Release, **[Draft a new release](https://github.com/VaeterchenFrost/tdvisu/releases/new)**\n- Enter v'YOUR VERSION NUMBER' as the tag.\n- Add a **Release Title** (could be just the version)\n- Add some description (like in the CHANGELOG.md)\n- Click on **Publish release** on the bottom\n\n## Should automatically release to [PyPI](https://pypi.org/project/tdvisu/)\n\n- For details see: [Upload Python Package](https://github.com/VaeterchenFrost/tdvisu/blob/main/.github/workflows/python-publish.yml)\n\n**Now you are set for the new release :tada:**\n\n---\n",
"bugtrack_url": null,
"license": "GPLv3",
"summary": "Visualizing Dynamic Programming on Tree Decompositions.",
"version": "1.2.0",
"project_urls": {
"Homepage": "https://github.com/VaeterchenFrost/tdvisu"
},
"split_keywords": [
"graph",
"visualization",
"dynamic-programming",
"msol-solver"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9793d04156d03eb35dce354cc5c850598997777b47b63727396704a272b20723",
"md5": "859b930f3612ff40ebbccdd37bbc3f32",
"sha256": "a5486cefa52a43abd6b61697347945eb83f3db000ea451436d21cae42f2c4f7b"
},
"downloads": -1,
"filename": "tdvisu-1.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "859b930f3612ff40ebbccdd37bbc3f32",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 59533,
"upload_time": "2024-12-23T23:43:26",
"upload_time_iso_8601": "2024-12-23T23:43:26.227770Z",
"url": "https://files.pythonhosted.org/packages/97/93/d04156d03eb35dce354cc5c850598997777b47b63727396704a272b20723/tdvisu-1.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7ebece36e6a7644c35925aa1d8b1e3e68642557172bfed14847fa78a8b615bcb",
"md5": "8421eedfcf89d2e65aa0bb4f1ac6818e",
"sha256": "e92ef56ea1889012b3f739180a53bb6ebce90162bca8e2e05e0063efa81060b8"
},
"downloads": -1,
"filename": "tdvisu-1.2.0.tar.gz",
"has_sig": false,
"md5_digest": "8421eedfcf89d2e65aa0bb4f1ac6818e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 72537,
"upload_time": "2024-12-23T23:43:28",
"upload_time_iso_8601": "2024-12-23T23:43:28.549493Z",
"url": "https://files.pythonhosted.org/packages/7e/be/ce36e6a7644c35925aa1d8b1e3e68642557172bfed14847fa78a8b615bcb/tdvisu-1.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-23 23:43:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "VaeterchenFrost",
"github_project": "tdvisu",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "graphviz",
"specs": [
[
"~=",
"0.20"
]
]
},
{
"name": "hypothesis",
"specs": [
[
"~=",
"6.122"
]
]
},
{
"name": "psycopg",
"specs": [
[
"~=",
"3.2.3"
]
]
},
{
"name": "pytest-mock",
"specs": [
[
"~=",
"3.14"
]
]
},
{
"name": "pytest",
"specs": [
[
"~=",
"8.3"
]
]
},
{
"name": "python-benedict",
"specs": [
[
"~=",
"0.34.0"
]
]
},
{
"name": "PyYAML",
"specs": [
[
"~=",
"6.0"
]
]
},
{
"name": "xmltodict",
"specs": [
[
"~=",
"0.14.2"
]
]
}
],
"lcname": "tdvisu"
}