pgr_kruskalDD
— Catchament nodes using Kruskal’s algorithm.
Availability
Support
Using Kruskal’s algorithm, extracts the nodes that have aggregate costs less than
or equal to the value Distance
from a root vertex (or vertices) within
the calculated minimum spanning tree.
The main Characteristics are:
pgr_kruskalDD(edges_sql, root_vid, distance)
pgr_kruskalDD(edges_sql, root_vids, distance)
RETURNS SET OF (seq, depth, start_vid, node, edge, cost, agg_cost)
pgr_kruskalDD(edges_sql, root_vid, distance)
RETURNS SET OF (seq, depth, start_vid, node, edge, cost, agg_cost)
Example:  The Minimum Spanning Tree starting on vertex \(2\) with \(agg\_cost <= 3.5\) 

SELECT * FROM pgr_kruskalDD(
'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
2, 3.5
);
seq  depth  start_vid  node  edge  cost  agg_cost
++++++
1  0  2  2  1  0  0
2  1  2  1  1  1  1
3  1  2  3  2  1  1
4  2  2  4  3  1  2
5  3  2  9  16  1  3
(5 rows)
pgr_kruskalDD(edges_sql, root_vids, distance)
RETURNS SET OF (seq, depth, start_vid, node, edge, cost, agg_cost)
Example:  The Minimum Spanning Tree starting on vertices \(\{13, 2\}\) with \(agg\_cost <= 3.5\); 

SELECT * FROM pgr_kruskalDD(
'SELECT id, source, target, cost, reverse_cost FROM edge_table ORDER BY id',
ARRAY[13,2],
3.5
);
seq  depth  start_vid  node  edge  cost  agg_cost
++++++
1  0  2  2  1  0  0
2  1  2  1  1  1  1
3  1  2  3  2  1  1
4  2  2  4  3  1  2
5  3  2  9  16  1  3
6  0  13  13  1  0  0
7  1  13  10  14  1  1
8  2  13  5  10  1  2
9  3  13  8  7  1  3
10  2  13  11  12  1  2
11  3  13  6  11  1  3
12  3  13  12  13  1  3
(12 rows)
Parameter  Type  Description 

Edges SQL  TEXT 
SQL query described in Inner query. 
Root vid  BIGINT 
Identifier of the root vertex of the tree.

Root vids  ARRAY[ANYINTEGER] 
Array of identifiers of the root vertices.

Distance  ANYNUMERIC 
Upper limit for the inclusion of the node in the result.

Where:
ANYINTEGER:  SMALLINT, INTEGER, BIGINT 

ANYNUMERIC:  SMALLINT, INTEGER, BIGINT, REAL, FLOAT, NUMERIC 
Column  Type  Default  Description 

id  ANYINTEGER 
Identifier of the edge.  
source  ANYINTEGER 
Identifier of the first end point vertex of the edge.  
target  ANYINTEGER 
Identifier of the second end point vertex of the edge.  
cost  ANYNUMERICAL 
Weight of the edge (source, target)


reverse_cost  ANYNUMERICAL 
1  Weight of the edge (target, source),

Where:
ANYINTEGER:  SMALLINT, INTEGER, BIGINT 

ANYNUMERICAL:  SMALLINT, INTEGER, BIGINT, REAL, FLOAT 
Returns SET OF (seq, depth, start_vid, node, edge, cost, agg_cost)
Column  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 . 
Indices and tables