From 60bbd3010046c56de4255ecd10bda70c951d474d Mon Sep 17 00:00:00 2001
From: Max <m.giller@tu-braunschweig.de>
Date: Wed, 29 Jun 2022 11:55:25 +0200
Subject: [PATCH] Fixed exception when trying to parse empty graph

---
 src/editor/js/structures/graph/graph.ts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/editor/js/structures/graph/graph.ts b/src/editor/js/structures/graph/graph.ts
index b9edda1..566589a 100644
--- a/src/editor/js/structures/graph/graph.ts
+++ b/src/editor/js/structures/graph/graph.ts
@@ -304,9 +304,9 @@ export class Graph extends ManagedData {
             // No need to replace node ids with proper node objects, since that should be done in the graph itself. Only have to prepare valid GraphData
         });
 
-        // Collect all node types and give id of none given yet
+        // Collect all node types and give id if none given yet
         let typeId: number = undefined;
-        if (data.nodes[0].type.id === undefined) {
+        if (data.nodes.length > 0 && data.nodes[0].type.id === undefined) {
             typeId = 0;
         }
 
-- 
GitLab