pgr_drivingDistance¶
pgr_drivingDistance
- Devuelve la distancia de manejo desde un nodo de inicio.
Disponibilidad
Versión 2.1.0:
Cambio de firma pgr_drivingDistance(single vertex)
Nuevo Oficial pgr_drivingDistance(multiple vertices)
Versión 2.0.0:
Oficial pgr_drivingDistance(single vertex)
Descripción¶
Usando el algoritmo Dijkstra, se extraen todos los nodos que tienen costes menores o iguales al valor distance
. Los bordes extraídos se ajustarán al árbol de expansión correspondiente.
Firmas¶
Resumen
pgr_drivingDistance(edges_sql, start_vid, distance [, directed])
pgr_drivingDistance(edges_sql, start_vids, distance [, directed] [, equicost])
RETURNS SET OF (seq, [start_vid,] node, edge, cost, agg_cost)
Uso de valores predeterminados
pgr_drivingDistance(edges_sql, start_vid, distance)
RETURNS SET OF (seq, node, edge, cost, agg_cost)
- Ejemplo
TBD
Vértice Único¶
pgr_drivingDistance(edges_sql, start_vid, distance [, directed])
RETURNS SET OF (seq, node, edge, cost, agg_cost)
- Ejemplo
TBD
Múltiples Vértices¶
pgr_drivingDistance(edges_sql, start_vids, distance, [, directed] [, equicost])
RETURNS SET OF (seq, start_vid, node, edge, cost, agg_cost)
- Ejemplo
TBD
Parámetros¶
Columna |
Tipo |
Descripción |
---|---|---|
edges_sql |
|
Consulta SQL como se describió anteriormente. |
start_vid |
|
Identificador del vértice inicial. |
start_vids |
|
Arreglo de identificadores de los vértices iniciales. |
distancia |
|
Límite superior para la inclusión del nodo en el resultado. |
dirigido |
|
(opcional). En caso de |
equicost |
|
(opcional). En caso de |
Consulta interna¶
Columna |
Tipo |
Valores predeterminados |
Descripción |
---|---|---|---|
id |
|
Identificador de la arista. |
|
origen |
|
Identificador del primer punto final en el vértice de la arista. |
|
objetivo |
|
Identificador del segundo punto final en el vértice de la arista. |
|
cost |
|
Peso de la arista (source, target)
|
|
reverse_cost |
|
-1 |
Peso de la arista (target, source),
|
Donde:
- ANY-INTEGER
SMALLINT, INTEGER, BIGINT
- ANY-NUMERICAL
SMALLINT, INTEGER, BIGINT, REAL, FLOAT
Columnas de Resultados¶
Devuelve el conjunto (seq [, start_v], node, edge, cost, agg_cost)
Columna |
Tipo |
Descripción |
---|---|---|
seq |
|
Valor secuencial a partir de 1. |
start_vid |
|
Identificador del vértice inicial. |
nodo |
|
Identificador del nodo en la ruta dentro de los límites de |
arista |
|
Identificador del borde utilizado para llegar a |
cost |
|
Costo para atravesar |
agg_cost |
|
Costo agregado de |
Ejemplos Adicionales¶
- Ejemplo
Para consultas marcadas como
directed
con columnascost
andreverse_cost
Los ejemplos de esta sección utilizan lo siguiente Se utilizan redes para consultas marcadas como directed , cost y reverse_cost
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost, reverse_cost FROM edge_table',
2, 3
);
seq | node | edge | cost | agg_cost
-----+------+------+------+----------
1 | 2 | -1 | 0 | 0
2 | 1 | 1 | 1 | 1
3 | 5 | 4 | 1 | 1
4 | 6 | 8 | 1 | 2
5 | 8 | 7 | 1 | 2
6 | 10 | 10 | 1 | 2
7 | 7 | 6 | 1 | 3
8 | 9 | 9 | 1 | 3
9 | 11 | 12 | 1 | 3
10 | 13 | 14 | 1 | 3
(10 rows)
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost, reverse_cost FROM edge_table',
13, 3
);
seq | node | edge | cost | agg_cost
-----+------+------+------+----------
1 | 13 | -1 | 0 | 0
2 | 10 | 14 | 1 | 1
3 | 5 | 10 | 1 | 2
4 | 11 | 12 | 1 | 2
5 | 2 | 4 | 1 | 3
6 | 6 | 8 | 1 | 3
7 | 8 | 7 | 1 | 3
8 | 12 | 13 | 1 | 3
(8 rows)
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost, reverse_cost FROM edge_table',
array[2,13], 3
);
seq | from_v | node | edge | cost | agg_cost
-----+--------+------+------+------+----------
1 | 2 | 2 | -1 | 0 | 0
2 | 2 | 1 | 1 | 1 | 1
3 | 2 | 5 | 4 | 1 | 1
4 | 2 | 6 | 8 | 1 | 2
5 | 2 | 8 | 7 | 1 | 2
6 | 2 | 10 | 10 | 1 | 2
7 | 2 | 7 | 6 | 1 | 3
8 | 2 | 9 | 9 | 1 | 3
9 | 2 | 11 | 12 | 1 | 3
10 | 2 | 13 | 14 | 1 | 3
11 | 13 | 13 | -1 | 0 | 0
12 | 13 | 10 | 14 | 1 | 1
13 | 13 | 5 | 10 | 1 | 2
14 | 13 | 11 | 12 | 1 | 2
15 | 13 | 2 | 4 | 1 | 3
16 | 13 | 6 | 8 | 1 | 3
17 | 13 | 8 | 7 | 1 | 3
18 | 13 | 12 | 13 | 1 | 3
(18 rows)
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost, reverse_cost FROM edge_table',
array[2,13], 3, equicost:=true
);
seq | from_v | node | edge | cost | agg_cost
-----+--------+------+------+------+----------
1 | 2 | 2 | -1 | 0 | 0
2 | 2 | 1 | 1 | 1 | 1
3 | 2 | 5 | 4 | 1 | 1
4 | 2 | 6 | 8 | 1 | 2
5 | 2 | 8 | 7 | 1 | 2
6 | 2 | 7 | 6 | 1 | 3
7 | 2 | 9 | 9 | 1 | 3
8 | 13 | 13 | -1 | 0 | 0
9 | 13 | 10 | 14 | 1 | 1
10 | 13 | 11 | 12 | 1 | 2
11 | 13 | 12 | 13 | 1 | 3
(11 rows)
- Ejemplo
Para consultas marcadas como
undirected
con columnascost
yreverse_cost
Los ejemplos de esta sección utilizan lo siguiente Se utiliza la red para consultas marcadas como undirected , cost y reverse_cost
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost, reverse_cost FROM edge_table',
2, 3, false
);
seq | node | edge | cost | agg_cost
-----+------+------+------+----------
1 | 2 | -1 | 0 | 0
2 | 1 | 1 | 1 | 1
3 | 3 | 2 | 1 | 1
4 | 5 | 4 | 1 | 1
5 | 4 | 3 | 1 | 2
6 | 6 | 8 | 1 | 2
7 | 8 | 7 | 1 | 2
8 | 10 | 10 | 1 | 2
9 | 7 | 6 | 1 | 3
10 | 9 | 16 | 1 | 3
11 | 11 | 12 | 1 | 3
12 | 13 | 14 | 1 | 3
(12 rows)
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost, reverse_cost FROM edge_table',
13, 3, false
);
seq | node | edge | cost | agg_cost
-----+------+------+------+----------
1 | 13 | -1 | 0 | 0
2 | 10 | 14 | 1 | 1
3 | 5 | 10 | 1 | 2
4 | 11 | 12 | 1 | 2
5 | 2 | 4 | 1 | 3
6 | 6 | 8 | 1 | 3
7 | 8 | 7 | 1 | 3
8 | 12 | 13 | 1 | 3
(8 rows)
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost, reverse_cost FROM edge_table',
array[2,13], 3, false
);
seq | from_v | node | edge | cost | agg_cost
-----+--------+------+------+------+----------
1 | 2 | 2 | -1 | 0 | 0
2 | 2 | 1 | 1 | 1 | 1
3 | 2 | 3 | 2 | 1 | 1
4 | 2 | 5 | 4 | 1 | 1
5 | 2 | 4 | 3 | 1 | 2
6 | 2 | 6 | 8 | 1 | 2
7 | 2 | 8 | 7 | 1 | 2
8 | 2 | 10 | 10 | 1 | 2
9 | 2 | 7 | 6 | 1 | 3
10 | 2 | 9 | 16 | 1 | 3
11 | 2 | 11 | 12 | 1 | 3
12 | 2 | 13 | 14 | 1 | 3
13 | 13 | 13 | -1 | 0 | 0
14 | 13 | 10 | 14 | 1 | 1
15 | 13 | 5 | 10 | 1 | 2
16 | 13 | 11 | 12 | 1 | 2
17 | 13 | 2 | 4 | 1 | 3
18 | 13 | 6 | 8 | 1 | 3
19 | 13 | 8 | 7 | 1 | 3
20 | 13 | 12 | 13 | 1 | 3
(20 rows)
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost, reverse_cost FROM edge_table',
array[2,13], 3, false, equicost:=true
);
seq | from_v | node | edge | cost | agg_cost
-----+--------+------+------+------+----------
1 | 2 | 2 | -1 | 0 | 0
2 | 2 | 1 | 1 | 1 | 1
3 | 2 | 3 | 2 | 1 | 1
4 | 2 | 5 | 4 | 1 | 1
5 | 2 | 4 | 3 | 1 | 2
6 | 2 | 6 | 8 | 1 | 2
7 | 2 | 8 | 7 | 1 | 2
8 | 2 | 7 | 6 | 1 | 3
9 | 2 | 9 | 16 | 1 | 3
10 | 13 | 13 | -1 | 0 | 0
11 | 13 | 10 | 14 | 1 | 1
12 | 13 | 11 | 12 | 1 | 2
13 | 13 | 12 | 13 | 1 | 3
(13 rows)
- Ejemplo
Para consultas marcadas como
directed
con columna``cost``
Los ejemplos de esta sección utilizan lo siguiente Red para consultas marcadas como directed y sólo se utiliza la columna cost
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost FROM edge_table',
2, 3
);
seq | node | edge | cost | agg_cost
-----+------+------+------+----------
1 | 2 | -1 | 0 | 0
2 | 5 | 4 | 1 | 1
3 | 6 | 8 | 1 | 2
4 | 10 | 10 | 1 | 2
5 | 9 | 9 | 1 | 3
6 | 11 | 11 | 1 | 3
7 | 13 | 14 | 1 | 3
(7 rows)
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost FROM edge_table',
13, 3
);
seq | node | edge | cost | agg_cost
-----+------+------+------+----------
1 | 13 | -1 | 0 | 0
(1 row)
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost FROM edge_table',
array[2,13], 3
);
seq | from_v | node | edge | cost | agg_cost
-----+--------+------+------+------+----------
1 | 2 | 2 | -1 | 0 | 0
2 | 2 | 5 | 4 | 1 | 1
3 | 2 | 6 | 8 | 1 | 2
4 | 2 | 10 | 10 | 1 | 2
5 | 2 | 9 | 9 | 1 | 3
6 | 2 | 11 | 11 | 1 | 3
7 | 2 | 13 | 14 | 1 | 3
8 | 13 | 13 | -1 | 0 | 0
(8 rows)
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost FROM edge_table',
array[2,13], 3, equicost:=true
);
seq | from_v | node | edge | cost | agg_cost
-----+--------+------+------+------+----------
1 | 2 | 2 | -1 | 0 | 0
2 | 2 | 5 | 4 | 1 | 1
3 | 2 | 6 | 8 | 1 | 2
4 | 2 | 10 | 10 | 1 | 2
5 | 2 | 9 | 9 | 1 | 3
6 | 2 | 11 | 11 | 1 | 3
7 | 13 | 13 | -1 | 0 | 0
(7 rows)
- Ejemplo
Para consultas marcadas como
undirected
con columnacost
Los ejemplos de esta sección utilizan lo siguiente Red para consultas marcadas como undirected y solo se utiliza la columna cost
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost FROM edge_table',
2, 3, false
);
seq | node | edge | cost | agg_cost
-----+------+------+------+----------
1 | 2 | -1 | 0 | 0
2 | 1 | 1 | 1 | 1
3 | 5 | 4 | 1 | 1
4 | 6 | 8 | 1 | 2
5 | 8 | 7 | 1 | 2
6 | 10 | 10 | 1 | 2
7 | 3 | 5 | 1 | 3
8 | 7 | 6 | 1 | 3
9 | 9 | 9 | 1 | 3
10 | 11 | 12 | 1 | 3
11 | 13 | 14 | 1 | 3
(11 rows)
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost FROM edge_table',
13, 3, false
);
seq | node | edge | cost | agg_cost
-----+------+------+------+----------
1 | 13 | -1 | 0 | 0
2 | 10 | 14 | 1 | 1
3 | 5 | 10 | 1 | 2
4 | 11 | 12 | 1 | 2
5 | 2 | 4 | 1 | 3
6 | 6 | 8 | 1 | 3
7 | 8 | 7 | 1 | 3
8 | 12 | 13 | 1 | 3
(8 rows)
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost FROM edge_table',
array[2,13], 3, false
);
seq | from_v | node | edge | cost | agg_cost
-----+--------+------+------+------+----------
1 | 2 | 2 | -1 | 0 | 0
2 | 2 | 1 | 1 | 1 | 1
3 | 2 | 5 | 4 | 1 | 1
4 | 2 | 6 | 8 | 1 | 2
5 | 2 | 8 | 7 | 1 | 2
6 | 2 | 10 | 10 | 1 | 2
7 | 2 | 3 | 5 | 1 | 3
8 | 2 | 7 | 6 | 1 | 3
9 | 2 | 9 | 9 | 1 | 3
10 | 2 | 11 | 12 | 1 | 3
11 | 2 | 13 | 14 | 1 | 3
12 | 13 | 13 | -1 | 0 | 0
13 | 13 | 10 | 14 | 1 | 1
14 | 13 | 5 | 10 | 1 | 2
15 | 13 | 11 | 12 | 1 | 2
16 | 13 | 2 | 4 | 1 | 3
17 | 13 | 6 | 8 | 1 | 3
18 | 13 | 8 | 7 | 1 | 3
19 | 13 | 12 | 13 | 1 | 3
(19 rows)
SELECT * FROM pgr_drivingDistance(
'SELECT id, source, target, cost FROM edge_table',
array[2,13], 3, false, equicost:=true
);
seq | from_v | node | edge | cost | agg_cost
-----+--------+------+------+------+----------
1 | 2 | 2 | -1 | 0 | 0
2 | 2 | 1 | 1 | 1 | 1
3 | 2 | 5 | 4 | 1 | 1
4 | 2 | 6 | 8 | 1 | 2
5 | 2 | 8 | 7 | 1 | 2
6 | 2 | 3 | 5 | 1 | 3
7 | 2 | 7 | 6 | 1 | 3
8 | 2 | 9 | 9 | 1 | 3
9 | 13 | 13 | -1 | 0 | 0
10 | 13 | 10 | 14 | 1 | 1
11 | 13 | 11 | 12 | 1 | 2
12 | 13 | 12 | 13 | 1 | 3
(12 rows)
Ver también¶
pgr_alphaShape - Cálculo de Alpha Shape
Red Datos Muestra .
Índices y tablas