DFS  Category¶
Traversal using Depth First Search.
Proposed
Warning
Proposed functions for next mayor release.
They are not officially in the current release.
They will likely officially be part of the next mayor release:
The functions make use of ANYINTEGER and ANYNUMERICAL
Name might not change. (But still can)
Signature might not change. (But still can)
Functionality might not change. (But still can)
pgTap tests have being done. But might need more.
Documentation might need refinement.
pgr_depthFirstSearch  Proposed  Depth first search traversal of the graph.
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
DFS 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