digraph test { 
n0[ color=green ];
n1;
n2;
n3;
n4[ fontcolor=red ];
n5[ fontcolor=red ];
n6[ fontcolor=red ];
n0 -> n1[ label= "A"];
n1 -> n2[ label= "B"];
n2 -> n3[ label= "A"];
n3 -> n4[ label= "B"];
n4 -> n5[ label= "Y"];
n4 -> n6[ label= "X"];
n5 -> n5[ label= "Y"];
n5 -> n6[ label= "X"];
n6 -> n5[ label= "Y"];
n6 -> n6[ label= "X"];
}
