/// <summary> /// This will clean the graph (before loading a new graph for example /// </summary> private void ClearGraph() { if (Nodes == null || Nodes.Count <= 0 || _containerCache.NodeLinks.Count <= 0) { return; } //Set entry points guid back from the save. Discard existing guid. Nodes.Find(match: x => x.EntryPoint).GUID = _containerCache.NodeLinks[0].BaseNodeGuid; foreach (var node in Nodes) { //Remove edges that connected to this node if (node.EntryPoint) { continue; } Edges.Where(x => x.input.node == node).ToList() .ForEach(edge => _targetGraphView.RemoveElement(edge)); //Then remove the node _targetGraphView.RemoveElement(node); } }