2

I am wondering is there a way to maybe offset the entry of arrows (some to the left of center, some to the right of center) or maybe make the head of arrows more distinguishable in the bottom left? I am also color blind so I tried to use a different pattern (dotted vs. dash) to distinguish between arrows at the bottom left but it didn't work. So maybe if there was an option to change the thickness of arrows, it would be great.

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage[a4paper, total={6in, 8in}]{geometry} \usepackage{algorithm} \usepackage{algpseudocode} \usepackage{amsmath,amssymb} \usepackage{amsthm} \usepackage{forest} \usepackage{tikz} \usepackage{pdflscape} \pagenumbering{gobble}

\usetikzlibrary{positioning,calc,arrows.meta}%arrows is deprecated

\begin{document}

\begin{landscape}

\begin{figure}[htbp] \centering \begin{tikzpicture}[->,>=Stealth,auto,scale=0.6, thick,main node/.style={draw, rectangle, align=center}]

\node[main node,text width=2cm] (1) at (0,14) {$\text{shared_info}$}; \node[main node,text width=2cm, anchor=north west] (2) at(1.north east) {$\text{outer_names}$}; \node[main node,text width=2cm, anchor=south west] (3) at(2.north east) {$\text{all_names}$}; \node[main node,text width=2cm, anchor=north west] (4) at(3.north east) {$\text{msgs}$};

\node[main node,text width=2cm] (5) at (-8,0) {$\text{shared_info}$}; \node[main node,text width=2cm, anchor=north west] (6) at(5.north east) {$\text{assigned_in}$}; \node[main node,text width=2cm, anchor=south west] (7) at(6.north east) {$\text{all_names}$}; \node[main node,text width=2cm, anchor=north west] (8) at(7.north east) {$\text{msgs}$};

\node[main node,text width=2cm] (9) at (8,0) {$\text{shared_info}$}; \node[main node,text width=2cm, anchor=north west] (10) at(9.north east) {$\text{assigned_in}$}; \node[main node,text width=2cm, anchor=south west] (11) at(10.north east) {$\text{all_names}$}; \node[main node,text width=2cm, anchor=north west] (12) at(11.north east) {$\text{msgs}$}; \node[main node,text width=2cm, anchor=north west] (13) at(12.north east) {$\text{assigned_out}$};

\draw[black] (1.south) to[out=-90, in=90,looseness=0.8] (5.north); \draw[black] (1.south) to[out=-90, in=90,looseness=0.8] (9.north);

\draw[black] (2.south) to[out=-90, in=90,looseness=0.8] (10.north);

\draw[black] (7.north) to[out=90, in=-90,looseness=0.8] (3.south);

\draw[black] (8.north) to[out=90, in=-90,looseness=0.8] (4.south);

\draw[black] (11.north) to[out=90, in=-90,looseness=0.8] (3.south);

\draw[black] (12.north) to[out=90, in=-90,looseness=0.8] (4.south);

\draw[black] (13.north) to[out=90, in=90,looseness=0.8] (6.north); \draw[black] (13.north) to[out=90, in=90,looseness=0.8] (10.north);

\draw[red] (10.south) to[out=-90, in=-90,looseness=0.8] (13.south);

\draw[red,dash dot] (5.south) to[out=-90, in=-90,looseness=1] (6.south); \draw[red,dash dot] (5.south) to[out=-90, in=-90,looseness=1] (7.south); \draw[red,dash dot] (5.south) to[out=-90, in=-90,looseness=1] (8.south);

\draw[blue,dotted] (6.south) to[out=-90, in=-90,looseness=1] (8.south);

\draw[green!50!black,dotted] (7.south) to[out=-90, in=-90,looseness=1] (8.south); \draw[green!50!black,dotted] (7.south) to[out=-90, in=-90,looseness=1] (6.south);

\draw[red,dotted] (2.north) to[out=90, in=90,looseness=1] (4.north);

\end{tikzpicture}

\end{figure}

\end{landscape}

\end{document}

enter image description here

