Skip to content

Commit 0feff6c

Browse files
committed
Check if target nodes exist when an edge is added
1 parent 6c0bd6b commit 0feff6c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fd/Graph.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ function Graph.new()
9696
-- @param target - The node id to which the edge is pointing to.
9797
--
9898
function self:connectIDs( originID, targetID )
99+
assert( nodes[originID], string.format( "Tried to add an Edge to the nonexistent Node \"%s\".", originID ));
100+
assert( nodes[targetID], string.format( "Tried to add an Edge to the nonexistent Node \"%s\".", targetID ));
99101
addEdge( nodes[originID], nodes[targetID] );
100102
end
101103

0 commit comments

Comments
 (0)