Skip to content

Commit cbc2457

Browse files
committed
refact(plot): add op & data to plot in one place
1 parent f29863f commit cbc2457

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

graphtik/plot.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -264,19 +264,19 @@ def get_node_name(a):
264264
# draw nodes
265265
for nx_node in graph.nodes:
266266
if isinstance(nx_node, str):
267-
kw = {}
268-
269-
# FrameColor change by step type
270-
if steps and nx_node in steps:
271-
kw = {"color": "#990000"}
272-
273267
# SHAPE change if with inputs/outputs.
274268
# tip: https://graphviz.gitlab.io/_pages/doc/info/shapes.html
275269
choice = _merge_conditions(
276270
inputs and nx_node in inputs, outputs and nx_node in outputs
277271
)
278272
shape = "rect invhouse house hexagon".split()[choice]
279273

274+
kw = {"name": quote_dot_word(nx_node), "shape": shape}
275+
276+
# FrameColor change by step type
277+
if steps and nx_node in steps:
278+
kw["color"] = "#990000"
279+
280280
# LABEL change with solution.
281281
if solution and nx_node in solution:
282282
kw["style"] = "filled"
@@ -288,9 +288,13 @@ def get_node_name(a):
288288
## NOTE: SVG tooltips not working without URL:
289289
# https://gitlab.com/graphviz/graphviz/issues/1425
290290
kw["tooltip"] = html.escape(str(solution.get(nx_node)))
291-
node = pydot.Node(name=quote_dot_word(nx_node), shape=shape, **kw,)
291+
292292
else: # Operation
293-
kw = {"fontname": "italic"}
293+
kw = {
294+
"shape": "oval",
295+
"name": quote_dot_word(nx_node.name),
296+
"fontname": "italic",
297+
}
294298

295299
if nx_node.rescheduled:
296300
kw["penwidth"] = resched_thickness
@@ -318,15 +322,8 @@ def get_node_name(a):
318322
fn_tooltip = str(nx_node)
319323
kw["tooltip"] = html.escape(fn_tooltip)
320324

321-
node = pydot.Node(
322-
name=quote_dot_word(nx_node.name),
323-
shape="oval",
324-
## NOTE: Jupyter lab is blocking local-urls (e.g. on SVGs).
325-
**kw,
326-
)
327-
325+
node = pydot.Node(**kw,)
328326
_apply_user_props(node, node_props, key=node.get_name())
329-
330327
append_or_cluster_node(dot, nx_node, node)
331328

332329
_report_unmatched_user_props(node_props, "node")

0 commit comments

Comments
 (0)