![如何将边弯曲到其他节点和边上](https://linux22.com/image/356546/%E5%A6%82%E4%BD%95%E5%B0%86%E8%BE%B9%E5%BC%AF%E6%9B%B2%E5%88%B0%E5%85%B6%E4%BB%96%E8%8A%82%E7%82%B9%E5%92%8C%E8%BE%B9%E4%B8%8A.png)
我尝试创建类似的东西
我的代码是:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{operator}=[circle, radius=0.2cm, text centered, draw=black]
\tikzstyle{arrow}=[thick, ->, >=stealth]
\begin{document}
\begin{tikzpicture}[node distance=1.5cm]
\node(A0)[operator] {$A_0$};
\node(A1)[operator, below of = A0] {$A_1$};
\node(A2)[operator, below of = A1] {$A_2$};
\node(B0)[operator, right of = A0, xshift=2cm] {$B_0$};
\node(B1)[operator, below of = B0] {$B_1$};
\node(B2)[operator, below of = B1] {$B_2$};
\node(C0)[operator, right of = B0, xshift=2cm] {$C_0$};
\node(C1)[operator, below of = C0] {$C_1$};
\node(C2)[operator, below of = C1] {$C_2$};
\node(p1) [above of = B0] {};
\node(p2) [above of = A0] {};
\draw (A0) edge[out=0, in=180,arrow] node[pos=0.85, above]{3D} (B1);
\draw (A1) edge[out=0, in=180,arrow] node[pos=0.85, above]{3D} (B2);
\draw (A2) edge[out=0, in=180,arrow] node[pos=0.85, above]{4D} (B0);
\draw (B0) edge[out=0, in=180,arrow] (C2);
\draw (B1) edge[out=0, in=180,arrow] node[pos=0.85, above]{D} (C0);
\draw (B2) edge[out=0, in=180,arrow] node[pos=0.85, above]{D} (C1);
\draw (C0) edge[out=40, in=0,arrow] node[pos=0.85, above]{6D} (A2);
\draw (C1) edge[out=40, in=0,arrow] node[pos=0.85, above]{7D} (A0);
\draw (C2) edge[out=180, in=0,arrow] node[pos=0.85, above]{7D} (A1);
\end{tikzpicture}
\end{document}
因此结果是
我不知道如何正确连接 C 节点和 A 节点。感谢您的时间。
答案1
与您的第一张图片类似的内容:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows,calc}
\tikzstyle{operator}=[circle, radius=0.2cm, text centered, draw=black]
\tikzstyle{arrow}=[thick, ->, >=stealth]
\begin{document}
\begin{tikzpicture}[node distance=1.5cm]
\node(A0)[operator] {$A_0$};
\node(A1)[operator, below of = A0] {$A_1$};
\node(A2)[operator, below of = A1] {$A_2$};
\node(B0)[operator, right of = A0, xshift=2cm] {$B_0$};
\node(B1)[operator, below of = B0] {$B_1$};
\node(B2)[operator, below of = B1] {$B_2$};
\node(C0)[operator, right of = B0, xshift=2cm] {$C_0$};
\node(C1)[operator, below of = C0] {$C_1$};
\node(C2)[operator, below of = C1] {$C_2$};
\node(p1) [above of = B0] {};
\node(p2) [above of = A0] {};
%%%%
\draw[arrow] (A0) -- node[pos=0.5, above]{3D} (B1);
\draw[arrow] (A1) -- node[pos=0.5, above]{3D} (B2);
\draw[arrow] (A2) -- node[pos=0.5, above]{4D} (B0);
\draw[arrow] (B0) -- (C2);
\draw[arrow] (B1) -- node[pos=0.5, above]{D} (C0);
\draw[arrow] (B2) -- node[pos=0.5, above]{D} (C1);
\draw[arrow, rounded corners=5mm] (C0) -- ($(C0.-45) + (0.5,-0.5)$) -- ($(C2.-45) + (0.5,-0.5)$) -- ($(A2.-45) + (0.5,-0.5)$) -- node[pos=0.5, below]{6D} (A2);
\draw[arrow, rounded corners=5mm] (C1) -- ($(C1.45) + (0.5,0.5)$) -- ($(C0.45) + (0.5,0.5)$) -- ($(A0.45) + (0.5,0.5)$) -- node[pos=0.5, above]{7D} (A0);
\draw[arrow, rounded corners=6mm] (C2) -- ($(C2.45) + (0.7,0.7)$) -- ($(C0.45) + (0.7,0.7)$) -- ($(A0.135) + (-0.7,0.7)$) -- ($(A1.135) + (-0.7,0.7)$) -- node[pos=0.5, anchor=north east]{7D} (A1);
\end{tikzpicture}
\end{document}
答案2
你可以尝试一下这个looseness
选项。来自 TikZ 文档:
/tikz/looseness=<数字>
此数字指定曲线的“松散程度”。具体来说,会发生以下情况:TikZ 计算起点和目标坐标之间的距离(如果起点和/或目标坐标是节点,则计算其边界点之间的距离)。然后将此距离乘以固定因子,再乘以因子 <number>。得到的距离,我们称之为 d,然后用作控制点与起点和目标坐标之间的距离。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{operator}=[circle, radius= 0.2 cm, text centered, draw=black]
\tikzstyle{arrow}= [thick, ->, >=stealth]
\begin{document}
\begin{tikzpicture}[node distance =1.5 cm ]
\node(A0)[operator] {$A_0$};
\node(A1)[operator, below of = A0] {$A_1$};
\node(A2)[operator, below of = A1] {$A_2$};
\node(B0)[operator, right of = A0, xshift=2cm] {$B_0$};
\node(B1)[operator, below of = B0] {$B_1$};
\node(B2)[operator, below of = B1] {$B_2$};
\node(C0)[operator, right of = B0, xshift=2cm] {$C_0$};
\node(C1)[operator, below of = C0] {$C_1$};
\node(C2)[operator, below of = C1] {$C_2$};
\draw (A0) edge[out=0, in=180, arrow] node[pos=0.85, above]{3D} (B1);
\draw (A1) edge[out=0, in=180, arrow] node[pos=0.85, above]{3D} (B2);
\draw (A2) edge[out=0, in=180, arrow] node[pos=0.85, above]{4D} (B0);
\draw (B0) edge[out=0, in=180, arrow] (C2);
\draw (B1) edge[out=0, in=180, arrow] node[pos=0.85, above]{D} (C0);
\draw (B2) edge[out=0, in=180, arrow] node[pos=0.85, above]{D} (C1);
\draw (C0) edge[out=-63, in=-20, arrow, out looseness=2.6, in looseness=1.5] node[pos=0.85, below]{6D} (A2);
\draw (C1) edge[out=40, in=20, arrow, out looseness=1.5] node[pos=0.85, above]{7D} (A0);
\draw (C2) edge[out=-40, in=-40, arrow, in looseness=1.6] node[pos=0.85, below]{7D} (A1);
\end{tikzpicture}
\end{document}