pgr_astar - Deprecated Signature¶
Warning
This function signature is deprecated!!!
- That means it has been replaced by new signature(s)
- This signature is no longer supported, and may be removed from future versions.
- All code that use this function signature should be converted to use its replacement pgr_aStar.
Name¶
pgr_astar — Returns the shortest path using A* algorithm.
Synopsis¶
The A* (pronounced “A Star”) algorithm is based on Dijkstra’s algorithm with a heuristic that allow it to solve most shortest path problems by evaluation only a sub-set of the overall graph. Returns a set of pgr_costResult (seq, id1, id2, cost) rows, that make up a path.
pgr_costResult[] pgr_astar(sql text, source integer, target integer,
directed boolean, has_rcost boolean);
Description¶
sql: | a SQL query, which should return a set of rows with the following columns: SELECT id, source, target, cost, x1, y1, x2, y2 [,reverse_cost] FROM edge_table
|
||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
source: | int4 id of the start point |
||||||||||||||||||
target: | int4 id of the end point |
||||||||||||||||||
directed: | true if the graph is directed |
||||||||||||||||||
has_rcost: | if true, the reverse_cost column of the SQL generated set of rows will be used for the cost of the traversal of the edge in the opposite direction. |
Returns set of pgr_costResult[]:
seq: | row sequence |
---|---|
id1: | node ID |
id2: | edge ID (-1 for the last row) |
cost: | cost to traverse from id1 using id2 |
History
- Renamed in version 2.0.0
Examples¶
- Without reverse_cost
SELECT * FROM pgr_AStar(
'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, x1, y1, x2, y2
FROM edge_table',
4, 1, false, false);
NOTICE: Deprecated signature of function pgr_astar
seq | id1 | id2 | cost
-----+-----+-----+------
0 | 4 | 16 | 1
1 | 9 | 9 | 1
2 | 6 | 8 | 1
3 | 5 | 4 | 1
4 | 2 | 1 | 1
5 | 1 | -1 | 0
(6 rows)
- With reverse_cost
SELECT * FROM pgr_AStar(
'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost, x1, y1, x2, y2, reverse_cost
FROM edge_table ',
4, 1, true, true);
NOTICE: Deprecated signature of function pgr_astar
seq | id1 | id2 | cost
-----+-----+-----+------
0 | 4 | 3 | 1
1 | 3 | 2 | 1
2 | 2 | 1 | 1
3 | 1 | -1 | 0
(4 rows)
The queries use the Sample Data network.