void Start()
        {
            EdgeGraph      testgraph       = new EdgeGraph(15);
            ProcessingUtil graphprocessing = new ProcessingUtil();

            for (int i = 0; i < 20; i++)
            {
                testgraph.AddVertex();
            }

            //TestGraph | Build graph
            //first connected component set of edges
            testgraph.AddEdge(1, 2);
            testgraph.AddEdge(2, 3);
            testgraph.AddEdge(3, 1);
            testgraph.AddEdge(3, 5);
            testgraph.AddEdge(5, 6);
            testgraph.AddEdge(6, 4);
            testgraph.AddEdge(4, 5);
            testgraph.AddEdge(7, 6);
            testgraph.AddEdge(3, 8);
            testgraph.AddEdge(8, 1);
            testgraph.AddEdge(6, 9);
            testgraph.AddEdge(9, 4);
            testgraph.AddEdge(8, 10);
            testgraph.AddEdge(10, 11);
            testgraph.AddEdge(11, 12);
            testgraph.AddEdge(12, 10);

            //second component (not connected to first)
            testgraph.AddEdge(15, 18);
            testgraph.AddEdge(18, 19);
            testgraph.AddEdge(17, 18);

            //TestGraph | Analysis
            int componentcount = 0;
            int closurecount   = 0;
            List <HashSet <int> > components = new List <HashSet <int> >();

            _graphprocessing.CountClosures(testgraph, out componentcount, out closurecount, out components);
            float closurerate = (float)closurecount / (float)testgraph.EdgeCount;

            //TestGraph | Debug Print Results
            Debug.Log("TestGraph | Components Count = " + componentcount);
            for (int i = 0; i < components.Count; i++)
            {
                HashSet <int> set       = components[i];
                string        setstring = string.Join(",", components[i]);
                Debug.Log("TestGraph | ConnectedComponent# " + (i + 1) + " = " + setstring);
            }

            float[] normalizedcomponents       = _graphprocessing.RemapComponentsToArray(testgraph, components);
            string  normalizedcomponentsstring = string.Join(",", normalizedcomponents);

            Debug.Log("TestGraph | NormalizedComponents = " + normalizedcomponentsstring);

            Debug.Log("TestGraph | Closures Count = " + closurecount);
            Debug.Log("TestGraph | Closures Rate = " + closurerate);
        }
Ejemplo n.º 2
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");
            }
        }