mirror of
https://github.com/rm-code/Graphoon.git
synced 2024-11-16 18:24:22 +00:00
Remove constructor
This commit is contained in:
parent
7901ac1381
commit
af7f49a2ad
26
fd/Graph.lua
26
fd/Graph.lua
@ -57,32 +57,6 @@ function Graph.new()
|
||||
-- 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.
|
||||
-- @param id - The ID will be used to reference the Node inside of the graph.
|
||||
|
Loading…
Reference in New Issue
Block a user