static void DeleteElementsFromGraph(State previousState, IReadOnlyCollection <IGraphElementModel> elementsToRemove, GraphModel graphModel)
        {
            IGraphElementModel[] deletables = elementsToRemove.Where(x => (x.Capabilities & CapabilityFlags.Deletable) != 0).Distinct().ToArray();

            var vsGraphModel = (VSGraphModel)graphModel;

            IStickyNoteModel[] stickyNotesToDelete         = GetStickyNotesToDelete(deletables);
            IReadOnlyCollection <INodeModel> nodesToDelete = GetNodesToDelete(vsGraphModel, deletables);
            IReadOnlyCollection <IEdgeModel> edgesToDelete = GetEdgesToDelete(graphModel, deletables, nodesToDelete);

            VariableDeclarationModel[] declarationModelsToDelete = GetDeclarationModelsToDelete(deletables, nodesToDelete);

            if (declarationModelsToDelete.Any())
            {
                previousState.MarkForUpdate(UpdateFlags.RequestRebuild);
            }
            if (IsReferenceDatabaseDirty(nodesToDelete))
            {
                graphModel.Stencil.GetSearcherDatabaseProvider().ClearReferenceItemsSearcherDatabases();
            }
            AnalyticsHelper.Instance.FlushNodeCreationEvent(NodeCreationEvent.UndoOrDelete, nodesToDelete.Select(n => n.Guid));
            graphModel.DeleteStickyNotes(stickyNotesToDelete);
            graphModel.DeleteEdges(edgesToDelete);
            graphModel.DeleteNodes(nodesToDelete, GraphModel.DeleteConnections.False);
            vsGraphModel.DeleteVariableDeclarations(declarationModelsToDelete, false);
        }
        static void DeleteElementsFromGraph(State previousState, IReadOnlyCollection <IGTFGraphElementModel> elementsToRemove, GraphModel graphModel)
        {
            IGTFGraphElementModel[] deletables = elementsToRemove.Where(x => x is IDeletable).Distinct().ToArray();

            var vsGraphModel = (VSGraphModel)graphModel;

            IStickyNoteModel[] stickyNotesToDelete         = GetStickyNotesToDelete(deletables);
            IPlacematModel[]   placematsToDelete           = GetPlacematsToDelete(deletables);
            IReadOnlyCollection <INodeModel> nodesToDelete = GetNodesToDelete(vsGraphModel, deletables);
            IReadOnlyCollection <IEdgeModel> edgesToDelete = GetEdgesToDelete(graphModel, deletables, nodesToDelete);

            VariableDeclarationModel[] declarationModelsToDelete = GetDeclarationModelsToDelete(deletables, nodesToDelete);

            if (declarationModelsToDelete.Any())
            {
                previousState.MarkForUpdate(UpdateFlags.RequestRebuild);
            }

            graphModel.DeleteStickyNotes(stickyNotesToDelete);
            graphModel.DeletePlacemats(placematsToDelete);
            graphModel.DeleteEdges(edgesToDelete);
            graphModel.DeleteNodes(nodesToDelete, GraphModel.DeleteConnections.False);
            vsGraphModel.DeleteVariableDeclarations(declarationModelsToDelete, false);
        }