summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force')
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/CoarseGraph.lua2
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/Control.lua28
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlCoarsening.lua2
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlDeclare.lua41
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlElectric.lua2
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlIteration.lua2
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlSprings.lua2
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlStart.lua2
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/QuadTree.lua2
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalHu2006.lua16
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalLayouts.lua2
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalWalshaw2000.lua14
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringHu2006.lua9
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringLayouts.lua2
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/library.lua4
15 files changed, 75 insertions, 55 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/CoarseGraph.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/CoarseGraph.lua
index c9739dcaf63..6cd46c60eb2 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/CoarseGraph.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/CoarseGraph.lua
@@ -8,7 +8,7 @@
--
-- See the file doc/generic/pgf/licenses/LICENSE for more information
--- @release $Header: /cvsroot/pgf/pgf/generic/pgf/graphdrawing/lua/pgf/gd/force/CoarseGraph.lua,v 1.1 2012/11/27 17:24:25 tantau Exp $
+-- @release $Header$
--- A class for handling "coarse" versions of a graph. Such versions contain
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/Control.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/Control.lua
deleted file mode 100644
index 113f54b7ace..00000000000
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/Control.lua
+++ /dev/null
@@ -1,28 +0,0 @@
--- 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/force/Control.lua,v 1.3 2013/05/23 20:01:27 tantau Exp $
-
-
--- Imports
-local declare = require("pgf.gd.interface.InterfaceToAlgorithms").declare
-
-
----
--- @section subsection {Controlling and Configuring Force-Based Algorithms}
---
--- All force-based algorithms are based on
--- a general pattern which we detail in the following. Numerous options
--- can be used to influence the behaviour of this general pattern; more
--- specific options that apply only to individual algorithms are
--- explained along with these algorithms.
---
--- @end
-
-
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlCoarsening.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlCoarsening.lua
index 330f401d5b5..17cd121b85e 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlCoarsening.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlCoarsening.lua
@@ -7,7 +7,7 @@
--
-- See the file doc/generic/pgf/licenses/LICENSE for more information
--- @release $Header: /cvsroot/pgf/pgf/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlCoarsening.lua,v 1.3 2013/05/23 20:01:27 tantau Exp $
+-- @release $Header$
-- Imports
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlDeclare.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlDeclare.lua
new file mode 100644
index 00000000000..6d80fff6aa6
--- /dev/null
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlDeclare.lua
@@ -0,0 +1,41 @@
+-- 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$
+
+
+-- Imports
+local declare = require("pgf.gd.interface.InterfaceToAlgorithms").declare
+
+
+---
+-- @section subsection {Controlling and Configuring Force-Based Algorithms}
+--
+-- All force-based algorithms are based on
+-- a general pattern which we detail in the following. Numerous options
+-- can be used to influence the behaviour of this general pattern; more
+-- specific options that apply only to individual algorithms are
+-- explained along with these algorithms.
+--
+-- The vertices are initially laid out in a random configuration.
+-- Then the configuration is annealed to find a configuration of
+-- minimal energy. To avoid getting stuck in a local minimum or at a
+-- saddle point, random forces are added. All of this makes the final
+-- layout extremely susceptible to changes in the random numbers. To
+-- achieve a certain stability of the results, you should fix the
+-- random seed. However, in the recent past Lua has switched its
+-- random number generator, which means that you won't get the same
+-- sequence of random numbers as in a previous version, even for
+-- identical seed. If you rely on the long-term stability of vertex
+-- placement, you should consider using a different layout. With the
+-- spring layout you have to assume that the layout will be random.
+--
+-- @end
+
+
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlElectric.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlElectric.lua
index d708bd6d7b7..7bd118d7b85 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlElectric.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlElectric.lua
@@ -7,7 +7,7 @@
--
-- See the file doc/generic/pgf/licenses/LICENSE for more information
--- @release $Header: /cvsroot/pgf/pgf/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlElectric.lua,v 1.3 2013/05/23 20:01:27 tantau Exp $
+-- @release $Header$
-- Imports
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlIteration.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlIteration.lua
index f07f23aeac3..b845d9d1f89 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlIteration.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlIteration.lua
@@ -7,7 +7,7 @@
--
-- See the file doc/generic/pgf/licenses/LICENSE for more information
--- @release $Header: /cvsroot/pgf/pgf/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlIteration.lua,v 1.3 2013/05/23 20:01:27 tantau Exp $
+-- @release $Header$
-- Imports
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlSprings.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlSprings.lua
index 2ef55169bca..9252f7b1cb8 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlSprings.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlSprings.lua
@@ -7,7 +7,7 @@
--
-- See the file doc/generic/pgf/licenses/LICENSE for more information
--- @release $Header: /cvsroot/pgf/pgf/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlSprings.lua,v 1.3 2013/05/23 20:01:27 tantau Exp $
+-- @release $Header$
-- Imports
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlStart.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlStart.lua
index 6b93f311290..b62be10c0a5 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlStart.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlStart.lua
@@ -7,7 +7,7 @@
--
-- See the file doc/generic/pgf/licenses/LICENSE for more information
--- @release $Header: /cvsroot/pgf/pgf/generic/pgf/graphdrawing/lua/pgf/gd/force/ControlStart.lua,v 1.3 2013/05/23 20:01:27 tantau Exp $
+-- @release $Header$
-- Imports
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/QuadTree.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/QuadTree.lua
index 1a7d0abf25a..4e511746bb2 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/QuadTree.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/QuadTree.lua
@@ -8,7 +8,7 @@
--
-- See the file doc/generic/pgf/licenses/LICENSE for more information
--- @release $Header: /cvsroot/pgf/pgf/generic/pgf/graphdrawing/lua/pgf/gd/force/QuadTree.lua,v 1.1 2012/11/27 17:24:25 tantau Exp $
+-- @release $Header$
--- An implementation of a quad trees.
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalHu2006.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalHu2006.lua
index 54ceddcc25a..9fa709a8053 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalHu2006.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalHu2006.lua
@@ -7,7 +7,7 @@
--
-- See the file doc/generic/pgf/licenses/LICENSE for more information
--- @release $Header: /cvsroot/pgf/pgf/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalHu2006.lua,v 1.1 2012/11/27 17:24:25 tantau Exp $
+-- @release $Header$
local SpringElectricalHu2006 = {}
@@ -97,7 +97,11 @@ function SpringElectricalHu2006:run()
-- initialize node weights
for _,node in ipairs(self.graph.nodes) do
- node.weight = node:getOption('electric charge')
+ if node:getOption('electric charge') ~= nil then
+ node.weight = node:getOption('electric charge')
+ else
+ node.weight = 1
+ end
end
-- initialize edge weights
@@ -171,7 +175,7 @@ function SpringElectricalHu2006:run()
-- set the spring length to the average edge length of the initial layout
spring_length = 0
- for _,e in ipairs(coarse_graph.graph.edges) do
+ for _,edge in ipairs(coarse_graph.graph.edges) do
spring_length = spring_length + edge.nodes[1].pos:minus(edge.nodes[2].pos):norm()
end
spring_length = spring_length / #coarse_graph.graph.edges
@@ -205,7 +209,7 @@ function SpringElectricalHu2006:computeInitialLayout(graph, spring_length)
-- position the loose node relative to the fixed node, with
-- the displacement (random direction) matching the spring length
- local direction = Vector.new{x = math.random(1, spring_length), y = math.random(1, spring_length)}
+ local direction = Vector.new{x = lib.random(1, spring_length), y = lib.random(1, spring_length)}
local distance = 3 * spring_length * self.graph_density * math.sqrt(self.graph_size) / 2
local displacement = direction:normalized():timesScalar(distance)
@@ -218,7 +222,7 @@ function SpringElectricalHu2006:computeInitialLayout(graph, spring_length)
-- use a random positioning technique
local function positioning_func(n)
local radius = 3 * spring_length * self.graph_density * math.sqrt(self.graph_size) / 2
- return math.random(-radius, radius)
+ return lib.random(-radius, radius)
end
-- compute initial layout based on the random positioning technique
@@ -518,4 +522,4 @@ end
-- done
-return SpringElectricalHu2006 \ No newline at end of file
+return SpringElectricalHu2006
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalLayouts.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalLayouts.lua
index f8854e71618..df7dc70a745 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalLayouts.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalLayouts.lua
@@ -7,7 +7,7 @@
--
-- See the file doc/generic/pgf/licenses/LICENSE for more information
--- @release $Header: /cvsroot/pgf/pgf/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalLayouts.lua,v 1.4 2013/05/23 20:01:27 tantau Exp $
+-- @release $Header$
-- Imports
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalWalshaw2000.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalWalshaw2000.lua
index 25782bc9c3c..02fd09a72d9 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalWalshaw2000.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalWalshaw2000.lua
@@ -8,7 +8,7 @@
--
-- See the file doc/generic/pgf/licenses/LICENSE for more information
--- @release $Header: /cvsroot/pgf/pgf/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalWalshaw2000.lua,v 1.1 2012/11/27 17:24:25 tantau Exp $
+-- @release $Header$
@@ -127,7 +127,11 @@ function SpringElectricalWalshaw2000:run()
-- initialize node weights
for _,node in ipairs(self.graph.nodes) do
- node.weight = node:getOption('electric charge')
+ if node:getOption('electric charge') ~= nil then
+ node.weight = node:getOption('electric charge')
+ else
+ node.weight = 1
+ end
-- a node is charged if its weight derives from the default setting
-- of 1 (where it has no influence on the forces)
@@ -212,7 +216,7 @@ function SpringElectricalWalshaw2000:computeInitialLayout(graph, spring_length)
-- position the loose node relative to the fixed node, with
-- the displacement (random direction) matching the spring length
- local direction = Vector.new{x = math.random(1, 2), y = math.random(1, 2)}
+ local direction = Vector.new{x = lib.random(1, 2), y = lib.random(1, 2)}
local distance = 3 * spring_length * self.graph_density * math.sqrt(self.graph_size) / 2
local displacement = direction:normalized():timesScalar(distance)
@@ -227,7 +231,7 @@ function SpringElectricalWalshaw2000:computeInitialLayout(graph, spring_length)
-- use the random positioning technique
local function positioning_func(n)
local radius = 3 * spring_length * self.graph_density * math.sqrt(self.graph_size) / 2
- return math.random(-radius, radius)
+ return lib.random(-radius, radius)
end
-- compute initial layout based on the random positioning technique
@@ -513,4 +517,4 @@ end
-- done
-return SpringElectricalWalshaw2000 \ No newline at end of file
+return SpringElectricalWalshaw2000
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringHu2006.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringHu2006.lua
index 35dc21008fb..b53bc9bff98 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringHu2006.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringHu2006.lua
@@ -8,7 +8,7 @@
--
-- See the file doc/generic/pgf/licenses/LICENSE for more information
--- @release $Header: /cvsroot/pgf/pgf/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringHu2006.lua,v 1.1 2012/11/27 17:24:25 tantau Exp $
+-- @release $Header$
@@ -64,7 +64,6 @@ local lib = require("pgf.gd.lib")
-
function SpringHu2006:run()
-- Setup some parameters
@@ -214,7 +213,7 @@ function SpringHu2006:computeInitialLayout(graph, spring_length)
-- position the loose node relative to the fixed node, with
-- the displacement (random direction) matching the spring length
- local direction = Vector.new{x = math.random(1, spring_length), y = math.random(1, spring_length)}
+ local direction = Vector.new{x = lib.random(1, spring_length), y = lib.random(1, spring_length)}
local distance = 1.8 * spring_length * self.graph_density * math.sqrt(self.graph_size) / 2
local displacement = direction:normalized():timesScalar(distance)
@@ -226,7 +225,7 @@ function SpringHu2006:computeInitialLayout(graph, spring_length)
-- use a random positioning technique
local function positioning_func(n)
local radius = 2 * spring_length * self.graph_density * math.sqrt(self.graph_size) / 2
- return math.random(-radius, radius)
+ return lib.random(-radius, radius)
end
-- compute initial layout based on the random positioning technique
@@ -384,4 +383,4 @@ end
-- done
-return SpringHu2006 \ No newline at end of file
+return SpringHu2006
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringLayouts.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringLayouts.lua
index ab0126d7fcd..5554410816e 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringLayouts.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringLayouts.lua
@@ -7,7 +7,7 @@
--
-- See the file doc/generic/pgf/licenses/LICENSE for more information
--- @release $Header: /cvsroot/pgf/pgf/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringLayouts.lua,v 1.4 2013/05/23 20:01:27 tantau Exp $
+-- @release $Header$
-- Imports
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/library.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/library.lua
index af3a1a62c27..be0faf465c1 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/library.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/library.lua
@@ -7,7 +7,7 @@
--
-- See the file doc/generic/pgf/licenses/LICENSE for more information
--- @release $Header: /cvsroot/pgf/pgf/generic/pgf/graphdrawing/lua/pgf/gd/force/library.lua,v 1.4 2013/05/23 20:01:27 tantau Exp $
+-- @release $Header$
@@ -109,7 +109,7 @@
local force -- Library name
-- Load declarations from:
-require "pgf.gd.force.Control"
+require "pgf.gd.force.ControlDeclare"
require "pgf.gd.force.ControlStart"
require "pgf.gd.force.ControlIteration"
require "pgf.gd.force.ControlSprings"