3

I draw the following graph in Metapost. How to make the vertices of the subgraph with red edges not connect to arrows. The graph I obtained is enter image description here

I want the vertices looks like the following picture (there is small space between a vertex and the arrows connnected to it). Thank you very much.

enter image description here

beginfig(1) ;
pair A[],L[],R[],N[],q[];
path p[];

A[1] := (0,2cm);

for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;

label.top(btex 1  etex, A[1]);
label.rt(btex 2  etex, A[2]);
label.bot(btex 3  etex, A[3]);
label.bot(btex 4  etex, A[4]);
label.lft(btex 5  etex, A[5]);


for i=1 upto 5:
q[i]:=A[i] rotated -36;
endfor;

q[6]:=0.5[A[1], A[4]];

for i=1 upto 6:
draw q[i] withpen pencircle scaled 2bp;
endfor;


for i=1 upto 5:
draw A[i] withpen pencircle scaled 2bp;
endfor;

N[1]:=0.5[A[1],A[4]];
N[2]:=1.5[A[5],N[1]];
N[3]:=0.5[A[5],N[1]];

p[1]:=A[1]..N[2]..A[4];
p[2]:=A[4]..N[3]..A[1];

draw p[1];
draw p[2];

drawarrow subpath(0,1) of p[1];
drawarrow subpath(0,0.2) of p[1];
drawarrow subpath(0,1.8) of p[1];

drawarrow subpath(0,1) of p[2];
drawarrow subpath(0,0.2) of p[2];
drawarrow subpath(0,1.8) of p[2];

N[1]:=0.5[A[2],A[5]];
N[2]:=0.5[A[1],N[1]];

p[3]:=A[2]..N[2]..A[5];


draw p[3];

drawarrow subpath(0,1.3) of p[3];
drawarrow subpath(0,0.5) of p[3];
drawarrow subpath(0,1.8) of p[3];

N[1]:=0.5[A[5],A[3]];
N[2]:=0.5[A[4],N[1]];

p[4]:=A[5]..N[2]..A[3];


draw p[4];

drawarrow subpath(0,0.8) of p[4];
drawarrow subpath(0,0.3) of p[4];
drawarrow subpath(0,1.8) of p[4];

p[5]:=A[3]..A[2];


draw p[5];
drawarrow subpath(0,0.5) of p[5];


drawarrow q[2]..A[2]..q[1] withcolor red;
drawarrow q[5]..A[1]..q[1] withcolor red;
drawarrow q[5]..A[5]..q[4] withcolor red;
drawarrow q[3]..A[4]..q[4] withcolor red;
drawarrow q[3]..A[3]..q[2] withcolor red;


drawarrow q[1].. p[1] intersectionpoint p[3] ..q[6] withcolor red;
drawarrow q[6].. p[3] intersectionpoint p[2] ..q[5] withcolor red;
drawarrow q[4].. p[4] intersectionpoint p[2] ..q[6] withcolor red;
drawarrow q[6].. p[4] intersectionpoint p[1] ..q[3] withcolor red;


endfig;

end
  • Just an honest question to the upvoters? Is this latex related (in order of this site) or there is a better forum to ask this question? – koleygr Nov 12 '18 at 12:34
  • 1
    @koleygr METAPOST is part of TeX systems, shipped with texlive and friends. Btw this is TeX S.E., not LaTeX S.E. There also plain TeX users, ConTeXt users and more here. – sztruks Nov 12 '18 at 12:39
  • @sztruks... My question was honest, and haven't herd about metapost... Thanks for the info... (ConTeXt is also something I have no idea about and will check it soon). Thanks – koleygr Nov 12 '18 at 12:43
  • 2
    @koleygr. No problem, those great tools are not as known as they could be. And my first comment was definatly too rude, apologize. – sztruks Nov 12 '18 at 12:46
  • @sztruks.. Just show the edit in your comment... I didn't found rude your first comment... Really.. Not at all.. It was a useful comment for me, and just noticed there that I had asked about "LaTeX related" and not "TeX related" as had too by mistake. But your comment was not rude at all, but a nice comment with enough information I needed to know about. – koleygr Nov 12 '18 at 15:42
