I am looking for a very simple way to write a command for drawing (undirected or direct) graphs in Latex. I am aware of tikz, but it is an overkill for what I want, especially since I want the .tex file to have easy to understand logical form.

All I want is to specify a set of nodes (or just the number of nodes), a possible label for some of the nodes, and the set of edges. $G=(V,E)$ in the usual sense with labelings for $V$.

I don't mind too much what the graph looks like as long as it is logically correct.

EDIT: For example, I would specify a graph using:


and that would draw a graph with 5 nodes, labeled a-e with edges between vertex 1 and 5 and 4 and 3.

  • Perhaps with the psmatrix environment (from pst-node): you first describe the vertices as nodes in a matrix of nodes, then you describe the edges as links between some pairs of nodes. One advantage of pstricks syntax is that it is latex-like, and nowadays it can be compiled with pdflatex. – Bernard Oct 11 '14 at 22:28
  • It would be helpful if you specified exactly how you want to specify the set of nodes and edges. Much of the work involved in this is really just that as that is going to determine how much flexibility you desire. – Peter Grill Oct 11 '14 at 22:33
  • @PeterGrill I added an edit about that. – kloop Oct 12 '14 at 6:32

Not sure why TikZ is considered overkill. The following looks quite straight forward, although it requires LuaLaTeX:

\tikz[>=Stealth]\graph [simple necklace layout, nodes={circle, draw}, node sep=1cm]{
  a, b, c, d, e;
  a -> e;
  d -> c;

enter image description here

| improve this answer | |
  • this looks rather simple. I was unaware that you can create graphs that easily in tikz. – kloop Oct 12 '14 at 12:13
  • @kloop note this requires the latest PGF/TikZ release. – Mark Wibrow Oct 12 '14 at 12:16

I've had good luck making diagrams using graphviz and then importing those graphics. Below is from the web page and there is a gallery with source.

The Graphviz layout programs take descriptions of graphs in a simple text language, and make diagrams in useful formats, such as images and SVG for web pages; PDF or Postscript for inclusion in other documents; or display in an interactive graph browser. Graphviz has many useful features for concrete diagrams, such as options for colors, fonts, tabular node layouts, line styles, hyperlinks, and custom shapes.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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