如果您能告诉我绘制 DAG 的最优雅的方法,我将不胜感激,例如:
答案1
有可能,但不确定它是否最优雅。我使用 (x.45) 做了一些改动,以便从与示例相同的点绘制边缘。我还添加了一些样式。
\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}
可以得到更短的代码,但问题是知道更短的代码是否最优雅。我个人更喜欢是否可以避免混合多个操作,例如先绘制节点,然后绘制边缘。
\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}
答案2
使用 PSTricks。
\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}