示例#1
0
        private void UpdateVisitedLeft(Tuple <long, long> myTuple, ref Node myNode)
        {
            //set currentLeft as parent
            _VisitedNodesLeft[myTuple].addParent(myNode);

            //set currentNodeLeft as child
            myNode.addChild(_VisitedNodesLeft[myTuple]);
        }
示例#2
0
        private void SetAsVisitedRight(Tuple <long, long> myTuple, ref Node myCurrentNode, ref Node myNextNode, IVertex myVertex)
        {
            //create a new node and set currentRight = child
            myNextNode = new Node(myTuple);
            myNextNode.addChild(myCurrentNode);

            //set currentNodeRight as parent of current Right
            myCurrentNode.addParent(myNextNode);

            //never seen before
            //mark the node as visited
            _VisitedNodesRight.Add(myNextNode.Key, myNextNode);

            //and look what comes on the next level of depth
            _QueueRight.Enqueue(myVertex);
        }
示例#3
0
        private void SetAsVisitedLeft(Tuple <long, long> myTuple, ref Node myCurrentNode, ref Node myNextNode, IVertex myVertex)
        {
            //create a new node
            myNextNode = new Node(myTuple, myCurrentNode);

            //set currentNode
            myCurrentNode.addChild(myNextNode);

            //never seen before
            //mark the node as visited
            //_VisitedNodesLeft.Add(currentNodeLeft.Key, currentNodeLeft);
            _VisitedNodesLeft.Add(myNextNode.Key, myNextNode);

            //and put node into the queue
            _QueueLeft.Enqueue(myVertex);
        }
示例#4
0
        private bool VisitedByRightSide(Tuple <long, long> myTuple, ref Node myCurrentNodeLeft)
        {
            //get node
            Node temp = _VisitedNodesRight[myTuple];

            //add parent new
            temp.addParent(myCurrentNodeLeft);
            //add as child
            myCurrentNodeLeft.addChild(temp);

            _VisitedNodesRight.Remove(temp.Key);
            _VisitedNodesRight.Add(temp.Key, temp);

            if (_VisitedNodesLeft.Remove(temp.Key))
            {
                _VisitedNodesLeft.Add(temp.Key, temp);
            }

            if (_ShortestOnly && !_FindAll)
            {
                if ((_DepthLeft + _DepthRight + 1) > _MaxPathLength)
                {
                    _ShortestPathLength = _MaxPathLength;
                }
                else
                {
                    _ShortestPathLength = Convert.ToUInt64(_DepthLeft + _DepthRight + 1);
                }

                return(true);
            }
            else if (_ShortestOnly && _FindAll)
            {
                _MaxDepthLeft = _DepthLeft;

                _ShortestPathLength = Convert.ToUInt64(_MaxDepthLeft + _MaxDepthRight);
            }

            return(false);
        }
示例#5
0
        private bool VisitedByRightSide(Tuple<long, long> myTuple, ref Node myCurrentNodeLeft)
        {
            //get node
            Node temp = _VisitedNodesRight[myTuple];
            //add parent new
            temp.addParent(myCurrentNodeLeft);
            //add as child
            myCurrentNodeLeft.addChild(temp);

            _VisitedNodesRight.Remove(temp.Key);
            _VisitedNodesRight.Add(temp.Key, temp);

            if (_VisitedNodesLeft.Remove(temp.Key))
            {
                _VisitedNodesLeft.Add(temp.Key, temp);
            }

            if (_ShortestOnly && !_FindAll)
            {
                if ((_DepthLeft + _DepthRight + 1) > _MaxPathLength)
                {
                    _ShortestPathLength = _MaxPathLength;
                }
                else
                {
                    _ShortestPathLength = Convert.ToUInt64(_DepthLeft + _DepthRight + 1);
                }

                return true;
            }
            else if (_ShortestOnly && _FindAll)
            {
                _MaxDepthLeft = _DepthLeft;

                _ShortestPathLength = Convert.ToUInt64(_MaxDepthLeft + _MaxDepthRight);
            }

            return false;
        }
示例#6
0
        private void UpdateVisitedLeft(Tuple<long, long> myTuple, ref Node myNode)
        {
            //set currentLeft as parent
            _VisitedNodesLeft[myTuple].addParent(myNode);

            //set currentNodeLeft as child
            myNode.addChild(_VisitedNodesLeft[myTuple]);
        }
