예제 #1
0
        private void MoveForward(IList <DirectedConnection> connList, int currConnIdx)
        {
            // If the current node has at least one more outgoing connection leading to an unvisited node,
            // then update the node's entry on the top of the stack to point to said connection.
            for (int i = currConnIdx + 1; i < connList.Count && (connList[currConnIdx].SourceId == connList[i].SourceId); i++)
            {
                if (!_visitedNodes.Contains(connList[i].TargetId))
                {
                    _traversalStack.Poke(currConnIdx + 1);
                    return;
                }
            }

            // No more connections for the current node; pop/remove the current node from the top of the stack.
            // Traversal will thus continue from its traversal parent node's current position, or will terminate
            // if the stack is now empty.
            _traversalStack.Pop();
        }
예제 #2
0
        /// <summary>
        /// Update the stack state to point to the next connection to traverse down.
        /// </summary>
        /// <returns>The current connection to traverse down.</returns>
        private void MoveForward(int[] srcIdArr, int[] tgtIdAr, int currConnIdx)
        {
            // If the current node has at least one more outgoing connection leading to an unvisited node,
            // then update the node's entry on the top of the stack to point to said connection.
            for (int i = currConnIdx + 1; i < srcIdArr.Length && (srcIdArr[currConnIdx] == srcIdArr[i]); i++)
            {
                if (!_visitedNodeBitmap[tgtIdAr[i]])
                {
                    _traversalStack.Poke(currConnIdx + 1);
                    return;
                }
            }

            // No more connections for the current node; pop/remove the current node from the top of the stack.
            // Traversal will thus continue from its traversal parent node's current position, or will terminate
            // if the stack is now empty.
            _traversalStack.Pop();
        }