public static Structuring Clone(Structuring s)
        {
            ReductionPartition           _rp          = s as ReductionPartition;
            Partition                    _p           = s as Partition;
            Dictionary <string, Cluster> dic_clusters = new Dictionary <string, Cluster>();

            foreach (var item in s.Clusters.Values)
            {
                dic_clusters.Add(item.Name, new Cluster(item.Name, new List <Element>(item.Elements)));
            }

            List <Element> temp = s.UnassignedElements == null ? new List <Element>() : s.UnassignedElements;

            if (_p != null)
            {
                return new Partition()
                       {
                           Clusters = dic_clusters, UnassignedElements = new List <Element>(temp)
                       }
            }
            ;
            else if (_rp != null)
            {
                return(new ReductionPartition(_rp.Partition, _rp.NewSet, _rp.Map));
            }
            else
            {
                throw new Exception("Super mal, revisalo");
            }
        }
Exemplo n.º 2
0
        public ReductionPartition(Structuring aPartition, Set anewSet, Dictionary <string, List <object> > aMap)
        {
            this.Partition = aPartition;
            this.Map       = aMap;
            this.NewSet    = anewSet;

            Dictionary <Element, List <string> > _dic = new Dictionary <Element, List <string> >();

            for (int i = 0; i < anewSet.ElementsCount; i++)
            {
                Element       _newElement  = anewSet[i];
                List <string> _lisClusters = new List <string>();
                GetCluster(_newElement).ForEach(c => _lisClusters.Add(c.Name));

                _dic.Add(_newElement, _lisClusters);
            }
            Elements = _dic;
        }