Beispiel #1
0
        public int QuantumModeling(int startIndex, int stopIndex)
        {
            BWTNode currentNode = null;

            currentNode = DescendingTree.Find(x => x.Index == startIndex);
            if (currentNode == null)
            {
                currentNode = AscendingTree.Find(x => x.Index == startIndex);
            }
            if (currentNode == null)
            {
                throw new NullReferenceException($"There is no a node with index {startIndex}");
            }

            var currentNodes = new List <BWTNode> {
                currentNode
            };
            var counter = 0;

            while (true)
            {
                counter += 1;
                var newCurrentNodes = new List <BWTNode>();
                foreach (var node in currentNodes)
                {
                    var nodeDoubling1 = RandomStep(node);
                    if (nodeDoubling1.Index == stopIndex)
                    {
                        return(counter);
                    }
                    if (!newCurrentNodes.Contains(nodeDoubling1))
                    {
                        newCurrentNodes.Add(nodeDoubling1);
                    }
                    var nodeDoubling2 = RandomStep(node);
                    if (nodeDoubling2.Index == stopIndex)
                    {
                        return(counter);
                    }
                    if (!newCurrentNodes.Contains(nodeDoubling2))
                    {
                        newCurrentNodes.Add(nodeDoubling2);
                    }
                }
                currentNodes = newCurrentNodes;
            }
        }
Beispiel #2
0
        public int NormalModeling(int startIndex, int stopIndex)
        {
            BWTNode currentNode = null;

            currentNode = DescendingTree.Find(x => x.Index == startIndex);
            if (currentNode == null)
            {
                currentNode = AscendingTree.Find(x => x.Index == startIndex);
            }
            if (currentNode == null)
            {
                throw new NullReferenceException($"There is no a node with index {startIndex}");
            }

            var counter = 0;

            do
            {
                currentNode = RandomStep(currentNode);
                counter    += 1;
            }while(currentNode.Index != stopIndex);
            return(counter);
        }