From 4de75373dd536c125cba031f50c657c46b87bc43 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Mon, 29 Apr 2019 13:52:54 -0400 Subject: [PATCH] pgraph: Use pointers for unique vertex identifiers This will build more accurate graphs, since we could have duplicated vertex names for distinct vertices. This now builds the correct topology, even if the labels are duplicated. --- pgraph/graphviz.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pgraph/graphviz.go b/pgraph/graphviz.go index 9c7f9227..3b19a2d5 100644 --- a/pgraph/graphviz.go +++ b/pgraph/graphviz.go @@ -46,14 +46,17 @@ func (g *Graph) Graphviz() (out string) { //out += "\tnode [shape=box];\n" str := "" for i := range g.Adjacency() { // reverse paths - out += fmt.Sprintf("\t%s [label=%s];\n", strconv.Quote(i.String()), strconv.Quote(i.String())) + v1 := strconv.Quote(i.String()) // 1st vertex + out += fmt.Sprintf("\t\"%p\" [label=%s];\n", i, v1) for j := range g.Adjacency()[i] { k := g.Adjacency()[i][j] + //v2 := strconv.Quote(j.String()) // 2nd vertex + e := strconv.Quote(k.String()) // edge // use str for clearer output ordering //if fmtBoldFn(k) { // TODO: add this sort of formatting // str += fmt.Sprintf("\t\"%s\" -> \"%s\" [label=\"%s\",style=bold];\n", i, j, k) //} else { - str += fmt.Sprintf("\t%s -> %s [label=%s];\n", strconv.Quote(i.String()), strconv.Quote(j.String()), strconv.Quote(k.String())) + str += fmt.Sprintf("\t\"%p\" -> \"%p\" [label=%s];\n", i, j, e) //} } }