encoding/dot: set DOT node ID before adding node to graph (#775)

This makes it possible to implement the AddNode method of
graph.NodeAdder to track the nodes of a graph by DOT node
ID, as they are added.
This commit is contained in:
Robin Eklind
2018-12-23 00:19:38 +01:00
committed by GitHub
parent 5be5c19bdd
commit ff0fdabd90

View File

@@ -153,10 +153,10 @@ func (gen *generator) node(dst graph.NodeAdder, id string) graph.Node {
return n
}
n := dst.NewNode()
dst.AddNode(n)
if n, ok := n.(DOTIDSetter); ok {
n.SetDOTID(id)
}
dst.AddNode(n)
gen.ids[id] = n
// Check if within the context of a subgraph, that is to be used as a vertex
// of an edge.