# Python's graphviz module

**URL:** <https://forum.graphviz.org/t/pythons-graphviz-module/2697>\
**Category:** Uncategorized\
**Created:** [February 6, 2025, 9:16pm UTC](https://forum.graphviz.org/t/pythons-graphviz-module/2697 "2025-02-06T21:16:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjon](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@jjon](https://forum.graphviz.org/u/jjon)\
**Post date:** [February 6, 2025, 9:16pm UTC](https://forum.graphviz.org/t/pythons-graphviz-module/2697/1 "2025-02-06T21:16:47Z")

</div>

Doing this in dot is trivial  
[dot]  
strict digraph G  
{  
node[shape=ellipse];  
NodeI → NodeII [label = “prop1”];  
NodeIII → NodeI [label = “prop3”];  
{rank=same; NodeII → NodeIII [label=“prop2”];}  
}  
[/dot]

ie:

```dot
strict digraph G
{
   node[shape=ellipse];
   NodeI -> NodeII [label = "prop1"];
   NodeIII -> NodeI [label = "prop3"];
   {rank=same; NodeII -> NodeIII [label="prop2"];}
}

```

But I’ve tried in vain to reproduce this result using the python syntax of the `graphviz` module.

This is as close as I could get using the `graphviz` module:

```python
import graphviz as gv
dg = gv.Digraph('digraph experiment', comment='trying to get a triangular graph with named edges', filename='triangle.gv', engine='dot')
dg.node('1', 'Node I')
dg.node('2', 'Node II')
dg.node('3', 'Node III')
# dg.edges(['12', '13'])
dg.edge('1','2', label="relationI")
dg.edge('3', '1', label="relationIII", constraint='false')
dg.edge('2', '3', rank='same', label="relationII", constraint='false')
dg.view()

```

I can, of course, use python’s `graphviz` module to draw the graph from the dot source, like this:

```python
dg = gv.Source(dotsourcestring, filename='triangle.gv', engine='dot')
dg.view()

```

but perhaps the assembled wise here can help me understand what I’m missing in the graphviz module to generate this simple graph?
