Dynamo.Graph.Workspaces.WorkspaceModel.DoGraphAutoLayout C# (CSharp) Method

DoGraphAutoLayout() private method

This function wraps a few methods on the workspace model layer to set up and run the graph layout algorithm.
private DoGraphAutoLayout ( ) : void
return void
        internal void DoGraphAutoLayout()
        {
            if (Nodes.Count() < 2) return;

            var selection = DynamoSelection.Instance.Selection;

            // Check if all the selected models are groups
            bool isGroupLayout = selection.Count > 0 &&
                selection.All(x => x is AnnotationModel ||
                    selection.OfType<AnnotationModel>().Any(g => g.SelectedModels.Contains(x)));

            GenerateCombinedGraph(isGroupLayout);
            RecordUndoGraphLayout(isGroupLayout);

            // Generate subgraphs separately for each cluster
            SubgraphClusters.ForEach(
                x => GenerateSeparateSubgraphs(new HashSet<GraphLayout.Node>(x)));

            // Deselect all nodes
            SubgraphClusters.ForEach(c => c.ForEach(x => x.IsSelected = false));

            // Run layout algorithm for each subgraph
            LayoutSubgraphs.Skip(1).ToList().ForEach(g => RunLayoutSubgraph(g, isGroupLayout));
            AvoidSubgraphOverlap();
            SaveLayoutGraph();

            // Restore the workspace model selection information
            selection.ToList().ForEach(x => x.Select());
        }
WorkspaceModel