# Half arrows in graph using TikZ

How can I create half arrows like the colored ones in the answer to this post using TikZ? I know how I can create custom arrow tips, but how can I extend this to the tail of the arrow? I would appreciate some ideas. Thanks.

EDIT: The arrow should sit on top of an undirected edge.

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta}

\tikzset{arr/.style={line width=4pt, {-Latex[left]}, #1}}

\begin{document}
\begin{tikzpicture}
\node[draw,circle] (A) at (0,0) {};
\node[draw,circle] (B) at (3,0) {};
\draw (A) to (B);
\draw[arr=green!30]   (A) -- (B);
\end{tikzpicture}
\end{document}


produces which covers the edge underneath. I would also like to have a boundary in a slightly darker green around the arrow except where it touches the edge or a vertex and the tail of the arrow should fit along the start node. It would be nice if the solution would also support bended arrows.

EDIT: I got a little further with my problem. I used markings to define coordinates near the head and tail of the arrow, which I then connected.

\documentclass[tikz]{standalone}
\usetikzlibrary{matrix,arrows,arrows.meta,bending,decorations.pathreplacing,
decorations.pathmorphing,decorations.markings,fit,patterns,
shapes,intersections,calc}

\begin{document}

\tikzset
{
down oriented arrow/.style = {
thick,
decoration={
markings,
mark=at position 0.01 with
{
\coordinate (A) at (0,0);
\coordinate (B) at (.125,.125);
},
mark=at position 0.99 with
{
\coordinate (C) at (-.25,.125);
\coordinate (D) at (-.25,.25);
\coordinate (E) at (0,0);
\filldraw[thick,draw=#1,fill=green!30]
(A) -- (B) -- (C) -- (D) -- (E) -- cycle;
}
},
preaction = {decorate}
},
down oriented arrow/.default=black
}

\begin{tikzpicture}[align=center,node distance=3cm]
\node[draw,circle] (a) {};
\node[draw,circle,right of=a] (b) {};
\node[draw,circle,below of=a] (c) {};
\node[draw,circle,right of=c] (d) {};

\draw[down oriented arrow=green!90] (a) to (b);
\draw[down oriented arrow] (c) to (b);
\draw[down oriented arrow] (d) to[bend right] (b);
\end{tikzpicture}

\end{document}


which gives the following result.

How can I pass the fill color as a second argument to the down oriented arrow style? Obviously this does not work for the bended arrow. Any suggestions? Also I could not fit the tail of the arrow to the node, but I made a compromise there which looks quite ok.

One way, with the arrows.meta library of pgf/TikZ v3.0.

See Section 16.5 of the pgf manual for a full listing of available arrow tips and options.

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}
\draw[-{Latex[left]}] (0,0) -- (1,1);
\draw[-{Latex[right]}] (0,1) -- (1,0);
\draw[-{Diamond[left]}] (0,0.5) -- (1,0.5);
\end{tikzpicture}
\end{document}


The question only requested half-arrows, but Gonzalo Medina provided some additional code in a comment that might be useful in drawing diagrams similar to those in the linked answer:

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta}
\tikzset{arr/.style={line width=4pt, {-Latex[left]}, #1}}

\begin{document}
\begin{tikzpicture}
\node[draw,circle] (A) at (0,0) {};
\node[draw,circle] (B) at (3,0) {};
\node[draw,circle] (C) at (0,3) {};
\draw[arr=green!30]   (A) -- (B);
\draw[arr=red!30]     (B) -- (C);
\end{tikzpicture}
\end{document}


The style arr can be used throughout the diagram(s) with the color provided as an argument. This gives consistency throughout the document, and if you decide to change the drawing style later, it only needs to be updated in one place.

• Ah, you beat me! (+1) – Gonzalo Medina Jan 26 '15 at 19:00
• Can I suggest you to add this example to your answer? \documentclass{article} \usepackage{tikz} \usetikzlibrary{arrows.meta} \tikzset{ arr/.style={ line width=4pt, {-Latex[left]}, #1 } } \begin{document} \begin{tikzpicture} \node[draw,circle] (A) at (0,0) {}; \node[draw,circle] (B) at (3,0) {}; \node[draw,circle] (C) at (0,3) {}; \draw[arr=green!30] (A) -- (B); \draw[arr=red!30] (B) -- (C); \end{tikzpicture} \end{document} Your answer as is, contains all that is required, but people loves color ;) – Gonzalo Medina Jan 26 '15 at 19:02
• Sure thing, I will add now. Thanks @GonzaloMedina! – Paul Gessler Jan 26 '15 at 19:03
• Thanks but that's not quite it yet. See my EDIT above. – user26756 Jan 26 '15 at 19:24
• @user26756 that kind of fundamentally changes the question... I'll look at it later. – Paul Gessler Jan 26 '15 at 19:29

This now works for me. Bended arrows are still not possible though. Will post a follow up question about that.

\documentclass[tikz]{standalone}
\usetikzlibrary{matrix,arrows,arrows.meta,bending,decorations.pathreplacing,
decorations.pathmorphing,decorations.markings,fit,patterns,
shapes,intersections,calc}

\begin{document}

\tikzset
{
down oriented arrow/.style 2 args = {
thick,
decoration={
markings,
mark=at position 0.01 with
{
\coordinate (A) at (0,0);
\coordinate (B) at (.125,.125);
},
mark=at position 0.99 with
{
\coordinate (C) at (-.25,.125);
\coordinate (D) at (-.25,.25);
\coordinate (E) at (0,0);
\filldraw[#1,#2]
(A) -- (B) -- (C) -- (D) -- (E) -- cycle;
}
},
preaction = {decorate},
},
down oriented arrow/.default={draw=black}{fill=black!30}
}
\tikzset
{
up oriented arrow/.style 2 args = {
thick,
decoration={
markings,
mark=at position 0.01 with
{
\coordinate (A) at (0,0);
\coordinate (B) at (.125,-.125);
},
mark=at position 0.99 with
{
\coordinate (C) at (-.25,-.125);
\coordinate (D) at (-.25,-.25);
\coordinate (E) at (0,0);
\filldraw[#1,#2]
(A) -- (B) -- (C) -- (D) -- (E) -- cycle;
}
},
preaction = {decorate},
},
up oriented arrow/.default={draw=black}{fill=black!30}
}

\begin{tikzpicture}[align=center,node distance=3cm]
\node[draw,circle] (a) {};
\node[draw,circle,right of=a] (b) {};
\node[draw,circle,below of=a] (c) {};

\draw[down oriented arrow={draw=green!90}{fill=green!30}] (a) to (b);
\draw[down oriented arrow={draw=blue!90}{fill=blue!30}] (b) to (a);
\draw[up oriented arrow={draw=orange!90}{fill=orange!30}] (b) to (c);
\draw[up oriented arrow={draw=red!90}{fill=red!30}] (c) to (b);
\end{tikzpicture}

\end{document}