Split circle node vertically depending on text length

I am looking for solution that allow me split circle node vertically but the splitting line would be placed depending on text width.

I think the nearest solution could be similar to this one.

I am beginner with latex and here are my tries:

\documentclass{minimal}
\usepackage{graphics}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes,positioning}
\begin{document}

\begin{tikzpicture}
% this is approach from here: https://tex.stackexchange.com/a/186494/192768
% I don't like this solution because of rotation that is not intuitive for me.
\node [circle split,draw,rotate=90, label={$1$}] (z){\rotatebox{-90}{Very long} \nodepart{lower} \rotatebox{-90}{b}};

% 2 This works when left and right are similar
\node[inner sep=2pt, right = of z.south, draw, circle, label={$2$}] (za) {Left \quad Right};
\draw (za.north) -- (za.south);
% 3 line cross text
\node[inner sep=2pt, right = of za, draw, circle, label={$3$}] (za2) {Left long text \quad Right};
\draw (za2.north) -- (za2.south);
% 4 line cross text
\node[inner sep=2pt, right = of za2, draw, circle, label={$4$}] (za3) {Left long text \quad Right};
\draw (za3.north east) -- (za3.south east);
% 5 this is ok but just because of text width of right part
\node[inner sep=2pt, below = of za3, draw, circle, label={$5$}, align=left] (za4) {Left long \\ text Long long \quad R};
\draw (za4.north east) -- (za4.south east);

\end{tikzpicture}

\end{document}


Welcome! You could use path picture. You need to tell the style split circle what you put on the right such that it can measure the width and draw the vertical line accordingly.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{positioning}
\begin{document}

\begin{tikzpicture}[split circle/.style={circle,draw,path picture={
\pgfmathsetmacro{\mywidth}{width("#1")+6pt}
\draw ([xshift=-\mywidth]path picture bounding box.north east) --
([xshift=-\mywidth]path picture bounding box.south east);
}}]
\node[split circle=Right] (A) {long text\quad Right};
\node[split circle=pft,right=of A] (B) {long text\quad pft};
\node[split circle=hibernate,right=of B] (C) {long text\quad hibernate};
\end{tikzpicture}
\end{document}


Here is a version in which the style takes two arguments.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{positioning}
\begin{document}

\begin{tikzpicture}[split circle/.style 2 args={circle,draw,path picture={
\draw ([xshift=-\mywidth]path picture bounding box.north east) --
([xshift=-\mywidth]path picture bounding box.south east);
\node (A) [split circle={long text}{Right}];
\node (B) [split circle={long text}{pft},right=of A];
\node (C) [split circle={long text}{hibernate},right=of B];
\end{tikzpicture}
\end{document}


• Many thanks for quick response!. I think I missed one thing in question. I need also a brackets for the left and right part separately (I just posted minimal problem). I know how do this with two nodes in proposed similar solution but with your yet not. I will try mix that solution with yours and see it will work! – S.R Feb 17 '20 at 17:43
• @S.R I added such a version. Depending on what you really need, you may be better off with a pic. – user194703 Feb 17 '20 at 17:51
• I think we misunderstand - I wrote brackets but I mean braces. I have created my own answer that is mix of your solution and linked in my question. Maybe you would like to check that one. Thanks for your time. – S.R Feb 24 '20 at 22:53
• @S.R This is fine but I personally think you could write another, refined question instead of changing the above one, and answering it yourself. Asking questions is free, and if you really seek answers by others you should not blame them for not sensing that you meant braces when you wrote brackets. – user194703 Feb 24 '20 at 23:01
• Oh, I didn't blame you for this, I don't blame myself either - making mistakes i what makes us human. I just comment here because I treat you more as mentor I thought you could find some mistakes in my solution. I didn't edit question - just answered with additional functionality. And I think both answers are correct for question. – S.R Feb 24 '20 at 23:57

This gives:

\documentclass[tikz]{standalone}
% BEGIN section 1
\usepackage{tikz}
\usetikzlibrary{calc, positioning,fit,decorations.pathreplacing}
% END section 1
\begin{document}
% BEGIN section 2
\begin{tikzpicture}[scale=1]
\tikzset{
pics/circle vertically split/.style 2 args = {
code = {
\pgfmathsetmacro{\widthOne}{width("#1")+4pt}
\pgfmathsetmacro{\widthTwo}{width("#2")+4pt}

\node[text=green](-this_is_currcent_center){+};
\node[xshift=-\widthOne/2] (-left) {#1};
\node[xshift=\widthTwo/2] (-right) {#2};
\node[fit=(-left)(-right),draw,circle,text=red](-shape) {+};
\node(-splitline) at ($(-left.east)!.5!(-right.west)$) {};
\draw (-shape.north east -| -splitline.center) -- (-shape.south east -| -splitline.center);
}
}
}
\pic[inner sep = 1pt] (A) {circle vertically split={$Aaaaaa$}{$B$}};
\pic[inner sep = 1pt, right = of A-shape] (B) {circle vertically split={A}{$Bbbbb$}};

% this doesn't center correctly vertically :(
\pic[inner sep = 1pt, below = of A-shape.south] (D) {circle vertically split={$Aaaaaa$}{$B$}};
\pic[inner sep = 1pt, below = of B-shape.south] (E) {circle vertically split={$Aaaaaa$}{$B$}};

\draw [decoration={brace,raise=4pt,mirror},
decorate,
] (E-left.west) -- (E-left.east) node [pos=0.5,anchor=north,yshift=-4pt]{$brace$};
\end{tikzpicture}
% END section 2
\end{document}


What produces:

This solution allow add braces for left and right node separately. I missed this in question trying to keep it as simple as possible.

This also have a some flaws - for example it doesn't align correctly.

Fell free to edit or add new answer that is more general than this one.