mirror of
https://github.com/gonum/gonum.git
synced 2025-10-06 23:52:47 +08:00
encoding/dot: make all simple graph marshalling strict
Also fix bug in order of emitting strict keyword.
This commit is contained in:

committed by
Dan Kortschak

parent
cc0c958a30
commit
609b9d63e8
@@ -76,14 +76,11 @@ type Subgrapher interface {
|
||||
// however, advanced GraphViz DOT features provided by Marshal depend on
|
||||
// implementation of the Node, Attributer, Porter, Attributers, Structurer,
|
||||
// Subgrapher and Graph interfaces.
|
||||
func Marshal(g graph.Graph, name, prefix, indent string, strict bool) ([]byte, error) {
|
||||
func Marshal(g graph.Graph, name, prefix, indent string) ([]byte, error) {
|
||||
var p printer
|
||||
p.indent = indent
|
||||
p.prefix = prefix
|
||||
p.visited = make(map[edge]bool)
|
||||
if strict {
|
||||
p.buf.WriteString("strict ")
|
||||
}
|
||||
err := p.print(g, name, false, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -118,6 +115,9 @@ func (p *printer) print(g graph.Graph, name string, needsIndent, isSubgraph bool
|
||||
p.buf.WriteString(p.indent)
|
||||
}
|
||||
}
|
||||
if !isSubgraph {
|
||||
p.buf.WriteString("strict ")
|
||||
}
|
||||
_, isDirected := g.(graph.Directed)
|
||||
if isSubgraph {
|
||||
p.buf.WriteString("sub")
|
||||
|
Reference in New Issue
Block a user