Advertisement

[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}

全部评论 (0)

还没有任何评论哟~