Issue
I have the below code to create a simple flow using graphviz to be visualized in jupyter notebook
# Create Digraph object
dot = Digraph()
# Add nodes
dot.node('1', shape='box')
dot.node('2', shape='rectangle')
dot.node('3', shape='parallelogram')
dot.node('4', shape='diamond')
dot.node('5', shape='box')
# Add edge between nodes
dot.edges(['12', '23', '34', '42', '45' ])
# Visualize the graph
dot
How to make an edge from decision box right corner to box 2 a straight line?
Solution
Pls define edges and tailport='e', headport='e'
helps to define the right side (e=east). tailport: from where, headport: to where.
Code:
from graphviz import Digraph
dot = Digraph(graph_attr={'splines': 'ortho'})
dot.node('1', shape='box')
dot.node('2', shape='rectangle')
dot.node('3', shape='parallelogram')
dot.node('4', shape='diamond')
dot.node('5', shape='box')
dot.edge('1', '2')
dot.edge('2', '3')
dot.edge('3', '4')
dot.edge('4', '2', tailport='e', headport='e', constraint='false')
dot.edge('4', '5')
dot
Output:
Answered By - Ömer Sezer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.