-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plotting.py
59 lines (47 loc) · 1.16 KB
/
Plotting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import graphviz as gv
import Model
default_style = {
'graph': {
'rankdir': 'LR'
},
'nodes': {
'shape': 'circle',
},
'edges': {
'arrowhead': 'open',
}
}
#Pasted from graphviz
def apply_styles(graph, styles):
graph.graph_attr.update(
('graph' in styles and styles['graph']) or {}
)
graph.node_attr.update(
('nodes' in styles and styles['nodes']) or {}
)
graph.edge_attr.update(
('edges' in styles and styles['edges']) or {}
)
return graph
def ConstructGraph():
graph = gv.Digraph(format='jpg')
apply_styles(graph, default_style)
for i in Model.arguments:
graph.node(i, i)
ed = []
for i in Model.relations:
ed.append((i[0],i[1]))
print(ed)
graph.edges(ed)
graph.render('data/graph')
def ConstructColouredGraph(colargs):
graph = gv.Digraph(format='jpg')
apply_styles(graph, default_style)
for i in Model.arguments:
if i in colargs:
graph.node(i, i, color = "red")
ed = []
for i in Model.relations:
ed.append((i[0], i[1]))
graph.edges(ed)
graph.render('data/graph')