4

Here is an answer : I designed circles around your vertices and used cutbefore and cutafter primitives

beginfig(1) ;
pair A[],L[],R[],N[],q[];
path p[];

A[1] := (0,2cm);

for i=2 upto 5:
   A[i] := A[i-1] rotated -360/5;
endfor;

label.top(btex 1  etex, A[1]);
label.rt(btex 2  etex, A[2]);
label.bot(btex 3  etex, A[3]);
label.bot(btex 4  etex, A[4]);
label.lft(btex 5  etex, A[5]);


for i=1 upto 5:
q[i]:=A[i] rotated -36;
endfor;

q[6]:=0.5[A[1], A[4]];

for i=1 upto 6:
   draw q[i] withpen pencircle scaled 2bp;
endfor;

for i=1 upto 5:
   draw A[i] withpen pencircle scaled 2bp;
endfor;

N[1]:=0.5[A[1],A[4]];
N[2]:=1.5[A[5],N[1]];
N[3]:=0.5[A[5],N[1]];

p[1]:=A[1]..N[2]..A[4];
p[2]:=A[4]..N[3]..A[1];

draw p[1];
draw p[2];

drawarrow subpath(0,1) of p[1];
drawarrow subpath(0,0.2) of p[1];
drawarrow subpath(0,1.8) of p[1];

drawarrow subpath(0,1) of p[2];
drawarrow subpath(0,0.2) of p[2];
drawarrow subpath(0,1.8) of p[2];

N[1]:=0.5[A[2],A[5]];
N[2]:=0.5[A[1],N[1]];

p[3]:=A[2]..N[2]..A[5];

draw p[3];

drawarrow subpath(0,1.3) of p[3];
drawarrow subpath(0,0.5) of p[3];
drawarrow subpath(0,1.8) of p[3];

N[1]:=0.5[A[5],A[3]];
N[2]:=0.5[A[4],N[1]];

p[4]:=A[5]..N[2]..A[3];


draw p[4];

drawarrow subpath(0,0.8) of p[4];
drawarrow subpath(0,0.3) of p[4];
drawarrow subpath(0,1.8) of p[4];

p[5]:=A[3]..A[2];

draw p[5];
drawarrow subpath(0,0.5) of p[5];

%circles that will create buffers around your vertice
path c[]; 
for i=1 upto 6 :
   c[i]:= fullcircle scaled 4bp shifted q[i] ;
endfor

path r[];
 r[1]:= q[2]..A[2]..q[1] ;
 r[2]:= q[5]..A[1]..q[1] ;
 r[3]:= q[5]..A[5]..q[4] ;
 r[4]:= q[3]..A[4]..q[4] ;
 r[5]:= q[3]..A[3]..q[2] ;
 r[6]:= q[1].. p[1] intersectionpoint p[3] ..q[6] ;
 r[7]:= q[6].. p[3] intersectionpoint p[2] ..q[5] ;
 r[8]:= q[4].. p[4] intersectionpoint p[2] ..q[6] ;
 r[9]:= q[6].. p[4] intersectionpoint p[1] ..q[3] ;

%cutafter and cutbefore cut path before and after a pair
drawarrow (r[1] cutbefore c[2] cutafter c[1]) withcolor red;
drawarrow (r[2] cutbefore c[5] cutafter c[1]) withcolor red;
drawarrow (r[3] cutbefore c[5] cutafter c[4]) withcolor red;
drawarrow (r[4] cutbefore c[3] cutafter c[4]) withcolor red;
drawarrow (r[5] cutbefore c[3] cutafter c[2]) withcolor red;
drawarrow (r[6] cutbefore c[1] cutafter c[6]) withcolor red;
drawarrow (r[7] cutbefore c[6] cutafter c[5]) withcolor red;
drawarrow (r[8] cutbefore c[4] cutafter c[6]) withcolor red;
drawarrow (r[9] cutbefore c[6] cutafter c[3]) withcolor red;

endfig ;

end

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.