Skip to content

Instantly share code, notes, and snippets.

@vidhan13j07
Last active October 18, 2017 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vidhan13j07/0eea1639de7be70a12a8eef626f511e2 to your computer and use it in GitHub Desktop.
Save vidhan13j07/0eea1639de7be70a12a8eef626f511e2 to your computer and use it in GitHub Desktop.
This gist contains the sample queries used in the LineGraph presentation: https://docs.google.com/presentation/d/1TTSvKvF-a6P1WD_Aezc541vUHsoCUAQXMOfnBX3orcU/edit
DROP TABLE IF EXISTS edge_table;
CREATE TABLE edge_table (
id BIGSERIAL,
source BIGINT,
target BIGINT,
cost FLOAT,
reverse_cost FLOAT
);
INSERT INTO edge_table (
source, target,
cost, reverse_cost) VALUES
(5, 6, 1, 1), (2, 5, 1, 1),
(3, 6, 1, -1), (3, 2, 1, -1);
SELECT * FROM pgr_lineGraph (
'SELECT id, source, target, cost, reverse_cost FROM edge_table');
/*************OUTPUT**********************************
seq | source | target | cost | reverse_cost
-----+--------+--------+------+--------------
1 | 2 | 1 | 1 | 1
2 | 3 | -1 | 1 | -1
3 | 4 | 2 | 1 | -1
(3 rows)
*************************************/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment