Add Bytes method to dot.Graph
This way we can feed the buffer output directly to an io.Writer
This commit is contained in:
parent
07ec946e7e
commit
8d3e6f445f
13
dot/graph.go
13
dot/graph.go
|
@ -132,6 +132,19 @@ func (g *Graph) String() string {
|
|||
return w.String()
|
||||
}
|
||||
|
||||
// Returns the DOT representation of this Graph.
|
||||
func (g *Graph) Bytes() []byte {
|
||||
w := newGraphWriter()
|
||||
|
||||
g.drawHeader(w)
|
||||
w.Indent()
|
||||
g.drawBody(w)
|
||||
w.Unindent()
|
||||
g.drawFooter(w)
|
||||
|
||||
return w.Bytes()
|
||||
}
|
||||
|
||||
func (g *Graph) drawHeader(w *graphWriter) {
|
||||
if g.Directed {
|
||||
w.Printf("digraph {\n")
|
||||
|
|
Loading…
Reference in New Issue