Skip to content

ansonmiu0214/DotPruner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DotPruner DotPruner Python package Status publish-docs 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

About

Pruning redundant nodes from DOT graphs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages