TikZ 图形箭头问题

TikZ 图形箭头问题

我正在尝试使用 TikZ 绘制下图,但无法正确实现箭头。

B我本质上可以拥有从节点到的箭头,A但不是同一类型的从A到的箭头B

有没有办法在 TikZ 中实现这一点?

逻辑是

从节点A到节点B。连接箭头(导线)连接下一个B,这里的下一个意味着,不仅在它们下面,而且在它们下面的旁边。每个下面A有两个B,但导线连接到下一个最近的B. 左箭头有标签(即左边)

从一个节点B到另一个节点A。连接箭头(电线)就在下方连接A

在此处输入图片描述

这是我的 MWE(感谢老合作者):

\documentclass[border=0.1mm]{standalone}
\usepackage{tikz}
\usepackage{scalerel}
\usepackage{ifthen}
\usetikzlibrary{decorations.markings}
%\usepackage[dvipsnames]{xcolor}
  \colorlet{Mycolor1}{green!10!orange!70!}

\tikzset{
    mynode/.style = {circle, draw, thick, fill=black, inner sep=0pt},
    type1/.style = {mynode,black},
    type2/.style = {mynode,Mycolor1},
}

\begin{document}
\begin{tikzpicture}[>=stealth]
\path[clip] (-3.1,-7.25) rectangle +(4.8,4.8);
\begin{scope}[rotate=45]
    \foreach \x in {-8,...,0}
      \foreach \y in {-9,...,0} {
         \pgfmathsetmacro{\type}{int(mod(abs(\x+\y),2)+1)};
         \draw[blue, -] (\x-0.6, \y) -- (\x+0.6, \y);
         \ifthenelse{\type=1}{\node[black,below] at (\x-0.22, \y+0.27) {$\scaleto{l_{1}}{4.5pt}$};}{}
         \ifthenelse{\type=2}{\node[black,below] at (\x-0.22, \y+0.27)  {$\scaleto{l_{2}}{4.5pt}$};}{}

         \draw[red,  -] (\x, \y-0.6) -- (\x, \y+0.6);
         \ifthenelse{\type=1}{\node[type\type] at (\x,\y) {\color{white}$A$};}{}
         \ifthenelse{\type=2}{\node[type\type] at (\x,\y) {\color{black}$B$};}{}
     }
\end{scope}
\end{tikzpicture}

\end{document}

B这给了我们(我从步骤到有相同的接线连接,A但没有从AB): 在此处输入图片描述

编辑:经过一番努力,我可以获得第二步,即从步骤BA。但失去了连接下方邻居的第一步,即从步骤AB(在上述情况下存在)。此外,向左箭头的标签为 l(即左)

\begin{document}
\begin{tikzpicture}[>=stealth]
\path[clip] (-3.1,-7.25) rectangle +(4.8,4.8);
\begin{scope}[rotate=45]
    \foreach \x in {-8,...,0}
      \foreach \y in {-9,...,0} {
         \pgfmathsetmacro{\type}{int(mod(abs(\x+\y),2)+1)};
         \draw[blue, <-] (\x-0.8, \y+1) -- (\x+0.9, \y);
         \ifthenelse{\type=1}{\node[black,below] at (\x-0.22, \y+0.27) {$\scaleto{l_{1}}{4.5pt}$};}{}
         \ifthenelse{\type=2}{\node[black,below] at (\x-0.22, \y+0.27)  {$\scaleto{l_{2}}{4.5pt}$};}{}

         \draw[red,  <-] (\x+1, \y-0.8) -- (\x, \y+0.9);
         \ifthenelse{\type=1}{\node[type\type] at (\x,\y) {\color{white}$A$};}{}
         \ifthenelse{\type=2}{\node[type\type] at (\x,\y) {\color{black}$B$};}{}
     }
\end{scope}
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案1

如果我理解正确,并且给出手绘图表,这就是您想要做的吗?在此处输入图片描述

\documentclass[border=0.1mm]{standalone}
\usepackage{tikz}
\usepackage{scalerel}
\usepackage{ifthen}
\usetikzlibrary{decorations.markings}
%\usepackage[dvipsnames]{xcolor}
  \colorlet{Mycolor1}{green!10!orange!70!}

\tikzset{
    mynode/.style = {circle, draw, thick, fill=black, inner sep=0pt},
    type1/.style = {mynode,black},
    type2/.style = {mynode,Mycolor1},
}

\begin{document}
\begin{tikzpicture}[>=stealth]
\path[clip] (-3.1,-7.25) rectangle +(4.8,4.8);
\begin{scope}[rotate=45]
    \foreach \x in {-8,...,0}
      \foreach \y in {-9,...,0} {
         \pgfmathsetmacro{\type}{int(mod(abs(\x+\y),2)+1)};
         \draw[blue, <-] (\x-0.6, \y) -- (\x+0.6, \y);
         \ifthenelse{\type=1}{\node[black,below] at (\x-0.22, \y+0.27) {$\scaleto{l_{1}}{4.5pt}$};}{}
         \ifthenelse{\type=2}{\node[black,below] at (\x-0.22, \y+0.27)  {$\scaleto{l_{2}}{4.5pt}$};}{}

         \draw[red,  <-] (\x, \y-0.6) -- (\x, \y+0.6);
         \ifthenelse{\type=1}{\node[type\type] at (\x,\y) {\color{white}$A$};}{}
         \ifthenelse{\type=2}{\node[type\type] at (\x,\y) {\color{black}$B$};}{}
     }
\end{scope}
\end{tikzpicture}

\end{document}

相关内容