Giter Site home page Giter Site logo

dotpruner's Introduction

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

dotpruner's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.