. , ( ), ( , ). , , , . :
http://en.wikipedia.org/wiki/Depth-first_search
http://en.wikipedia.org/wiki/Breadth-first_search
, ( "#" node, ). (.. , , , [S, b, c] - , S c). DFS BFS , , , , , . DFS BFS , DFS ( ), BFS (.. ).
, DFS :
- node - S, - [S]. [S] ([[S]]).
- ( , [S]).
- , 1 node ( , b).
- node 3 , . . (.. [S, b], b c S, S , )
- 4 node, , . .
- node 4, node, (.. [S] [S, b] , [[S, b]])
- 2 6 , , , node.
. (, "e" s). , , "Node", . , "e" , , . ++, :
class Node:
method Constructor(label):
myLabel = label
links = list()
method addLink(node):
links.add(node)
, "#", node .
EDIT: 3 Python, . .
s = "foo"
s == "foo"
Python . "==" Python . , Java, , "==" . , Java ++, , .
, , , node ( ==, strcmp()!), .
, - node , . !