2

There's a couple of things I need in my diagrams which I can't seem to figure out how to do. Firstly, I need arrows of two different colours - straight arrows one colour, bent arrows another. And I also need to have information outside of but next to each circle (eitherA=1 or A=0). Help would be much appreciated!

\documentclass{article}

\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows,automata}
\usepackage[latin1]{inputenc}


\begin{document}

\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm,
                    semithick]
  %\tikzstyle{every state}=[fill=white,draw=black,text=black]

  \node[state]       (A)                    {$w_1$};
  \node[state]         (B) [above left of=A] {$w_2$};
  \node[state]         (C) [above right of=A] {$w_3$};


\path (A) edge              node {} (B)
               %edge              node {} (C)
        edge [bend right] node {} (C)
        (B) edge        node {} (A)
            %edge              node {0,1,L} (C)
        %(C) edge              node {0,1,L} (D)
           % edge [bend left]  node {1,0,R} (E)
        (C) %edge [loop below] node {1,1,R} (C)
            edge              node {} (A);
        %(E) edge [bend left]  node {1,0,R} (A);
\end{tikzpicture}

\end{document}
2

You can add colours as either arguments to the \path command and/or to each edge. For example,

 \path[red] (A)
 edge (B)
 edge [bend right, blue] (C)

will make the default colour red but colour the bent curve blue.

To put information close to the nodes, add a label=pos:text argument to the \node statment, e.g.

\node[state, label=left:{$A=1$}] (B) {$w_2$};

The presence of = in your "text" means you have enclose it in {...} brackets.

Sample output

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows,automata}

\begin{document}

\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node
  distance=2.8cm, semithick]

  \node[state, label=below:{$A=3$}] (A) {$w_1$};
  \node[state, label=left:{$A=1$}] (B) [above left of=A] {$w_2$};
  \node[state, label=right:{$A=0$}] (C) [above right of=A] {$w_3$};

  \path[red] (A)
  edge node {} (B)
  edge [bend right, blue] node {} (C)
  (B) edge node {} (A)
  (C) edge node {} (A);
\end{tikzpicture}

\end{document}

Should you wish to style the labels you can either set the every label style or write something like

\node[state, label={[font=\small]left:$A=1$}] (B) {$w_2$};
| improve this answer | |

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.