LaTeX

Bezier Curve

ForceCore 2009. 5. 24. 15:04
가끔, 곡선을 길게 그려야 할 때가 있다는...
node에서 node로 곡선을 이어야 하긴 하겠는데, bend left=각도 옵션으로도 예쁘게 커버가 안 되는 거리가 생길때가 있다. 가령 아래 그림에선, v_0에서 v_6나 v_5까지의 곡선이 되겠다.



그래서 엄... 코드는:

\tikzstyle{c} = [draw, shape=circle,minimum size=0.9cm]
\begin{tikzpicture}[auto]
\def\rad{3cm}
\node[c,fill=black!10] (v0) at(-2*\rad,0) {$v_0$};
\node[c,fill=black!10] (v1) at(90:\rad) {$v_1$};
\node[c,fill=black!10] (v2) at(150:\rad) {$v_2$};
\node[c,fill=black!10] (v3) at(210:\rad) {$v_3$};
\node[c,fill=black!10] (v4) at(270:\rad) {$v_4$};
\node[c,fill=black!10] (v5) at(330:\rad) {$v_5$};
\node[c,fill=black!10] (v6) at(30:\rad) {$v_6$};

% edges
% basic v0 nodes
\draw [-stealth] (v0) .. controls +(-90:2*\rad) and +(-90:2*\rad) .. node[swap]{0} (v5) ;
\draw [-stealth] (v0) .. controls +( 90:2*\rad) and +( 90:2*\rad) .. node{0} (v6) ;
\draw [-stealth,bend left=60] (v0) to node{0} (v1) ;
\draw [-stealth,bend right=60] (v0) to node[swap]{0} (v4) ;
\draw [-stealth,bend left] (v0) to node{0} (v2) ;
\draw [-stealth,bend right] (v0) to node[swap]{0} (v3) ;
% other inequalities
\draw [-stealth] (v2) to node{1} (v1);
\draw [-stealth] (v4) to node[pos=0.9]{-4} (v1);
\draw [-stealth] (v2) to node[swap]{2} (v3);
\draw [-stealth] (v5) to node[pos=0.7]{7} (v2);
\draw [-stealth] (v6) to node[pos=0.7]{5} (v2);
\draw [-stealth,bend right=10] (v6) to node[pos=0.9,swap]{10} (v3);
\draw [-stealth] (v2) to node[pos=0.7,swap]{2} (v4);
\draw [-stealth] (v1) to node[pos=0.7,swap]{-1} (v5);
\draw [-stealth] (v4) to node[swap]{3} (v5);
\draw [-stealth,bend right=10] (v3) to node[pos=0.9,swap]{-8} (v6);

\end{tikzpicture}

참 쉽죠?