I'm trying to draw a network flow diagram in tikz, and am having some problems.
Here is what I have so far:
However I'm having 2 problems with it currently. First of all, for some reason, arrow appear at both ends of my lines if I specify an anchor of my source node. If you look carefully at the picture, you can see some arcs have arrows at both ends. All arcs should be point left to right only.
For example (h1) edge [bend left=15] (1_1)
will give an arrow only at the end, as I expect; however (h1.east) edge [bend left=15] (1_1)
will put an arrow on both sides.
The second problem is that I need additional arcs that are longer and should avoid the existing arcs and nodes. Like this:
Here is my code so far:
\begin{tikzpicture}
\node [pattern=north east lines, circle, draw, inner sep=0.25cm] at (0,0) (h1);
\node [circle, draw, inner sep=0.075cm, fill=blue, fill opacity=0.33, text opacity=1] at (1.5,1.5) (1_1) { 1:1 };
\node [circle, draw, inner sep=0.075cm, fill=green, fill opacity=0.33, text opacity=1] at (1.5,0) (2_1) { 2:1 };
\node [circle, draw, inner sep=0.075cm, fill=red, fill opacity=0.33, text opacity=1] at (1.5,-1.5) (3_1) { 3:1 };
\node [pattern=north east lines, circle, draw, inner sep=0.25cm] at (3,0) (h2);
\node [circle, draw, inner sep=0.075cm, fill=orange, fill opacity=0.33, text opacity=1] at (4.5,0.75) (4_1) { 4:1 };
\node [circle, draw, inner sep=0.075cm, fill=orange, fill opacity=0.33, text opacity=1] at (6.0,0.75) (4_2) { 4:2 };
\node [circle, draw, inner sep=0.075cm, fill=purple, fill opacity=0.33, text opacity=1] at (4.5,-0.75) (5_1) { 5:1 };
\node [circle, draw, inner sep=0.075cm, fill=purple, fill opacity=0.33, text opacity=1] at (6.0,-0.75) (5_2) { 5:2 };
\node [pattern=north east lines, circle, draw, inner sep=0.25cm] at (7.5,0) (h3);
\node [circle, draw, inner sep=0.075cm, fill=teal, fill opacity=0.33, text opacity=1] at (9.0,0.75) (6_1) { 6:1 };
\node [circle, draw, inner sep=0.075cm, fill=teal, fill opacity=0.33, text opacity=1] at (10.5,0.75) (6_2) { 6:2 };
\node [circle, draw, inner sep=0.075cm, fill=olive, fill opacity=0.33, text opacity=1] at (9.75,-0.75) (7_1) { 7:1 };
\node [pattern=north east lines, circle, draw, inner sep=0.25cm] at (12,0) (h4);
\node [pattern=north east lines, circle, draw, inner sep=0.25cm] at (13.5,0) (h5);
\draw [->] (0.333,-2.5) -- (13.3335,-2.5) node [midway, below] {Time};
\path [line, ->] (h1) edge [bend left=15] (1_1);
\path [line, ->] (h1) edge (2_1);
\path [line, ->] (h1) edge [bend right=15] (3_1);
\path [line, ->] (1_1) edge [bend left=15] (h2);
\path [line, ->] (2_1) edge (h2);
\path [line, ->] (3_1) edge [bend right=15] (h2);
\path [line, ->] (h2.20) edge [bend left=15] (4_1);
\path [line, ->] (h2.-20) edge [bend right=15] (5_1);
\path [line, ->] (4_1) -- (4_2);
\path [line, ->] (5_1) -- (5_2);
\path [line, ->] (4_2) edge [bend left=15] (h3.160);
\path [line, ->] (5_2) edge [bend right=15] (h3.200);
\path [line, ->] (h3) edge [bend left=15] (6_1);
\path [line, ->] (h3) edge [bend right=15] (7_1);
\path [line, ->] (6_1) -- (6_2);
\path [line, ->] (6_2) edge [bend left=15] (h4);
\path [line, ->] (7_1) edge [bend right=15] (h4);
\path [line, ->] (h4) -- (h5);
\path [line, ->] (h2.60) edge [bend left=60] (4_2.north west);
\path [line, ->] (h2.-60) edge [bend right=60] (5_2.south west);
\path [line, ->] (4_1.north east) edge [bend left=60] (h3.120);
\path [line, ->] (5_1.south east) edge [bend right=60] (h3.240);
\path [line, ->] (h3.0) edge [bend right=15] (6_2.south west);
\path [line, ->] (6_1.south east) edge [bend right=15] (h4.180);
\path [line, ->] (4_1) -- (5_2);
\path [line, ->] (5_1) -- (4_2);
\draw [decorate, decoration={brace, amplitude=8pt, raise=8pt}] (0.2, 2) -- (2.8, 2) node [midway, above, yshift=0.5cm] {Day 1};
\draw [decorate, decoration={brace, amplitude=8pt, raise=8pt}] (3.2, 2) -- (7.3, 2) node [midway, above, yshift=0.5cm] {Day 2};
\draw [decorate, decoration={brace, amplitude=8pt, raise=8pt}] (7.7, 2) -- (11.8, 2) node [midway, above, yshift=0.5cm] {Day 3};
\draw [decorate, decoration={brace, amplitude=8pt, raise=8pt}] (12.2, 2) -- (13.3, 2) node [midway, above, yshift=0.5cm] {Day 4};
\end{tikzpicture}
Best Answer
tikzstyle
is deprecated. Use\tikzset
instead liketo define a line style. You are also using
\path[line, ->]
which results in modifying the line style. Use\path[line]
instead. To change the extent of bending you can adjust thelooseness
value within
andout
angles likeFurther, the
node
s should have an empty argument{}
which is missing in your code. Putting all these your code becomes