3
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath,amssymb}
\usepackage[utf8]{vietnam}
\usepackage{pstricks,pst-node} % required package
\usepackage{auto-pst-pdf} 
\begin{document}
\begin{pspicture}    
\psmatrix[linecolor=red,mnode=Circle,radius=3mm,colsep=1.25cm,rowsep=1.25cm]
   [name=2] 2 &  & [name=3] 3 \\
              &[name=5] 5 \\
   [name=1] 1 &  & [name=4] 4
\psset{linecolor=blue,arrowscale=1.5}

\ncline{->}{3}{2}
\ncline{->}{4}{3}
\ncline{->}{4}{5} 
\ncline{->}{5}{3}
\ncline{->}{5}{1}
\ncline{->}{1}{4}

\nccurve[angleA=80,angleB=25,ncurv=5]{->}{3}{3}

\ncarc[arcangle=22]{->}{1}{2}
\ncarc[arcangle=22]{->}{2}{1}
\endpsmatrix 

\end{pspicture}
\end{document}

How to draw Picture 1 like as Picture 2?(I see, 2 is more beautiful than 1)

How to compact \ncline or we can only typing manually? It means is there a macro like as \ncline{->}{3}{2}{->}{4}{3}{->}{4}{5}... ?

Picture 1:

enter image description here

Picture 2:

enter image description here

The code of Picture 2 ( use tikz )

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
[every node/.style={circle,draw=red},
 every path/.style={blue,-latex,thick}]
\def\a{2}
\node (5) at (0,0) {$5$};
\node (1) at (-\a,-\a) {$1$};
\node (2) at (-\a,\a) {$2$};
\node (3) at (\a,\a) {$3$};
\node (4) at (\a,-\a) {$4$};
\draw (1)--(4); \draw (4)--(3);
\draw (3)--(2); \draw (5)--(3);
\draw (5)--(1); \draw (4)--(5);
\draw (2) to[out=-70,in=70] (1);
\draw (1) to[out=110,in=-110] (2);
\draw (3) .. controls +(80:1) and +(30:1) .. (3); % <<<---- notice!
\end{tikzpicture}
\end{document}
  • 2
    Please improve question title. – albert Nov 29 '18 at 12:02
  • :))))))))))))))))))))))))))) – Trong Vuong Nov 29 '18 at 12:10
  • I assume you mean here that picture 2 (though hard to see that it are 2 pictures as they are in the output very close to one another) is nicer, in your eyse, than picture 1. In what respect ? What is the difference in the generation of picture 1 and picture 2? – albert Nov 29 '18 at 12:23
  • I don't know the difference in the generation between them. :-)). I only hope anyone improve its macro "\nccurve[angleA=80,angleB=25,ncurv=5]{->}{3}{3}". ;)) – Trong Vuong Nov 29 '18 at 12:32
  • Can you change the title to reflect which problem you have? At the moment it won't help any future users who might have the same problem as you – user36296 Nov 29 '18 at 12:37
5

define your own macro and for the loop use symmetrical angles with respect to 45 degrees::

\documentclass{article}
\usepackage{pst-node} % required package
\usepackage{auto-pst-pdf} 

\makeatletter
\newcommand\NCline[3]{\ncline{#1}{#2}{#3}\@ifnextchar\bgroup\NCline{}}
\makeatother
\begin{document}
 \psmatrix[linecolor=red,mnode=Circle,radius=3mm,colsep=1.25cm,rowsep=1.25cm]
    [name=2] 2 &            & [name=3] 3 \\
               &[name=5] 5 \\
    [name=1] 1 &            & [name=4] 4
\psset{linecolor=blue,arrowscale=1.5}
\NCline{->}{3}{2}{->}{4}{3}{->}{4}{5}{->}{5}{3}{->}{5}{1}{->}{1}{4}
\nccurve[angleA=75,angleB=15,ncurv=6]{->}{3}{3}

\ncarc[arcangle=22]{->}{1}{2}
\ncarc[arcangle=22]{->}{2}{1}
\endpsmatrix 

\end{document}

enter image description here

  • What do you think about its the tikz code?. ( I see its code "shorter" but "complete" :-(( .The pstricks code is longer, more complex than or the reason my code is not enough short as it ). See my editted comment – Trong Vuong Nov 29 '18 at 13:14
  • sure, it has absolute coordinates for the nodes! Can also be done with PSTricks. – user2478 Nov 29 '18 at 13:18

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.