Skip to content

Commit bb4c828

Browse files
jonathanbouchetJonathan Bouchetsydney-runkle
authored
added documentation to visualize a graph within a jupyter-notebook (#786)
Co-authored-by: Jonathan Bouchet <[email protected]> Co-authored-by: Sydney Runkle <[email protected]>
1 parent 89ea3a7 commit bb4c828

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docs/graph.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@ stateDiagram-v2
190190
Increment --> DivisibleBy5
191191
```
192192

193+
In order to visualize a graph within a `jupyter-notebook`, `IPython.display` needs to be used:
194+
195+
```python {title="jupyter_display_mermaid.py" test="skip"}
196+
from graph_example import DivisibleBy5, fives_graph
197+
from IPython.display import Image, display
198+
199+
display(Image(fives_graph.mermaid_image(start_node=DivisibleBy5)))
200+
```
201+
193202
## Stateful Graphs
194203

195204
The "state" concept in `pydantic-graph` provides an optional way to access and mutate an object (often a `dataclass` or Pydantic model) as nodes run in a graph. If you think of Graphs as a production line, then your state is the engine being passed along the line and built up by each node as the graph is run.

0 commit comments

Comments
 (0)