in reply to OT(ish) - Best Search Algorithm
Of course, the above pseudo-code doesn't facilitate storing the actual paths, this is easily done using input and output parameters. Hope that helps.# Pseudo-code array dflabels[] for each node I in graph dflables[I] = 0 s := 0 d := 0 # same as "s", which is you # as recursive function acyclic (start_node) if 1 > dflabels[start_node]# max num visits is 1 dflabels[start_node]++ for each i in adjacent_nodes(start_node) acyclic(i) end for dflabels[start_node]-- # unlike strict dft decrement else # indicates we've been here before if start_node == s # check if this is YOU print "Cycle back to me found!" end if end if return end function acyclic # initiate call acyclic(s)
|
|---|