import graphviz
Create a Digraph object
dot = graphviz.Digraph(format=‘png’)
Define the flowchart
dot.node(‘Start’, ‘Start’)
dot.node(‘Reactants’, ‘What are the reactants?’)
dot.node(‘Choice1’, ‘Choice 1’)
dot.node(‘Synthesis’, ‘Synthesis’)
dot.node(‘Choice2’, ‘Choice 2’)
dot.node(‘Decomposition’, ‘Decomposition’)
dot.node(‘Choice3’, ‘Choice 3’)
dot.node(‘Combustion’, ‘Combustion’)
dot.node(‘SingleDisplacement’, ‘Single Displacement’)
dot.node(‘Choice4’, ‘Choice 4’)
dot.node(‘DoubleDisplacement’, ‘Double Displacement’)
dot.node(‘Choice5’, ‘Choice 5’)
dot.node(‘Neutralization’, ‘Neutralization’)
dot.node(‘Other’, ‘Other’)
dot.node(‘End’, ‘End’)
Define the edges
dot.edges([
(‘Start’, ‘Reactants’),
(‘Reactants’, ‘Choice1’),
(‘Choice1’, ‘Synthesis’),
(‘Choice1’, ‘Choice2’),
(‘Choice2’, ‘Decomposition’),
(‘Choice2’, ‘Choice3’),
(‘Choice3’, ‘Combustion’),
(‘Choice3’, ‘Choice4’),
(‘Choice4’, ‘SingleDisplacement’),
(‘Choice4’, ‘Choice5’),
(‘Choice5’, ‘DoubleDisplacement’),
(‘Choice5’, ‘Neutralization’),
(‘Synthesis’, ‘End’),
(‘Decomposition’, ‘End’),
(‘Combustion’, ‘End’),
(‘SingleDisplacement’, ‘End’),
(‘DoubleDisplacement’, ‘End’),
(‘Neutralization’, ‘End’),
(‘Other’, ‘End’)
])
Render the flowchart as an image
dot.render(‘chemical_reactions_flowchart’, view=True)