Node.JS
  • 685
  • I do not quite understand. You already changed the thickness of the arrows here: \begin{tikzpicture}[->,>=Stealth,auto,scale=0.6, thick,main node/.style={draw, rectangle, align=center}]. So asking how to make them thick does not make sense. If you want them more thick try very thick. If you want just to change the size of the arrowhead see here. – Roland Mar 09 '22 at 00:20
  • 1
    Is there a way to offset the entry of the arrows to the rectangle to make it more distinguishable which one is entering the rectangle and which one exiting the rectangle. – Node.JS Mar 09 '22 at 00:30

3 Answers3

6

Remember that you can get exit or entry points of the nodes beyond the classic east, west, north and south, which are equivalent to 0.90°, 180°, 270° or their combinations at 45° angles, you can obtain points on the perimeter of the node between its intersection with a ray from the center of the node with the angle you indicate node_name.angle. You can review section 67 of the PGF manual.

In the example I used those points to find better landing places for the arrows to be displayed, I also matched the input and output values ​​of the arrows, I added some style management practices and used nodes in the arrows so as not to get lost. Sorry to have removed parts of your original code but it should adhere to the philosophy of being a minimal working example.

RESULT:

enter image description here

MWE:

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{arrows.meta,positioning}
\usepackage{amsmath}
\begin{document}
    \begin{tikzpicture}[
        >=Stealth,
        thick,
        auto,
        NodeBlack/.style={
            draw,
            rectangle,
            align=center,
            text width=2cm
        },
        NodeFancy/.style={
            draw=black,
            rectangle,
            rounded corners,
            align=center,
            text width=2cm,
            text opacity=1,
            text=green!50!black,
            fill=green!50!blue,
            fill opacity=0.4
        },
        ArrowBlack/.style={black,->},
        ArrowRed/.style={red,dash dot,->},
        ArrowGreen/.style={green!50!black, very thick,dotted,->}
    ]
    % Nodes
    \node[NodeBlack] (1) at (0,7)    {$\text{shared\_info}$};
    \node[NodeBlack, anchor=north west] (2) at(1.north east) {$\text{outer\_names}$};
    \node[NodeBlack, anchor=south west] (3) at(2.north east) {$\text{all\_names}$};
    \node[NodeBlack, anchor=north west] (4) at(3.north east) {$\text{msgs}$};
    \node[NodeBlack] (5) at (-5,0)    {$\text{shared\_info}$};
    \node[NodeBlack, anchor=north west] (6) at(5.north east) {$\text{assigned\_in}$};
    \node[NodeBlack, anchor=south west] (7) at(6.north east) {$\text{all\_names}$};
    \node[NodeBlack, anchor=north west] (8) at(7.north east) {$\text{msgs}$};
    \node[NodeFancy] (9) at (5,0)    {$\text{shared\_info}$};
    \node[NodeBlack, anchor=north west] (10) at(9.north east) {$\text{assigned\_in}$};
    \node[NodeBlack, anchor=south west] (11) at(10.north east) {$\text{all\_names}$};
    \node[NodeBlack, anchor=north west] (12) at(11.north east) {$\text{msgs}$};
    \node[NodeFancy, anchor=north west] (13) at(12.north east) {$\text{assigned\_out}$};
    % Arrows        
    \draw[ArrowBlack] (1.-105) to[out=-105, in=90,looseness=0.8]node[pos=0.7,sloped]{1} (5.90);
    \draw[ArrowBlack] (1.-75) to[out=-75, in=90,looseness=0.8]node[pos=0.7,sloped]{2} (9.90);
    \draw[ArrowBlack] (2.-90) to[out=-90, in=105,looseness=0.8]node[pos=0.7,sloped]{3} (10.105);
    \draw[ArrowBlack] (7.north) to[out=90, in=-105,looseness=0.8]node[pos=0.7,sloped]{4} (3.-105);
    \draw[ArrowBlack] (8.north) to[out=90, in=-105,looseness=0.8]node[pos=0.7,sloped]{5} (4.-105);
    \draw[ArrowBlack] (11.north) to[out=90, in=-75,looseness=0.8]node[pos=0.7,sloped]{6} (3.-75);
    \draw[ArrowBlack] (12.north) to[out=90, in=-75,looseness=0.8]node[pos=0.7,sloped]{7} (4.-75);
    \draw[ArrowBlack] (13.75) to[out=75, in=90,looseness=0.5]node[pos=0.7,sloped]{8} (6.north);
    \draw[ArrowBlack] (13.105) to[out=90, in=90,looseness=0.8]node[pos=0.7,sloped]{9} (10.75);
    \draw[red,<->] (10.south) to[out=-90, in=-90,looseness=0.8]node[pos=0.7,sloped]{10} (13.south);
    \draw[ArrowRed] (5.-55) to[out=-90, in=-125,looseness=1]node[pos=0.7,sloped]{11} (6.-125);
    \draw[ArrowRed] (5.south) to[out=-90, in=-90,looseness=2]node[pos=0.7,sloped]{12} (7.south);
    \draw[ArrowRed] (5.-125) to[out=-105, in=-55,looseness=2]node[pos=0.7,sloped]{13} (8.-55);
    \draw[ArrowRed] (6.south) to[out=-90, in=-90,looseness=1.7]node[pos=0.7,sloped]{14} (8.south);
    \draw[ArrowGreen] (7.-55) to[out=-85, in=-125,looseness=1.2]node[pos=0.7,sloped]{15} (8.-125);
    \draw[ArrowGreen] (7.-125) to[out=-90, in=-55,looseness=1.5]node[pos=0.7,sloped]{16} (6.-55);
    \draw[ArrowRed] (2.north) to[out=90, in=90,looseness=1]node[pos=0.7,sloped]{17} (4.north);
    %Example
    \node[NodeFancy,above left=1cm of 1] (N-FANCY) {Example};
    \draw[ArrowGreen] (N-FANCY.center)  -- node[pos=0.7,sloped]{1cm}(1.center); %using positioning
    \draw[ArrowRed] (N-FANCY.-135) to[out=-135, in=135,looseness=10]node[pos=0.7,sloped]{example} (N-FANCY.135);
    \draw[ArrowGreen] (N-FANCY.center)  -- node[pos=0.7,sloped]{-135}++(-135:3); 
    \draw[ArrowGreen] (N-FANCY.center)  -- node[pos=0.7,sloped]{135}++(135:3);
