BFS  Category  pgRouting Manual (3.4)
BFS  Category
Traversal using breadth first search.

It’s implementation is only on undirected graph.

Process is done only on edges with positive costs.

When the graph is connected

The resulting edges make up a tree


When the graph is not connected,

Finds a minimum spanning tree for each connected component.

The resulting edges make up a forest.

Parameters
Parameter 
Type 
Description 


Edges SQL as described below. 

root vid 

Identifier of the root vertex of the tree.

root vids 

Array of identifiers of the root vertices.

Where:
 ANYINTEGER :

SMALLINT, INTEGER, BIGINT
 ANYNUMERIC :

SMALLINT, INTEGER, BIGINT, REAL, FLOAT, NUMERIC
BFS optional parameters
Parameter 
Type 
Default 
Description 



\(9223372036854775807\) 
Upper limit of the depth of the tree.

Inner Queries
Edges SQL
Column 
Type 
Default 
Description 


ANYINTEGER 
Identifier of the edge. 


ANYINTEGER 
Identifier of the first end point vertex of the edge. 


ANYINTEGER 
Identifier of the second end point vertex of the edge. 


ANYNUMERICAL 
Weight of the edge (



ANYNUMERICAL 
1 
Weight of the edge (

Where:
 ANYINTEGER :

SMALLINT
,INTEGER
,BIGINT
 ANYNUMERICAL :

SMALLINT
,INTEGER
,BIGINT
,REAL
,FLOAT
Result Columns
Returns SET OF
(seq,
depth,
start_vid,
node,
edge,
cost,
agg_cost)
Parameter 
Type 
Description 



Sequential value starting from \(1\) . 


Depth of the



Identifier of the root vertex. 


Identifier of



Identifier of the



Cost to traverse



Aggregate cost from

Where:
 ANYINTEGER :

SMALLINT, INTEGER, BIGINT
 ANYNUMERIC :

SMALLINT, INTEGER, BIGINT, REAL, FLOAT, NUMERIC
See Also
Indices and tables