Check if target nodes exist when an edge is added

This commit is contained in:
Robert Machmer 2016-01-12 01:57:23 +01:00
parent 6c0bd6b50a
commit 0feff6c970

View File

@ -96,6 +96,8 @@ function Graph.new()
-- @param target - The node id to which the edge is pointing to. -- @param target - The node id to which the edge is pointing to.
-- --
function self:connectIDs( originID, targetID ) function self:connectIDs( originID, targetID )
assert( nodes[originID], string.format( "Tried to add an Edge to the nonexistent Node \"%s\".", originID ));
assert( nodes[targetID], string.format( "Tried to add an Edge to the nonexistent Node \"%s\".", targetID ));
addEdge( nodes[originID], nodes[targetID] ); addEdge( nodes[originID], nodes[targetID] );
end end