# Branch & Bound Geometric Shapes

I am dividing a box to two halves, and plotting it in Tikz. An example code is:

\begin{figure}[!h]
\scalebox{1.5}{
\begin{tikzpicture}
\filldraw[fill=gray!40!white, draw=black] (0,0) rectangle (4,2);
\node[black](dot) at (2,1) {\textbullet};
%\node[below=0cm of dot]  {\small{$x_a$}};
\draw[dashed] (1,-1) -- (3,3) ;
\node[] at (1,1.5) {\small{$r^\top x_a \geq r^\top x$}};
\node[] at (3,0.5) {\small{$r^\top x_a \leq r^\top x$}};
\node[] at (3.2,3.3) {\small{$r^\top x_a$}};
\end{tikzpicture}
}
\end{figure}


This produces:

Now I will calculate some mathematical stuff in the two halves, and again divide each half, and so on. Therefore, I need to use some Branch & Bound structure, but each element should be a geometric shape as the one above. I just need to have a tree where the elements are geometric shapes which will be inserted by me (thanks @marmot)

Any template or example link will be really appreciated.

• oh no, I have the technical part. I just want to plot some figures. I will say what to draw. So I don't need anything mathematical. Lets say I will give a box, I will draw two arrows coming out, I will put half boxes to the end of each arrow, etc. – independentvariable Jun 1 '19 at 21:44
• @marmot no sorry I was not clear at all than! I will fix this. The paper which I shared is not relevant at all. It is just an example figure. I can also make a tree and add 8 spheres side by side etc. I just need to have this tree :) – independentvariable Jun 1 '19 at 21:58

Here is a proposal.

\documentclass{article}
\usepackage{forest}
\usepackage{mathrsfs}
\begin{document}
\begin{forest}
for tree={s sep+=3em,l sep+=1em}
[$\mathscr{Z}$,minimum width=3cm,minimum height=1.2cm,draw,label=right:$x_2$,
alias=n1
[$\mathscr{Z}_{11}$,minimum width=1.2cm,minimum height=1.2cm,draw,trapezium,
trapezium left angle=90, trapezium right angle=60,label=right:$x_2^{(1,1)}$,
alias=n11]
[$\mathscr{Z}_{12}$,minimum width=1.2cm,minimum height=1.2cm,draw,,draw,trapezium,
trapezium left angle=120, trapezium right angle=90,label=right:$x_2^{(1,1)}$,
alias=n12]
]
\path (n1.south)  -- (n11.north) coordinate[midway] (aux);
\draw[dashed] (current bounding box.west|-aux)--
(current bounding box.east|-aux);
\end{forest}
\end{document}


• Awesome! How many years of experience do you have? You fix things like magic.. – independentvariable Jun 1 '19 at 22:08
• @independentvariable Excluding or including hibernation time? ;-) – user121799 Jun 1 '19 at 22:11
• Including @marmot :) – independentvariable Jun 1 '19 at 22:12
• I have been using Latex for 3 years now, every time I look back at the documents older than 2 months and find them poor. – independentvariable Jun 1 '19 at 22:13
• @independentvariable This feeling will stay, I am afraid. (Excluding hibernation time less than a year. ;-) – user121799 Jun 1 '19 at 22:15

Here is another proposal.

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\def\initialrectangle{
\draw[fill=gray!40!white] (0,0) rectangle (4,2)
(1,1.5) node{Tom} (3,0.5) node{Jerry};
}

\initialrectangle
\draw[dashed] (1,-1)--(3,3) node[above]{separator};

\begin{scope}[shift={(-100:3.5)}]
\clip (1,-1)--(3,3)-|(0,0);
\initialrectangle
\end{scope}

\begin{scope}[shift={(-80:3.5)}]
\clip (3,3)--(1,-1)-|(4,2);
\initialrectangle
\end{scope}

\end{tikzpicture}
\end{document}