From dba6a49587a4c5f22f1172278bcca602456040f6 Mon Sep 17 00:00:00 2001 From: Robert Machmer Date: Sun, 3 Jan 2016 02:31:57 +0100 Subject: [PATCH] Remove name attribute in Node class Seems kind of redundant to have both an id and a name attribute. --- fd/Graph.lua | 8 ++++---- fd/Node.lua | 7 +------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/fd/Graph.lua b/fd/Graph.lua index 83f1426..cd59105 100644 --- a/fd/Graph.lua +++ b/fd/Graph.lua @@ -55,9 +55,9 @@ function Graph.new() for _, node in pairs( table.nodes ) do local rx, ry = math.random( x, w ), math.random( y, h ); if type( node ) == 'string' then - self:addNode( node, nil, rx, ry ); + self:addNode( node, rx, ry ); elseif type( node ) == 'table' then - self:addNode( node.id, node.name, node.x or rx, node.y or ry, node.anchor ); + self:addNode( node.id, node.x or rx, node.y or ry, node.anchor ); end end @@ -72,9 +72,9 @@ function Graph.new() -- @param x - The x-coordinate at which to place the new node. -- @param y - The y-coordinate at which to place the new node. -- - function self:addNode( id, name, x, y, anchor ) + function self:addNode( id, x, y, anchor ) assert( not nodes[id], "Node IDs must be unique." ); - nodes[id] = Node.new( id, name, x, y, anchor ); + nodes[id] = Node.new( id, x, y, anchor ); return nodes[id]; end diff --git a/fd/Node.lua b/fd/Node.lua index 8fa751a..dd7ce0e 100644 --- a/fd/Node.lua +++ b/fd/Node.lua @@ -12,10 +12,9 @@ local DEFAULT_MASS = 0.05; --- -- @param id - A unique id which will be used to reference this node. -- -function Node.new( id, name, x, y, anchor ) +function Node.new( id, x, y, anchor ) local self = {}; - local name = name or id; local px, py = x or 0, y or 0; local ax, ay = 0, 0; local vx, vy = 0, 0; @@ -80,10 +79,6 @@ function Node.new( id, name, x, y, anchor ) return id; end - function self:getName() - return name; - end - function self:getX() return px; end