соединять узлы с Tikz, не пересекая другие блоки

Я хочу соединить блоки B и M в моем коде без перерезания соединительной линии F. Как я могу заставить соединение увеличить соединительную линию и избежать F?

\documentclass[11pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{calc,shapes.geometric,arrows,positioning,intersections}

\begin{document}


\begin{tikzpicture}[auto,node distance=1cm,thick,
main node/.style={black,draw,minimum width=1.5cm,minimum height=0.75cm}]%circle,draw,font=\sffamily\Large\bfseries}]

\node[main node] (L)                     {L};
\node[main node] (F) [left = of L  ] {F};
\node[main node] (C) [below = of F  ] {M};
\node[main node] (B)    [right = of L  ] {B};
\node[main node] (AP)    [below = of B  ] {AP};
\node[main node] (A)    [below = of L  ] {A};
\node[main node] (H)  [right = of B  ] {H};
\node[main node] (G) [right = of H] {G};
\node[main node] (BR)  [below = of G] {BR};
\node[main node] (LR)   [below = of BR] {LR};
\node[main node] (U)  [below = of AP  ] {U};
\node[main node] (P)  [below = of U  ] {P};
\path[every node/.style={font=\sffamily\small}]
(L)      edge node [right]                   {} (B)
(L)      edge node [right]                   {} (F)
(L)      edge node [right]                   {} (C)
(F)      edge node [right]                   {} (C)
(B.north) edge [out=90,in=90] node [right] {} (F.north)
(B.north) edge [out=90,in=180] node [right] {} (C.west)
(B)      edge node [right]                   {} (AP)
(B)      edge node [right]                   {} (A)
(AP.east) edge [out=0,in=270] node [left]    {} (H.south)
(B)      edge node [right]                   {} (H)
(H)    edge node [right]                   {} (G)
(U.east) edge [out=0,in=270] node [left]   {} (H.south)
(P.east) edge [out=0,in=270] node [left]   {} (H.south)
(U)      edge node [right]                 {} (P)
(BR.west) edge [out=180,in=270] node [right] {} (H.south)
(LR.west)  edge [out=180,in=270] node [right] {} (H.south)
(BR.east) edge [out=0,in=0] node [right]     {} (G.east)
(LR.east) edge [out=0,in=0] node [right]     {} (G.east);
\end{tikzpicture}


\end{document}

Это то, что я получаю сейчас

введите описание изображения здесь

и это то, что я хотел бы получить

введите описание изображения здесь

Спасибо!


person venom    schedule 09.05.2019    source источник


Ответы (1)


В tikz нет прямого способа сделать это, но это можно сделать, добавив промежуточные узлы. Вот два способа сделать это.

Первый (синий) использует ребра на вашем основном пути. Поскольку у ребер есть только одна ветвь, координата создается в нужном месте и повторно используется на другом ребре.

Второй способ (красный) - это обычная линия тикз с несколькими промежуточными узлами. Он более гибкий и при необходимости может содержать любое количество промежуточных узлов.

Позиции промежуточных узлов должны быть изменены для достижения желаемого эффекта.

\documentclass[11pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{calc,shapes.geometric,arrows,positioning,intersections}

\begin{document}


\begin{tikzpicture}[auto,node distance=1cm,thick,
main node/.style={black,draw,minimum width=1.5cm,minimum height=0.75cm}]%circle,draw,font=\sffamily\Large\bfseries}]

\node[main node] (L)                     {L};
\node[main node] (F) [left = of L  ] {F};
\node[main node] (C) [below = of F  ] {M};
\node[main node] (B)    [right = of L  ] {B};
\node[main node] (AP)    [below = of B  ] {AP};
\node[main node] (A)    [below = of L  ] {A};
\node[main node] (H)  [right = of B  ] {H};
\node[main node] (G) [right = of H] {G};
\node[main node] (BR)  [below = of G] {BR};
\node[main node] (LR)   [below = of BR] {LR};
\node[main node] (U)  [below = of AP  ] {U};
\node[main node] (P)  [below = of U  ] {P};
\path[every node/.style={font=\sffamily\small}]
(L)      edge node [right]                   {} (B)
(L)      edge node [right]                   {} (F)
(L)      edge node [right]                   {} (C)
(F)      edge node [right]                   {} (C)
(B.north) edge [out=90,in=90] node [right] {} (F.north)
%%%% (B.north) edge [out=90,in=180] node [right] {} (C.west)
%west_of_F is an intermediate node to allow a proper connection of B and C
(B.north) edge [blue,out=90,in=90] coordinate[at end] (west_of_F) ($(F.west)+(-1cm,0)$) 
(west_of_F) edge [blue, out=-90,in=180] (C.west)
(B)      edge node [right]                   {} (AP)
(B)      edge node [right]                   {} (A)
(AP.east) edge [out=0,in=270] node [left]    {} (H.south)
(B)      edge node [right]                   {} (H)
(H)    edge node [right]                   {} (G)
(U.east) edge [out=0,in=270] node [left]   {} (H.south)
(P.east) edge [out=0,in=270] node [left]   {} (H.south)
(U)      edge node [right]                 {} (P)
(BR.west) edge [out=180,in=270] node [right] {} (H.south)
(LR.west)  edge [out=180,in=270] node [right] {} (H.south)
(BR.east) edge [out=0,in=0] node [right]     {} (G.east)
(LR.east) edge [out=0,in=0] node [right]     {} (G.east);

\draw[red] (B.north) to[out=90,in=0]   ($(B.north)+(-3cm,2cm)$)
                     to [out=180,in=90] ($(C.west)+(-1.1cm,2cm)$) 
                     to [out=-90,in=180] (C.west);

\end{tikzpicture}


\end{document}

введите описание изображения здесь

person Alain Merigot    schedule 09.05.2019