이 코드가 있습니다
\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}