Missing label when gvContext() is called after graph creation
Steps to reproduce
auto graph = agmemread(dotString);
auto gvc = gvContext();
gvLayout(gvc, graph, "dot");
gvRenderFilename(gvc, graph, "svg", "Rubjerg.Graphviz/test.svg");
gvFreeLayout(gvc, graph);
agclose(graph);
where the value of dotstring is
digraph {
compound=true;
node [shape=Mrecord]
rankdir="LR"
subgraph "clusterOpen"
{
label = "Open"
"Assigned" [label="Assigned|exit / OnDeassigned"];
}
"Deferred" [label="Deferred|entry / Function"];
"Closed" [label="Closed"];
"OpenNode" -> "Assigned" [style="solid", label="Assign / OnAssigned"];
"Assigned" -> "Assigned" [style="solid", label="Assign"];
"Assigned" -> "Closed" [style="solid", label="Close"];
"Assigned" -> "Deferred" [style="solid", label="Defer"];
"Deferred" -> "Assigned" [style="solid", label="Assign / OnAssigned"];
init [label="", shape=point];
init -> "Open"[style = "solid"]
}
Expected Behaviour
Actual Behaviour
OS Version
Windows 11
Graphviz Version
dot - graphviz version 8.1.0 (20230707.0739)
Additional info
When we put the gvContext() call first, it seems to work correctly.
auto gvc = gvContext();
auto graph = agmemread(dotString);
gvLayout(gvc, graph, "dot");
gvRenderFilename(gvc, graph, "svg", "Rubjerg.Graphviz/test.svg");
gvFreeLayout(gvc, graph);
agclose(graph);
So that is a work around (though not trivial to implement in a C# wrapper library, where there is no single entry point). However, because this is not a documented requirement and because the resulting behavior is so strange, I suspect this points to a larger issue.
Origin: https://github.com/Rubjerg/Graphviz.NetWrapper/issues/50
Edited by Chiel ten Brinke