pgr_bdAstarCostMatrix - pgRouting Manual (3.4)
pgr_bdAstarCostMatrix
pgr_bdAstarCostMatrix
- Calculates the a cost matrix using
pgr_aStar
.
Availability
-
Version 3.0.0
-
Official function
-
-
Version 2.5.0
-
New proposed function
-
Description
The main characteristics are:
-
Using internaly the pgr_bdAstar algorithm
-
Returns a cost matrix.
-
No ordering is performed
-
let v and u are nodes on the graph:
-
when there is no path from v to u :
-
no corresponding row is returned
-
cost from v to u is \(\inf\)
-
-
when \(v = u\) then
-
no corresponding row is returned
-
cost from v to u is \(0\)
-
-
-
When the graph is undirected the cost matrix is symmetric
Signatures
Summary
[directed,
heuristic,
factor,
epsilon]
(start_vid,
end_vid,
agg_cost)
- Example :
-
Symmetric cost matrix for vertices \(\{5, 6, 10, 15\}\) on an undirected graph using heuristic \(2\)
SELECT * FROM pgr_bdAstarCostMatrix(
'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges',
(SELECT array_agg(id) FROM vertices WHERE id IN (5, 6, 10, 15)),
directed => false, heuristic => 2
);
start_vid end_vid agg_cost
-----------+---------+----------
5 6 1
5 10 2
5 15 3
6 5 1
6 10 1
6 15 2
10 5 2
10 6 1
10 15 1
15 5 3
15 6 2
15 10 1
(12 rows)
Parameters
Column |
Type |
Description |
---|---|---|
|
Edges SQL as described below |
|
start vids |
|
Array of identifiers of starting vertices. |
Optional parameters
Column |
Type |
Default |
Description |
---|---|---|---|
|
|
|
|
aStar optional Parameters
Parameter |
Type |
Default |
Description |
---|---|---|---|
|
|
5 |
Heuristic number. Current valid values 0~5.
|
|
|
|
For units manipulation. \(factor > 0\) . |
|
|
|
For less restricted results. \(epsilon >= 1\) . |
See heuristics available and factor handling.
Inner Queries
Edges SQL
Parameter |
Type |
Default |
Description |
---|---|---|---|
|
ANY-INTEGER |
Identifier of the edge. |
|
|
ANY-INTEGER |
Identifier of the first end point vertex of the edge. |
|
|
ANY-INTEGER |
Identifier of the second end point vertex of the edge. |
|
|
ANY-NUMERICAL |
Weight of the edge (
|
|
|
ANY-NUMERICAL |
-1 |
Weight of the edge (
|
|
ANY-NUMERICAL |
X coordinate of
|
|
|
ANY-NUMERICAL |
Y coordinate of
|
|
|
ANY-NUMERICAL |
X coordinate of
|
|
|
ANY-NUMERICAL |
Y coordinate of
|
Where:
- ANY-INTEGER :
-
SMALLINT
,INTEGER
,BIGINT
- ANY-NUMERICAL :
-
SMALLINT
,INTEGER
,BIGINT
,REAL
,FLOAT
Result Columns
Set of
(start_vid,
end_vid,
agg_cost)
Column |
Type |
Description |
---|---|---|
|
|
Identifier of the starting vertex. |
|
|
Identifier of the ending vertex. |
|
|
Aggregate cost from
|
Additional Examples
- Example :
-
Use with pgr_TSP
SELECT * FROM pgr_TSP(
$$
SELECT * FROM pgr_bdAstarCostMatrix(
'SELECT id, source, target, cost, reverse_cost, x1, y1, x2, y2 FROM edges',
(SELECT array_agg(id) FROM vertices WHERE id IN (5, 6, 10, 15)),
directed=> false, heuristic => 2
)
$$
);
NOTICE: pgr_TSP no longer solving with simulated annaeling
HINT: Ignoring annaeling parameters
seq node cost agg_cost
-----+------+------+----------
1 5 0 0
2 6 1 1
3 10 1 2
4 15 1 3
5 5 3 6
(5 rows)
See Also
Indices and tables