Remove constructor

This commit is contained in:
Robert Machmer 2016-01-09 05:08:32 +01:00
parent 7901ac1381
commit af7f49a2ad

View File

@ -57,32 +57,6 @@ function Graph.new()
-- Public Functions -- Public Functions
-- ------------------------------------------------ -- ------------------------------------------------
---
-- Creates a new graph based on the information passed via the table
-- parameter. It creates all nodes and connects them via edges.
-- @param table - A table containing information about nodes and edges.
-- @param x - The minimum x value to use when randomly spawning nodes.
-- @param y - The minimum y value to use when randomly spawning nodes.
-- @param w - The maximum x value to use when randomly spawning nodes.
-- @param h - The maximum y value to use when randomly spawning nodes.
--
function self:create( table, x, y, w, h )
math.randomseed( os.time() );
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, rx, ry );
elseif type( node ) == 'table' then
self:addNode( node.id, node.x or rx, node.y or ry, node.anchor );
end
end
for _, edge in pairs( table.edges ) do
addEdge( nodes[edge.origin], nodes[edge.target] );
end
end
--- ---
-- Add a node to the graph. -- Add a node to the graph.
-- @param id - The ID will be used to reference the Node inside of the graph. -- @param id - The ID will be used to reference the Node inside of the graph.