Tikz:右弯曲矩形信息集

Tikz:右弯曲矩形信息集

我有这个代码

\documentclass[10pt]{article}
\begin{document}
\tikzset{
    solid node/.style={circle,draw,inner sep=1.5,fill=black},
    hollow node/.style={circle,draw,inner sep=1.5}
}
\begin{tikzpicture}[grow = right, scale=1.5,font=\footnotesize]
    \tikzstyle{level 1}=[level distance=15mm, sibling distance=15mm]
    \tikzstyle{level 2}=[level distance=15mm, sibling distance=15mm]
    \tikzstyle{level 3}=[level distance=15mm, sibling distance=15mm]

    % The Tree
    \node(0)[solid node,label=left:{$N$}]{} 
    child{node(1)[solid node, white]{}
    }
    child{[white] node(2)[solid node, xshift=20]{}  %note that you need to adjust the yshift if you change the sibling distance
    child{[black] node[hollow node,label=right:{$(a,b)$}]{} edge from parent node[below]{$C$}}
    child{[black] node[hollow node,label=right:{$(c,d)$}]{} edge from parent node[above]{$D$}}
    edge from parent node[black, xshift=40,yshift=0]{$\alpha$} %note that you need to adjust the yshift if you change the level distance
    }
    child{node(3)[solid node, white]{}
    };
    % information set
    \draw[solid,bend right](1)to(3);
    \draw[dashed,rounded corners=7]($(1)+(.25,-.25)$)rectangle($(3)+(-.25,.25)$);
    \end{tikzpicture}
    \end{document}

产生这棵树

在此处输入图片描述

我怎样才能将矩形向右弯曲?我试过这个代码:

\draw[dashed,rounded corners=7, bend right]($(1)+(.25,-.25)$)rectangle($(3)+(-.25,.25)$);

但它不起作用!有什么想法吗?谢谢!

答案1

像这样?

截屏

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{calc}
\tikzset{
    solid node/.style={circle,draw,inner sep=1.5,fill=black},
    hollow node/.style={circle,draw,inner sep=1.5}
}
\begin{document}
\begin{tikzpicture}[grow = right, scale=1.5,font=\footnotesize]
    \tikzstyle{level 1}=[level distance=15mm, sibling distance=15mm]
    \tikzstyle{level 2}=[level distance=15mm, sibling distance=15mm]
    \tikzstyle{level 3}=[level distance=15mm, sibling distance=15mm]

    % The Tree
    \node(0)[solid node,label=left:{$N$}]{} 
    child{node(1)[solid node, white]{}
    }
    child{[white] node(2)[solid node, xshift=20]{}  %note that you need to adjust the yshift if you change the sibling distance
    child{[black] node[hollow node,label=right:{$(a,b)$}]{} edge from parent node[below]{$C$}}
    child{[black] node[hollow node,label=right:{$(c,d)$}]{} edge from parent node[above]{$D$}}
    edge from parent node[black, xshift=40,yshift=0]{$\alpha$} %note that you need to adjust the yshift if you change the level distance
    }
    child{node(3)[solid node, white]{}
    };
    % information set
    \draw[solid,bend right](1)to(3);
    %\draw[dashed,rounded corners=7]($(1)+(.25,-.25)$)rectangle($(3)+(-.25,.25)$);
    \coordinate (a) at ($(1.center)+(-.25,0)$);
    \coordinate (b) at ($(1.center)+(.25,0)$);
    \coordinate (c) at ($(3.center)+(.25,0)$);
    \coordinate (d) at ($(3.center)+(-.25,0)$);
    \draw[dashed,rounded corners=7] (1)--(b)to[bend right](c)--(d)to[bend left](a)--(1);
    \end{tikzpicture}
\end{document}

相关内容