コード例 #1
0
        private void UpdateAnalysis()
        {
            if (_graphExtractor != null && _tileModelManager != null)
            {
                if (_tileModelManager.Status == CollapseStatus.Complete)
                {
                    _graphExtractor.ExtractSharedEdgeGraph(_analysisGraph);

                    //Extracted Graph | Analysis

                    GetClosures();

                    CollectStructureInformation();

                    //normalized/remapped components to an array for graph coloring
                    _normalizedcomponents       = _graphProcessing.RemapComponentsToArray(_analysisGraph.Graph, _connectedComponents);
                    _normalizedcomponentsbysize = _graphProcessing.RemapComponentsSizeToArray(_analysisGraph.Graph, _connectedComponents);


                    //analyze/get 1) ground support sources, 2) list of vertex depths 3) max depth
                    _sources  = _graphProcessing.GetGroundSources(_analysisGraph.Graph, _analysisGraph.Vertices, 2f);
                    _depths   = _graphProcessing.DepthsFromGroundSources(_analysisGraph.Graph, _analysisGraph.Vertices, 2f);
                    _maxDepth = _graphProcessing.MaxDepth(_depths);

                    //analyze/get 1) unreachable vertices, 2) remapped vertex depths between 0,1, 3) edgeless vertices
                    _normalizeddepths    = new float[_analysisGraph.Graph.VertexCount];
                    _unreachablevertices = new List <int>();
                    _edgelessvertices    = new List <int>();
                    _graphProcessing.RemapGraphDepths(_analysisGraph.Graph, _depths, 0, 1, out _normalizeddepths, out _unreachablevertices, out _edgelessvertices);

                    StoreAnalysis();
                    DebugResults();
                }
            }
            else
            {
                Debug.Log("No Graph Extractor OR WFC Incomplete");
            }
        }
コード例 #2
0
ファイル: GraphAnalysisManager.cs プロジェクト: peljevic/July
        private void UpdateAnalysis()
        {

            if (_graphExtractor != null && _tileModelManager != null)
            {
                if (_tileModelManager.Status == CollapseStatus.Complete)
                {
                    _graphExtractor.ExtractSharedEdgeGraph(_analysisGraph);

                    //Extracted Graph | Analysis
                    //analyze/get # of closures / strongly connected components
                    int closurecount = 0;
                    int componentcount = 0;
                    List<HashSet<int>> connectedComponents = new List<HashSet<int>>();
                    _graphprocessing.CountClosures(_analysisGraph.Graph, out componentcount, out closurecount, out connectedComponents);
                    float closureRate = (float)closurecount / (float)_analysisGraph.Graph.EdgeCount;

                    Debug.Log($"GRAPH ANALYSIS MANAGER | CONNECTED COMPONENTS COUNT {connectedComponents.Count}");


                    //normalized/remapped components to an array for graph coloring
                    float[] normalizedcomponents = _graphprocessing.RemapComponentsToArray(_analysisGraph.Graph, connectedComponents);
                    float[] normalizedcomponentsbysize = _graphprocessing.RemapComponentsSizeToArray(_analysisGraph.Graph, connectedComponents);

                    //analyze/get 1) ground support sources, 2) list of vertex depths 3) max depth 
                    List<int> sources = _graphprocessing.GetGroundSources(_analysisGraph.Graph, _analysisGraph.Vertices, 2f);
                    int[] depths = _graphprocessing.DepthsFromGroundSources(_analysisGraph.Graph, _analysisGraph.Vertices, 2f);
                    int maxdepth = _graphprocessing.MaxDepth(depths);

                    //analyze/get 1) unreachable vertices, 2) remapped vertex depths between 0,1, 3) edgeless vertices
                    float[] normalizeddepths = new float[_analysisGraph.Graph.VertexCount];
                    List<int> unreachablevertices = new List<int>();
                    List<int> edgelessvertices = new List<int>();
                    _graphprocessing.RemapGraphDepths(_analysisGraph.Graph, depths, 0, 1, out normalizeddepths, out unreachablevertices, out edgelessvertices);

                    //store analysis in the shared analysis graph scriptable object - VIEW THIS DATA ON A UI CANVAS
                    _analysisGraph.ClosuresCount = closurecount;
                    _analysisGraph.ConnectedComponents = connectedComponents;
                    _analysisGraph.NormalizedComponents = normalizedcomponents;
                    _analysisGraph.NormalizedComponentsBySize = normalizedcomponentsbysize;
                    _analysisGraph.ConnectedComponentsCount = componentcount;
                    _analysisGraph.Sources = sources;
                    _analysisGraph.Depths = depths;
                    _analysisGraph.NormalizedDepths = normalizeddepths;
                    _analysisGraph.MaxDepth = maxdepth;
                    _analysisGraph.UnreachableVertices = unreachablevertices;
                    _analysisGraph.EdgelessVertices = edgelessvertices;

                    //Extracted Graph | Debug Print Results
                    Debug.Log("Exracted Graph | ComponentsCount = " + _analysisGraph.ConnectedComponentsCount);
                    for (int i = 0; i < connectedComponents.Count; i++)
                    {
                        HashSet<int> set = connectedComponents[i];
                        string setstring = string.Join(",", connectedComponents[i]);
                        Debug.Log("Exracted Graph | ConnectedComponent# " + (i + 1) + " = " + setstring);
                    }

                    string normalizedcomponentsstring = string.Join(",", _analysisGraph.NormalizedComponents);
                    string normalizedcomponentsbysizestring = string.Join(",", _analysisGraph.NormalizedComponentsBySize);

                    Debug.Log("Exracted Graph | NormalizedComponents = " + normalizedcomponentsstring);
                    Debug.Log("Exracted Graph | NormalizedComponentsBySize = " + normalizedcomponentsbysizestring);

                    Debug.Log("Exracted Graph | Closures Count = " + _analysisGraph.ClosuresCount);
                    Debug.Log("Exracted Graph | Closures Rate = " + _analysisGraph.ClosureRate);

                    string sourcesstring = string.Join(",", _analysisGraph.Sources);
                    string depthsstring = string.Join(",", _analysisGraph.Depths);
                    Debug.Log("Exracted Graph | Depths = " + depthsstring);
                    Debug.Log("Exracted Graph | Max Depth = " + _analysisGraph.MaxDepth);
                    Debug.Log("Exracted Graph | SourcesCount = " + _analysisGraph.SourcesCount);
                    Debug.Log("Exracted Graph | Sources = " + sourcesstring);

                    string normalizeddepthsstring = string.Join(",", _analysisGraph.NormalizedDepths);
                    string unreachablevrtsstring = string.Join(",", _analysisGraph.UnreachableVertices);
                    string edgelessvrtsstring = string.Join(",", _analysisGraph.EdgelessVertices);

                    Debug.Log("Exracted Graph | Normalized Depths = " + normalizeddepthsstring);
                    Debug.Log("Exracted Graph | Unreachable Vertices Count = " + _analysisGraph.UnreachableVerticesCount);
                    Debug.Log("Exracted Graph | Unreachable Vertices = " + unreachablevrtsstring);
                    Debug.Log("Exracted Graph | Edgeless Vertices Count = " + _analysisGraph.EdgelessVerticesCount);
                    Debug.Log("Exracted Graph | Edgeless Vertices = " + edgelessvrtsstring);

                }
            }
            else
            {
                Debug.Log("No Graph Extractor OR WFC Incomplete");
            }
        }