Graphviz in Jupyter notebook

at this moment it is a lot of trial and error.

description a e.g. like:

1: digraph G {
2: size ="4,4";
3: main [shape=box]; /* this is a comment */
4: main -> parse [weight=8];
5: parse -> execute;
6: main -> init [style=dotted];
7: main -> cleanup;
8: execute -> { make_string; printf}
9: init -> make_string;
10: edge [color=red]; // so is this
11: main -> printf [style=bold,label="100 times"];
12: make_string [label="make a\nstring"];
13: node [shape=box,style=filled,color=".7 .3 1.0"];
14: execute -> compare;
15: }

How to make it work in the notebook??
Greets grandpa Peter

Sorry, I don’t understand your question, but if your issue is with Jupyter notebook, you should ask them for help.

Hi Steve. the problem is that most examles are lijk that I showed above. Copy paste into a notebook does NOT work, I have to work a bit different e.g.
g = Digraph(…)
g.node(“a”, …)
etc
finally a
g
shows the graph
The main difference is ALL commands are between { and } , while in the Jupyter Notebook
the Digraph has ( and ) for only for example
from graphviz import Digraph

dot = Digraph(comment=‘The Round Table’)
followed by
dot.node(‘1’)
dot.node(‘2’)

Add edge between 1 and 2

dot.edges([‘12’])
dot
and NOT like the post I started.

I also don’t understand the question. Your code is being formatted poorly, you may hve to edit it to be in a code block for us to see.

What python import are you using for Digraph? Can you share an entire notebook file perhaps?

Hi Mark,
I have a github account and put there notebooks … etc,
But is it possible to include here so to as an attachment?
Today and tomorrowmoring I am not online (have to bring my wife to a hospital (150 km away from home and operation) …
In Dutch “Mantelzorger werk” …

from sympy.printing.dot import dotprint
from sympy.abc import x
print(dotprint(x+2))

This gives NOT a graph but only a description what digraph should do:

copy past from notebook

digraph{

# Graph style
"ordering"="out"
"rankdir"="TD"

#########
# Nodes #
#########

"Add(Integer(2), Symbol('x'))_()" ["color"="black", "label"="Add", "shape"="ellipse"];
"Integer(2)_(0,)" ["color"="black", "label"="2", "shape"="ellipse"];
"Symbol('x')_(1,)" ["color"="black", "label"="x", "shape"="ellipse"];

#########
# Edges #
#########

"Add(Integer(2), Symbol('x'))_()" -> "Integer(2)_(0,)";
"Add(Integer(2), Symbol('x'))_()" -> "Symbol('x')_(1,)";
}

if not nice formatted I tyr to append a picture

[edited by Matthew Fernandez to apply correct formatting.]

You could ask the folks over at sympy. This is the forum for Graphviz, the software that can render that code output by dotprint, but we don’t really know anything about sympy.

It looks to me from the sympy docs that the output you’re seeing is expected: https://docs.sympy.org/latest/tutorial/printing.html#dot

Perhaps save that to a file and run it through graphviz – e.g. paste it into http://magjac.com/graphviz-visual-editor/

Thanks Mark,
I think I understand what you mean .
Clear I hope, have to convert the sympy output what graphwizard in my Python Notebook needs.

the problem is: I added graphviz to my Anaconda3 for the Jupyler Notebook, which works nicely in
the Notebooks, BUT it is not that ‘normal’ graphviz users use normally.

Thanks and have a nice Pentecost-days
Peter