Further reading

Example and algorithms modified from Callan R (2003) Artificial Intelligence Palgrave
ISBN 0-333-80136-9 pg 50-55
1.
BFS
For both BFS and DFS the goal of the example is to get to Q
1.1
Psuedocode
node current;
queue toVisit;
List alreadyVisited;
put root node in toVisit;
while toVisit is notEmpty
current=first node in toVisit;
remove first node in toVisit;
if current==goal
add current to alreadyVisited;
return true;
endif
for each child node C of current
add C to toVisit;
endfor;
add current to alreadyVisited;
endwhile;
1.2 Result
toVisit
A
BC
CDE
alreadyVisited
[]
A
AB
DEFGH
EFGHI
FGHIJK
GHIJKLM
HIJKLM
IJKLMN
JKLMNO
KLMNO
LMNO
MNOP
NOPQ
OPQ
PQ
Q
[]
ABC
ABCD
ABCDE
ABCDEF
ABCDEFG
ABCDEFGH
ABCDEFGHI
ABCDEFGHIJ
ABCDEFGHIJK
ABCDEFGHIJKL
ABCDEFGHIJKLM
ABCDEFGHIJKLMN
ABCDEFGHIJKLMNO
ABCDEFGHIJKLMNOP
ABCDEFGHIJKLMNOPQ
Basically it is going producing to lists toVisit where the nodes connect to the current
node are add at the end of the queue (so in effect the search goes through level by
level through the tree). The alreadyVisited list is the output list.
2. DFS
2.1
Psuedocode
node current;
stack toVisit;
List alreadyVisited;
put root node in toVisit;
while toVisit is notEmpty
current=first node in toVisit;
remove first node in toVisit;
if current==goal
add current to alreadyVisited;
return true;
endif
for each child node C of current
add C to toVisit;
endfor;
add current to alreadyVisited;
endwhile;
2.2 Result
toVisit
alreadyVisited
A
[]
BC
A
DEC
AB
IEC
ABD
OEC
ABDI
EC
ABDIO
JKC
ABDIOE
KC
ABDIOEJ
C
FGH
LMGH
PMGH
MGH
QGH
ABDIOEJK
ABDIOEJKC
ABDIOEJKCF
ABDIOEJKCFL
ABDIOEJKCFLP
ABDIOEJKCFLPM
In this case it is basically trying to go as left as possible all the time visiting nodes it
has not visietd before and once it can't do that it any more it goes up the 'tree' until it
can or until the goal is met.
Further reading
General overview of three search methods
Johnson J and Picton P (1995) Mechatronics : designing intelligent machines. - Vol.2 : concepts in artificial
intelligence Oxford : Butterworth-Heinemann
Shelfmark in library: 670.285/JOH
Pages 58-67
Depth first
http://en.wikipedia.org/wiki/Depth-first_search
Breadth-first
http://en.wikipedia.org/wiki/Breadth-first_search
A*
http://en.wikipedia.org/wiki/A%2A_search_algorithm
http://www.geocities.com/jheyesjones/astar.html - You might have to scroll down the page a bit.
http://www.gameai.com/javastar.html - Java implementation