[Tex/LaTex] Tikz and directed graph

tikz-pgf

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

Best Answer

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.

Related Question