1

I appreciate it if you let me know the most elegant way to draw a DAG such as the followings: enter image description here

1
  • 1
    For better answers you might explain what a DAG is and what specifies it. Commented Apr 18, 2013 at 19:09

2 Answers 2

3

A possibility but not sure it's the most elegant. I added a little change with (x.45) to draw the edges from the same point like your example. I added also some styles.

 \documentclass{article}
 \usepackage{tikz}

 \begin{document}
 \begin{tikzpicture}[dot/.style={fill,draw,circle,minimum width=4pt},
        arrow style/.style={->,bend left,
        line width=1.2pt,shorten >=3pt}]

 \path[every node/.style={dot}]     
                   node [label=west:$X$]          (x) {}
       + ( 45:3cm) node [label=east:$T$]          (t) {}
       + (-20:3cm) node [label=south east:$Z$]    (z) {}
       + (-60:3cm) node [label=south:$Y$]         (y) {};

 \draw
      (x.45)  edge [arrow style] node [auto] {$y$} (y)
              edge [arrow style] node [auto] {$z$} (z)     
              edge [arrow style] node [auto] {$t$} (t);

 \end{tikzpicture}
 \end{document}   

enter image description here

It's possible to get a shorter code but the question is to know if a shorter code is most elegant. Personally I prefer if it's possible to avoid the mix of multiple actions like to draw the nodes first and then to draw the edges.

   \documentclass{article}
   \usepackage{tikz}

   \begin{document}
   \begin{tikzpicture}[dot/.style={fill,draw,circle,minimum width=4pt},
                       arrow style/.style={<-,bend right,line width=1.2pt,
                       shorten <=3pt,shorten >=3pt}]

   \node [dot,label=west:$X$]  (x) {};
   \node [dot,label=east:$T$]  (t)  at   (45:3cm)  {}
                       edge [arrow style] node [auto] {$t$} (x);
   \node [dot,label=south east:$Z$]  (z)  at   (-20:3cm)  {}
                       edge [arrow style] node [auto] {$z$} (x);
   \node [dot,label=south:$Y$]  (y)  at   (-60:3cm)  {}
                       edge [arrow style] node [auto] {$y$} (x);
   \end{tikzpicture}
   \end{document}   
0
1

With PSTricks.

enter image description here

\documentclass[preview,border=15pt]{standalone}
\usepackage{pst-eucl}
\psset{shortput=tablr,arrows=->,nodesepB=5pt,dotscale=2,arcangle=45}
\begin{document}
\begin{pspicture}(4,5)
    \pstGeonode[PosAngle={0,180,-45,-90}](3,5){T}(0,3){X}(4,2){Z}(2,0){Y}
    \ncarc{X}{T}^[tpos=0.3]{$t$}
    \ncarc{X}{Z}^[tpos=0.6]{$z$}
    \ncarc{X}{Y}^[tpos=0.9]{$y$}
\end{pspicture}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .