# Tikz paths not starting/ending at edges of nodes

I'm trying to draw a graph with directed arcs. There will be quite a few arcs, so I'll need to bend them in various ways so the diagram is legible.

Here is what I have so far:

\begin{tikzpicture}
\filldraw [pattern=north east lines] (0,0) circle (0.333) node (h1);

\fill [blue, opacity=0.33] (1.5,1.5) circle (0.333);
\draw (1.5,1.5) circle (0.333) node (1_1) { 1:1 };
\fill [green, opacity=0.33] (1.5,0) circle (0.333);
\draw (1.5,0) circle (0.333) node (2_1) { 2:1 };
\fill [red, opacity=0.33] (1.5,-1.5) circle (0.333);
\draw (1.5,-1.5) circle (0.333) node (3_1) { 3:1 };

\filldraw [pattern=north east lines] (3,0) circle (0.333) node (h2);

\fill [orange, opacity=0.33] (4.5,0.75) circle (0.333);
\draw (4.5,0.75) circle (0.333) node (4_1) { 4:1 };
\fill [orange, opacity=0.33] (6,0.75) circle (0.333);
\draw (6,0.75) circle (0.333) node (4_2) { 4:2 };
\fill [purple, opacity=0.33] (4.5,-0.75) circle (0.333);
\draw (4.5,-0.75) circle (0.333) node (5_1) { 5:1 };
\fill [purple, opacity=0.33] (6,-0.75) circle (0.333);
\draw (6,-0.75) circle (0.333) node (5_2) { 5:2 };

\filldraw [pattern=north east lines] (7.5,0) circle (0.333) node (h3);

\fill [teal, opacity=0.33] (9,0.75) circle (0.333);
\draw (9,0.75) circle (0.333) node (6_1) { 6:1 };
\fill [teal, opacity=0.33] (10.5,0.75) circle (0.333);
\draw (10.5,0.75) circle (0.333) node (6_2) { 6:2 };
\fill [olive, opacity=0.33] (9.75,-0.75) circle (0.333);
\draw (9.75,-0.75) circle (0.333) node (7_1) { 7:1 };

\filldraw [pattern=north east lines] (12,0) circle (0.333) node (h4);
\filldraw [pattern=north east lines] (13.5,0) circle (0.333) node (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) -- (4_1);
\path [line, ->] (h2) -- (5_1);
\path [line, ->] (4_1) -- (4_2);
\path [line, ->] (5_1) -- (5_2);
\path [line, ->] (4_2) -- (h3);
\path [line, ->] (5_2) -- (h3);
\path [line, ->] (h3) -- (6_1);
\path [line, ->] (h3) -- (7_1);
\path [line, ->] (6_1) -- (6_2);
\path [line, ->] (6_2) -- (h4);
\path [line, ->] (7_1) -- (h4);
\path [line, ->] (h4) -- (h5);

\path [line, --] (h1) edge [bend left] ++(1.5,2.5) -- (h2);
\end{tikzpicture}


which produces:

A few things that I can't seem to fix:

1. The directed arcs do not seem to start and end at the edges of the circles. I was just going \path [line,->] (h1) -- (1_1); which produced a different result, but I wasn't sure how to do the bend left with that. Also, edge seemed like it should fix the problem,even though it actually made it worse.
2. Notice my last line: \path [line, --] (h1) edge [bend left] ++(1.5,2.5) -- (h2);. I want to connect (h1) to (h2) but I want the line to go above (1_1) so it's not too cramped. For some reason, the line isn't getting to (h2). I tried bend left=200 but this just makes it look weird. Also, the arrow is different to the other arrows in the graph. And I'm not sure why there's an arrow at all, since there is no -> on that line anywhere.
-
You nodes (with patterns) are too small. Try something like \node[pattern=north east lines,circle,draw,inner sep=0.3cm] at (12,0) (h4) {}; –  Harish Kumar Jan 10 at 0:16
The node size doesn't seem to be the problem: i.imgur.com/9jCJZH2.png –  user41709 Jan 10 at 0:32
You have to remove \filldraw [pattern=north east lines] (12,0) circle (0.333) node (h4);. Did you? :) –  Harish Kumar Jan 10 at 0:35
No, I left filldraw and made the circle 3x the size. The code you gave doesn't compile, and I don't know enough about tikz to fix it myself. –  user41709 Jan 10 at 1:05
If I get rid of (h4) at the end, your code works. I haven't tested the line positioning, but it will draw a circle (although the wrong size). But since without (h4) I can't reference it, I'm not sure if it's useful? –  user41709 Jan 10 at 2:19

I think you are trying to start/end the arrows from the patterned circle. This two step process you are doing can be done with the definition of a node like

mynode/.style={pattern=north east lines, circle, draw,inner sep=2pt,outer sep=0pt},


And put phantom{1:1} as the argument so that the circles are of same size.

