I'm a TikZ newbie, what is the best package (and technique) that can be used to quickly (and easily) build a drawing of a directed graph like this one (picture from M. Sipser's book)?
In particular what is the best way to draw the (aligned) dots in the middle of the drawing (add "..." text and place it at absolute position)? And what about the halved arcs?
And does there exist a graphical Tikz GUI tool powerful enough to achieve the same result?

enter image description here

  • 2
    There is also an italian guide to quickly learn the basis of TikZ: L'Arte di disegnare con LaTeX. In another italian guide, Introduzione all’uso di TikZ in Ingegneria, I was reporting examples of drawings with very basic code; you can be interested in chapter 5. – Claudio Fiandrino Feb 26 '14 at 13:35
  • @ClaudioFiandrino: thanks, it seems a good resource that can be used also as a quick reference! If there is an English version you can convert your comment into an answer and I'll upvote it :) What about the GUI tool? Are TikzIt or TikzEd powerful enough for such a (simple) task? – Marzio De Biasi Feb 26 '14 at 13:39
  • @MarzioDeBiasi it's relatively easy to achieve this result with Tikz only with basic commands – Alain Matthes Feb 26 '14 at 13:56
  • @AlainMatthes: thank you! BTW, yesterday it has been released the new version of L'Arte di disegnare con LaTeX which is also showing some of the new features of TikZ 3.0.0. The authors made a great work! – Claudio Fiandrino Feb 28 '14 at 7:58
up vote 17 down vote accepted

There are some packages to do this but if it's perhaps interesting to learn something simple about Tikz and how use some basic commands

1) You load the package tikz

2) Then you load a library arrows to get some special styles about arrows

3) We can define some styles for vertex and edge but you can look at this after

4) We place some nodes. My method here is simple but it's not a good one because it's not easy to modify the values.

5) We draw the edges

6) The dots are between (a3) and (c) \pathis useful because we don't draw anything but we can place a node. By default, the node are placed at the middle of each extremities.

7) I created nodes empty without drawing

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

\begin{tikzpicture}

\tikzset{vertex/.style = {shape=circle,draw,minimum size=1.5em}}
\tikzset{edge/.style = {->,> = latex'}}
% vertices
\node[vertex] (a) at  (0,0) {};
\node[vertex] (b) at  (4,3) {};
\node[vertex] (c) at  (8,0) {};
\node[vertex] (d) at  (4,-3) {$t$};
\node[vertex] (a1) at (1.5,0) {};
\node[vertex] (a2) at (3,0) {};
%edges
\draw[edge] (b) to (a);
\draw[edge] (b) to (c);
\draw[edge] (a) to (d);
\draw[edge] (c) to (d);

\draw[edge] (a)  to[bend left] (a1);
\draw[edge] (a1) to[bend left] (a);

\draw[edge] (a1) to[bend left] (a2);
\draw[edge] (a2) to[bend left] (a1);

\path (a2) to node {\dots} (c);
\node [shape=circle,minimum size=1.5em] (a3) at (4.5,0) {};
\draw[edge] (a2) to[bend left] (a3);
\draw[edge] (a3) to[bend left] (a2);

\node [shape=circle,minimum size=1.5em] (c1) at (6.5,0) {};
\draw[edge] (c) to[bend left] (c1);
\draw[edge] (c1) to[bend left] (c);
\end{tikzpicture}

\end{document}

enter image description here

Remarks : It's possible to define constant to define the distance between the nodes. Tikz also gives the possibilities to use some option like node distance. There are other options to place the nodes but it's a more complex for a first approach.

  • Great! And for what regards the dots, can I use a node as a hidden "hook" and place it at absolute position? – Marzio De Biasi Feb 26 '14 at 14:04
  • I complete my answer but I think some users give you answers based on powerful package or based on more complex commands of tikz ... – Alain Matthes Feb 26 '14 at 14:17
  • Another small question, if I want to add a simple label "$e_1,e_2$" to the diagonal edges (in the middle of the edge just above it); how can I modify the "\draw[edge] (b) to (a);" command ? I tried "\draw[edge] (y1) to (d1_1) node [midway, below] {Text};" but it doesn't work. – Marzio De Biasi Feb 27 '14 at 11:00
  • Don't worry I found that: "\draw[edge] (y1) to node[label= above:$e_1$] {}(d1_1);" works well. – Marzio De Biasi Feb 27 '14 at 11:05

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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