Skip to content

Latest commit

 

History

History
47 lines (35 loc) · 1.48 KB

README.org

File metadata and controls

47 lines (35 loc) · 1.48 KB

dagre-py

https://img.shields.io/travis/com/Vernacular-ai/dagre-py/master.svg?style=flat-square https://img.shields.io/pypi/v/dagre-py.svg?style=flat-square

Thin python wrapper around dagre-d3 for building quick dags with tooltips and a few other niceties. It’s not really generically usable right now, but you can try something like:

from dagre_py.core import plot

plot({
    "nodes": [
        {"label": "A"},
        {"label": "B", "description": "This is an output node"}
    ],
    "edges": [{"source": "A", "target": "B", "label": "edge1"},
              {"source": "A", "target": "B", "label": "edge2"}]
})

With the following effect:

./screens/multi-edges.png

It’s also possible to use an id field coupled with a label to disambiguate nodes that you want to have the same label. Where source and target fields in edges use node id instead of node label. For example:

from dagre_py.core import plot

plot({
    "nodes": [
        {"label": "A", "id": "A"},
        {"label": "A", "id": "B", "description": "This is an output node"}
    ],
    "edges": [{"source": "A", "target": "B"}]
})

With the following effect:

./screens/duplicate-labels.png

For more description of the data that goes in, check the docstring of dagre_py.core.plot function.