[Xy-pic] arrow head direction

Aaron Lauda A.Lauda at dpmms.cam.ac.uk
Mon Sep 5 19:05:55 CEST 2005


Hi

Your code seems similar to the way I use xypic.  I would use the following 
code:
\[
\xy
%states
(0,30)*{q_0}*\xycircle(3.5,3.5){-}="q0";
(30,30)*{q_1}*\xycircle(3.5,3.5){-}="q1";
(30,0)*{q_2}*\xycircle(3.5,3.5){-}="q2";
%final state
(0,0)*{q_3}*\xycircle(3.0,3.0){-}*\xycircle(3.5,3.5){-}="q3";
%initial
(-8,30)*+{} = "i";
    {\ar "i"; "q0"};
    {\ar^{\txt{$a$}}  "q0"; "q1"};
    {\ar@<.5ex>               "q0"; "q2"};
    {\ar^{\txt{$b$}}  "q1"; "q2"};
    {\ar@<.5ex>              "q1"; "q3"};
    {\ar^{\txt{$c$}}  "q2"; "q3"};
    {\ar@<.5ex>               "q2"; "q0"};
    {\ar^{\txt{$d$}}  "q3"; "q0"};
    {\ar@<.5ex>               "q3"; "q1"};
%transitions
\endxy
\]

Or if you don't like the way the arrows bunch up on the circles, then add 
some `+' signs like I do below.

\[
\xy
%states
(0,30)*{q_0}*+\xycircle(3.5,3.5){-}="q0";
(30,30)*{q_1}*+\xycircle(3.5,3.5){-}="q1";
(30,0)*{q_2}*+\xycircle(3.5,3.5){-}="q2";
%final state
(0,0)*{q_3}*\xycircle(3.0,3.0){-}*+\xycircle(3.5,3.5){-}="q3";
%initial
(-8,30)*+{} = "i";
    {\ar "i"; "q0"};
    {\ar^{\txt{$a$}}  "q0"; "q1"};
    {\ar@<.5ex>               "q0"; "q2"};
    {\ar^{\txt{$b$}}  "q1"; "q2"};
    {\ar@<.5ex>              "q1"; "q3"};
    {\ar^{\txt{$c$}}  "q2"; "q3"};
    {\ar@<.5ex>               "q2"; "q0"};
    {\ar^{\txt{$d$}}  "q3"; "q0"};
    {\ar@<.5ex>               "q3"; "q1"};
%transitions
\endxy
\]

Hope this helps.
Regards,
Aaron


On 5 Sep 2005 r8yjke202 at sneakemail.com wrote:

> Hello,
> 
> my way to draw automata is to define the state positions and then to draw the transitions, p.ex.:
> 
> \[
> \xy
> %states
> (0,30)*{q_0}*\xycircle(3.5,3.5){-}="q0";
> (30,30)*{q_1}*\xycircle(3.5,3.5){-}="q1";
> (30,0)*{q_2}*\xycircle(3.5,3.5){-}="q2";
> %final state
> (0,0)*{q_3}*\xycircle(3.0,3.0){-}*\xycircle(3.5,3.5){-}="q3";
> %initial
> (-5,30)*+{} = "i";
> \ar @( l, r) "i"; "q0" <2pt>
> %transitions
> \ar @( r, l) "q0"; "q1" <2pt> ^{\txt{$a$}}
> \ar @(dr,ul) "q0"; "q2" <2pt>
> \ar @( d, u) "q1"; "q2" <2pt> ^{\txt{$b$}}
> \ar @(dl,ur) "q1"; "q3" <2pt>
> \ar @( l, r) "q2"; "q3" <2pt> ^{\txt{$c$}}
> \ar @(ul,dr) "q2"; "q0" <2pt>
> \ar @( d, u) "q3"; "q0" <2pt> ^{\txt{$d$}}
> \ar @(ur,dl) "q3"; "q1" <2pt>
> \endxy
> \]
> 
> The problem is, that in three cases the arrow head points to the wrong direction (q1->q3, q2->q0, q3->q1):
> 
> http://img197.imageshack.us/img197/1327/wrong7wl.png
> 
> Changing the position of q1 and q2 slightly (+1pt to the right) leads to the right behaviour:
> 
> http://img277.imageshack.us/img277/6443/right2sb.png
> 
> So, is this a bug or a failure in my code?
> 
> Greetings,
> 
> Frank.
> 
> _______________________________________________
> xy-pic mailing list
> http://tug.org/mailman/listinfo/xy-pic
> 



More information about the xy-pic mailing list