2

I already visit too many pages and I have not found any similar to draw or draw

This is what I want to draw

3
  • Welcome to TSE. Did you try something? Sep 27, 2021 at 18:24
  • sure, I tried the information on the internet, but the issue is very difficult for me. That's why I posted my question because I try to make that graph specifically and I can't, I tried several codes that I found to modify them and not even like that. sorry Sep 27, 2021 at 19:49
  • @AlexCastilloNava Where does the figure come from? in particular, I want to know the name of objects in the figure
    – Black Mild
    Sep 29, 2021 at 10:41

1 Answer 1

3

like-node pic

The question is not so good (without MWE), and OP is not so active to communicate with helpers. However, the figure attracts me by its complexity. I intensively use several anchors of the like-node pic simcard, simsource, and a weird (user-defined) shape like-node pic snode. Neither [name prefix] nor (-parent), (-children), ... are used here. I will be surprised if there is a simpler (TikZ or others) way.

This way of using pics is almost as flexible as nodes. In particular, this way can handle old questions in here and here.

enter image description here

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[>=latex]
\def\l{1.8}
\pgfmathsetmacro{\simwidth}{1+\l}

% a simcard ?
\tikzset{pics/simcard/.style args=
{nodename #1}{code={%
\path (.5-.5*\l,0) 
node[draw,fill=blue!10,rounded corners=3mm,minimum height=2cm,minimum width=\simwidth cm,outer sep=0,inner sep=0,transform shape] (#1) {};
\draw[orange] (0,1)--(0,-1) (0,0)--(-\l,0);
\draw[rounded corners=3mm] (1,1) rectangle (-\l,-1);
\fill 
(.5,0)      circle(3pt) coordinate (#1e)
(-\l/2,.5)  circle(3pt) coordinate (#1p)
(-\l/2,-.5) circle(3pt) coordinate (#1c)
(0,1) coordinate (#1N)
;
}}}

% a simsource ?
\tikzset{pics/simsource/.style args=
{nodename #1}{code={%
\path (0,0) 
node[draw,fill=blue!10,rounded corners=2mm,minimum height=9mm,minimum width=4.5cm,transform shape] (#1) {};
\fill 
(-1.5,0) circle(2pt) coordinate (#1s1) 
(-.5,0)  circle(2pt) coordinate (#1s2)
(.5,0)   circle(2pt) coordinate (#1s3)
(1.5,0)  circle(2pt) coordinate (#1s4)
;
\foreach \i in {1,...,4}
\draw (#1s\i) circle(5pt); 
}}}

% pic as node with weird (user-defined) shape and reusable anchor #1top  
\tikzset{pics/snode/.style args=
{nodename #1 nodecontent #2}{code={%
\path (0,0) node[transform shape,font=\itshape] (#1) {#2};
\path ([shift={(.2,-.05)}]#1.north) coordinate (#1top);
\draw[blue,rounded corners,fill=yellow] plot coordinates {(#1top)
([shift={(0,.1)}]#1.north east) (#1.south east) 
([shift={(-.4,-.2)}]#1.south) 
([shift={(-.1,.1)}]#1.south west) 
([shift={(.25,.1)}]#1.north west)}--cycle;
\path (0,0) node[transform shape,font=\itshape] (#1) {#2};
}}}

% the left block
\begin{scope}[local bounding box=Left block]
\path
(0,0) pic{simcard=nodename L};      
\draw[->,magenta] (Lp) to[bend left] +(0,1) node[above,black]{parent};
\draw[->,magenta] (Lc) to[bend right] +(0,-1) node[below,black]{children};
\draw[->,magenta] (Le) to[bend left] +(1,0) node[right,black]{element};
\end{scope}

\tikzset{declare function={a=1.2;b=3.5;}}
\begin{scope}[local bounding box=Right block,xshift=8cm]
\path
(-3*a,0) pic[scale=.5]{simcard=nodename A}      
(-a,0)   pic[scale=.5]{simcard=nodename B}
(a,0)    pic[scale=.5]{simcard=nodename C}
(3*a,0)  pic[scale=.5]{simcard=nodename D}      
(0,b)    pic[scale=.5]{simcard=nodename E}      
(0,.5*b) pic{simsource=nodename S}
(-2.1*a,-1.5) pic{snode=nodename Bal nodecontent Baltimore}
(-.1*a,-1.5)  pic{snode=nodename Chi nodecontent Chicago}
(2*a,-1.5)   pic{snode=nodename Pro nodecontent Providence}
(4.1*a,-1.5)  pic{snode=nodename Sea nodecontent Seattle}
(3.8*a,.7*b)  pic{snode=nodename New nodecontent New York}
;       
\end{scope}

\begin{scope}[magenta]
\draw[->] (Ss1) to[bend right] (AN);
\draw[->] (Ss2) to[bend right] (BN);
\draw[->] (Ss3) to[bend left]  (CN);
\draw[->] (Ss4) to[bend left]  (DN);

\draw[->] (Ap) to[out=120,in=180] (E.165);
\draw[->] (Bp) .. controls +(160:2) and +(180:2) .. (E.-165);
\draw[->,shorten >=-.5mm] (Cp) 
.. controls +(130:1) and +(200:.5) .. ++(1.5,.7)
.. controls +(40:2) and +(-30:1) .. (E.-30);
\draw[->] (Dp) .. controls +(60:2.5) and +(0:2) .. (E.-15);

\def\shiftpoint{(-75:1.8)}
\draw[->] (Ac) to[bend left] +\shiftpoint;
\draw[->] (Bc) to[bend left] +\shiftpoint;
\draw[->] (Cc) to[bend left] +\shiftpoint;
\draw[->] (Dc) to[bend left] +\shiftpoint;
\draw[->] (Ec) to[bend left] (S);

\draw[->] (Ep) to[bend right] +(0,1);
\draw[<-] (E.125) to[bend right] +(-1,.8);

\draw[->] (Ae) to[bend left] (Baltop);
\draw[->] (Be) to[bend left] (Chitop);
\draw[->] (Ce) to[bend left] (Protop);
\draw[->] (De) to[bend left] (Seatop);
\draw[->] (Ee) to[out=20,in=120] (Newtop);
\end{scope}

\path 
(Left block.south) node[below=3mm] (Lba) {\bfseries (a)}
(Right block.south|-Lba) node{\bfseries (b)};

\end{tikzpicture}
\end{document}

Old This is a suggestion for you - the left block. Similarly, you can draw the right block.

I define a pic named simcard (it looks like that ^^). Naming a pic is somehow limited, but it is enough in this case. Inside that pic, there are 3 coordinates: -element, -parent, and -parent. Therefore, after naming that pic, say L, then you can reuse them as (L-element), L-parent, and L-parent.

PS: you can draw the left and the right as standalone figures as well.

enter image description here

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\tikzset{simcard/.pic={
\draw (0,1)--(0,-1) (0,0)--(-2,0);
\draw[rounded corners=3mm,very thick] (1,1) rectangle (-2,-1);
\fill 
(.5,0) circle(3pt) coordinate (-element)
(-1,.5) circle(3pt) coordinate (-parent)
(-1,-.5) circle(3pt) coordinate (-children)
;
}}

% the left block
\begin{scope}[local bounding box=blockA]
\path
(0,0) pic (L) {simcard};        
\draw[-stealth,magenta] (L-parent) to[bend left] +(0,1) node[above,black]{parent};
\draw[-stealth,magenta] (L-children) to[bend right] +(0,-1) node[below,black]{children};
\draw[-stealth,magenta] (L-element) to[bend left] +(1,0) node[right,black]{element};
\end{scope}

\path (blockA.south) node[below=3mm]{(a)};
\end{tikzpicture}
\end{document} 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .