diff options
author | Karl Berry <karl@freefriends.org> | 2014-02-27 00:01:50 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-02-27 00:01:50 +0000 |
commit | 90ae413a94da014dbf7a6a8ab584f7c668483a5a (patch) | |
tree | 4e0528a2b2fb2004988e7fc804ea2f1354f1f5d5 /Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/examples/SimpleDemo.lua | |
parent | 800cc56380d1edfe567a6a66bef13e8950eb2b0c (diff) |
pgf 3.0.0
git-svn-id: svn://tug.org/texlive/trunk@33057 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/examples/SimpleDemo.lua')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/examples/SimpleDemo.lua | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/examples/SimpleDemo.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/examples/SimpleDemo.lua new file mode 100644 index 00000000000..cff5d95253a --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/examples/SimpleDemo.lua @@ -0,0 +1,82 @@ +-- Copyright 2010 by Renée Ahrens, Olof Frahm, Jens Kluttig, Matthias Schulz, Stephan Schuster +-- Copyright 2012 by Till Tantau +-- +-- This file may be distributed an/or modified +-- +-- 1. under the LaTeX Project Public License and/or +-- 2. under the GNU Public License +-- +-- See the file doc/generic/pgf/licenses/LICENSE for more information + +-- @release $Header: /cvsroot/pgf/pgf/generic/pgf/graphdrawing/lua/pgf/gd/examples/SimpleDemo.lua,v 1.6 2013/12/20 14:44:46 tantau Exp $ + + +--- +-- @section subsubsection {The ``Hello World'' of Graph Drawing} +-- +-- @end + + +-- Inputs +local declare = require "pgf.gd.interface.InterfaceToAlgorithms".declare + +--- + +declare { + key = "simple demo layout", + algorithm = { + run = + function (self) + local g = self.digraph + local alpha = (2 * math.pi) / #g.vertices + + for i,vertex in ipairs(g.vertices) do + local radius = vertex.options['radius'] or g.options['radius'] + vertex.pos.x = radius * math.cos(i * alpha) + vertex.pos.y = radius * math.sin(i * alpha) + end + end + }, + + summary = [[" + This algorithm is the ``Hello World'' of graph drawing. + "]], + documentation = [=[" + The algorithm + arranges nodes in a circle (without paying heed to the sizes of the + nodes or to the edges). In order to ``really'' layout nodes in a + circle, use |simple necklace layout|; the present layout is only intended + to demonstrate how much (or little) is needed to implement a graph + drawing algorithm. +\begin{codeexample}[code only, tikz syntax=false] +-- File pgf.gd.examples.SimpleDemo +local declare = require "pgf.gd.interface.InterfaceToAlgorithms".declare + +declare { + key = "simple demo layout", + algorithm = { + run = + function (self) + local g = self.digraph + local alpha = (2 * math.pi) / #g.vertices + + for i,vertex in ipairs(g.vertices) do + local radius = vertex.options['radius'] or g.options['radius'] + vertex.pos.x = radius * math.cos(i * alpha) + vertex.pos.y = radius * math.sin(i * alpha) + end + end + }, + summary = "This algorithm is the 'Hello World' of graph drawing.", + documentation = [[" + This algorithm arranges nodes in a circle ... + "]] +} +\end{codeexample} + + On the display layer (\tikzname, that is) the algorithm can now + immediately be employed; you just need to say + |\usegdlibrary{examples.SimpleDemo}| at the beginning + somewhere. + "]=] +}
\ No newline at end of file |