两张 tikz 图片之间的边缘

两张 tikz 图片之间的边缘

我正在尝试在 latex 中绘制 tikzpictures 之间的一些边缘。我将发布代码示例和一张显示其外观的图片,以及一张展示我希望边缘外观的图片。我曾尝试在线查找帮助,但运气不佳。我非常感谢能得到的所有帮助。

\begin{figure}
    \centering
    \begin{tikzpicture}[every node/.style={draw=black},every 
node/.append style={transform shape},scale=0.8]
     \node[circle,fill=red](one){};
     \node at ($(one)+(-0.75,-1)$)[draw=none](two){2};
     \node at ($(one)+(0.75,-1)$)[draw=none](three){3};
     \path[thick](one)edge(two)edge(three);
    \end{tikzpicture}\hspace{1.5cm}
\begin{tikzpicture}[every node/.style={draw=black},every 
node/.append style={transform shape},scale=0.8]
     \node[circle,fill=red](one){};
     \node at ($(one)+(-0.75,-1)$)[draw=none](two){1};
     \node at ($(one)+(0.75,-1)$)[draw=none](three){3};
     \path[thick](one)edge(two)edge(three);
    \end{tikzpicture}
    \vspace{4.5cm}

    \begin{tikzpicture}[every node/.style={draw=black},every 
node/.append style={transform shape},scale=0.8]
     \node[circle,fill=red](one){};
     \node at ($(one)+(-0.75,-1)$)[draw=none](two){1};
     \node at ($(one)+(0.75,-1)$)[draw=none](three){2};
     \path[thick](one)edge(two)edge(three);
    \end{tikzpicture}\hspace{1.5cm}
    \begin{tikzpicture}[every node/.style={draw=black},every 
node/.append style={transform shape},scale=0.8]
     \node[fill=blue,scale=1.2](one){};
     \node at ($(one)+(-0.75,-1)$)[draw=none](two){1};
     \node at ($(one)+(0.75,-1)$)[draw=none](three){3};
     \path[thick](one)edge(two)edge(three);
    \end{tikzpicture}\hspace{1.5cm}

    \caption{Caption}
    \label{fig:my_label}
\end{figure}

在此处输入图片描述

答案1

像这样?

在此处输入图片描述

使用treescopes来移动树:

\documentclass{article}
\usepackage{tikz}

\begin{document}
    \begin{figure}
    \centering
\begin{tikzpicture}[
rdot/.style = {circle, draw, fill=red, 
               minimum size=3mm, inner sep=0pt, outer sep=0pt,
               node contents={}},
sdot/.style  ={draw, fill=blue,
               minimum size=3mm, inner sep=0pt, outer sep=0pt,
               node contents={}},
sibling distance = 7mm
                    ]
\node (one) [rdot] 
    child{ node {1}} 
    child{ node (one south) {} edge from parent[draw=none]}
    child{ node {2}};
\begin{scope}[xshift=33mm]
\node (two) [rdot] 
    child{ node {1}} 
    child{ node (two south) {} edge from parent[draw=none]}
    child{ node {2}};
\end{scope}
\begin{scope}[yshift=-44mm]
\node (three) [rdot] 
    child{ node {1}} 
    child{ node {} edge from parent[draw=none]}
    child{ node {2}};
\end{scope}
\begin{scope}[shift={(33mm,-44mm)}]
\node (four) [sdot] 
    child{ node {3}} 
    child{ node {} edge from parent[draw=none]}
    child{ node {4}};
\end{scope}
\draw[very thick]   ([yshift=3mm] three.north) -- (one south.south) -- 
                    ([yshift=3mm] four.north) -- (two south);
    \end{tikzpicture}

\caption{Caption}
\label{fig:my_label}
    \end{figure}
\end{document}

附录: 或者你更喜欢这样:

在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\begin{document}
    \begin{figure}
    \centering
\begin{tikzpicture}[
rdot/.style = {circle, draw, fill=red, 
               minimum size=3mm, inner sep=0pt, outer sep=0pt,
               node contents={}},
sdot/.style  ={draw, fill=blue,
               minimum size=3mm, inner sep=0pt, outer sep=0pt,
               node contents={}},
every edge/.style = {draw,very thick,-Stealth, shorten >=2mm},
sibling distance = 7mm
                    ]
\node (one) [rdot] 
    child{ node {1}} 
    child{ node (one south) {} edge from parent[draw=none]}
    child{ node {2}};
\begin{scope}[xshift=33mm]
\node (two) [rdot] 
    child{ node {1}} 
    child{ node (two south) {} edge from parent[draw=none]}
    child{ node {2}};
\end{scope}
\begin{scope}[shift={(-14mm,-44mm)}]
\node (three) [rdot] 
    child{ node {1}} 
    child{ node {} edge from parent[draw=none]}
    child{ node {2}};
\end{scope}
\begin{scope}[shift={(19mm,-44mm)}]
\node (four) [sdot] 
    child{ node {3}} 
    child{ node {} edge from parent[draw=none]}
    child{ node {4}};
\end{scope}
\path   (one south) edge    (three) 
        (one south) edge    (four) 
        (two south) edge    (four);
    \end{tikzpicture}
\caption{Caption}
\label{fig:my_label}
    \end{figure}
\end{document}

相关内容