[latex tikz]畫無向圖的例子

%Tikz畫圖
\usepackage{tikz}
\usetikzlibrary{arrows,graphs} %指明是圖庫
	\begin{tikzpicture}[> = stealth, % arrow head style
	shorten > = 1pt, % don't touch arrow head to node
	auto,
	node distance = 3cm, % distance between nodes
	semithick % line style
	,scale=.8,auto=left,every node/.style={circle,fill=blue!20}]
	\node (n1) at (0,0)		{1};
	\node (n2) at (0,-2)  	{2};
	\node (n3) at (0,-4) 	{3};
	\node (n4) at (0,-6) 	{4};
	\node (n5) at (0,-8) 	{5};
	\draw (n1)--(n2);
	\draw (n2)--(n3);
	\draw (n3)--(n4);
	\draw [red,very thick](n4)--(n5);
	\draw [red,very thick] (n1) .. controls (-2,-2.5)  ..(n4);
	\draw [red,very thick](n1) .. controls (2,-3.5) 	..(n5);
	\end{tikzpicture}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章