我想实现一个 DFS 以在 Reddit API 中获取父子对话。
我完全不知道如何做到这一点。有什么指点吗?
最佳答案
PRAW 的 list()
方法对评论进行广度优先遍历。 https://github.com/praw-dev/praw/blob/5ee4b1820c2591117e32be45778372e7c03a5f56/praw/models/comment_forest.py#L83
如果你想让它成为深度优先,你可以做同样的事情,但是交换:
queue.extend(comment.replies)
与:
queue[0:0] = comment.replies
关于depth-first-search - 如何在 Reddit PRAW 上实现 DFS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49151084/