What is the difference between graph search and tree search?

后端 未结 5 951
予麋鹿
予麋鹿 2020-12-02 03:50

What is the difference between graph search and tree search versions regarding DFS, A* searches in artificial intelligence?

5条回答
  •  执笔经年
    2020-12-02 04:21

    The only difference between a graph and a tree is cycle. A graph may contain cycles, a tree cannot. So when you're going to implement a search algorithm on a tree, you don't need to consider the existence of cycles, but when working with an arbitrary graph, you'll need to consider them. If you don't handle the cycles, the algorithm may eventually fall in an infinite loop or an endless recursion.

    Another point to think is the directional properties of the graph you're dealing with. In most cases we deal with trees that represent parent-child relationships at each edge. A DAG (directed acyclic graph) also shows similar characteristics. But bi-directional graphs are different. Each edge in a bi-directional graphs represents two neighbors. So the algorithmic approaches should differ a bit for these two types of graphs.

提交回复
热议问题