Is Depth-First Search Order for Graph Traversal Direction-Agnostic?

gfd43tg
Gold Member
Messages
947
Reaction score
48
ImageUploadedByPhysics Forums1407629937.062203.jpg


Hello, I drew up this graph to try and understand the concept of depth-first search. Starting at node C, I was wondering if its correct for the order to be C-A-B-D or C-B-A-D? It seems like you can traverse in either direction without a problem.
 
Physics news on Phys.org
For me, both are valid. You could certainly look at all the children, order them by some preference and visit each one in that order.
 
I'm confused as to what movements are not allowed? It seems very unclear to me what is a legitimate traversal and what isn't. Can you go C-D-B-A or C-D-A-B? What counts as not being permitted?
 
Depth-first means the whole subtree of each child node is processed before any other child nodes are processed. Does that make sense? Your example tree is a bad example because the children of C have no children themselves.

Oh sorry, you are talking about a graph, not a tree. Hmm.
 
Ok, for a graph, depth-first must mean, process every unvisited neighbor before backtracking. CAD -- not allowed.
 
There are two things I don't understand about this problem. First, when finding the nth root of a number, there should in theory be n solutions. However, the formula produces n+1 roots. Here is how. The first root is simply ##\left(r\right)^{\left(\frac{1}{n}\right)}##. Then you multiply this first root by n additional expressions given by the formula, as you go through k=0,1,...n-1. So you end up with n+1 roots, which cannot be correct. Let me illustrate what I mean. For this...
Back
Top