Example: Combinatorial graphs

Published 2007-02-23 | Author: Rafael Villarroel

Two fascinating graphs from the very interesting Graph Theory in LaTeX gallery. The graphs are excellent examples of how flexible and powerful TikZ' path constructs are. See the source code for more details.

Update: Fixed an error in the code for drawing Tutte's 8-cage graph.

Author:Rafael Villarroel
Source:The Graph Theory in LaTeX gallery

Download as: [PDF] [TEX]

Combinatorial graphs

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% Combinatorial graphs
% Author: Rafael Villarroel
% Source: http://graphtheoryinlatex.blogspot.com/

% Define style for nodes
\tikzstyle{every node}=[circle, draw, fill=black!50,
                        inner sep=0pt, minimum width=4pt]
%  Tutte's 8-cage
    % The following path utilizes several useful tricks and features:
    % 1) The foreach statement is put inside a path, so all the edges
    %    will in fact be a the same path.
    % 2) The node construct is used to draw the nodes. Nodes are special
    %    in the way that they are drawn *after* the path is drawn. This
    %    is very useful in this case because the nodes will be drawn on
    %    top of the path and therefore hide all edge joins.
    % 3) Simple arithmetics can be used when specifying coordinates.
    \draw \foreach \x in {0,36,...,324}
        (\x:2) node {}  -- (\x+108:2)
        (\x-10:3) node {} -- (\x+5:4)
        (\x-10:3) -- (\x+36:2)
        (\x-10:3) --(\x+170:3)
        (\x+5:4) node {} -- (\x+41:4)
% The largest 3-regular graph of diameter 3
    \draw \foreach \x in {18,90,...,306} {
        (\x:4) node{} -- (\x+72:4)
        (\x:4) -- (\x:3) node{}
        (\x:3) -- (\x+15:2) node{}
        (\x:3) -- (\x-15:2) node{}
        (\x+15:2) -- (\x+144-15:2)
        (\x-15:2) -- (\x+144+15:2)



  • #1 Hajder, May 7, 2009 at 9:05 p.m.

    Thanks alot !!

  • #2 Sheng Bau, November 7, 2009 at 12:59 p.m.

    Well! This is really great!!!

  • #3 Arii, January 15, 2010 at 5:38 a.m.

    You are great Rafaell.


Adding comments is currently not enabled.