Skip to content

Instantly share code, notes, and snippets.

@danaoira
Last active March 1, 2016 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danaoira/90743cdaa2f67ba1a01e to your computer and use it in GitHub Desktop.
Save danaoira/90743cdaa2f67ba1a01e to your computer and use it in GitHub Desktop.
Sample Graphviz Python Code for Curriculum Graph Visualizer
# cgv.dot - Resulting DOT output from Python Graphviz input
digraph cgv {
size="6,6"
"MATH 150A" -> "MATH 150B"
"MATH 150B" -> "MATH 338"
"MATH 338" -> "CPSC 335"
"MATH 270A" -> "MATH 270B"
"MATH 270A" -> "CPSC 240"
"MATH 270B" -> "CPSC 335"
"CPSC 335" -> "CPSC 481"
"CPSC 240" -> "CPSC 440"
"CPSC 120" -> "CPSC 121"
"CPSC 121" -> "CPSC 131"
"CPSC 131" -> "CPSC 240"
"CPSC 131" -> "CPSC 223"
"CPSC 131" -> "CPSC 254"
"CPSC 131" -> "CPSC 332"
"CPSC 131" -> "CPSC 311"
"CPSC 254" -> "CPSC 301"
"CPSC 254" -> "CPSC 351"
"CPSC 301" -> "CPSC 335"
"CPSC 301" -> "CPSC 323"
"CPSC 301" -> "CPSC 362"
"CPSC 351" -> "CPSC 471"
"ENGL 101" -> "CPSC 311"
"CPSC 311" -> "CPSC 315"
"CPSC 311" -> "CPSC 362"
}
# cgv.py - Curriculum Graph Visualizer
from graphviz import Digraph
c = Digraph('cgv', filename='cgv.gv')
c.body.append('size="6,6"')
c.node_attr.update(color='lightblue2', style='filled')
c.edge('MATH 150A', 'MATH 150B')
c.edge('MATH 150B', 'MATH 338')
c.edge('MATH 338', 'CPSC 335')
c.edge('MATH 270A', 'MATH 270B')
c.edge('MATH 270A', 'CPSC 240')
c.edge('MATH 270B', 'CPSC 335')
c.edge('CPSC 335', 'CPSC 481')
c.edge('CPSC 240', 'CPSC 440')
c.edge('CPSC 120', 'CPSC 121')
c.edge('CPSC 121', 'CPSC 131')
c.edge('CPSC 131', 'CPSC 240')
c.edge('CPSC 131', 'CPSC 223')
c.edge('CPSC 131', 'CPSC 254')
c.edge('CPSC 131', 'CPSC 332')
c.edge('CPSC 131', 'CPSC 311')
c.edge('CPSC 254', 'CPSC 301')
c.edge('CPSC 254', 'CPSC 351')
c.edge('CPSC 301', 'CPSC 335')
c.edge('CPSC 301', 'CPSC 323')
c.edge('CPSC 301', 'CPSC 362')
c.edge('CPSC 351', 'CPSC 471')
c.edge('ENGL 101', 'CPSC 311')
c.edge('CPSC 311', 'CPSC 315')
c.edge('CPSC 311', 'CPSC 362')
c.view()
@danaoira
Copy link
Author

danaoira commented Mar 1, 2016

The resulting graph output with only one crossed edge.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment