2

Possible Duplicate:
LaTeX for Graph Theory?

For the first time, I was going to draw a graph in LaTeX. (I was intended for a graph similar to the following)

enter image description here

Graph Theory is an important topic in Computer Science so I thought graph-drawing in LaTeX should be trivial, i.e. a package is given the adjacency matrix of graph and it positions each node in its perfect place automatically without the user having to manually place each node. But after some googling I now feel graph drawing is probably a time consuming task in the TeX world.

Is it better to draw graphs with some graphic software and insert it as an image, or there is some better solution? (How do I balance the trade-off between elegant looks and time-efficiency?) Is there a software that allows you to draw a graph in a GUI and then generate LaTeX markup for that (I mean a graph specific app not a general one).

note: This is not a duplicate, please note to bold text.

Real Dreams
  • 8,298
  • 12
  • 56
  • 78
  • 1
    A combination of R, the package igraph and tikzDevice might suffice. Or you could look at http://www.texample.net/tikz/ for examples using tikz. – mnel May 31 '12 at 06:25
  • There's an intriguing comment here: http://tex.stackexchange.com/a/17976/86 Generally, drawing graphs is quite complicated and whilst TeX is Turing complete, that doesn't mean that it is the best choice for implementing graph drawing routines. One option is to use Graphviz to lay out the graph and then render it using TikZ. This needs the dot2tikz program which is available via texample (which mnel has linked to). – Andrew Stacey May 31 '12 at 07:05
  • @mnel consider http://www.texample.net/tikz/examples/cycle/. It's a simplest graph example of that site, however it's still bulky. I think drawing should be through markup, not programming. – Real Dreams May 31 '12 at 07:07
  • 2
    possible duplicate of LaTeX for Graph Theory? and What GUI applications are there to assist in generating graphics for TeX?. Please try to ask only one concise question per post, and make sure they haven't been asked before. – doncherry May 31 '12 at 07:20
  • @doncherry It is not dublicate at all, please consider removing your comment. – Real Dreams May 31 '12 at 10:25
  • @Reza: Two other 3k+ users agree with me. Could you tell us why you don't think it is a duplicate? – doncherry May 31 '12 at 10:30
  • @doncherry Both of your suggested links are about graph in general (i.e. diagrams) my concern is about graph in graph theory. – Real Dreams May 31 '12 at 10:36
  • 2
    @doncherry First sentence of the first link : "What should I use to make Graphs for Graph Theory in LaTeX?" – PHL May 31 '12 at 10:46
  • You need to provide more explanation as to why the linked questions (including mine) don't help you. Your bolded text doesn't help much - there is no "perfect place" for the node of a graph and laying out a graph is a very complicated task, witness the complexity of Graphviz. So expecting a typesetting program to have a solution seems a little ambitious. doncherry's first linked question contains several resources, including a way to get Graphviz to generate the graph and TikZ to render it - best of both worlds. What more do you want? – Andrew Stacey May 31 '12 at 11:22
  • @Reza Have you looked at Graphviz? Whilst it doesn't take an adjacency matrix, it would be trivial to write a script to convert an adjacency matrix to the right format - either in TeX or out of it. That would be a reasonable question to ask, but that's more focussed than what you're asking here. – Andrew Stacey May 31 '12 at 11:24
  • tikz-pgf, in its development version, has a new module to draw graphs. All the math work is done at lua level. Till Tantau (the author of tikz) is working hard those days to make the code cleaner, the user interface as intuitive as in other parts of tikz and to document the new features. – cjorssen May 31 '12 at 11:28
  • @AndrewStacey Thanks. all right. I will investigate the mentioned apps more deeply and will ask more precisely if necessary. yEd program have a "Layout" option that can place all nodes in a neat way, also a lots of java applets that demonstrate algorithms, draw graphs in a good looking way just using adjacency matrix. so why a package could not draw a graph just with adjacency matrix? – Real Dreams May 31 '12 at 11:35
  • @Reza Second hit on search for "graphviz adjacency matrix" was http://www.thomasmargraf.org/wordpress/?p=16 which has a short Perl script that could be adapted to produce the dot file that could be converted to TikZ via dot2tikz. I suspect that the "java applets" use an algorithm that works okay for a small number of nodes but scales badly. Graphviz has quite sophisticated algorithms that can deal with a vast number of nodes. – Andrew Stacey May 31 '12 at 11:40

0 Answers0