Skip to content

skit-ai/dagre-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.