From 0feff6c97003ad7f5b1e240b96308b47d1ae8041 Mon Sep 17 00:00:00 2001 From: Robert Machmer Date: Tue, 12 Jan 2016 01:57:23 +0100 Subject: [PATCH] Check if target nodes exist when an edge is added --- fd/Graph.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fd/Graph.lua b/fd/Graph.lua index 6ac7fa6..7e5b46c 100644 --- a/fd/Graph.lua +++ b/fd/Graph.lua @@ -96,6 +96,8 @@ function Graph.new() -- @param target - The node id to which the edge is pointing to. -- 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] ); end