Pruning redundant nodes from DOT graphs
Project description
DotPruner
Pruning redundant nodes from DOT graphs
Before:
After:
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
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
dotpruner-0.1.1.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for dotpruner-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9398602670e1ff5bed435598104108ed506d6738d4508c39f05df35d762b27d3 |
|
MD5 | e2271151e808df74de0169bc04a07ad6 |
|
BLAKE2b-256 | 57ba7996826c8e9f2b8dc4278904e7362fcdeba01d84634c251f9f079245a417 |