본문 바로가기

misc./TeX

LaTeX 그래프 그리기


과제를 하던중 그래프를 그려야 하는 문제가 있어서 여기저기 찾아보다가 비교적 금방 "tikz" 라는 것을 발견했다.
한 시간 정도 공부하고 써보니 나름 괜찮은것 같다.

\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit}

...

\begin{tikzpicture}
\tikzstyle{Vertex} = [circle, draw, minimum size=6mm, inner sep=0pt]
\node (r) at (0,1) [Vertex, fill=white][label=above:$r$] {$\infty$};
\node (s) at (1,1) [Vertex, fill=white][label=above:$s$] {$\infty$};
\node (t) at (2,1) [Vertex, fill=white][label=above:$t$] {$\infty$};
\node (u) at (3,1) [Vertex, fill=gray ][label=above:$u$] {$0$};
\node (v) at (0,0) [Vertex, fill=white][label=below:$v$] {$\infty$};
\node (w) at (1,0) [Vertex, fill=white][label=below:$w$] {$\infty$};
\node (x) at (2,0) [Vertex, fill=white][label=below:$x$] {$\infty$};
\node (y) at (3,0) [Vertex, fill=white][label=below:$y$] {$\infty$};
\draw [-] (r) to (s);
\draw [-] (r) to (v);
\draw [-] (s) to (w);
\draw [-] (t) to (u);
\draw [-] (t) to (w);
\draw [-] (t) to (x);
\draw [-] (u) to (x);
\draw [-] (u) to (y);
\draw [-] (w) to (x);
\draw [-] (x) to (y);

\tikzstyle{Element} = [draw, minimum width=6mm, minimum height=6mm, node distance=6mm]
\node [name=Q1, Element][label=below:$1$][label=left:$Q$] at (4.5,0.5) {$u$};
\end{tikzpicture}

...



그런데 문제를 다시보니 그래프를 그리라는게 아니자나!!!!

난 여태 무었을 하고 있었던 거지

'misc. > TeX' 카테고리의 다른 글

Notepad++ MikTeX 연동하기  (0) 2010.03.14
LaTeX 바이너리 트리 그리기  (2) 2010.03.06