you can create a node at each end of the lines and then connect these nodes. by adjusting the minimum size of node you can improve aesthetics.
(sorry for my google english)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri,calc,shadows}
\begin{document}
\begin{tikzpicture}[
parent/.style={%
rounded corners,
thick,
draw=red!75,
fill=red!20,
thick,
inner ysep=2pt,
inner xsep=2pt,
minimum width = 4cm,
minimum height = 1.5cm,
align=center
},
child/.style={%
rounded corners,
thick,
draw=blue!90,
fill=blue!35,
thick,
inner ysep=2pt,
inner xsep=2pt,
minimum width = 4cm,
minimum height = 1.5cm,
align=center
},
grandchild/.style={%
rounded corners,
thick,
draw=green!90,
fill=green!35,
thick,
inner ysep=2pt,
inner xsep=2pt,
minimum width = 4cm,
minimum height = 1.5cm,
align=center
},
line/.style={%
semithick,
->,
shorten >=1pt,
>=stealth'
},
call/.style={%
blue,
semithick,
->,
shorten >=1pt,
>=stealth'
},
return/.style={%
red,
semithick,
->,
shorten >=1pt,
>=stealth'
}]
\node[child] (child) {Child};
\node[parent] at (-6,3) (parent 1) {Node 1\\I have manually\\connected this one};
\node[parent] at (0,3) (parent 2) {Node 2\\I have manually\\connected this one};
\node[parent] at (6,3) (parent 3) {Node 3\\I have manually\\connected this one};
\node[parent] at (-6,-3) (grandchild 1) {Node 4\\I have manually\\connected this one};
\node[parent] at (0,-3) (grandchild 2) {Node 5\\I have NOT manually\\connacted this one};
\node[parent] at (6,-3) (grandchild 3) {Node 6\\I have NOT manually\\connacted this one};
%draw three lines from each parent to each child
\draw [line] (parent 1.south east)node[above left](p1){} -- (child.north west)node[below right](c1){};
\draw [line] (parent 2.south)node[above](p2){} -- (child.north)node[below](c2){};
\draw [line] (parent 3.south west)node[above right](p3){} -- (child.north east) node[below left](c3){};
%draw three lines from each parent to each child
\draw [line] (grandchild 1.north east)node[below left,minimum size=2em](p4){} -- (child.south west)node[above right,minimum size=2em](c4){};
\draw [line] (grandchild 2.north)node[below,minimum size=2em](p5){} -- (child.south)node[above,minimum size=2em](c5){};
\draw [line] (grandchild 3.north west)node[below right](p6){} -- (child.south east)node[above left](c6){};
\foreach \nn in{1,2,3,4,5,6}{
\draw [call] (p\nn) to [bend right=15] (c\nn);
\draw [return] (c\nn) to [bend right=15] (p\nn);
}
\end{tikzpicture}
\end{document}!
I found out that the graph concept is not suited best for my purpose. I could solve my problems with a path
definition instead of a graph
.
Here is the fully working corrected example from above:
\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{shapes}
\usetikzlibrary{graphs}
\usetikzlibrary{quotes}
\begin{document}
\tikzset{
role/.style = {rounded rectangle, minimum size=6mm, very thick, draw=blue!50,top color=white,bottom color=blue!20, font=\ttfamily \scriptsize,align=center,text=black},
hv/.style = {to path={-| (\tikztotarget)}},
vh/.style = {to path={|- (\tikztotarget)}},
comp/.style = {Diamond-},
ass/.style = {-{>[width=2pt 2]}},
imp/.style = {-{Latex[open]}},
proh/.style = {{Bar[sep=1pt]}-{Bar[sep=1pt]}}
}
\begin{tikzpicture}[node distance=5mm and 5mm,thick,
every edge/.style={rounded corners,draw=black!50,font=\tiny,near end}]
% nodes
\node[role] (n1) {Node 1};
\node[role] (n2) [below left=of n1] {Node 2};
\node[role] (n3) [below right=of n1] {Node 3};
\node[role] (n4) [below right=of n2] {Node 4};
% connections
\path
(n1) edge[comp,hv] (n2)
(n1) edge[comp,hv] (n3)
(n2) edge[ass,"label"] (n3)
(n4) edge[imp,hv] (n2)
(n3) edge[proh,vh] (n4);
\end{tikzpicture}
\end{document}
The edge kinds are defined in \tikzset
: comp
,ass
,inh
,proh
. Here, ass
stands for association. Furthermore, the defaults for the edge labels could be defined in the configuration of the tikzpicture
itself via every edge/.style
.
That's an acceptable solution for me.
Best Answer
To obtain west anchor for node
long node name
you can useright anchor=west
.Code
Result