Skip to content

Instantly share code, notes, and snippets.

@craigarms
Created January 15, 2024 16:17
Show Gist options
  • Save craigarms/2d729d0ba036e43f3e7d64e2f40dc370 to your computer and use it in GitHub Desktop.
Save craigarms/2d729d0ba036e43f3e7d64e2f40dc370 to your computer and use it in GitHub Desktop.
ChatGPT Sequence Diagram Corrected
from graphviz import Digraph
graph = Digraph(format='png')
graph.attr(dpi='300')
graph.attr(size='8,5')
graph.node_attr.update(color='lightblue2', style='filled')
graph.attr('node', shape='box', fontname="Arial", style='filled, rounded', fillcolor='#e2e2f0')
graph.node('b_start', label='Bob')
graph.node('b_0', label='', shape='point', height='0')
graph.node('b_1', label='', shape='point', height='0')
graph.node('b_2', label='', shape='point', height='0')
graph.node('b_3', label='', shape='point', height='0')
graph.node('b_end', label='Bob')
graph.edge('b_start', 'b_0', style='dashed', arrowhead='none')
graph.edge('b_0', 'b_1', style='dashed', arrowhead='none')
graph.edge('b_1', 'b_2', style='dashed', arrowhead='none')
graph.edge('b_2', 'b_3', style='dashed', arrowhead='none')
graph.edge('b_3', 'b_end', style='dashed', arrowhead='none')
graph.node('a_start', label='Alice')
graph.node('a_0', label='', shape='point', height='0')
graph.node('a_1', label='', shape='point', height='0')
graph.node('a_2', label='', shape='point', height='0')
graph.node('a_3', label='', shape='point', height='0')
graph.node('a_end', label='Alice')
graph.edge('a_start', 'a_0', style='dashed', arrowhead='none')
graph.edge('a_0', 'a_1', style='dashed', arrowhead='none')
graph.edge('a_1', 'a_2', style='dashed', arrowhead='none')
graph.edge('a_2', 'a_3', style='dashed', arrowhead='none')
graph.edge('a_3', 'a_end', style='dashed', arrowhead='none')
graph.node('c_start', label='Charlie')
graph.node('c_0', label='', shape='point', height='0')
graph.node('c_1', label='', shape='point', height='0')
graph.node('c_2', label='', shape='point', height='0')
graph.node('c_end', label='Charlie')
graph.edge('c_start', 'c_0', style='dashed', arrowhead='none')
graph.edge('c_0', 'c_1', style='dashed', arrowhead='none')
graph.edge('c_1', 'c_2', style='dashed', arrowhead='none')
graph.edge('c_2', 'c_end', style='dashed', arrowhead='none')
graph.attr('node', shape='plaintext', fontname="Arial", style='filled, rounded', fillcolor='#e2e2f0')
graph.edge('b_0', 'a_0', weight='0', arrowhead='vee', fontname='Arial', label='<<B>1 </B>Authentication Request>')
graph.edge('a_1', 'c_1', weight='0', arrowhead='vee', fontname='Arial', label='<<B>2 </B>Authentication Validation>')
graph.edge('c_2', 'a_2', weight='0', arrowhead='vee', fontname='Arial', label='<<B>3 </B>Authentication Valid>')
graph.edge('a_3', 'b_3', weight='0', arrowhead='vee', fontname='Arial', label='<<B>4 </B>Authentication Response>')
# Save the graph as an image
graph.render('output_chatgpt_2', format='png', cleanup=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment