TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My friends send me this .tex code, but it is only part of the code. I need your help to edit this code into a full document, because when I insert this code to TeXworks it does not compile into a pdf file.

This is the part of code which I need to be edited into a full document:

digraph {
A [peripheries = 2];
B [peripheries = 2];

A->B [label = "a"];
S->A [label = "a"];

A->A [label = "b"];
S->S [label = "b"];

A->S [label = "c"];
S->B [label = "c"];


Console output:

This is pdfTeX, Version 3.1415926-1.40.11 (Web2C 2010) restricted \write18 enabled. entering extended mode (./untitled-1.tex LaTeX2e <2009/09/24> Loading CZ hyphenation patterns: Pavel Sevecek, v3, 1995 Loading SK hyphenation patterns: Jana Chlebikova, 1992

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ...

                                               l.1 d
 igraph { ?
share|improve this question
Welcome to TeX.SE. What is this code supposed to do? – Peter Grill Nov 14 '12 at 2:04
its graph of automation – user1779502 Nov 14 '12 at 2:09
Please, post your preamble. Are you trying to compile only this code? – Sigur Nov 14 '12 at 2:14
Try dot2tex maybe: fauskes.net/code/dot2tex – Scott H. Nov 14 '12 at 2:21

To compile that code you would need a dot language interpreter (i.e. graphviz or equivalent) which through a package (or otherwise) could spit out TiKz (or equivalent) code. I don't have graphviz installed, but I do have Gephi installed. I made a .dot file that contains your code and had Gephi do the layout and then exported to TiKz. The result could be improved (label adjustments etc.) if I knew any TiKz but I don't so unfortunately I can't help you there. Below is the output and generated .tex file.

enter image description here

\usepackage{tikz, tkz-graph}
\node at (0.8159795,0) [circle, line width=1, fill=COLOR0,  inner sep=0pt, minimum size = 5pt, label={[label distance=0] 315:A}] (1) {};
\node at (-1.6908659,4.5319248) [circle, line width=1, fill=COLOR0,  inner sep=0pt, minimum size = 5pt, label={[label distance=0] 315:B}] (2) {};
\node at (0.8748864,5.7434276) [circle, line width=1, fill=COLOR0,  inner sep=0pt, minimum size = 5pt, label={[label distance=0] 315:S}] (3) {};
\tikzset{EdgeStyle/.style = {->,shorten >=1pt,>=stealth, bend right=10}}
\tikzset{EdgeStyle/.style = {->, shorten >=1pt, >=stealth, bend right=10, line width=0.5, color=COLOR0}}
\Loop[dist=1cm,dir=EA,style={->,shorten >=1pt,>=stealth,line width=0.5}, color=COLOR1, label=b](1)
\Edge [label=a](1)(2)
\Edge [label=c](1)(3)
\Edge [label=a](3)(1)
\Edge [label=c](3)(2)
\Loop[dist=1cm,dir=EA,style={->,shorten >=1pt,>=stealth,line width=0.5}, color=COLOR1, label=b](3)
share|improve this answer

Googling digraph latex produced this:

You need graphviz.sty (available here) and you need the following in your document preamble:

share|improve this answer
Where would one find your graphviz.sty? This answer seems a little useless without it. – naught101 Nov 14 '12 at 5:05
The information in the answer, including a description of graphviz.sty, is from here. – Andrew Uzzell Nov 14 '12 at 10:20
The fact that the OP tried to latex the code snippet as is suggests s/he does not know what a full latex document is. (As the error shows, the first line of the supposed latex file was digraph). A real answer should probably provide a full and compilable latex file. – jon Nov 14 '12 at 11:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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