Graphics, Figures & TablesDrawing Hasse diagrams using TikZ

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
pieter
Posts: 3
Joined: Sun Nov 08, 2009 1:44 pm

Drawing Hasse diagrams using TikZ

Post by pieter »

In Galois theory (and many other parts of mathematics) one often finds Galois correspondence. This can be represented in a Hasse diagram. Now I'm looking for a way to draw these Hasse diagrams. An example can be found in the attachment, it's from http://www.galois-theorie.de/. More examples of Hasse diagrams can be found at http://en.wikipedia.org/wiki/Hasse_diagram.

A bit of searching didn't gave satisfactory results, I found one example of such a diagram in the xypic manual. And of course there's TikZ. But I'm not that satisfied with the possible placement options, for instance, the list of examples on generic graphs at http://www.texample.net/tikz/examples/tag/graphs/ does not contain the kind of relative placement modifiers I'm looking for.

This leads me to these questions:
- Is there a package I'm overlooking? But "hasse diagram latex" only has 2910 results on Google, so unless I'm missing a far more obvious term for Hasse diagrams I'm afraid there is no ready-to-go package :). Of course, there are packages for trees, but Hasse diagrams differ from trees in ways that are hard to overcome using these tree packages.
- When resorting to TikZ, is it possible to place nodes using only two types of information, i.e., the level on which a node must be placed and their order? The relative placement modifiers below of= and its variants don't (I think) allow me to center a row according to the number of nodes present. Or is it possible to group the nodes on a row while retaining the possibility to give them separate names to place the necessary arrows?


Of course it's possible to create these kind of diagrams using semi-hard-coded positions, but I feel / hope it is possible to let the placement occur automatically :).


Thanks in advance.

I placed this in Graphics, Figures & Tables, maybe the more mathematical nature of the diagrams requires it to be in Math & Science?
Attachments
An example of a Galois correspondence
An example of a Galois correspondence
galois-theory.gif (6.26 KiB) Viewed 11803 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Drawing Hasse diagrams using TikZ

Post by gmedina »

Hi,

using TikZ you can define a matrix of nodes. The PGF/TikZ manual contains the details.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
pieter
Posts: 3
Joined: Sun Nov 08, 2009 1:44 pm

Re: Drawing Hasse diagrams using TikZ

Post by pieter »

Yes, but in that case you're limited to the lay-out of the matrix. Each row should get aligned according to the number of nodes present in it, not by some smallest common multiple of the number of elements.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Drawing Hasse diagrams using TikZ

Post by gmedina »

I don't understand your last reply. Using empty cells you can achieve the desired layout. What's the problem with something like the following really simple example?

Code: Select all

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,matrix}

\begin{document}

\begin{tikzpicture}
  \matrix (galois)
    [matrix of nodes,%
     nodes in empty cells,
     nodes={outer sep=0pt,circle,minimum size=4pt},
     column sep={1cm,between origins},
     row sep={1cm,between origins}]
  {
   && a &&\\
   b & c & d & e & f\\
   g && h && i\\
   && j &&\\
  };
  \foreach \a in {1,...,5}
    \draw (galois-1-3) -- (galois-2-\a);
  \foreach \a in {1,3,5}
    \draw (galois-3-\a) -- (galois-4-3);
  \foreach \a in {1,2,3}
    \draw (galois-2-\a) -- (galois-3-1);
  \foreach \a in {3,4,5}
    \draw (galois-2-\a) -- (galois-3-5);
  \draw (galois-2-3) -- (galois-3-3);
\end{tikzpicture}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
pieter
Posts: 3
Joined: Sun Nov 08, 2009 1:44 pm

Re: Drawing Hasse diagrams using TikZ

Post by pieter »

That works of course, but things aren't always that regular, for instance the lattice of partitions of a set of four elements ordered by inclusion as in http://en.wikipedia.org/wiki/Hasse_diagram. I was wondering whether it's possible to align nodes in a more general way instead of having them fixed on matrix element boundaries.
Post Reply