Skip to content

Commit 52b112e

Browse files
Add quotes to labels always
1 parent 90180ea commit 52b112e

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

gap/dot.gi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,11 @@ function(gv, labels)
640640

641641
nodes := GraphvizNodes(gv);
642642
for i in [1 .. Size(nodes)] do
643-
GV_ErrorIfNotValidLabel(labels[i]);
643+
labels[i] := String(labels[i]);
644+
if not StartsWith(labels[i], "\"") or not EndsWith(labels[i], "\"") then
645+
labels[i] := Concatenation("\"", labels[i], "\"");
646+
fi;
647+
# GV_ErrorIfNotValidLabel(labels[i]);
644648
GraphvizSetAttr(nodes[i], "label", labels[i]);
645649
od;
646650
return gv;

tst/dot.tst

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#############################################################################
99
##
1010

11-
#@local a, b, color, e, g, gv, label, n, shape
11+
#@local a, b, color, e, g, gv, label, n, shape, G, D
1212
gap> START_TEST("graphviz package: dot.tst");
1313
gap> LoadPackage("graphviz", false);;
1414

@@ -121,18 +121,18 @@ gap> GraphvizSetNodeLabels(gv, ["i", "ii", "iii"]);
121121
gap> Print(AsString(gv));
122122
//dot
123123
graph xxx {
124-
1 [label=i]
125-
2 [label=ii]
126-
3 [label=iii]
124+
1 [label="i"]
125+
2 [label="ii"]
126+
3 [label="iii"]
127127
}
128128
gap> GraphvizSetNodeLabels(gv, ["a", "b", "c"]);
129129
<graphviz graph "xxx" with 3 nodes and 0 edges>
130130
gap> Print(AsString(gv));
131131
//dot
132132
graph xxx {
133-
1 [label=a]
134-
2 [label=b]
135-
3 [label=c]
133+
1 [label="a"]
134+
2 [label="b"]
135+
3 [label="c"]
136136
}
137137
gap> GraphvizSetNodeLabels(gv, ["i", "ii"]);
138138
Error, the 2nd argument (list of node labels) has incorrect length, expected 3\
@@ -230,5 +230,14 @@ graph xxx {
230230
1 [label=<<>>, "probably not ok"=1]
231231
}
232232

233+
# Fix adding of quotes to labels
234+
gap> G := AsList(SymmetricGroup(3));
235+
[ (), (2,3), (1,3), (1,3,2), (1,2,3), (1,2) ]
236+
gap> D := Digraph(G, {x, y} -> x * y = y * x);
237+
<immutable digraph with 6 vertices, 18 edges>
238+
gap> SetDigraphVertexLabels(D, G);
239+
gap> gv := GraphvizVertexLabelledGraph(D);
240+
<graphviz graph "hgn" with 6 nodes and 6 edges>
241+
233242
#
234243
gap> STOP_TEST("graphviz package: dot.tst", 0);

0 commit comments

Comments
 (0)