Skip to content

Instantly share code, notes, and snippets.

@xlfe
Created September 10, 2017 20:08
Show Gist options
  • Save xlfe/1125d2b7442d936bf6a46bb6573a628a to your computer and use it in GitHub Desktop.
Save xlfe/1125d2b7442d936bf6a46bb6573a628a to your computer and use it in GitHub Desktop.
Generate OpenIOC Chart
from graphviz import Digraph
edges = set()
dot = Digraph(graph_attr={
'overlap':'false',
'outputorder':'edgesfirst'
})
ioc = dot.node('OpenIOC')
with open('terms.csv') as terms:
for line in terms:
entries = line.strip().split('/')
if entries[0] in edges:
continue
node = dot.node(entries[0], style='filled', shape="box")
dot.edge('OpenIOC', entries[0])
edges.add(entries[0])
continue
last = entries[0]
for e in entries[1:]:
edge = '{}/{}'.format(last, e)
if edge in edges:
continue
node = dot.node(e, style='filled', shape='box')
dot.edge(last, e)
last = e
edges.add(edge)
dot.save('graph.gv')
@xlfe
Copy link
Author

xlfe commented Sep 10, 2017

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