modgraphviz: condense graph output
This CL aims to make the graph produced by modgraphviz easier to read
through stylistic choices made through graphviz's dot format. We do this in
2 main ways
* Settle on a node shape (i.e rectangle)
* Settle on font and fontsize (times new roman / 12)
Example graph ran on golang.org/x/exp: https://ibb.co/bQ8VKFG
Change-Id: I82d5fe8fd789ba5bcc54854de46d8cd630f08b20
Reviewed-on: https://go-review.googlesource.com/c/exp/+/187878
Run-TryBot: Jean de Klerk <deklerk@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jean de Klerk <deklerk@google.com>
diff --git a/cmd/modgraphviz/main.go b/cmd/modgraphviz/main.go
index 016ea22..a0351dc 100644
--- a/cmd/modgraphviz/main.go
+++ b/cmd/modgraphviz/main.go
@@ -71,6 +71,7 @@
}
fmt.Fprintf(out, "digraph gomodgraph {\n")
+ fmt.Fprintf(out, "\tnode [ shape=rectangle fontsize=12 ]\n")
out.Write(graph.edgesAsDOT())
for _, n := range graph.mvsPicked {
fmt.Fprintf(out, "\t%q [style = filled, fillcolor = green]\n", n)
@@ -152,7 +153,6 @@
// Make this function deterministic.
sort.Strings(g.mvsPicked)
-
return &g, nil
}
diff --git a/cmd/modgraphviz/main_test.go b/cmd/modgraphviz/main_test.go
index 01b0cac..bec88cf 100644
--- a/cmd/modgraphviz/main_test.go
+++ b/cmd/modgraphviz/main_test.go
@@ -23,6 +23,7 @@
gotGraph := string(out.Bytes())
wantGraph := `digraph gomodgraph {
+ node [ shape=rectangle fontsize=12 ]
"test.com/A@v1.0.0" -> "test.com/B@v1.2.3"
"test.com/B@v1.0.0" -> "test.com/C@v4.5.6"
"test.com/A@v1.0.0" [style = filled, fillcolor = green]