Beispiel #1
0
        public List <TNode> GetPathTo(TNode node)
        {
            if (!this.labels.Keys.Contains(node))
            {
                throw new NotImplementedException();
            }

            List <TNode> result = new List <TNode>();

            TNode currentNode = node;

            result.Add(currentNode);

            while (!currentNode.Equals(this.startNode))
            {
                BreadthFirstSearchNode <TNode> temp = this.labels[currentNode].Predecessor;

                if (object.Equals(temp, null))
                {
                    return(null);
                }
                else
                {
                    currentNode = this.labels.Keys[this.labels.Values.IndexOf(temp)];

                    result.Add(currentNode);
                }
            }

            result.Reverse();

            return(result);
        }
Beispiel #2
0
 /// <summary>
 /// Create a new search node for BreadFirstSearch.
 /// </summary>
 /// <param name="x">X coordinate of the search node.</param>
 /// <param name="y">Y coordinate of the search node.</param>
 /// <param name="previousNode">Search node preceeding this one.</param>
 public BreadthFirstSearchNode(int x, int y,
                               BreadthFirstSearchNode previousNode = null)
 {
     this.x            = x;
     this.y            = y;
     this.searchStatus = SearchState.Unchecked;
     this.previousNode = previousNode;
 }
        /// <summary>
        /// Create a new search node for BreadFirstSearch.
        /// </summary>
        /// <param name="x">X coordinate of the search node.</param>
        /// <param name="y">Y coordinate of the search node.</param>
        /// <param name="previousNode">Search node preceeding this one.</param>
        public BreadthFirstSearchNode(int x, int y,
			BreadthFirstSearchNode previousNode = null)
        {
            this.x = x;
            this.y = y;
            this.searchStatus = SearchState.Unchecked;
            this.previousNode = previousNode;
        }