Skip to content

Commit 768aed0

Browse files
committed
ENH(plot): plot with Ortho-edges (graphviz) ...
actually a fix, since splines were on each node.
1 parent 1ccea4b commit 768aed0

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

docs/source/arch.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ Architecture
313313
endurance
314314
Keep executing as many `operation`\s as possible, even if some of them fail.
315315
Endurance for an operation is enabled if :func:`.set_endure_operations()`
316-
is true globally in the `configurations` or if :attr:`.FunctionalOperation.endurance`
316+
is true globally in the `configurations` or if :attr:`.FunctionalOperation.endured`
317317
is true.
318318

319319
You may interrogate :attr:`.Solution.executed` to discover the status

graphtik/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ def plot(
251251
an optional nested dict of Graphviz attributes for certain edges
252252
:param clusters:
253253
an optional mapping of nodes --> cluster-names, to group them
254+
:param splines:
255+
Whether to plot `curved/polyline edges
256+
<https://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:splines>`_
257+
[default: "ortho"]
254258
:param jupyter_render:
255259
a nested dictionary controlling the rendering of graph-plots in Jupyter cells,
256260
if `None`, defaults to :data:`jupyter_render` (you may modify it in place
@@ -341,6 +345,7 @@ def plot(
341345
digraph netop {
342346
fontname=italic;
343347
label=<netop>;
348+
splines=ortho;
344349
<a> [fillcolor=wheat, shape=invhouse, style=filled, tooltip=1];
345350
...
346351

graphtik/plot.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def build_pydot(
202202
node_props=None,
203203
edge_props=None,
204204
clusters=None,
205+
splines="ortho",
205206
legend_url="https://graphtik.readthedocs.io/en/latest/_images/GraphtikLegend.svg",
206207
) -> pydot.Dot:
207208
"""
@@ -251,7 +252,10 @@ def get_node_name(a):
251252
return quote_dot_word(a)
252253

253254
dot = pydot.Dot(
254-
graph_type="digraph", label=quote_dot_word(title), fontname="italic"
255+
graph_type="digraph",
256+
label=quote_dot_word(title),
257+
fontname="italic",
258+
splines="ortho",
255259
)
256260
if name:
257261
dot.set_name(as_identifier(name))
@@ -337,8 +341,7 @@ def get_node_name(a):
337341
if solution and dst not in solution and dst not in steps:
338342
kw["color"] = broken_color
339343

340-
# `splines=ortho` not working :-()
341-
edge = pydot.Edge(src=src_name, dst=dst_name, splines="ortho", **kw)
344+
edge = pydot.Edge(src=src_name, dst=dst_name, **kw)
342345

343346
_apply_user_props(edge, edge_props, key=(src, dst))
344347

test/test_plot.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,14 @@ def test_node_quoting():
239239
digraph graph_ {
240240
fontname=italic;
241241
label=<graph>;
242+
splines=ortho;
242243
<edge> [shape=invhouse];
243244
<digraph&#58; strict> [shape=invhouse];
244245
<node> [fontname=italic, shape=oval, tooltip="FunctionalOperation(name='node', needs=['edge', 'digraph: strict'], provides=['<graph>'], fn='add')"];
245246
<graph> [shape=house];
246-
<edge> -> <node> [splines=ortho];
247-
<digraph&#58; strict> -> <node> [splines=ortho];
248-
<node> -> <graph> [splines=ortho];
247+
<edge> -> <node>;
248+
<digraph&#58; strict> -> <node>;
249+
<node> -> <graph>;
249250
legend [URL="https://graphtik.readthedocs.io/en/latest/_images/GraphtikLegend.svg", fill_color=yellow, shape=component, style=filled];
250251
}
251252
"""

0 commit comments

Comments
 (0)