What is the difference between graph search and tree search versions regarding DFS, A* searches in artificial intelligence?
GRAPH VS TREE
But in case of AI Graph-search vs Tree-search
Graph search have a good property that's whenever the algorithm explore a new node and it mark it as visited , "Regardless of the algorithm used", the algorithm typically explores all the other nodes that are reachable from the current node.
For example consider the following graph with 3 vertices A B and C, and consider the following the edges
A-B, B-C, and C-A, Well there is a cycle from C to A,
And when do DFS starting from A, A will generate a new state B, B will generate a new state C, but when C is explored the algorithm will try to generate a new state A but A is already visited thus it will be ignored. Cool!
But what about trees? well trees algorithm don't mark the visited node as visited, but trees don't have cycles, how it would get in an infinite loops?
Consider this Tree with 3 vertices and consider the following edges
A - B - C rooted at A, downward. And let's assume we are using DFS algorithm
A will generate a new state B, B will generate two states A & C, because Trees don't have "Mark a node visited if it's explored" thus maybe the DFS algorithm will explore A again, thus generating a new state B, thus we are getting in an infinite loop.
But have you noticed something, we are working on undirected edges i.e. there is a connection between A-B and B-A. of course this is not a cycle, because the cycle implies that the vertices must be >= 3 and all the vertices are distinct except the first and the last nodes.
S.T A->B->A->B->A it's not a cycle because it violates the cycling property >= 3. But indeed A->B->C->A is a cycle >= 3 distinct nodes Checked, the first and the last node are the same Checked.
Again consider the tree edges, A->B->C->B->A, of course its not a cycle, because there are two Bs, which mean not all the nodes are distinct.
Lastly you could implement a tree-search algorithm, to prevent exploring the same node twice. But that have consequences.