Open offerm opened 4 years ago
@offerm did you find a solution or workaround this issue?
@offerm Can the Graphviz's dot command output correctly ?
package main
import (
"bytes"
"context"
"log"
"os"
"github.com/goccy/go-graphviz"
)
func main() {
ctx := context.Background()
g, _ := graphviz.New(ctx)
graph, err := g.Graph(graphviz.WithDirectedType(graphviz.UnDirected))
if err != nil {
log.Fatal(err)
}
defer func() {
if err := graph.Close(); err != nil {
log.Fatal(err)
}
g.Close()
}()
n, err := graph.CreateNodeByName("n")
if err != nil {
log.Fatal(err)
}
m, err := graph.CreateNodeByName("m")
if err != nil {
log.Fatal(err)
}
_, err = graph.CreateNodeByName("l")
if err != nil {
log.Fatal(err)
}
e, err := graph.CreateEdgeByName("e", n, m)
if err != nil {
log.Fatal(err)
}
e.SetLabel("e")
n.SetRoot(true)
graph.SetLayout("twopi")
var buf bytes.Buffer
if err := g.Render(ctx, graph, graphviz.PNG, &buf); err != nil {
log.Fatal(err)
}
os.WriteFile("twopi.png", buf.Bytes(), 644)
}
When I ran the above code with output to stderr enabled, I received the following error. I believe similar code would likely not work with the original dot command either.
Assertion failed: sym->id >= 0 && sym->id < topdictsize(obj) (/graphviz/lib/cgraph/attr.c: agxset: 491)
I'm trying to graph using twopi and sent one of the nodes to be the graph root. This lead to a crash.
not using
twopi
orsetRoot
prevent this error.source code: