55import re
66import sys
77
8+ import graphGeneration as g
9+
810## settings for running example
911# for diff
1012# NODE_POSITION_LAYOUT = "circo"
1719# POS_SCALING_Y = 0.5
1820# plt.margins(x=0.11)
1921
20- import graphGeneration as g
21-
2222# + install graphviz on your system: https://www.graphviz.org/download/
2323
2424# format
@@ -153,6 +153,8 @@ def plot_graphs(S, exportDir):
153153 node_colors .append (g .DIFFTYPE_ADD_COLOR )
154154 elif nodedata .difftype == g .DIFFTYPE_REM :
155155 node_colors .append (g .DIFFTYPE_REM_COLOR )
156+ else :
157+ raise Exception ("Could not determine color of node " + str (nodedata .difftype ))
156158
157159 if nodedata .codetype == g .CODETYPE_CODE :
158160 node_type_colors .append (g .CODE_TYPE_CODE_COLOR )
@@ -164,12 +166,7 @@ def plot_graphs(S, exportDir):
164166 edge_colors = []
165167 for _ , _ , d in difftree .edges .data ():
166168 typeName = str (d ['label' ])
167- if typeName .startswith ("a" ):
168- edge_colors .append (EDGE_ADD_COLOR )
169- if typeName .startswith ("ba" ):
170- edge_colors .append (EDGE_NON_COLOR )
171- elif typeName .startswith ("b" ):
172- edge_colors .append (EDGE_REM_COLOR )
169+ edge_colors .append (g .edgeColour (typeName ))
173170
174171 # pos = nx.spring_layout(S[i], scale=3)
175172 # pos = nx.planar_layout(S[i], scale=3)
@@ -198,6 +195,9 @@ def plot_graphs(S, exportDir):
198195 ycenter = (ymax + ymin ) / 2
199196 yhalf = (ymax - ymin ) / 2
200197
198+ if yhalf == 0 :
199+ yhalf = ycenter / 2
200+
201201 # 3: shift our nodes and normalize their position on the y scale
202202 new_pos = {}
203203 for k , v in pos .items ():
@@ -216,7 +216,8 @@ def plot_graphs(S, exportDir):
216216 # draw nodes
217217 if SHOW_LABELS :
218218 node_labels = dict ([(v , d ['label' ]) for v , d in difftree .nodes (data = True )])
219- nx .draw (difftree , pos ,
219+ nx .draw (difftree ,
220+ pos ,
220221 node_size = NODE_SIZE ,
221222 node_color = node_colors ,
222223 width = EDGE_SIZE ,
@@ -283,6 +284,7 @@ def getAllFilesInDirectoryRecusivelyThat(dirname, condition):
283284 FONT_SIZE = args .fontsize
284285 LINE_NO_OFFSET = args .startlineno
285286
287+ # print("args.format", args.format)
286288 if args .format == "default" :
287289 NODE_PARSER = g .parseNodeDefault
288290 elif args .format == "patternsdebug" :
0 commit comments