完成迭代深化深度优先搜索
目前我有一个看起来有点像这样的物体。
C#
public class Step {
int id;
List<Step> nextSteps;
}
我正在尝试将其转换为另一个看起来非常相似的对象,除了它不允许循环这一事实之外。
它应该通过不扩展已经出现在更高深度的节点的子节点来处理循环。迭代深化解决了这个问题(深度优先搜索实现,但广度优先搜索顺序),但我正在努力使用以下结构的实现。
我发现的所有实现都依赖于寻找某种目标节点,而我需要扩展整个树。
任何帮助将不胜感激。 :D
At the minute I have an object that looks a bit like this.
C#
public class Step {
int id;
List<Step> nextSteps;
}
And I'm trying to convert it into another object that looks pretty similar apart from the fact that it doesn't allow loops.
It should handle loops by not expanding the children of nodes that have already appeared at a higher depth. Iterative deepening solves this (depth first search implementation but breadth first search order) but I'm struggling with an implementation using the following structure.
All implementations I found rely on finding some sort of goal node, whereas I need the whole tree expanded.
Any help would be appreciated. :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加一个
Dictionary
,每次展开节点时,都添加它的深度。Add a
Dictionary<Step, int>
and each time you expand a node, add it with its depth.