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 | TEXT |
Edges SQL as described below. |
Root vid | BIGINT |
Identifier of the root vertex of the tree.
|
Root vids | ARRAY[ANY-INTEGER] |
Array of identifiers of the root vertices.
|
Where:
ANY-INTEGER: | SMALLINT, INTEGER, BIGINT |
---|---|
ANY-NUMERIC: | SMALLINT, INTEGER, BIGINT, REAL, FLOAT, NUMERIC |
BFS optional parameters¶
Parameter | Type | Default | Description |
---|---|---|---|
max_depth |
BIGINT |
\(9223372036854775807\) | Upper limit of the depth of the tree.
|
Inner Queries¶
Edges SQL¶
Column | Type | Default | Description |
---|---|---|---|
id |
ANY-INTEGER | Identifier of the edge. | |
source |
ANY-INTEGER | Identifier of the first end point vertex of the edge. | |
target |
ANY-INTEGER | Identifier of the second end point vertex of the edge. | |
cost |
ANY-NUMERICAL | Weight of the edge (source , target ) |
|
reverse_cost |
ANY-NUMERICAL | -1 | Weight of the edge (
|
Where:
ANY-INTEGER: | SMALLINT , INTEGER , BIGINT |
---|---|
ANY-NUMERICAL: | SMALLINT , INTEGER , BIGINT , REAL , FLOAT |
Result Columns¶
Returns SET OF (seq, depth, start_vid, node, edge, cost, agg_cost)
Parameter | Type | Description |
---|---|---|
seq |
BIGINT |
Sequential value starting from \(1\). |
depth |
BIGINT |
Depth of the
|
start_vid |
BIGINT |
Identifier of the root vertex. |
node |
BIGINT |
Identifier of node reached using edge . |
edge |
BIGINT |
Identifier of the
|
cost |
FLOAT |
Cost to traverse edge . |
agg_cost |
FLOAT |
Aggregate cost from start_vid to node . |
Where:
ANY-INTEGER: | SMALLINT, INTEGER, BIGINT |
---|---|
ANY-NUMERIC: | SMALLINT, INTEGER, BIGINT, REAL, FLOAT, NUMERIC |
See Also¶
- Boost: Prim’s algorithm
- Boost: Kruskal’s algorithm
- Wikipedia: Prim’s algorithm
- Wikipedia: Kruskal’s algorithm
Indices and tables