Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions nix/tests/expected/pgrouting.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
create schema v;
-- create the roads table
create table v.roads (
id serial primary key,
source integer,
target integer,
cost double precision
);
-- insert sample data into roads table
insert into v.roads (source, target, cost) values
(1, 2, 1.0),
(2, 3, 1.0),
(3, 4, 1.0),
(1, 3, 2.5),
(3, 5, 2.0);
-- create a function to use pgRouting to find the shortest path
select * from pgr_dijkstra(
'select id, source, target, cost from v.roads',
1, -- start node
4 -- end node
);
seq | path_seq | node | edge | cost | agg_cost
-----+----------+------+------+------+----------
1 | 1 | 1 | 1 | 1 | 0
2 | 2 | 2 | 2 | 1 | 1
3 | 3 | 3 | 3 | 1 | 2
4 | 4 | 4 | -1 | 0 | 3
(4 rows)

drop schema v cascade;
NOTICE: drop cascades to table v.roads
27 changes: 27 additions & 0 deletions nix/tests/sql/pgrouting.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
create schema v;

-- create the roads table
create table v.roads (
id serial primary key,
source integer,
target integer,
cost double precision
);

-- insert sample data into roads table
insert into v.roads (source, target, cost) values
(1, 2, 1.0),
(2, 3, 1.0),
(3, 4, 1.0),
(1, 3, 2.5),
(3, 5, 2.0);

-- create a function to use pgRouting to find the shortest path
select * from pgr_dijkstra(
'select id, source, target, cost from v.roads',
1, -- start node
4 -- end node
);

drop schema v cascade;

Loading