gorgonia.org/gorgonia@v0.9.17/encoding/dot/operatorsubgraph.go (about) 1 package dot 2 3 import ( 4 "strconv" 5 6 "gonum.org/v1/gonum/graph" 7 "gonum.org/v1/gonum/graph/encoding" 8 gonumDot "gonum.org/v1/gonum/graph/encoding/dot" 9 internalEncoding "gorgonia.org/gorgonia/internal/encoding" 10 ) 11 12 type operatorSubGraph struct { 13 name string 14 id int 15 graph.DirectedBuilder 16 subs map[internalEncoding.Group]operatorSubGraph 17 } 18 19 func (g operatorSubGraph) DOTID() string { 20 return "cluster_" + g.name + strconv.Itoa(g.id) 21 } 22 23 // DOTAttributers to specify the top-level graph attributes for the graphviz generation 24 func (g operatorSubGraph) DOTAttributers() (graph, node, edge encoding.Attributer) { 25 // Create a special attribute "rank" to place the input at the same level in the graph 26 27 graphAttributes := attributer{ 28 encoding.Attribute{ 29 Key: "label", 30 Value: g.name, 31 }, 32 encoding.Attribute{ 33 Key: "color", 34 Value: "coral", 35 }, 36 encoding.Attribute{ 37 Key: "style", 38 Value: "filled", 39 }, 40 encoding.Attribute{ 41 Key: "nodeset", 42 Value: "0.5", 43 }, 44 encoding.Attribute{ 45 Key: "ranksep", 46 Value: `"1.2 equally"`, 47 }, 48 } 49 nodeAttributes := attributer{ 50 encoding.Attribute{ 51 Key: "style", 52 Value: `"rounded,filled"`, 53 }, 54 encoding.Attribute{ 55 Key: "fillcolor", 56 Value: "white", 57 }, 58 encoding.Attribute{ 59 Key: "shape", 60 Value: "Mrecord", 61 }, 62 } 63 return graphAttributes, nodeAttributes, attributer{} 64 } 65 66 // Structure fulfils the dot.Structurer interface. 67 func (g operatorSubGraph) Structure() []gonumDot.Graph { 68 output := make([]gonumDot.Graph, 0, len(g.subs)) 69 for _, subg := range g.subs { 70 output = append(output, subg) 71 } 72 return output 73 }