0

I am trying to get straight line edges that exit a node on the right and enter on the left. I have tried to use splines='line but it does not appear to create straight lines. Code below, as executed in jupyter notebook.

from graphviz import Digraph
g = Digraph('G', filename='cluster.gv')

with g.subgraph(name='cluster_0') as c:
    c.attr(style='filled', color='lightgrey')
    c.node_attr.update(style='filled', color='white')
    c.edges([('a0', 'a1'), ('a1', 'a2'), ('a2', 'a3')])
    c.attr(label='process #1')

with g.subgraph(name='cluster_1') as c:
    c.attr(color='blue')
    c.node_attr['style'] = 'filled'
    c.edges([('b0', 'b1'), ('b1', 'b2'), ('b2', 'b3')])
    c.attr(label='process #2')

g.edge('a1', 'b3',splines='line',tailport="e", headport="w", constraint='false')
g.edge('a2', 'b0',splines='line',tailport="e", headport="w", constraint='false')

g.view()

This is the graph that is produced by the code: Graph

amme
  • 3
  • 2

1 Answers1

0

I have solved this. The placement of splines='line' was incorrect. Correct code below in case any future users have the same problem.

g = Digraph('G', filename='cluster.gv')

with g.subgraph(name='cluster_0') as c:
    c.attr(style='filled', color='lightgrey')
    c.node_attr.update(style='filled', color='white')
    c.edges([('a0', 'a1'), ('a1', 'a2'), ('a2', 'a3')])
    c.attr(label='process #1')

with g.subgraph(name='cluster_1') as c:
    c.attr(color='blue')
    c.node_attr['style'] = 'filled'
    c.edges([('b0', 'b1'), ('b1', 'b2'), ('b2', 'b3')])
    c.attr(label='process #2')

g.attr(splines='false')
g.edge('a1', 'b3',tailport="e", headport="w", constraint='false')
g.edge('a2', 'b0',tailport="e", headport="w", constraint='false')

g.view()
amme
  • 3
  • 2