Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

What should I use to make Graphs for Graph Theory in LaTeX?

I have seen a lot of stuff about tkz (specifically tkz-berge), but I'm running Ubuntu and there is no package for it, that I can tell. Trying to download all the .sty's is confusing the bejesus out of me. I cannot even find all the dependencies for tkz-graph.

share|improve this question
3  
As an Ubuntu user sadly one has to do some manual installing for many packages because only texlive 2009 ships with ubuntu and not the 2010 version. However, I'd recommend you to be a bit adventurous and install packages manually. tkz-graph is, i believe, the same as tkz-euclide and can be found here: altermundus.com/pages/downloads/index.html You may want to get a new version of tikz too, it can be found here: tlcontrib.metatex.org. Use the search function to find out how to manually install packages –  Martin H Feb 13 '11 at 23:20
    
Moved tkz.zip into /usr/share/texmf-texlive/tex/latex/tkz and also put the tkz-graph,tkz-berge,tkz-arith.sty's and also dl'ed pgf and place in the generic folder. Now, I get a pgf math error when I try to make examples. I guess I installed something wrong? Work on it tomorrow. –  Buttink Feb 14 '11 at 2:46
    
I'd actually recommend to just skip the Ubuntu/Debian packages and install TeX Live directly from tug.org/texlive. That's easier than installing lots of packages by hand and makes it easy to keep up to date. –  Caramdir Feb 14 '11 at 5:06
    
The Ubuntu packaged version of texlive is pretty good for the basics, but the more you dig into it, the less satisfactory it becomes until one day you decide you have to uninstall it and install tl2010 for yourself... I'm just trying to find a time when I don't have several half written documents I need to finish so I can take the time to do it... –  Seamus Feb 14 '11 at 11:01
1  
Sorry but you can't use the old tkz-berge and tkz-arith inside tkz with tkz-euclide. I wrote a new version of some arithmetic tools for the tkz packages and tkz-berge use these tools. I try to send all my packages on the servers of CTAN. Now I work to update tkz-berge but I need to adapt the packages with the pgf CVS version because some of my tools are now inside pgf. Well, I have a lot of works with all theses packages, so you need to be patient. I will make a new version of tkz-berge for the CTAN in some days. –  Alain Matthes Feb 14 '11 at 16:56

5 Answers 5

up vote 14 down vote accepted

This perhaps isn't quite the answer you were looking for as it isn't TeX-centric, but Graphviz has always been (for me) the tool for drawing any kind graph with more then three vertices. The ability to export to PS or PDF is a plus and there are tons of wrappers so you can use your lanuage of choice (personally I use pydot). Graphviz shines when you have many vertices that you would like to be arranged according to some pattern (several are provided).

That being said, for small graphs (or those with a tree-like dependency), nothing can beat tikz with the iteration of TeX directly into the document, though the verbosity sometimes is off putting.

Example of a simple tikz graph code

\begin{tikzpicture}[shorten >=1pt,->]
  \tikzstyle{vertex}=[circle,fill=black!25,minimum size=12pt,inner sep=2pt]
  \node[vertex] (G_1) at (-1,-1) {1};
  \node[vertex] (G_2) at (0,0)   {2};
  \node[vertex] (G_3) at (1,-1)  {3};
  \draw (G_1) -- (G_2) -- (G_3) -- cycle;
\end{tikzpicture}}
share|improve this answer
3  
You can even write graphviz right in your tex doc with dot2texi, but you have to use --shel-escape when compiling with pdflatex. I actually prefer just using one of the graphviz tools (dot, neato, et al) and embedding it. –  TJ Ellis Feb 14 '11 at 3:17
1  
I asked a similar question recently regarding drawing chemical connectivity graphs, and insomuch as automatic node placement is concerned, GraphViz really seems to be the way to go, as PGF/TikZ requires explicit node placement, relative or absolute. When dealing with a large graph (or even a small one) automatic placement is pretty much necessary if you want something half-way appealing that isn't a tree or a grid. neato is fantastic as it carries out a balls-and-springs 'energy minimisation' of sorts to generate optimised node positioning. –  Richard Terrett Feb 14 '11 at 11:03
1  
When I use Graphviz, I always import the graphs as a TikZ image using dot2tex --codeonly --usepdflatex --tikzedgelabels --styleonly -t raw -f tikz graph.dot > graph.tikz. dot2tex is available here: fauskes.net/code/dot2tex. This allows one to include TeX markup in the graph node/edge labels. –  ESultanik Feb 14 '11 at 15:30
    
Ended up using this. It was probably over kill considering my graph had only 6 vertices, but it wasn't that bad. –  Buttink Feb 14 '11 at 20:24

I'm the author of tkz-graph and tkz-berge. These packages are removed from my sites altermundus.fr and altermundus.com because I work actually to update them and to adapt them to pgf 2.0 and 2.1. I use some arithmetic tools and now these tools are in pgf 2.1 so it's better for me to update all the packages. There are also actually some problems of compatibility with my new packages tkz-base and euclide. If you want to use old versions of tkz-berge, don't install tkz-base. Problems come from arithmetic functions in tkz-arith and pgfmath. You can use my email from my site if you want an old version adapted to pgf 2.1

share|improve this answer
    
I thought that was probably why they were not up. I really want to use tkz-berge, but this time I went with dot and dot2tex. Once the new one is up though, I will definitely try it –  Buttink Feb 14 '11 at 20:21

I hear that a lot of graph theory people use Ipe. I am not a graph theorist, but I use Ipe, and I can see how the snapping modes of Ipe would make graph creation pretty easy.

share|improve this answer

I like metapost - it combines with latex very easily (you can use latex to enter the text on the graph so that fount sizes are consistent) and you can program the elements of the graph exactly how you want (Including recursively).

www.tug.org/docs/metapost/mpman.pdf

Note to get metapost to play with latex you often need to define

export TEX=latex

before you run the mpost command. It took me a while to find that out.

Also note: be careful about adding the above command to your .bashrc or you can get very strange errors when generating docs with texi (took me even longer to discover this).

share|improve this answer

pgf is in the Ubuntu repositories, so for that you only need sudo apt-get install pgf. You do not need the newest version of tikz to use tkz-graph. Then create a directory in your home folder, say ~/texmf/tex/latex/tkz, and put tkz-graph.sty, tkz-arith.sty and tkz-berge.sty there. This should be enough. I have some examples of the usage of tkz-berge in my blog: http://graphtheoryinlatex.wordpress.com

share|improve this answer
    
I have been using your blog for tests to see if my install worked :) sadly not working yet but i will try to just do only what your said and see if it works –  Buttink Feb 14 '11 at 14:28
    
I tried what you said and got some stuff working. I don't know if I found an old tkz-graph/arith/berge but it will complain about "\grCirculant" and a PGF math error "unkown function modl." –  Buttink Feb 14 '11 at 14:37
    
Yes I've seen some times that \grCirculant misbehaves. In those cases I would just draw a \grCycle and then use \EdgeInGraphMod for the other edges. Hopefully Alain will release an updated version to CTAN soon. –  rvf0068 Feb 14 '11 at 14:49
    
@Buttink: you can find the new version of tkz-graph and tkz-berge here : altermundus.com/pages/downloads/index.html and I put some examples for tkz-graph here : altermundus.com/pages/tkz/graph/index.html and for tkz-berge : altermundus.com/pages/tkz/berge/index.html. There is also a document about Named Graphs. You need to wait some days if you want to see these packages on CTAN. –  Alain Matthes Feb 28 '11 at 23:27

Your Answer

 
discard

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.