summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalWalshaw2000.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalWalshaw2000.lua')
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/force/SpringElectricalWalshaw2000.lua14
1 files changed, 9 insertions, 5 deletions
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