Magic Property | AllegroGraph 9.0.1
Author: Franz Incorporated

Copyright (c) 2005 - 2026 Franz, Incorporated
Last updated 27 May 2026 at 10:34

# SPARQL Magic Property

- Documentation Index
  - Release Notes
  - Quick Start
  - SSL/TLS Quick Start
  - Introduction
  - Setup and Configuration
    - Download
    - Server Installation
    - Server Configuration and Control
    - WebView
    - Database Upgrading
    - Managing Users
  - Server Management
    - Performance Tuning
    - Deleting Duplicate Triples
    - Purging Deleted Triples
    - Auditing
    - Managing Users
    - Replication
    - Point-in-Time Recovery
    - Transaction Log Archiving
    - Security Overview
    - Security Implementation
  - Tools
    - agtool
    - Data Loading
    - Data Export
    - Backup and Restore
    - Querying
    - RDFS++
    - Materializer
    - Event Scheduler
    - SHACL
  - Details
    - Triple Indices
    - Freetext Indices
    - Encoded IDs
    - Connection Pooling
    - N-dimensional Geospatial Overview
    - 2-D Geospatial
    - Temporal
    - Social Network
    - JavaScript
    - Datatypes
    - Data Conversion (Rapper)
    - Stored Procedures
    - Triple Attributes
    - Lineparse Format
  - Querying
    - SPARQL documentation summary
    - SPARQL Reference
    - SPIN
    - SPARQL Magic Properties
    - Prolog
  - 3rd-party tools
    - Solr text Indices
    - MongoDB integration
    - TopBraid Composer Plugin
    - Cloudera
  - Client APIs
    - Gruff
    - GraphTalker
    - REST/HTTP interface
    - HTTP reference
    - Javadocs (Sesame and Jena)
    - Python API
    - Lisp Reference
    - JavaScript
  - Tutorials
    - N-dimensional Geospatial
    - SPARQL Tutorial
    - Java Sesame
    - Java Jena
    - Python Sesame
    - Lisp
    - Prolog
    - More...
  - Other
    - Conferences and Seminars
    - Source Code on Github
    - Amazon EC2
    - Copyrights
  - Franz, Inc.

## 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:

- fti - <http://franz.com/ns/allegrograph/2.2/textindex/>
- geo - <http://franz.com/ns/allegrograph/3.0/geospatial/>
- geofn - <http://franz.com/ns/allegrograph/3.0/geospatial/fn/>
- nd - <http://franz.com/ns/allegrograph/5.0/geo/nd#>
- ndfn - <http://franz.com/ns/allegrograph/5.0/geo/nd/fn#>
- sna - <http://franz.com/ns/allegrograph/4.11/sna/>

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