graph/encoding/dot: factor out repeated forward keys
diff --git a/graph/encoding/dot/encode.go b/graph/encoding/dot/encode.go
index 1cba7c1..2ff893e 100644
--- a/graph/encoding/dot/encode.go
+++ b/graph/encoding/dot/encode.go
@@ -210,16 +210,17 @@
sort.Sort(ordered.ByID(to))
for _, t := range to {
tid := t.ID()
+ f := edge{inGraph: name, from: nid, to: tid}
if isDirected {
- if p.visited[edge{inGraph: name, from: nid, to: tid}] {
+ if p.visited[f] {
continue
}
- p.visited[edge{inGraph: name, from: nid, to: tid}] = true
+ p.visited[f] = true
} else {
- if p.visited[edge{inGraph: name, from: nid, to: tid}] {
+ if p.visited[f] {
continue
}
- p.visited[edge{inGraph: name, from: nid, to: tid}] = true
+ p.visited[f] = true
p.visited[edge{inGraph: name, from: tid, to: nid}] = true
}
@@ -512,16 +513,17 @@
for _, l := range lines {
lid := l.ID()
+ f := line{inGraph: name, from: nid, to: tid, id: lid}
if isDirected {
- if p.visited[line{inGraph: name, from: nid, to: tid, id: lid}] {
+ if p.visited[f] {
continue
}
- p.visited[line{inGraph: name, from: nid, to: tid, id: lid}] = true
+ p.visited[f] = true
} else {
- if p.visited[line{inGraph: name, from: nid, to: tid, id: lid}] {
+ if p.visited[f] {
continue
}
- p.visited[line{inGraph: name, from: nid, to: tid, id: lid}] = true
+ p.visited[f] = true
p.visited[line{inGraph: name, from: tid, to: nid, id: lid}] = true
}