Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions gap/dot.gi
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ function(name)
Attrs := [],
Parent := fail,
Idx := 1,
Counter := 1));
Counter := 1,
Comments := []));
end);

InstallMethod(GraphvizDigraph, "for no args", [], {} -> GraphvizDigraph(""));
Expand Down Expand Up @@ -328,6 +329,13 @@ function(x, value)
return x;
end);

InstallMethod(GraphvizAddComment, "for a graphviz (di)graph and string",
[IsGraphvizGraphDigraphOrContext, IsString],
function(gv, comment)
Append(gv!.Comments, SplitString(comment, "\n"));
return gv;
end);

#############################################################################
# GraphvizAddNode
#############################################################################
Expand Down Expand Up @@ -642,7 +650,8 @@ function(gv, labels)

nodes := GraphvizNodes(gv);
for i in [1 .. Size(nodes)] do
GV_ErrorIfNotValidLabel(labels[i]);
# FIXME something in the next function call causes a seg fault!!
# GV_ErrorIfNotValidLabel(labels[i]);
GraphvizSetAttr(nodes[i], "label", labels[i]);
od;
return gv;
Expand Down
13 changes: 8 additions & 5 deletions gap/gv.gi
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ function(graph, name)
ErrorNoReturn("the 2nd argument (string/node name) cannot be empty");
fi;
out := Objectify(GV_NodeType,
rec(
Name := name,
Attrs := GV_Map(),
Idx := GV_GetCounter(graph)));
rec(Name := name,
Attrs := GV_Map(),
Idx := GV_GetCounter(graph)));
GV_IncCounter(graph);
return out;
end);
Expand Down Expand Up @@ -667,7 +666,8 @@ InstallMethod(GV_StringifyGraph,
"for a graphviz graph and a string",
[IsGraphvizGraphDigraphOrContext, IsBool],
function(graph, is_subgraph)
local result, obj;
local result, comment, obj;

result := "";

# get the correct head to use
Expand All @@ -679,6 +679,9 @@ function(graph, is_subgraph)
fi;
elif IsGraphvizDigraph(graph) then
Append(result, "//dot\n");
for comment in graph!.Comments do
Append(result, StringFormatted("// {}\n", comment));
od;
Append(result, GV_StringifyDigraphHead(graph));
elif IsGraphvizGraph(graph) then
Append(result, "//dot\n");
Expand Down
Loading