Esempio n. 1
0
        public void IsDiscreteCellTest()
        {
            int[][]   cellData = new int[][] { new[] { 0 }, new[] { 1 }, new[] { 2 }, new[] { 3 }, new[] { 4 }, new[] { 5 } };
            Partition p        = new Partition(cellData);

            for (int i = 0; i < p.Count; i++)
            {
                Assert.IsTrue(p.IsDiscreteCell(i));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Refines the coarse partition "a" into a finer one.
        /// </summary>
        /// <param name="coarser">the partition to refine</param>
        /// <returns>a finer partition</returns>
        public Partition Refine(Partition coarser)
        {
            var finer = new Partition(coarser);

            // start the queue with the blocks of a in reverse order
            blocksToRefine = new Queue <SortedSet <int> >();
            for (int i = 0; i < finer.Count; i++)
            {
                blocksToRefine.Enqueue(finer.CopyBlock(i));
            }

            var numberOfVertices = refinable.GetVertexCount();

            while (blocksToRefine.Any())
            {
                var t = blocksToRefine.Dequeue();
                currentBlockIndex = 0;
                while (currentBlockIndex < finer.Count && finer.Count < numberOfVertices)
                {
                    if (!finer.IsDiscreteCell(currentBlockIndex))
                    {
                        // get the neighbor invariants for this block
                        var invariants = GetInvariants(finer, t);

                        // split the block on the basis of these invariants
                        Split(invariants, finer);
                    }
                    currentBlockIndex++;
                }

                // the partition is discrete
                if (finer.Count == numberOfVertices)
                {
                    return(finer);
                }
            }
            return(finer);
        }