On the other hand, for other nodes, you are filling the circular area and the draw the circle and then put a node making it a three step process. The three lines of code you are using can be only one line like this:

\node[myothernode,fill=orange!30] at (4.5,0.75) (4₁) { 4:1 };


where the myothernode is defined like

myothernode/.style = {draw,circle,inner sep=2pt,outer sep=0pt}


Now all the circles are all drawn by

\node [mynode] at (0,0) (h1){\phantom{1:1}};

\node[myothernode,fill=blue!30] at (1.5,1.5)  (1₁) { 1:1 };
\node[myothernode,fill=green!30] at (1.5,0) (2₁) { 2:1 };
\node[myothernode,fill=red!30] at (1.5,-1.5) (3₁) { 3:1 };

\node [mynode] at (3,0) (h2){\phantom{1:1}};

\node[myothernode,fill=orange!30] at (4.5,0.75) (4₁) { 4:1 };
\node[myothernode,fill=orange!30] at (6,0.75) (4₂) { 4:2 };
\node[myothernode,fill=purple!30] at (4.5,-0.75) (5₁) { 5:1 };
\node[myothernode,fill=purple!30] at (6,-0.75) (5₂) { 5:2 };

\node [mynode] at (7.5,0) (h3){\phantom{1:1}};

\node[myothernode,fill=teal!30] at (9,0.75) (6₁) { 6:1 };
\node[myothernode,fill=teal!30] at (10.5,0.75) (6₂) { 6:2 };
\node[myothernode,fill=olive!30] at (9.75,-0.75) (7₁) { 7:1 };

\node [mynode] at (12,0) (h4){\phantom{1:1}};
\node [mynode] at (13.5,0) (h5){\phantom{1:1}};


Now, the code for drawing edges can be simplified further. You are using \path[line,->] which gives wrong results. Moving on, the arc/curve you are talking about can be drawn by several ways. One of them will be to define a control point like

(h1.north) edge [controls=+(80:2.5) and +(100:2.5)](h2.north);


You can change the angles and the distance to suit your needs.

The complete code will be

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{patterns,arrows}
\tikzset{line/.style={-latex'},
mynode/.style={pattern=north east lines, circle, draw,inner sep=2pt,outer sep=0pt},
myothernode/.style = {draw,circle,inner sep=2pt,outer sep=0pt}
}
\begin{document}
\begin{tikzpicture}
\node [mynode] at (0,0) (h1){\phantom{1:1}};

\node[myothernode,fill=blue!30] at (1.5,1.5)  (1₁) { 1:1 };
\node[myothernode,fill=green!30] at (1.5,0) (2₁) { 2:1 };
\node[myothernode,fill=red!30] at (1.5,-1.5) (3₁) { 3:1 };

\node [mynode] at (3,0) (h2){\phantom{1:1}};

\node[myothernode,fill=orange!30] at (4.5,0.75) (4₁) { 4:1 };
\node[myothernode,fill=orange!30] at (6,0.75) (4₂) { 4:2 };
\node[myothernode,fill=purple!30] at (4.5,-0.75) (5₁) { 5:1 };
\node[myothernode,fill=purple!30] at (6,-0.75) (5₂) { 5:2 };

\node [mynode] at (7.5,0) (h3){\phantom{1:1}};

\node[myothernode,fill=teal!30] at (9,0.75) (6₁) { 6:1 };
\node[myothernode,fill=teal!30] at (10.5,0.75) (6₂) { 6:2 };
\node[myothernode,fill=olive!30] at (9.75,-0.75) (7₁) { 7:1 };

\node [mynode] at (12,0) (h4){\phantom{1:1}};
\node [mynode] at (13.5,0) (h5){\phantom{1:1}};

\draw [->] (0.333,-2.5) -- (13.3335,-2.5) node [midway, below] {Time};

\path [line] (h1) edge [bend left=15] (1₁)
(h1) edge (2₁)
(h1) edge [bend right=15] (3₁)
(1₁) edge [bend left=15] (h2)
(2₁) edge (h2)
(3₁) edge [bend right=15] (h2)
(h2) edge (4₁)
(h2) edge (5₁)
(4₁) edge (4₂)
(5₁) edge (5₂)
(4₂) edge (h3)
(5₂) edge (h3)
(h3) edge (6₁)
(h3) edge (7₁)
(6₁) edge (6₂)
(6₂) edge (h4)
(7₁) edge (h4)
(h4) edge (h5)
(h1.north) edge [controls=+(80:2.5) and +(100:2.5)](h2.north);  %% change control point: angle:<vertical distance>
\end{tikzpicture}
\end{document}


-
Or better use automata library of tikz –  Harish Kumar Jan 10 at 13:16
Instead of \phantom you could better use the minimum size key; 1:1 is not as wide as 5:2` –  Tobi Jan 10 at 15:27
@Tobi: Yes, that is a better choice towards procrastination :-) Thanks. –  Harish Kumar Jan 10 at 22:36