http://franz.com/ns/allegrograph/4.11/sna/breadthFirstSearch

Compute Breadth-first Search paths.

This magic property can be used in several ways:

The first is:

?start sna:breadthFirstSearch ( ex:namedGenerator ?end )  
?start sna:breadthFirstSearch ( ex:namedGenerator ?end ?depth ) 

which will succeed when there is a path between ?start and ?end (both of which must be bound) using generator ex:namedGenerator and the optional ?depth to limit the search.

The second is

(?start ?node) sna:breadthFirstSearch ( ex:namedGenerator ?end )  
(?start ?node) sna:breadthFirstSearch ( ex:namedGenerator ?end ?depth ) 

which is like the above but also returns one binding to ?node for each node along the path between ?start and ?end. Note that although they will tend to appear in sequence there is no guaranteed order between the bindings. The third form provides a way to capture the order in the path. It is:

(?start ?node ?nodeId) sna:breadthFirstSearch ( ex:namedGenerator ?end )  
(?start ?node ?nodeId) sna:breadthFirstSearch ( ex:namedGenerator ?end ?depth ) 

which is like the above but also returns one binding to ?node for each node along the path and a sequential numeric binding to ?nodeId that represents the path element.

The final form is:

(?start ?node ?nodeId ?pathId) sna:breadthFirstSearch ( ex:namedGenerator ?end )  
(?start ?node ?nodeId ?pathId) sna:breadthFirstSearch ( ex:namedGenerator ?end ?depth ) 

It is like the above but also binds ?pathId to a sequential count of the number of the path. I.e., the first path will have ?pathId bound to 0; the second to 1 and so on.

Notes

The following namespace abbreviations are used:

The SPARQL magic properties reference has additional information on using AllegroGraph magic properties and functions.