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.
This commit is contained in:
@@ -46,14 +46,17 @@ func (g *Graph) Graphviz() (out string) {
|
|||||||
//out += "\tnode [shape=box];\n"
|
//out += "\tnode [shape=box];\n"
|
||||||
str := ""
|
str := ""
|
||||||
for i := range g.Adjacency() { // reverse paths
|
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] {
|
for j := range g.Adjacency()[i] {
|
||||||
k := g.Adjacency()[i][j]
|
k := g.Adjacency()[i][j]
|
||||||
|
//v2 := strconv.Quote(j.String()) // 2nd vertex
|
||||||
|
e := strconv.Quote(k.String()) // edge
|
||||||
// use str for clearer output ordering
|
// use str for clearer output ordering
|
||||||
//if fmtBoldFn(k) { // TODO: add this sort of formatting
|
//if fmtBoldFn(k) { // TODO: add this sort of formatting
|
||||||
// str += fmt.Sprintf("\t\"%s\" -> \"%s\" [label=\"%s\",style=bold];\n", i, j, k)
|
// str += fmt.Sprintf("\t\"%s\" -> \"%s\" [label=\"%s\",style=bold];\n", i, j, k)
|
||||||
//} else {
|
//} 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)
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user