如何绘制具有一定半径的圆弧

如何绘制具有一定半径的圆弧

我正在尝试在图表中的节点之间绘制箭头,如下图所示。圆弧不太好看,因为它们与我想要的半径不一致,而且我画的是虚线。非常感谢您的任何建议。

更新:我忘了说我还想在每个弧上方写一段文字。更新 2:新代码和结果位于本文末尾。

在此处输入图片描述

\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, automata,
                calc,
                positioning,
                quotes}


\begin{document}
 \begin{tikzpicture}[auto, node distance = 30mm and 40mm,
        dot/.style = {circle, fill=red, inner sep=2pt, node contents={}},
every state/.style = {circle, draw=red, very thick},
 every edge/.style = {draw=blue, line width=1pt, -Stealth,
                      shorten >=2pt, shorten <=2pt,
                      },
 every edge quotes/.style = {auto, sloped, inner sep=2pt},
       every label/.style = {rectangle, inner sep=2pt, font=\large},
     mincut/.style = {draw=green!40!black, line width=3pt, dashed}
                                              ]

 \foreach [count=\i] \ang in {60} 
 { 
\node[state]         (1) at (120:5cm)         {$1$};

\node[state]         (2) at (\ang+120:5cm)    {$2$};

\node[state]         (3) at (2*\ang+120:5cm)   {$3$};

\node[state]         (6) at (3*\ang+120:5cm)   {$6$};

\node[state]         (5) at (4*\ang+120:5cm)   {$5$};

\node[state]         (4) at (5*\ang+120:5cm)   {$4$};
}
;


\path       (1) edge["text 1",bend right]    (2)
                edge["text 2",bend left]     (4)
                edge[near start]    (6)
            
            (2) edge["text 3", bend right]   (3)
            
            (3) edge[ near start]   (4)
            
            (4) edge["text 4", bend left]    (5)

            (5) edge["text 5", bend left]    (6)            

            (6) edge["text 6", bend left]   (3);

\draw[-latex,dashed] (5,0) arc[start angle=0, end angle=360,radius=5cm];



\end{tikzpicture}
\end{document}

这是我根据以下答案编写的更新后的代码。

\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, automata,
                calc,
                positioning,
                quotes}


\begin{document}
 \begin{tikzpicture}[auto, node distance = 30mm and 40mm,
        dot/.style = {circle, fill=red, inner sep=2pt, node contents={}},
every state/.style = {circle, draw=red, very thick},
 every edge/.style = {draw=blue, line width=1pt, -Stealth,
                      shorten >=2pt, shorten <=2pt,
                      },
 every edge quotes/.style = {auto, sloped, inner sep=2pt},
       every label/.style = {rectangle, inner sep=2pt, font=\large},
     mincut/.style = {draw=green!40!black, line width=3pt, dashed}
                                              ]

 \foreach [count=\i] \ang in {60} 
 { 
\node[state]         (5) at (0:5cm)   {$5$};
\node[state]         (4) at (60:5cm)   {$4$};
\node[state]         (1) at (120:5cm)   {$1$};
\node[state]         (2) at (180:5cm)    {$2$};
\node[state]         (3) at (240:5cm)   {$3$};
\node[state]         (6) at (300:5cm)   {$6$};
}
;


\path       (1) edge["text 7",near start]    (6)
            
            (3) edge["text 8", near start]   (4);

% 1-4            
\draw[{Stealth}-,line width=1pt, blue] (60*1+5:5cm) arc (60*1+5:60*1+55:5cm) node [pos=0.5, above, red, sloped] {text 2};

% 4-5
\draw[{Stealth}-,line width=1pt, blue] (60*6+5:5cm) arc (60*6+5:60*6+55:5cm) node [pos=0.5, above, red, sloped] {text 4};

% 5-6
\draw[{Stealth}-,line width=1pt, blue] (60*5+5:5cm) arc (60*5+5:60*5+55:5cm) node [pos=0.5, above, red, sloped] {text 5};

% 6-3
\draw[{Stealth}-,line width=1pt, blue] (60*4+5:5cm) arc (60*4+5:60*4+55:5cm) node [pos=0.5, above, red, sloped] {text 5};

% 1-2            
\draw[-{Stealth},line width=1pt, blue] (60*2+5:5cm) arc (60*2+5:60*2+55:5cm) node [pos=0.5, above, red, sloped] {text 1};

% 2-3
\draw[-{Stealth},line width=1pt, blue] (60*3+5:5cm) arc (60*3+5:60*3+55:5cm) node [pos=0.5, above, red, sloped] {text 3};


\end{tikzpicture}
\end{document}

由此得到此图。

在此处输入图片描述

答案1

您可以使用它arc在节点之间绘制完美的曲线,但您应该提供一些偏移以免与节点重叠。

\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, automata, calc, positioning, quotes}

\begin{document}

\begin{tikzpicture}[auto, node distance = 30mm and 40mm,
        dot/.style = {circle, fill=red, inner sep=2pt, node contents={}},
every state/.style = {circle, draw=red, very thick},
 every edge/.style = {draw=blue, line width=1pt, -Stealth, shorten >=2pt, shorten <=2pt,},
 every edge quotes/.style = {auto, sloped, inner sep=2pt},
       every label/.style = {rectangle, inner sep=2pt, font=\large},
     mincut/.style = {draw=green!40!black, line width=3pt, dashed}
                                              ]
\foreach [count=\i] \ang in {60} { 
 \node[state]         (1) at (120:5cm)        {$1$};
 \node[state]         (2) at (\ang+120:5cm)   {$2$};
 \node[state]         (3) at (2*\ang+120:5cm) {$3$};
 \node[state]         (6) at (3*\ang+120:5cm) {$6$};
 \node[state]         (5) at (4*\ang+120:5cm) {$5$};
 \node[state]         (4) at (5*\ang+120:5cm) {$4$};
};

\foreach \i in {0,...,5}
 \draw[{Stealth}-,line width=1pt] (60*\i+5:5cm) arc (60*\i+5:60*\i+55:5cm);

\end{tikzpicture}

\end{document}

在此处输入图片描述

答案2

没有专家解决方案:

\documentclass[border=1cm]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}

    \foreach \i in {1,...,6}{%
        \draw[-latex,line width=2pt] (60*\i+5:5cm) arc (60*\i+5:60*\i+55:5cm);
        \draw[red] (60*\i:5cm) circle(12pt);
        \node at (60*\i:5cm) () {$\i$};
        }
    \filldraw (0,0) circle(2pt); % comment this line if you dont want the circle center 

\end{tikzpicture}

\end{document}

输出:

在此处输入图片描述

编辑:针对您的编辑请求:

\documentclass[border=1cm]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \foreach \i in {1,...,6}{%
        \draw[blue,-latex,line width=2pt] (60*\i+5:5cm) arc (60*\i+5:60*\i+55:5cm) node [pos=0.5, above, red, sloped] {text\i};
        \filldraw[red!20] (60*\i:5cm) circle(12pt);
        \node at (60*\i:5cm) (\i) {$\i$};
        }
    \draw[blue,-latex,shorten >=5pt, shorten <=5pt] (2)--(5) node [pos=0.3, above, red, sloped] {text7};;
    \draw[blue,-latex,shorten >=5pt, shorten <=5pt,] (4)--(1) node [pos=0.3, above, red, sloped] {text8};;
    \filldraw (0,0) circle(2pt);
\end{tikzpicture}

\end{document}

输出: 在此处输入图片描述

相关内容