ipydagred3

0.4.1 · active · verified Tue Apr 14

ipydagred3 is an ipywidgets library designed for drawing and interacting with directed acyclic graphs (DAGs) directly within JupyterLab environments using the dagre-d3 JavaScript library. It enables dynamic creation and modification of graph structures from Python, including control over node/edge styles, tooltips, and click event handling. The library is currently in a 'Beta' development status (version 0.4.1) and provides interactive features for data pipeline visualization and similar applications.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a simple directed graph with nodes and edges, customize their appearance, and display it within a Jupyter Notebook or JupyterLab environment. The `display()` function from `IPython.display` is used to render the widget.

from ipydagred3 import Graph
from IPython.display import display

# Create a new graph
g = Graph()

# Add nodes
g.add_node("A", label="Start Node")
g.add_node("B", label="Process B", shape='rect')
g.add_node("C", label="End Node")

# Add edges
g.add_edge("A", "B", label="step 1")
g.add_edge("B", "C", label="step 2", style='stroke-dasharray: 5, 5;')

# Display the graph in a Jupyter environment
display(g)

view raw JSON →