示例#7
0
        /// <summary>
        /// Checks if the search should be aborted.
        /// </summary>
        /// <param name="myTuple">the Tuple of the current Vertex.</param>
        /// <param name="myCurrentNode">The current Node.</param>
        /// <param name="myNextNode">The next Node.</param>
        /// <param name="myVertex">The actual Vertex.</param>
        /// <returns>True, if the target is found AND the BFS could be finished. False, if the BFS should be continued.</returns>
        private bool TargetFoundCheckAbort(Tuple<long, long> myTuple, ref Node myCurrentNode, ref Node myNextNode, IVertex myVertex)
        {
            if (myTuple.Equals(_Target.Key))
            {
                //set currentLeft as parent of _Target
                _Target.addParent(myCurrentNode);

                #region check if already visited
                if (_VisitedNodesLeft.ContainsKey(myTuple))
                {
                    //set currentLeft as parent
                    _VisitedNodesLeft[myTuple].addParent(myCurrentNode);

                    //set currentNodeLeft as child
                    myCurrentNode.addChild(_VisitedNodesLeft[myTuple]);
                }
                else
                {
                    //create a new node and set currentLeft = parent
                    myNextNode = new Node(myTuple, myCurrentNode);

                    //set currentNodeLeft as child of currentLeft
                    myCurrentNode.addChild(myNextNode);

                    //never seen before
                    //mark the node as visited
                    _VisitedNodesLeft.Add(myNextNode.Key, myNextNode);

                    //and put node into the queue
                    _QueueLeft.Enqueue(myVertex);
                }

                #endregion

                #region check how much parents are searched

                if (_ShortestOnly && !_FindAll)
                {
                    if ((_DepthLeft + _DepthRight + 1) > _MaxPathLength)
                    {
                        _ShortestPathLength = _MaxPathLength;
                    }
                    else
                    {
                        _ShortestPathLength = Convert.ToUInt64(_DepthLeft + _DepthRight + 1);
                    }

                    return true;
                }
                //if find all shortest paths
                else if (_ShortestOnly && _FindAll)
                {
                    //set maxDepth to actual depth
                    _MaxDepthLeft = _DepthLeft;
                    _MaxDepthRight = _DepthRight;

                    if ((_DepthLeft + _DepthRight) > _MaxPathLength)
                    {
                        _ShortestPathLength = _MaxPathLength;
                    }
                    else
                    {
                        _ShortestPathLength = Convert.ToUInt64(_DepthLeft + _DepthRight);
                    }
                }

                #endregion
            }

            return false;
        }
示例#8
0
        private void SetAsVisitedRight(Tuple<long, long> myTuple, ref Node myCurrentNode, ref Node myNextNode, IVertex myVertex)
        {
            //create a new node and set currentRight = child
            myNextNode = new Node(myTuple);
            myNextNode.addChild(myCurrentNode);

            //set currentNodeRight as parent of current Right
            myCurrentNode.addParent(myNextNode);

            //never seen before
            //mark the node as visited
            _VisitedNodesRight.Add(myNextNode.Key, myNextNode);

            //and look what comes on the next level of depth
            _QueueRight.Enqueue(myVertex);
        }
示例#9
0
        private void SetAsVisitedLeft(Tuple<long, long> myTuple, ref Node myCurrentNode, ref Node myNextNode, IVertex myVertex)
        {
            //create a new node
            myNextNode = new Node(myTuple, myCurrentNode);

            //set currentNode
            myCurrentNode.addChild(myNextNode);

            //never seen before
            //mark the node as visited
            //_VisitedNodesLeft.Add(currentNodeLeft.Key, currentNodeLeft);
            _VisitedNodesLeft.Add(myNextNode.Key, myNextNode);

            //and put node into the queue
            _QueueLeft.Enqueue(myVertex);
        }
示例#10
0
        private bool RootFoundCheckAbort(Tuple<long, long> myTuple, ref Node myCurrentNode, ref Node myNextNode, IVertex myVertex)
        {
            #region check if already visited
            //mark node as visited
            if (_VisitedNodesRight.ContainsKey(myTuple))
            {
                //set found children
                _VisitedNodesRight[myTuple].addChild(myCurrentNode);

                myCurrentNode.addParent(_VisitedNodesRight[myTuple]);
            }
            else
            {
                //create a new node and set currentRight = child
                myNextNode = new Node(myTuple);
                myNextNode.addChild(myCurrentNode);

                //set currentNodeRight as parent of current Right
                myCurrentNode.addParent(myNextNode);

                //never seen before
                //mark the node as visited
                _VisitedNodesRight.Add(myNextNode.Key, myNextNode);

                //and look what comes on the next level of depth
                _QueueRight.Enqueue(myVertex);
            }

            #endregion check if already visited
            #region check how much paths are searched

            if (_ShortestOnly && !_FindAll)
            {
                if ((_DepthLeft + _DepthRight + 1) > _MaxPathLength)
                {
                    _ShortestPathLength = _MaxPathLength;
                }
                else
                {
                    _ShortestPathLength = Convert.ToUInt64(_DepthLeft + _DepthRight + 1);
                }

                return true;
            }
            //if find all shortest paths
            else if (_ShortestOnly && _FindAll)
            {
                //set maxDepth to actual depth
                _MaxDepthLeft = _DepthLeft;
                _MaxDepthRight = _DepthRight;

                if ((_DepthLeft + _DepthRight) > _MaxPathLength)
                {
                    _ShortestPathLength = _MaxPathLength;
                }
                else
                {
                    _ShortestPathLength = Convert.ToUInt64(_DepthLeft + _DepthRight);
                }
            }
            #endregion check how much paths are searched

            return false;
        }
