Esempio n. 1
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);
        }
 /// <inheritdoc/>
 protected internal override int GetVertexCount()
 {
     return(refinable.GetVertexCount());
 }