protected override SortedDictionary<UInt32, Double> CalculateCycles3Trajectory()
        {
            // Retrieving research parameters from network. //
            // TODO without parce
            if(network.ResearchParameterValues == null)
                throw new CoreException("Research parameters are not set.");
            UInt32 stepCount = UInt32.Parse(network.ResearchParameterValues[ResearchParameter.EvolutionStepCount].ToString());
            Single nu = Single.Parse(network.ResearchParameterValues[ResearchParameter.Nu].ToString());
            bool permanentDistribution = Boolean.Parse(network.ResearchParameterValues[ResearchParameter.PermanentDistribution].ToString());
            object v = network.ResearchParameterValues[ResearchParameter.TracingStepIncrement];
            UInt16 tracingStepIncrement = ((v != null) ? UInt16.Parse(v.ToString()) : (ushort)0);

            // keep initial container
            NonHierarchicContainer initialContainer = container.Clone();

            SortedDictionary<UInt32, double> trajectory = new SortedDictionary<UInt32, double>();
            uint currentStep = 0;
            uint currentTracingStep = tracingStepIncrement;
            double currentCycle3Count = CalculateCycles3();
            trajectory.Add(currentStep, currentCycle3Count);

            NonHierarchicContainer previousContainer = new NonHierarchicContainer();
            RNGCrypto rand = new RNGCrypto();
            while (currentStep != stepCount)
            {
                previousContainer = container.Clone();
                try
                {
                    ++currentStep;

                    long deltaCount = permanentDistribution ?
                        container.PermanentRandomization() :
                        container.NonPermanentRandomization();
                    double newCycle3Count = currentCycle3Count + deltaCount;

                    int delta = (int)(newCycle3Count - currentCycle3Count);
                    if (delta > 0)
                    {
                        // accept
                        trajectory.Add(currentStep, newCycle3Count);
                        currentCycle3Count = newCycle3Count;
                    }
                    else
                    {
                        double probability = Math.Exp((-nu * Math.Abs(delta)));
                        if (rand.NextDouble() < probability)
                        {
                            // accept
                            trajectory.Add(currentStep, newCycle3Count);
                            currentCycle3Count = newCycle3Count;
                        }
                        else
                        {
                            // reject
                            trajectory.Add(currentStep, currentCycle3Count);
                            container = previousContainer;
                        }
                    }

                    if (currentTracingStep == currentStep - 1)
                    {
                        container.Trace(network.ResearchName,
                            "Realization_" + network.NetworkID.ToString(),
                            "Matrix_" + currentTracingStep.ToString());
                        currentTracingStep += tracingStepIncrement;
                    }
                }
                catch (Exception ex)
                {
                    container = initialContainer;
                    //log.Error(String.Format("Error occurred in step {0} ,Error message {1} ", currentStep, ex.InnerException));
                }
            }

            container = initialContainer;
            return trajectory;
        }
        public int NonPermanentRandomization()
        {
            RNGCrypto rand = new RNGCrypto();

            int edgeToRemove = rand.Next(0, existingEdges.Count - 1);
            int rvertex1 = existingEdges[edgeToRemove].Key;
            int rvertex2 = existingEdges[edgeToRemove].Value;

            int edgeToAdd = rand.Next(0, nonExistingEdges.Count - 1);
            int avertex1 = nonExistingEdges[edgeToAdd].Key;
            int avertex2 = nonExistingEdges[edgeToAdd].Value;

            RemoveConnection(rvertex1, rvertex2);
            // Calculate removed cycles count
            int removedCyclesCount = Cycles3ByVertices(rvertex1, rvertex2);

            AddConnection(avertex1, avertex2);
            // Calculate removed cycles count
            int addedCyclesCount = Cycles3ByVertices(avertex1, avertex2);

            return addedCyclesCount - removedCyclesCount;
        }
        public int PermanentRandomization()
        {
            RNGCrypto rand = new RNGCrypto();

            int e1 = rand.Next(0, existingEdges.Count - 1);
            int e2 = rand.Next(0, existingEdges.Count - 1);

            while (e1 == e2 ||
                existingEdges[e1].Key == existingEdges[e2].Key ||
                existingEdges[e1].Value == existingEdges[e2].Value ||
                existingEdges[e1].Key == existingEdges[e2].Value ||
                existingEdges[e1].Value == existingEdges[e2].Key ||
                AreConnected(existingEdges[e1].Key, existingEdges[e2].Key) ||
                AreConnected(existingEdges[e1].Value, existingEdges[e2].Value))
            {
                e1 = rand.Next(0, existingEdges.Count - 1);
                e2 = rand.Next(0, existingEdges.Count - 1);
            }

            int vertex1 = existingEdges[e1].Key, vertex2 = existingEdges[e1].Value;
            int vertex3 = existingEdges[e2].Key, vertex4 = existingEdges[e2].Value;
            RemoveConnection(vertex1, vertex2);
            RemoveConnection(vertex3, vertex4);
            // Calculate removed cycles count
            int removedCyclesCount = Cycles3ByVertices(vertex1, vertex2) +
                Cycles3ByVertices(vertex3, vertex4);

            AddConnection(vertex1, vertex3);
            AddConnection(vertex2, vertex4);
            // Calculate removed cycles count
            int addedCyclesCount = Cycles3ByVertices(vertex1, vertex3) +
                Cycles3ByVertices(vertex2, vertex4);

            return addedCyclesCount - removedCyclesCount;
        }
        protected override SortedDictionary<Double, Double> CalculateCycles3Trajectory()
        {
            // Retrieving research parameters from network. Research MUST be Evolution. //
            Debug.Assert(network.ResearchParameterValues != null);
            Debug.Assert(network.ResearchParameterValues.ContainsKey(ResearchParameter.EvolutionStepCount));
            Debug.Assert(network.ResearchParameterValues.ContainsKey(ResearchParameter.TracingStepIncrement));
            Debug.Assert(network.ResearchParameterValues.ContainsKey(ResearchParameter.Nu));
            Debug.Assert(network.ResearchParameterValues.ContainsKey(ResearchParameter.PermanentDistribution));

            UInt32 stepCount = Convert.ToUInt32(network.ResearchParameterValues[ResearchParameter.EvolutionStepCount]);
            Double nu = Convert.ToDouble(network.ResearchParameterValues[ResearchParameter.Nu]);
            bool permanentDistribution = Convert.ToBoolean(network.ResearchParameterValues[ResearchParameter.PermanentDistribution]);
            object v = network.ResearchParameterValues[ResearchParameter.TracingStepIncrement];
            UInt32 tracingStepIncrement = ((v != null) ? Convert.ToUInt32(v) : 0);

            // keep initial container
            NonHierarchicContainer initialContainer = container.Clone();

            SortedDictionary<Double, Double> trajectory = new SortedDictionary<Double, Double>();
            uint currentStep = 0;
            uint currentTracingStep = tracingStepIncrement;
            double currentCycle3Count = CalculateCycles3();
            trajectory.Add(currentStep, currentCycle3Count);

            NonHierarchicContainer previousContainer = new NonHierarchicContainer();
            RNGCrypto rand = new RNGCrypto();
            while (currentStep != stepCount)
            {
                previousContainer = container.Clone();
                try
                {
                    ++currentStep;

                    long deltaCount = permanentDistribution ?
                        container.PermanentRandomization() :
                        container.NonPermanentRandomization();
                    double newCycle3Count = currentCycle3Count + deltaCount;

                    int delta = (int)(newCycle3Count - currentCycle3Count);
                    if (delta > 0)
                    {
                        // accept
                        trajectory.Add(currentStep, newCycle3Count);
                        currentCycle3Count = newCycle3Count;
                    }
                    else
                    {
                        double probability = Math.Exp((-nu * Math.Abs(delta)));
                        if (rand.NextDouble() < probability)
                        {
                            // accept
                            trajectory.Add(currentStep, newCycle3Count);
                            currentCycle3Count = newCycle3Count;
                        }
                        else
                        {
                            // reject
                            trajectory.Add(currentStep, currentCycle3Count);
                            container = previousContainer;
                        }
                    }

                    network.UpdateStatus(NetworkStatus.StepCompleted);

                    if (currentTracingStep == currentStep)
                    {
                        container.Trace(network.ResearchName,
                            "Realization_" + network.NetworkID.ToString(),
                            "Matrix_" + currentTracingStep.ToString());
                        currentTracingStep += tracingStepIncrement;

                        network.UpdateStatus(NetworkStatus.StepCompleted);
                    }
                }
                catch (SystemException)
                {
                    container = initialContainer;
                }
            }

            container = initialContainer;
            return trajectory;
        }