Compare commits

..

No commits in common. "2ed30ebefd097af21561548ae9930b915df93c59" and "1583496887bd4655696c662d3abd8de1f3a29b9c" have entirely different histories.

1 changed files with 12 additions and 7 deletions

View File

@ -172,7 +172,6 @@ public class BFS<T>
private List<int> _closeList = new List<int>();
private Queue<int> _openList = new Queue<int>();
private Dictionary<Node<T>, Node<T>> _nodeMap = new Dictionary<Node<T>, Node<T>>();
private List<int> ids = new List<int>();
public BFS(Graph<T> graph)
{
@ -187,10 +186,6 @@ public class BFS<T>
public Path<T> FindPath(Node<T> begin, Node<T> end)
{
if (begin == null)
throw new NullReferenceException("begin");
if (end == null)
throw new NullReferenceException("end");
_openList.Clear();
_closeList.Clear();
_nodeMap.Clear();
@ -225,6 +220,12 @@ public class BFS<T>
{
if (this._nodeMap.TryGetValue(node, out node))
{
if (node != null)
{
Debug.Log($"{node.index} is null");
isTrue = false;
break;
}
if (!this.ids.Contains(node.index))
{
@ -233,10 +234,11 @@ public class BFS<T>
path.AddNode(new PathNode<T>(node.index, node.data));
}
}
if (node==null || node == begin)
if (node == begin)
{
Debug.Log("结束了");
isTrue = false;
break;
}
}
@ -245,6 +247,9 @@ public class BFS<T>
return path;
}
// add
private List<int> ids = new List<int>();
private void Search(Node<T> node)
{
var readOnlyList = this._graph.GetNeighbours(node);