graph/encoding/dot: fix line visit marking

This commit is contained in:
Dan Kortschak
2020-11-28 21:57:14 +10:30
parent d24ce68544
commit e2a07cfc01
2 changed files with 85 additions and 4 deletions

View File

@@ -220,7 +220,7 @@ func (p *simpleGraphPrinter) print(g graph.Graph, name string, needsIndent, isSu
continue
}
p.visited[edge{inGraph: name, from: nid, to: tid}] = true
p.visited[edge{inGraph: name, from: tid, to: n.ID()}] = true
p.visited[edge{inGraph: name, from: tid, to: nid}] = true
}
if !havePrintedEdgeHeader {
@@ -432,6 +432,8 @@ type multiGraphPrinter struct {
type line struct {
inGraph string
from int64
to int64
id int64
}
@@ -510,10 +512,18 @@ func (p *multiGraphPrinter) print(g graph.Multigraph, name string, needsIndent,
for _, l := range lines {
lid := l.ID()
if p.visited[line{inGraph: name, id: lid}] {
continue
if isDirected {
if p.visited[line{inGraph: name, from: nid, to: tid, id: lid}] {
continue
}
p.visited[line{inGraph: name, from: nid, to: tid, id: lid}] = true
} else {
if p.visited[line{inGraph: name, from: nid, to: tid, id: lid}] {
continue
}
p.visited[line{inGraph: name, from: nid, to: tid, id: lid}] = true
p.visited[line{inGraph: name, from: tid, to: nid, id: lid}] = true
}
p.visited[line{inGraph: name, id: lid}] = true
if !havePrintedEdgeHeader {
p.buf.WriteByte('\n')