public void HasPathTest()
        {
            Node[] net = new[] {
                new Node(0)
                {
                    NearestNodes = new[] { 9 }, IsActive = true
                },
                new Node(1)
                {
                    NearestNodes = new[] { 5, 4, 2, 3 }, IsActive = true
                },
                new Node(2)
                {
                    NearestNodes = new[] { 1, 5, 4 }, IsActive = true
                },
                new Node(3)
                {
                    NearestNodes = new[] { 1, 4, 8 }, IsActive = true
                },
                new Node(4)
                {
                    NearestNodes = new[] { 2, 3, 1 }, IsActive = true
                },
                new Node(5)
                {
                    NearestNodes = new[] { 2, 1 }, IsActive = true
                },
                new Node(6)
                {
                    NearestNodes = new[] { 8 }, IsActive = true
                },
                new Node(7)
                {
                    NearestNodes = new[] { 8, 1 }, IsActive = true
                },
                new Node(8)
                {
                    NearestNodes = new[] { 3, 6, 7 }, IsActive = true
                },
                new Node(9)
                {
                    NearestNodes = new[] { 0 }, IsActive = true
                }
            };

            Assert.AreEqual(true, GrafCalculator.HasPath(net, 5, 7));
            Assert.AreEqual(true, GrafCalculator.HasPath(net, 1, 6));
            Assert.AreEqual(true, GrafCalculator.HasPath(net, 6, 1));
            Assert.AreEqual(true, GrafCalculator.HasPath(net, 3, 5));
            Assert.AreEqual(false, GrafCalculator.HasPath(net, 0, 1));
            Assert.AreEqual(false, GrafCalculator.HasPath(net, 7, 9));
        }
        private void Process()
        {
            var  inactivCount = 0;
            bool hasPath      = GrafCalculator.HasPath(_connections, A, B);
            var  step         = 0;

            while ((inactivCount < _connections.Length) && (hasPath))
            {
                inactivCount = (int)(_calculationTask.PofInfective * (_netMap.Sum(node => node.NearestNodes.Length) / 2));
                Inactivate(_connections, inactivCount);
                hasPath = GrafCalculator.HasPath(_connections, A, B);
                step++;
            }
            _percalationResult.Add(step);
        }
        private void Process()
        {
            var  inactivCount = 0;
            bool hasPath      = GrafCalculator.HasPath(NetMap, A, B);
            var  step         = 0;

            while ((inactivCount < NetMap.Length) && (hasPath))
            {
                ClaerNet();
                inactivCount = (int)(_calculationTask.PofInfective * step * NetMap.Length);
                Inactivate(NetMap, inactivCount);
                hasPath = GrafCalculator.HasPath(NetMap, A, B);
                step++;
            }
            _percalationResult.Add(step);
        }
        public void WriteResult(IResultWriter writer)
        {
            int maxStep = _percalationResult.Max();
            var result  = new Dictionary <int, double>(maxStep);

            foreach (var percalationStep in _percalationResult)
            {
                var t = percalationStep;
                while (t <= maxStep)
                {
                    if (result.ContainsKey(t))
                    {
                        result[t]++;
                    }
                    else
                    {
                        result.Add(t, 1);
                    }
                    t++;
                }
            }
            for (int i = 0; i <= maxStep; i++)
            {
                if (result.ContainsKey(i))
                {
                    result[i] = (double)result[i] / (double)_calculationTask.CountOfIteration;
                }
                else
                {
                    result.Add(i, 0);
                }
            }

            writer.WriteDoubleValue(GrafCalculator.GetAvarageLinkCount(_netMap));
            writer.WritePercalation(result);
        }
        private void Process()
        {
            var hasPath = GrafCalculator.HasPath(_connections, _a, _b);

            _percalationResult.Add(hasPath ? 1 : 0);
        }