Database Reference
In-Depth Information
Let's now take a look at the other built-in branch selector strategy: breadth-first.
8.1.2. Breadth-first
Asitsnamesuggests,thebreadth-firstalgorithmtriestogoaswideinthegraphaspossible,
before visiting nodes more distant from the starting node. As part of the breadth-first al-
gorithm, the traversal will first visit all siblings of the current node before moving on to
their children. Siblings in this sense means nodes the same distance from the root node as
the node you're currently visiting. Figure 8.3 shows the breadth-first traversal order for the
same graph used earlier.
Figure 8.3. Breadthfirst traversal of the sample graph
You start from root node 1, as before, and continue by visiting its first descendant, node
2 (via relationship a ). Next, you visit the siblings of node 2, moving to nodes 3 and then
4. Once you visit node 4, there are no more nodes the same distance from the root node
 
Search WWH ::




Custom Search