Fix logic in graph-creation error-checking