aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2008-11-20 12:49:15 +0000
committerArmin Rigo <arigo@tunes.org>2008-11-20 12:49:15 +0000
commitdcbf2bd228abd8720d3319b1dd1a8a20cc99d388 (patch)
treeb9af197040d6407bbdf89862a27ee6086ec05e74 /dotviewer
parentthese days we can reuse the same huge values :-) Also, skip impl details (diff)
downloadpypy-dcbf2bd228abd8720d3319b1dd1a8a20cc99d388.tar.gz
pypy-dcbf2bd228abd8720d3319b1dd1a8a20cc99d388.tar.bz2
pypy-dcbf2bd228abd8720d3319b1dd1a8a20cc99d388.zip
We don't know when the list of vertices in the right
or reversed order. Reverse it whe we detect it is the case.
Diffstat (limited to 'dotviewer')
-rw-r--r--dotviewer/drawgraph.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/dotviewer/drawgraph.py b/dotviewer/drawgraph.py
index 7fcab5723a..f001740f8b 100644
--- a/dotviewer/drawgraph.py
+++ b/dotviewer/drawgraph.py
@@ -167,8 +167,16 @@ class Edge:
def arrowhead(self):
result = self.cachedarrowhead
if result is None:
- bottom_up = self.points[0][1] > self.points[-1][1]
- if (self.tail.y > self.head.y) != bottom_up: # reversed edge
+ # we don't know if the list of points is in the right order
+ # or not :-( try to guess...
+ def dist(node, pt):
+ return abs(node.x - pt[0]) + abs(node.y - pt[1])
+
+ error_if_direct = (dist(self.head, self.points[-1]) +
+ dist(self.tail, self.points[0]))
+ error_if_reversed = (dist(self.tail, self.points[-1]) +
+ dist(self.head, self.points[0]))
+ if error_if_direct > error_if_reversed: # reversed edge
head = 0
dir = 1
else: