Created
September 10, 2017 20:08
-
-
Save xlfe/1125d2b7442d936bf6a46bb6573a628a to your computer and use it in GitHub Desktop.
Generate OpenIOC Chart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
terms.csv