I am attempting to draw the figure shown in the picture below in Metapost, where it is important that the edge between the boxes starts at the middle of the bottom line of the "perfect" box, and ends at the middle of the top line of the "chordal" box. After using the boxit command to make a box with the desired text, I set its coordinates using .c. Then I want to draw the line between the boxes before I draw the boxes themselves, however, I am unable to reference .n, .s, or any coordinates besides .c of the box. After some headache I finally found a workaround to do what I want, but it appears like black magic to me why it does. Maybe the calls to bpath.perfect and bpath.chordal somehow generates the necessary information. Can someone enlighten me as to what is going on?
prologues := 3;
%outputtemplate := "%j-%c.mps";
input boxes;
beginfig(0);
% Boxes
boxit.perfect(btex perfect etex); perfect.c=(0,0);
boxit.chordal(btex chordal etex); chordal.c=15right+30down;
% Will crash:
draw perfect.s--chordal.n;
drawboxed(perfect, chordal);
endfig;
beginfig(1);
% Boxes
boxit.perfect(btex perfect etex); perfect.c=(0,0);
boxit.chordal(btex chordal etex); chordal.c=15right+30down;
% Black magic. This is never actually drawn.
path temp;
temp = perfect.c--chordal.c cutbefore bpath.perfect cutafter bpath.chordal;
% Works perfectly fine:
draw perfect.s--chordal.n;
drawboxed(perfect, chordal);
endfig;
The error message I receive when I compile is the following:
This is MetaPost, version 1.999 (TeX Live 2015) (kpathsea version 6.2.1)
(/usr/local/texlive/2015/texmf-dist/metapost/base/mpost.mp
(/usr/local/texlive/2015/texmf-dist/metapost/base/plain.mp
Preloading the plain mem file, version 1.005) ) (./mwe.mp
(/usr/local/texlive/2015/texmf-dist/metapost/base/boxes.mp)
>> -ypart perfect.nw
! Undefined y coordinate has been replaced by 0.
<to be read again>
{
--->{
curl1}..{curl1}
l.13 draw perfect.s--
chordal.n;
?

drawboxed, so the anchors work after the firstdrawboxed(ordrawunboxed). If you want to use the anchors before you draw the boxes you can callfixsize(..list of suffixes..)andfixpos(..list of suffixes..). If you look at the source ofboxes.mpit shows you how. – Thruston Jun 17 '16 at 19:30bpathalso automatically callsfixsizeandfixpos. – Thruston Jun 17 '16 at 19:31