[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}
[latex tikz]画无向图的例子_第1张图片

你可能感兴趣的:(latex)