if unknown N: N:= 5 fi; % number of vertices if unknown thick#: thick#:=0.5pt# fi; % linewidth if unknown R#: R#:= 7.5mm# fi; % radius of the circle, on which the vertices lie if unknown DV#: DV#:= R#/3 fi; % diameter of "vertex" if unknown HR#: HR#:= DV#/2 fi; % size of the arrow tip if unknown Horiz#: Horiz# = 10/3*R# fi; % height of the character if unknown Vert#: Vert# = 2.1*R#+DV# fi; % width of the character Dphi:= 360/N; % angle between two adjacent vertices define_pixels(thick, R, DV, HR); % draw the vertex no. iii on coordinates (xxx,yyy) % and save the coordinates into xx[] and yy[] def vertex(expr iii, xxx, yyy) = draw fullcircle scaled DV shifted(xxx,yyy); xx[iii]:= xxx; yy[iii]:= yyy; enddef; % draw N small circles (vertices of the graph) placed on vertices of regular polygon % and save the coordinates into xx[] and yy[] def vertices = phi:= (180-Dphi)/2; for i=1 upto N: vertex(i, R - R*cosd(phi), R - R*sind(phi)); phi:= phi + Dphi; endfor; enddef; % pickup the pen def pickupthepen = pickup pencircle scaled thick; enddef; % draw the line between the vertices u, v def line(expr u, v) = len:= length ((xx[u],yy[u])-(xx[v],yy[v])); draw point DV/2/len of ((xx[u],yy[u])--(xx[v],yy[v]))--point (len-DV/2)/len of ((xx[u],yy[u])--(xx[v],yy[v])); enddef; % draw the arrow tip def UzavrenyHrot = begingroup save x, y; ((0,0)--(-HR,HR/2)--(-HR,-HR/2)--cycle) endgroup enddef; % draw the arrow tip def OtevrenyHrot = begingroup save x, y; ((0,0)--(-HR,HR/2)--(0,0)--(-HR,-HR/2)--cycle) endgroup enddef; % draw the arrow from u to v def arrow(expr u,v) = pair konec; % pomocna promenna len:= length ((xx[u],yy[u])-(xx[v],yy[v])); konec = point (len-DV/2)/len of ((xx[u],yy[u])--(xx[v],yy[v])); draw point DV/2/len of ((xx[u],yy[u])--(xx[v],yy[v]))--konec; filldraw UzavrenyHrot rotated angle((xx[v],yy[v])-(xx[u],yy[u])) shifted konec; enddef;