Skip to main content

DotPruner DotPruner Python package Status PyPI version

Pruning redundant nodes from DOT graphs

Before:

DOT graph before pruning

After:

DOT graph after pruning

Installation

To install DotPruner with pip, run: pip install dotpruner

To install DotPruner from source, first clone the repository and then run: python setup.py install

Usage

CLI

Prune graph "in-place":

python -m dotpruner path/to/original/graph.dot

Use --dest or -d to specify destination for new graph:

python -m dotpruner path/to/original/graph.dot --dest path/to/new/graph.dot

Use --overwrite or -o to overwrite existing file in destination:

python -m dotpruner path/to/original/graph.dot -d path/to/new/graph.dot --overwrite

API

import dotpruner

# string representation of DOT graph
original_graph_str = ...

# pruned graph represented using pydot
pruned_graph = dotpruner.process_from_string(original_graph_str)

Optionally pass in a node_picker function to change which node is preserved in the pruning stage -- by default, the lexicographically smaller node is preserved.

# keep the lexicographically larger node
dotpruner.process_from_string(original_graph_str, node_picker=max)

Tests

python -m unittest discover dotpruner.tests --verbose

Metadata

Release files for dotpruner 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dotpruner 0.1.3
File Size Uploaded
dotpruner-0.1.3.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dotpruner 0.1.3
File Interpreter ABI Platform
dotpruner-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / dotpruner-0.1.3.tar.gz

Download URL dotpruner-0.1.3.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
55631691a0620b3610a960ef5308de160286c85002ad0b1c43190ffb19640f11
BLAKE2b-256 checksum
How to use checksums
ae2103c21876e839079556b4cb00aabe8ff568a989defe66020eaf5d8a8c8165
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.3

Release files / dotpruner-0.1.3-py3-none-any.whl

Download URL dotpruner-0.1.3-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8fca246a594c7dd0f6842765cbc78920fcdf8587a67d45979fb19a30967c8b7b
BLAKE2b-256 checksum
How to use checksums
bc1b57af149256246224729318ba3a798d1b26715482dd037db75fde2f8bdd07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page