\end{tikzpicture} 

\end{document}

J Leon V.
  • 11,533
  • 16
  • 47
5

Regarding the question: Is there a way to offset the entry of the arrows to the rectangle?

You can do that with shorten >= 4pt

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage[a4paper, total={6in, 8in}]{geometry} \usepackage{algorithm} \usepackage{algpseudocode} \usepackage{amsmath,amssymb} \usepackage{amsthm} \usepackage{forest} \usepackage{tikz} \usepackage{pdflscape} \pagenumbering{gobble}

\usetikzlibrary{positioning,calc,arrows.meta}%arrows is deprecated

\begin{document}

\begin{landscape}

\begin{figure}[htbp] \centering \begin{tikzpicture}[->,>=Stealth,auto,scale=0.6,shorten >= 4pt, very thick,main node/.style={draw, rectangle, align=center}]

\node[main node,text width=2cm] (1) at (0,14) {$\text{shared_info}$}; \node[main node,text width=2cm, anchor=north west] (2) at(1.north east) {$\text{outer_names}$}; \node[main node,text width=2cm, anchor=south west] (3) at(2.north east) {$\text{all_names}$}; \node[main node,text width=2cm, anchor=north west] (4) at(3.north east) {$\text{msgs}$};

\node[main node,text width=2cm] (5) at (-8,0) {$\text{shared_info}$}; \node[main node,text width=2cm, anchor=north west] (6) at(5.north east) {$\text{assigned_in}$}; \node[main node,text width=2cm, anchor=south west] (7) at(6.north east) {$\text{all_names}$}; \node[main node,text width=2cm, anchor=north west] (8) at(7.north east) {$\text{msgs}$};

\node[main node,text width=2cm] (9) at (8,0) {$\text{shared_info}$}; \node[main node,text width=2cm, anchor=north west] (10) at(9.north east) {$\text{assigned_in}$}; \node[main node,text width=2cm, anchor=south west] (11) at(10.north east) {$\text{all_names}$}; \node[main node,text width=2cm, anchor=north west] (12) at(11.north east) {$\text{msgs}$}; \node[main node,text width=2cm, anchor=north west] (13) at(12.north east) {$\text{assigned_out}$};

\draw[black] (1.south) to[out=-90, in=90,looseness=0.8] (5.north); \draw[black] (1.south) to[out=-90, in=90,looseness=0.8] (9.north);

