我需要帮助来制作以下图表:
但是如果不越过顶点,我就无法弯曲边缘。
\begin{tikzpicture}[scale = 0.75]
\tikzstyle{every state}=[fill opacity=0.5,text opacity=1,semithick,minimum size=10pt]
\tikzset{roundnode/.style={thick, draw = black, fill = white, outer sep = 1.5, circle, minimum size = 10pt, scale = 0.75}}
\node[roundnode = black] (1) at (30, 2.01){1};
\node[roundnode = black] (2) at (31.91, 0.62){2};
\node[roundnode = black] (3) at (31.18, -1.63){3};
\node[roundnode = black] (4) at (28.82, -1.63){4};
\node[roundnode = black] (5) at (28.09, 0.62){5};
\draw
(1) edge[-,thick] (2)
(2) edge[-,thick] (3)
(3) edge[-,thick] (4)
(4) edge[-,thick] (5)
(5) edge[-,thick] (1)
%(3) edge[-,thick] (4)
\end{tikzpicture}
答案1
另一个选择是使用controls
:
\documentclass[tikz, border=20]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale = 0.75]
\tikzstyle{every state}=[fill opacity=0.5,text opacity=1,semithick,minimum size=10pt]
\tikzset{roundnode/.style={thick, draw = black, fill = white, outer sep = 1.5, circle, minimum size = 10pt, scale = 0.75}}
\node[roundnode = black] (1) at (30, 2.01){1};
\node[roundnode = black] (2) at (31.91, 0.62){2};
\node[roundnode = black] (3) at (31.18, -1.63){3};
\node[roundnode = black] (4) at (28.82, -1.63){4};
\node[roundnode = black] (5) at (28.09, 0.62){5};
\draw
(1) edge[-,thick] (2)
(2) edge[-,thick] (3)
(3) edge[-,thick] (4)
(4) edge[-,thick] (5)
(5) edge[-,thick] (1)
(3) edge[-,thick] (4);
\draw (1) edge[-,thick] (4);
\draw (1) edge[-,thick] (3);
\draw[thick] (5) .. controls ($(1) + (0, 1.5)$) .. (2);
\draw[thick] (4) .. controls ($(3) + (0.8, -1)$) .. (2);
\end{tikzpicture}
\end{document}
答案2
你只需要足够的弯曲。
\documentclass[tikz,border=2mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[enough bend/.style={looseness=2,bend left=80}] foreach \x [evaluate=\x as \y using {162-72*\x}] in {1,...,5}
{(\y:2) node[circle,fill,inner sep=1.5pt,label=\y:{$\x$}](\x){}
\ifnum\x>1
edge (1) edge (\the\numexpr\x-1)
\fi}
(5) to[enough bend] (2)
(2) to[enough bend] (4);
\end{tikzpicture}
\end{document}
答案3
使用[out=90,in=90]
指定出角和入角或[bend right=<val>]
,然后looseness
允许您的路径或多或少远离您的节点。
\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}[thick,scale = 0.75]
\tikzstyle{every state}=[fill opacity=0.5,text opacity=1,semithick,minimum size=10pt]
\tikzset{roundnode/.style={thick, draw = black, fill = white, outer sep = 1.5, circle, minimum size = 10pt, scale = 0.75}}
\foreach \i in {1,...,5}
\node[roundnode] (\i) at (162-72*\i:3){\i};
\draw
(1) edge (2)
(2) edge (3)
(3) edge (4)
(4) edge (5)
(5) edge (1)
(3) edge (1)
(4) edge (1)
(4) to[bend right=80,looseness=2] (2)
(5) edge[out=90,in=90,looseness=2] (2);
\end{tikzpicture}
\end{document}