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