I want to draw the process like in the picture using the code below, however, there is some problem, would someone help me?

enter image description here


        \tikzstyle{level 1}=[level distance=1.5cm, sibling distance=3.5cm]
        \tikzstyle{level 2}=[level distance=1.5cm, sibling distance=2cm]

    \tikzstyle{bag} = [text width=20em, text centered]
    \tikzstyle{end} = [circle, minimum width=3pt,fill, inner sep=0pt]

    \node[bag] { $(B)$}
        child {
            node[bag] {$(R_{good})$}
                child {
                    node[bag] {$(and)$}
                    edge from parent
                    node[right]  {$and$}
                edge from parent
                node[right] {$t$}
  • 2
    Instead of posting only code snippets, you should post complete minimal example documents. That makes it easier for others to help you. Also, you should avoid general statements like "there is some problem": It's better to explain in words how your output differs from what you expect. – Jake Aug 13 '12 at 12:40

Do you want something like:

enter image description here

The code is:


\tikzset{level 1/.style={level distance=1.5cm, sibling distance=3.5cm}}
\tikzset{level 2/.style={level distance=1.5cm, sibling distance=2cm}}

\tikzset{bag/.style={text width=20em, text centered,yshift=-0.2cm}}

\begin{tikzpicture}[grow=down, -stealth]
    child{ edge from parent node[right]{t}; \node[bag]{$(Rgood)$}
            child{ edge from parent node[right]{and}; \node[bag]{$(and)$}
                    child{ edge from parent node[right=0.1cm]{it}; \node[bag]{$(path1)$}}
                    child{ edge from parent node[right=0.1cm]{else}; \node[bag]{$(path2)$}}


I actually removed the unused style end, changed the deprecate syntax tikzstyle with the equivalent tikzset. Moreover, for the leaves, i made use of the option missing to let path1 be exactly below the previous and. You can add an arrow by simply inserting it as option of the tikzpicture environment.

| improve this answer | |
  • thanks, however, in the picture, the connector is an arrow. I don't know how to draw the arrow to connect two objects. – sweetyBaby Aug 13 '12 at 12:45
  • @sweetyBaby: you are right. I've edited my answer to accomplish this, however for it I would recommend you to reference to the pgfmanual. – Claudio Fiandrino Aug 13 '12 at 12:53
  • As we can see, in latex image in the above, two arrows are different. For example "and->path1" and "and->path2", the arrow connecting "and -> path2" is bolder than that of "and->path1", why? – sweetyBaby Aug 13 '12 at 18:18
  • Actually, in the code there are no option that can made one arrow bolder than the other one. I don't have an answer for this, sorry. – Claudio Fiandrino Aug 14 '12 at 6:19

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.