示例#11
0
        private bool RootFoundCheckAbort(Tuple <long, long> myTuple, ref Node myCurrentNode, ref Node myNextNode, IVertex myVertex)
        {
            #region check if already visited
            //mark node as visited
            if (_VisitedNodesRight.ContainsKey(myTuple))
            {
                //set found children
                _VisitedNodesRight[myTuple].addChild(myCurrentNode);

                myCurrentNode.addParent(_VisitedNodesRight[myTuple]);
            }
            else
            {
                //create a new node and set currentRight = child
                myNextNode = new Node(myTuple);
                myNextNode.addChild(myCurrentNode);

                //set currentNodeRight as parent of current Right
                myCurrentNode.addParent(myNextNode);

                //never seen before
                //mark the node as visited
                _VisitedNodesRight.Add(myNextNode.Key, myNextNode);

                //and look what comes on the next level of depth
                _QueueRight.Enqueue(myVertex);
            }

            #endregion check if already visited
            #region check how much paths are searched

            if (_ShortestOnly && !_FindAll)
            {
                if ((_DepthLeft + _DepthRight + 1) > _MaxPathLength)
                {
                    _ShortestPathLength = _MaxPathLength;
                }
                else
                {
                    _ShortestPathLength = Convert.ToUInt64(_DepthLeft + _DepthRight + 1);
                }

                return(true);
            }
            //if find all shortest paths
            else if (_ShortestOnly && _FindAll)
            {
                //set maxDepth to actual depth
                _MaxDepthLeft  = _DepthLeft;
                _MaxDepthRight = _DepthRight;

                if ((_DepthLeft + _DepthRight) > _MaxPathLength)
                {
                    _ShortestPathLength = _MaxPathLength;
                }
                else
                {
                    _ShortestPathLength = Convert.ToUInt64(_DepthLeft + _DepthRight);
                }
            }
            #endregion check how much paths are searched

            return(false);
        }
示例#12
0
        /// <summary>
        /// Checks if the search should be aborted.
        /// </summary>
        /// <param name="myTuple">the Tuple of the current Vertex.</param>
        /// <param name="myCurrentNode">The current Node.</param>
        /// <param name="myNextNode">The next Node.</param>
        /// <param name="myVertex">The actual Vertex.</param>
        /// <returns>True, if the target is found AND the BFS could be finished. False, if the BFS should be continued.</returns>
        private bool TargetFoundCheckAbort(Tuple <long, long> myTuple, ref Node myCurrentNode, ref Node myNextNode, IVertex myVertex)
        {
            if (myTuple.Equals(_Target.Key))
            {
                //set currentLeft as parent of _Target
                _Target.addParent(myCurrentNode);

                #region check if already visited
                if (_VisitedNodesLeft.ContainsKey(myTuple))
                {
                    //set currentLeft as parent
                    _VisitedNodesLeft[myTuple].addParent(myCurrentNode);

                    //set currentNodeLeft as child
                    myCurrentNode.addChild(_VisitedNodesLeft[myTuple]);
                }
                else
                {
                    //create a new node and set currentLeft = parent
                    myNextNode = new Node(myTuple, myCurrentNode);

                    //set currentNodeLeft as child of currentLeft
                    myCurrentNode.addChild(myNextNode);

                    //never seen before
                    //mark the node as visited
                    _VisitedNodesLeft.Add(myNextNode.Key, myNextNode);

                    //and put node into the queue
                    _QueueLeft.Enqueue(myVertex);
                }

                #endregion

                #region check how much parents are searched

                if (_ShortestOnly && !_FindAll)
                {
                    if ((_DepthLeft + _DepthRight + 1) > _MaxPathLength)
                    {
                        _ShortestPathLength = _MaxPathLength;
                    }
                    else
                    {
                        _ShortestPathLength = Convert.ToUInt64(_DepthLeft + _DepthRight + 1);
                    }

                    return(true);
                }
                //if find all shortest paths
                else if (_ShortestOnly && _FindAll)
                {
                    //set maxDepth to actual depth
                    _MaxDepthLeft  = _DepthLeft;
                    _MaxDepthRight = _DepthRight;

                    if ((_DepthLeft + _DepthRight) > _MaxPathLength)
                    {
                        _ShortestPathLength = _MaxPathLength;
                    }
                    else
                    {
                        _ShortestPathLength = Convert.ToUInt64(_DepthLeft + _DepthRight);
                    }
                }

                #endregion
            }

            return(false);
        }