\draw[black] (2.south) to[out=-90, in=90,looseness=0.8] (10.north);

\draw[black] (7.north) to[out=90, in=-90,looseness=0.8] (3.south);

\draw[black] (8.north) to[out=90, in=-90,looseness=0.8] (4.south);

\draw[black] (11.north) to[out=90, in=-90,looseness=0.8] (3.south);

\draw[black] (12.north) to[out=90, in=-90,looseness=0.8] (4.south);

\draw[black] (13.north) to[out=90, in=90,looseness=0.8] (6.north); \draw[black] (13.north) to[out=90, in=90,looseness=0.8] (10.north);

\draw[red] (10.south) to[out=-90, in=-90,looseness=0.8] (13.south);

\draw[red,dash dot] (5.south) to[out=-90, in=-90,looseness=1] (6.south); \draw[red,dash dot] (5.south) to[out=-90, in=-90,looseness=1] (7.south); \draw[red,dash dot] (5.south) to[out=-90, in=-90,looseness=1] (8.south);

\draw[blue,dotted] (6.south) to[out=-90, in=-90,looseness=1] (8.south);

\draw[green!50!black,dotted] (7.south) to[out=-90, in=-90,looseness=1] (8.south); \draw[green!50!black,dotted] (7.south) to[out=-90, in=-90,looseness=1] (6.south);

\draw[red,dotted] (2.north) to[out=90, in=90,looseness=1] (4.north);

\end{tikzpicture}

\end{figure}

\end{landscape}

\end{document}

enter image description here

Roland
  • 6,655
4

As supplement to @J Leon V. answer. Main difference is simpler and shorted image code:

\documentclass{article}
\usepackage[margin=25mm]{geometry}

\usepackage{tikz} \usetikzlibrary{arrows.meta, bending, positioning, }

\usepackage{pdflscape} \pagenumbering{gobble}

\begin{document}

\begin{landscape} %\noindent\rule{\linewidth}{2pt} \begin{figure}[htbp] \centering \begin{tikzpicture}[%scale=0.6, node distance = 0pt, every edge/.style = {draw, very thick, -{Stealth[bend]} }, mn/.style = {draw, thick, inner sep=2mm, text depth=0.5ex, text height=2.2ex, text width=2cm, align=center, outer sep=0pt}, ]

\node[mn] (1) at (0,8) {shared_info}; \node[mn, right=of 1] (2) {outer_names}; \node[mn, above right=of 2] (3) {all_names}; \node[mn, right=of 3] (4) {msgs}; % \node[mn, below left=8 and 2.4 of 1] (5) {shared_info}; \node[mn, right=of 5] (6) {assigned_in}; \node[mn, above right=of 6] (7) {all_names}; \node[mn, right=of 7] (8) {msgs}; % \node[mn, below right=0 and 0.4 of 8] (9) {shared_info}; \node[mn, right=of 9] (10) {assigned_in}; \node[mn, above right=of 10] (11) {all_names}; \node[mn, right=of 11] (12) {msgs}; \node[mn, right=of 12] (13) {assigned_out}; % \draw (1.250) edge[out=-90, in= 90] (5) (1.290) edge[out=-90, in= 90] (9) (2) edge[out=-90, in= 90] (10.110) (7) edge[out= 90, in=-90] (3.250) (8) edge[out= 90, in=-90] (4.250) (11) edge[out= 90, in=-90] (3.290) (12) edge[out= 90, in=-90] (4.290) (13.70) edge[out= 90, in= 90] (6) (13.110) edge[out= 90, in= 90] (10.70) (10) edge[out=-90, in=-90, red] (13); \draw[red,dash dot]
(5.290) edge[out=-90, in=-90] (6.250) (5) edge[out=-90, in=-90] (7) (5.250) edge[out=-90, in=-90] (8.290); \draw[blue,dotted]
(6) edge[out=-90, in=-90] (8); \draw[green!50!black,dotted] (7.290) edge[out=-90, in=-90] (8.250) (7.250) edge[out=-90, in=-90] (6.290); \draw[red,dotted] (2) edge[out= 90, in= 90] (4);

\end{tikzpicture}

\end{figure} \end{landscape} \end{document}

enter image description here

Zarko
  • 296,517