图深度优先,广度优先 [英] Graph depth first search, breadth first search

查看:89
本文介绍了图深度优先,广度优先的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C ++中实现的具有广度优先搜索(BFS)和深度优先搜索(DFS)遍历的图形简介


[edit]不要大喊大叫.使用所有大写字母被认为是在互联网上大喊大叫,并且粗鲁(使用所有小写字母被认为是幼稚的).如果要认真对待,请使用大写字母. -OriginalGriff [/edit]

Introduction to Graph with Breadth First Search(BFS) and Depth First Search(DFS) Traversal Implemented in C++


[edit]DON''T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously. - OriginalGriff[/edit]

推荐答案

如果您要张贴作业,至少要使其看起来像是您自己尝试做某事!

我们不做您的作业:这是有原因的.在这里,您可以考虑自己被告知的内容,并尝试理解它.也可以在那里帮助您的导师识别您的弱点,并将更多的注意力放在补救措施上.

自己尝试一下,或学习魔语:您想要炸薯条吗?"
If you are going to post your homework, at least try to make it look like you have attempted to do something yourself!

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, or learn the Magic Words: "Do you want fries with that?"


如果您想一想,可以清楚地看到,这些算法不适用于一般图形.至少一个简单的原因:对于这种图形,无法从宽度上分辨出宽度. :-)该算法仅适用于在给出根节点的情况下称为树"的特殊情况.树定义为无循环的图.与许多图问题不同,此搜索绝对是微不足道的,但至少没有阅读基本定义,它无法做任何事情.

—SA
If you think a bit you would clearly see that those algorithms are inapplicable for a general graph by at least one simple reason: for such a graph there is no way to tell the width from breadth. :-) The algorithms are only applicable to the special case of graph called "tree" when the root node is given. Tree is defined as a graph without cycle. Unlike many graph problems, this search is absolutely trivial, but it could not do anything without at least reading of the basic definitions.

—SA


这篇关于图深度优先,广度优先的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