I have the following tikz code:





        \draw (10,10) node(C)[ellipse,draw] {C};
        \draw (8.5,8.5) node(N)[ellipse,draw] {N};
        \draw (11.2,8.5) node(Y)[ellipse,draw] {Y};
        \draw (7.5,7.2) node(W)[ellipse,draw] {W};
        \draw (9.3,7.2) node(K)[ellipse,draw] {K};

        \draw [->] (C) -- (N) {N};
        \draw [->] (C) -- (Y) {cc};
        \draw [->] (N) -- (W) {dd};
        \draw [->] (N) -- (K) {ee};



It has several problems.

1) the code won't compile because of the bottom drawing commands, what I am trying to do is draw a label next to each of the arrows. If I remove the labels such as {cc} or {dd} etc. for all -> commands, it works, but it doesn't show labels next to the edges.

  1. I want to have a labeled "self-loop" for the C node (labeled with "T"), but when I do draw -> from one node to the same node, it won't draw a self loop.
  • Rather then \draw [->] (C) -- (N) {N}; you can use \draw [->] (C) -- node[right] {N}(N);
    – Salim Bou
    Commented Jul 28, 2016 at 7:45
  • thanks @salim, that works. now i am just left with the self loop issue :-) what I mean is draw an arc that looks like a self loop in a graph.
    – kloop
    Commented Jul 28, 2016 at 7:49
  • 1
    \draw [->] (C) edge[loop above]node{T} (C);
    – Salim Bou
    Commented Jul 28, 2016 at 8:06

1 Answer 1


Something like this?

enter image description here


    \node[ellipse,draw] (C) at (10,10) {C};
    \node[ellipse,draw] (N) at (8.5,8.5) {N};
    \node[ellipse,draw] (Y) at (11.2,8.5) {Y};
    \node[ellipse,draw] (W) at (7.5,7.2) {W};
    \node[ellipse,draw] (K) at (9.3,7.2) {K};

    \path (C) edge              node[above] {C} (N);
    \path (C) edge              node[above,right] {cc} (Y);
    \path (N) edge              node[above,left] {dd} (W);
    \path (N) edge              node[above, right] {ee} (K);
    \path (C) edge [loop above] node {T} (C);

  • Is there a way to do this using bayesnet? Or alternatively, is there a way to color in nodes? Commented Mar 21, 2020 at 21:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .