使用 Tikz Graph 进行循环

使用 Tikz Graph 进行循环

如何在任意节点上放置自定义自循环?

\documentclass[legalpaper,landscape]{article}
\usepackage[utf8]{inputenc}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[paperheight=22cm,paperwidth=22cm,bottom=0.5cm,top=0.5cm,left=0cm,right=0cm]{geometry}

\usepackage[upright]{fourier}
\usepackage{tkz-graph}
\usetikzlibrary{arrows}
\thispagestyle{empty}

\begin{document}
\SetVertexNormal[Shape  = circle,
             FillColor  = black,
             LineWidth  = 2pt,
             InnerSep   =  0pt]
\SetUpEdge[lw     = 3pt,
       color      = black,
       labelcolor = white]

\begin{center}
\begin{tikzpicture}{\SetGraphUnit{5}
\Vertices[x=0,y=0]{line}{1,2,3,4,5}}
\Vertex[x=10,y=10]{6}
\Vertex[x=10,y=5]{7}
\Vertex[x=10,y=-10]{8}
\Vertex[x=10,y=-5]{9}
\Vertex[x=5,y=3]{10}
\Vertex[x=5,y=-3]{11}
\Vertex[x=15,y=3]{12}
\Vertex[x=15,y=-3]{13}
\Vertex[x=7.5,y=5]{14}
\Vertex[x=7.5,y=-5]{15}
\Vertex[x=12.5,y=5]{16}
\Vertex[x=12.5,y=-5]{17}
\Edges(1,10,3,12,5,13,3,11,1,2,3,4,5)
\Edges(3,14,6,16,3,17,8,15,3)
\Edges(6,7,3,9,8)
\end{tikzpicture}
\end{center}

\end{document}  

答案1

\Loop

\documentclass[border=3pt]{standalone}
\usepackage[upright]{fourier}
\usepackage{tkz-graph}
\usetikzlibrary{arrows}

\begin{document}
\SetVertexNormal[Shape  = circle,
             FillColor  = black,
             LineWidth  = 2pt,
             InnerSep   =  0pt]
\SetUpEdge[lw     = 3pt,
       color      = black,
       labelcolor = white]

\begin{tikzpicture}{\SetGraphUnit{5}
\Vertices[x=0,y=0]{line}{1,2,3,4,5}}
\Vertex[x=10,y=10]{6}
\Vertex[x=10,y=5]{7}
\Vertex[x=10,y=-10]{8}
\Vertex[x=10,y=-5]{9}
\Vertex[x=5,y=3]{10}
\Vertex[x=5,y=-3]{11}
\Vertex[x=15,y=3]{12}
\Vertex[x=15,y=-3]{13}
\Vertex[x=7.5,y=5]{14}
\Vertex[x=7.5,y=-5]{15}
\Vertex[x=12.5,y=5]{16}
\Vertex[x=12.5,y=-5]{17}
\Edges(1,10,3,12,5,13,3,11,1,2,3,4,5)
\Edges(3,14,6,16,3,17,8,15,3)
\Edges(6,7,3,9,8)
\Loop[dist=2cm,dir=WE,style={ultra thick,->}](1)
\Loop[dist=3cm,dir=EA,style={line width=4pt,blue,->}](6)
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容