I'm trying to draw some graphs (as in edges and vertices) for an article. I would like to add a bar to all edges and label them as half-edges.


          every node/.style={circle, draw, fill=black!50,
                            inner sep=0pt, minimum width=4pt}, thick
        \node(A) at (0,0){};
        \node(B) at (0.5,1){};
        \node(C) at (1,0){};
        \node(D) at (2,0){};

        \draw (D) to [out=-45,in=45,looseness=40] (D);

This gives me this graph:

enter image description here

Here's the result I would like:

enter image description here

How can I do something like that ? I am using MikTex.

Thank you :)

1 Answer 1


You can use decorations.markings.

\begin{tikzpicture}[pft/.style n args={3}{postaction={decorate,
    mark=at position 0.25 with {\path (0,#1) node{#2};},
    mark=at position 0.5 with {\draw[thick] (0,-1*#1) -- (0,#1);},
    mark=at position 0.75 with {\path (0,#1) node{#3};}}}},font=\small]     
    \begin{scope}[nodes={circle, draw, fill=black!50,
                            inner sep=0pt, minimum width=4pt}, thick]
        \node(A) at (0,0){};
        \node(B) at (0.5,1){};
        \node(C) at (1,0){};
        \node(D) at (2,0){};
        \draw[pft={1ex}{1}{2}](A)-- (B);
        \draw[pft={-1ex}{9}{10}] (D) to [out=-45,in=45,looseness=40] (D);

enter image description here

  • Thank you so much !
    – Simon
    Jan 31, 2020 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.