Graphviz Issue Tracker
Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0002141graphvizDotpublic2011-09-28 12:212011-09-28 14:17
Reporterianamason 
Assigned To 
PrioritynormalSeverityimportantReproducibilityalways
StatusnewResolutionopen 
PlatformOSOS Version
Summary0002141: Triangle dimensions incorrect
Description
I'm reporting the situation just for triangles, but on the forum thread:

http://www.graphviz.org/content/dots-triangles [^]

erg says:

"This is a bug in the shape-handling code that occurs when the [shape is] bilaterally symmetric both horizontally and vertically. In particular, it occurs if the node has an odd number of sides."
Steps To Reproduce
In particular when dot lays out a triangle

<strong> input.dot</strong>
<code>
digraph temp {
    graph [rankdir=TB];
    node [label="\N"];
    node1 [label=" ", shape=triangle, style=filled, fillcolor="0.75 0.8 1.0", color="0.0 0.0 0.0"];
}
<code>

using the command

<code>
dot -Tdot input.dot -o output.dot
</code>

it claims the dimensions are:

width="0.75", height="0.68889"

which is a width/height ratio of roughly 1.09.

<strong>output.dot</strong>
<code>
digraph temp {
    graph [rankdir=TB];
    node [label="\N"];
    graph [bb="0,0,54,50"];
    node1 [label=" ", shape=triangle, style=filled, fillcolor="0.75 0.8 1.0", color="0.0 0.0 0.0", pos="27,25", width="0.75", height="0.68889"];
}
</code>


When we ask dot to draw this triangle

dot -Tpng output.dot -o output.png

We see a triangle (output.png) that is 74 x 51, i.e. has a
width to height ratio of roughly 1.45.

How are we to interpret dot's width and height measurements so that
when we draw by dot's numbers, our shapes coincide? This is particularly
crucial when we draw edges from triangles.

TagsNo tags attached.
AUXILLARY-FILES
DATE-FIXED
FIX-COMMENT
FORMER-ID
INPUT-FILE
OUTPUT-FILE
STATUS-COMMENT
VERSION
Attached Filespng file icon output.png [^] (1,875 bytes) 2011-09-28 12:21

- Relationships

-  Notes
User avatar (0000073)
ellson (administrator)
2011-09-28 12:51

The width/height is actually that of the ellipse that touches all points of the polygon. This is always produces a box that is big enough for the polygon, but not always the smallest possible. The center of the box is also the center of the largest rectangular area in the node (the label area). The geometric center is not always in the same place. It is better to keep label centers aligned across a rank of nodes, rather than the geometric centers of the node shapes.

We could produce a more accurate bounding rectangle, but we'd need to represent it with 4 coords instead of the 2 now (width, height) to allow for the offset of the center. Certainly this information is available internally.

The meaning of width, height in the dot format is really just an input constraint. As an input constraint, the output values of width, height work fine for a downstream subsequent re-layout.
User avatar (0000074)
ellson (administrator)
2011-09-28 12:52

BTW. A triangle is not "symmetric vertically"
User avatar (0000075)
ianamason (reporter)
2011-09-28 13:25

Hmmmm. We use dot to layout large biological pathways, then render them in Java. See for example pl.csl.sri.com. Currently we restrict our nodes to be ellipses and rectangles, but as things become more complex it would be nice to have a wider repetoire, like for example triangles. However to do this we would
need to be able to interpret the height and width dimensions that dot reports,
and any other information that may be relevant.
User avatar (0000076)
ellson (administrator)
2011-09-28 13:59

Others have used the -Txdot format which provides all the shape and spline coordinates, or perhaps you could use -Tsvg ?
User avatar (0000077)
ianamason (reporter)
2011-09-28 14:17

Yes -Txdot does look promising. Thanks for the pointer. Very much appreciated.

- Issue History
Date Modified Username Field Change
2011-09-28 12:21 ianamason New Issue
2011-09-28 12:21 ianamason File Added: output.png
2011-09-28 12:51 ellson Note Added: 0000073
2011-09-28 12:52 ellson Note Added: 0000074
2011-09-28 13:25 ianamason Note Added: 0000075
2011-09-28 13:59 ellson Note Added: 0000076
2011-09-28 14:17 ianamason Note Added: 0000077


MantisBT 1.2.5[^]
Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker