feat: try to add map dot

上级 4ebfa2f9
package tequila
import (
"fmt"
"github.com/awalterschulze/gographviz"
"sort"
"strconv"
......@@ -139,3 +140,25 @@ func (fullGraph *FullGraph) ToDot(split string, include func(string) bool) *gogr
return graph
}
func (fullGraph *FullGraph) ToMapDot(split string, include func(key string) bool) {
graph := gographviz.NewGraph()
_ = graph.SetName("G")
//nodeIndex := 1
//layerIndex := 1
//nodes := make(map[string]string)
layerMap := make(map[string][]string)
for nodeKey := range fullGraph.NodeList {
tmp := strings.Split(nodeKey, split)
packageName := tmp[0]
if _, ok := layerMap[packageName]; !ok {
layerMap[packageName] = make([]string, 0)
}
layerMap[packageName] = append(layerMap[packageName], nodeKey)
}
fmt.Println(layerMap)
}
package tequila
import (
. "github.com/onsi/gomega"
"testing"
)
func Test_VisualDemo(t *testing.T) {
g := NewGomegaWithT(t)
fullGraph := &FullGraph{
NodeList: make(map[string]string),
RelationList: make(map[string]*Relation),
}
from := "com.phodal.Ledge"
to := "com.spring.Boot"
fullGraph.NodeList[from] = from
fullGraph.NodeList[to] = to
relation := Relation{
From: from,
To: to,
Style: "\"solid\"",
}
fullGraph.RelationList["com.phodal.Ledge->com.spring.Boot"] = &relation
var nodeFilter = func(key string) bool {
return true
}
fullGraph.ToMapDot(".", nodeFilter)
g.Expect(true).To(Equal(true))
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册