Commit f8f17f2a authored by Andrew McDonnell's avatar Andrew McDonnell

Fixes for dijkstra weights and added regression tests for several other issues

parents 0febfba5 db048e78
......@@ -46,6 +46,22 @@ NULL 12 10 1 NULL NULL
SELECT count(*) FROM graph;
count(*)
13
# Return all edges when latch is NULL
SELECT * FROM graph where latch is NULL;
latch origid destid weight seq linkid
NULL 1 2 1 NULL NULL
NULL 2 1 1 NULL NULL
NULL 1 3 1 NULL NULL
NULL 3 1 1 NULL NULL
NULL 3 4 1 NULL NULL
NULL 4 3 1 NULL NULL
NULL 5 6 1 NULL NULL
NULL 6 5 1 NULL NULL
NULL 5 7 1 NULL NULL
NULL 9 9 1 NULL NULL
NULL 10 11 1 NULL NULL
NULL 11 12 1 NULL NULL
NULL 12 10 1 NULL NULL
# Return all vertices, and subsets of vertices
SELECT * FROM graph where latch='';
latch origid destid weight seq linkid
......@@ -1018,37 +1034,37 @@ dijkstras 12 11 1 1 10
dijkstras 12 11 1 2 11
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
latch origid destid weight seq linkid
dijkstras 1 NULL 0 4 4
dijkstras 1 NULL 0 3 3
dijkstras 1 NULL 0 2 2
dijkstras 1 NULL 2 4 4
dijkstras 1 NULL 1 3 3
dijkstras 1 NULL 1 2 2
dijkstras 1 NULL 0 1 1
SELECT * FROM graph WHERE latch='dijkstras' AND origid=2;
latch origid destid weight seq linkid
dijkstras 2 NULL 0 4 4
dijkstras 2 NULL 0 3 3
dijkstras 2 NULL 0 2 1
dijkstras 2 NULL 3 4 4
dijkstras 2 NULL 2 3 3
dijkstras 2 NULL 1 2 1
dijkstras 2 NULL 0 1 2
SELECT * FROM graph WHERE latch='dijkstras' AND origid=3;
latch origid destid weight seq linkid
dijkstras 3 NULL 0 4 2
dijkstras 3 NULL 0 3 4
dijkstras 3 NULL 0 2 1
dijkstras 3 NULL 2 4 2
dijkstras 3 NULL 1 3 4
dijkstras 3 NULL 1 2 1
dijkstras 3 NULL 0 1 3
SELECT * FROM graph WHERE latch='dijkstras' AND origid=4;
latch origid destid weight seq linkid
dijkstras 4 NULL 0 4 2
dijkstras 4 NULL 0 3 1
dijkstras 4 NULL 0 2 3
dijkstras 4 NULL 3 4 2
dijkstras 4 NULL 2 3 1
dijkstras 4 NULL 1 2 3
dijkstras 4 NULL 0 1 4
SELECT * FROM graph WHERE latch='dijkstras' AND origid=5;
latch origid destid weight seq linkid
dijkstras 5 NULL 0 3 7
dijkstras 5 NULL 0 2 6
dijkstras 5 NULL 1 3 7
dijkstras 5 NULL 1 2 6
dijkstras 5 NULL 0 1 5
SELECT * FROM graph WHERE latch='dijkstras' AND origid=6;
latch origid destid weight seq linkid
dijkstras 6 NULL 0 3 7
dijkstras 6 NULL 0 2 5
dijkstras 6 NULL 2 3 7
dijkstras 6 NULL 1 2 5
dijkstras 6 NULL 0 1 6
SELECT * FROM graph WHERE latch='dijkstras' AND origid=7;
latch origid destid weight seq linkid
......@@ -1060,18 +1076,18 @@ latch origid destid weight seq linkid
dijkstras 9 NULL 0 1 9
SELECT * FROM graph WHERE latch='dijkstras' AND origid=10;
latch origid destid weight seq linkid
dijkstras 10 NULL 0 3 12
dijkstras 10 NULL 0 2 11
dijkstras 10 NULL 2 3 12
dijkstras 10 NULL 1 2 11
dijkstras 10 NULL 0 1 10
SELECT * FROM graph WHERE latch='dijkstras' AND origid=11;
latch origid destid weight seq linkid
dijkstras 11 NULL 0 3 10
dijkstras 11 NULL 0 2 12
dijkstras 11 NULL 2 3 10
dijkstras 11 NULL 1 2 12
dijkstras 11 NULL 0 1 11
SELECT * FROM graph WHERE latch='dijkstras' AND origid=12;
latch origid destid weight seq linkid
dijkstras 12 NULL 0 3 11
dijkstras 12 NULL 0 2 10
dijkstras 12 NULL 2 3 11
dijkstras 12 NULL 1 2 10
dijkstras 12 NULL 0 1 12
SELECT * FROM graph WHERE latch='dijkstras' AND origid=666;
latch origid destid weight seq linkid
......@@ -1193,37 +1209,37 @@ latch origid destid weight seq linkid
1 12 11 1 2 11
SELECT * FROM graph WHERE latch='1' AND origid=1;
latch origid destid weight seq linkid
1 1 NULL 0 4 4
1 1 NULL 0 3 3
1 1 NULL 0 2 2
1 1 NULL 2 4 4
1 1 NULL 1 3 3
1 1 NULL 1 2 2
1 1 NULL 0 1 1
SELECT * FROM graph WHERE latch='1' AND origid=2;
latch origid destid weight seq linkid
1 2 NULL 0 4 4
1 2 NULL 0 3 3
1 2 NULL 0 2 1
1 2 NULL 3 4 4
1 2 NULL 2 3 3
1 2 NULL 1 2 1
1 2 NULL 0 1 2
SELECT * FROM graph WHERE latch='1' AND origid=3;
latch origid destid weight seq linkid
1 3 NULL 0 4 2
1 3 NULL 0 3 4
1 3 NULL 0 2 1
1 3 NULL 2 4 2
1 3 NULL 1 3 4
1 3 NULL 1 2 1
1 3 NULL 0 1 3
SELECT * FROM graph WHERE latch='1' AND origid=4;
latch origid destid weight seq linkid
1 4 NULL 0 4 2
1 4 NULL 0 3 1
1 4 NULL 0 2 3
1 4 NULL 3 4 2
1 4 NULL 2 3 1
1 4 NULL 1 2 3
1 4 NULL 0 1 4
SELECT * FROM graph WHERE latch='1' AND origid=5;
latch origid destid weight seq linkid
1 5 NULL 0 3 7
1 5 NULL 0 2 6
1 5 NULL 1 3 7
1 5 NULL 1 2 6
1 5 NULL 0 1 5
SELECT * FROM graph WHERE latch='1' AND origid=6;
latch origid destid weight seq linkid
1 6 NULL 0 3 7
1 6 NULL 0 2 5
1 6 NULL 2 3 7
1 6 NULL 1 2 5
1 6 NULL 0 1 6
SELECT * FROM graph WHERE latch='1' AND origid=7;
latch origid destid weight seq linkid
......@@ -1235,18 +1251,18 @@ latch origid destid weight seq linkid
1 9 NULL 0 1 9
SELECT * FROM graph WHERE latch='1' AND origid=10;
latch origid destid weight seq linkid
1 10 NULL 0 3 12
1 10 NULL 0 2 11
1 10 NULL 2 3 12
1 10 NULL 1 2 11
1 10 NULL 0 1 10
SELECT * FROM graph WHERE latch='1' AND origid=11;
latch origid destid weight seq linkid
1 11 NULL 0 3 10
1 11 NULL 0 2 12
1 11 NULL 2 3 10
1 11 NULL 1 2 12
1 11 NULL 0 1 11
SELECT * FROM graph WHERE latch='1' AND origid=12;
latch origid destid weight seq linkid
1 12 NULL 0 3 11
1 12 NULL 0 2 10
1 12 NULL 2 3 11
1 12 NULL 1 2 10
1 12 NULL 0 1 12
SELECT * FROM graph WHERE latch='1' AND origid=666;
latch origid destid weight seq linkid
......@@ -1331,14 +1347,14 @@ dijkstras 10 13 1 1 11
dijkstras 10 13 1 2 13
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
latch origid destid weight seq linkid
dijkstras 1 NULL 0 4 4
dijkstras 1 NULL 0 3 3
dijkstras 1 NULL 0 2 2
dijkstras 1 NULL 2 4 4
dijkstras 1 NULL 1 3 3
dijkstras 1 NULL 1 2 2
dijkstras 1 NULL 0 1 1
INSERT INTO graph_base(from_id, to_id) VALUES (21,22);
SELECT * FROM graph WHERE latch='dijkstras' AND origid=21;
latch origid destid weight seq linkid
dijkstras 21 NULL 0 2 22
dijkstras 21 NULL 1 2 22
dijkstras 21 NULL 0 1 21
SELECT * FROM graph WHERE latch='dijkstras' AND origid=22;
latch origid destid weight seq linkid
......@@ -1346,29 +1362,29 @@ dijkstras 22 NULL 0 1 22
INSERT INTO graph_base(from_id, to_id) VALUES (4,17);
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
latch origid destid weight seq linkid
dijkstras 1 NULL 0 5 17
dijkstras 1 NULL 0 4 4
dijkstras 1 NULL 0 3 3
dijkstras 1 NULL 0 2 2
dijkstras 1 NULL 3 5 17
dijkstras 1 NULL 2 4 4
dijkstras 1 NULL 1 3 3
dijkstras 1 NULL 1 2 2
dijkstras 1 NULL 0 1 1
INSERT INTO graph_base(from_id, to_id) VALUES (4,16);
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
latch origid destid weight seq linkid
dijkstras 1 NULL 0 6 17
dijkstras 1 NULL 0 5 16
dijkstras 1 NULL 0 4 4
dijkstras 1 NULL 0 3 3
dijkstras 1 NULL 0 2 2
dijkstras 1 NULL 3 6 17
dijkstras 1 NULL 3 5 16
dijkstras 1 NULL 2 4 4
dijkstras 1 NULL 1 3 3
dijkstras 1 NULL 1 2 2
dijkstras 1 NULL 0 1 1
INSERT INTO graph_base(from_id, to_id) VALUES (17,18);
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
latch origid destid weight seq linkid
dijkstras 1 NULL 0 7 18
dijkstras 1 NULL 0 6 17
dijkstras 1 NULL 0 5 16
dijkstras 1 NULL 0 4 4
dijkstras 1 NULL 0 3 3
dijkstras 1 NULL 0 2 2
dijkstras 1 NULL 4 7 18
dijkstras 1 NULL 3 6 17
dijkstras 1 NULL 3 5 16
dijkstras 1 NULL 2 4 4
dijkstras 1 NULL 1 3 3
dijkstras 1 NULL 1 2 2
dijkstras 1 NULL 0 1 1
SELECT * FROM graph WHERE latch='dijkstras' AND destid=1;
latch origid destid weight seq linkid
......
This diff is collapsed.
DROP TABLE IF EXISTS graph_base;
DROP TABLE IF EXISTS graph;
CREATE TABLE graph_base (
from_id INT UNSIGNED NOT NULL,
to_id INT UNSIGNED NOT NULL,
PRIMARY KEY (from_id,to_id),
INDEX (to_id)
) ENGINE=MyISAM;
CREATE TABLE graph (
latch VARCHAR(32) NULL,
origid BIGINT UNSIGNED NULL,
destid BIGINT UNSIGNED NULL,
weight DOUBLE NULL,
seq BIGINT UNSIGNED NULL,
linkid BIGINT UNSIGNED NULL,
KEY (latch, origid, destid) USING HASH,
KEY (latch, destid, origid) USING HASH
) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1);
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '2' AND origid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '1' AND origid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '2' AND destid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '1' AND destid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '2' AND origid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '1' AND origid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '2' AND destid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '1' AND destid = 666 and weight = 1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '' AND origid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '0' AND origid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch is NULL AND origid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '' AND destid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = '0' AND destid = 666;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch is NULL AND destid = 666;
latch origid destid weight seq linkid
DELETE FROM graph_base;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph_base;
DROP TABLE graph;
# Regression test for https://bugs.launchpad.net/oqgraph/+bug/1196020
#-- bug where select blah with origid = X where X does not exist, returns a row
#-- bug where select blah with destid = X where X does not exist, returns a row
--disable_warnings
DROP TABLE IF EXISTS graph_base;
DROP TABLE IF EXISTS graph;
--enable_warnings
# Create the backing store
CREATE TABLE graph_base (
from_id INT UNSIGNED NOT NULL,
to_id INT UNSIGNED NOT NULL,
PRIMARY KEY (from_id,to_id),
INDEX (to_id)
) ENGINE=MyISAM;
CREATE TABLE graph (
latch VARCHAR(32) NULL,
origid BIGINT UNSIGNED NULL,
destid BIGINT UNSIGNED NULL,
weight DOUBLE NULL,
seq BIGINT UNSIGNED NULL,
linkid BIGINT UNSIGNED NULL,
KEY (latch, origid, destid) USING HASH,
KEY (latch, destid, origid) USING HASH
) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1);
# All the following should return no result because no vertex 666 exists in the graph
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 666;
SELECT * FROM graph WHERE latch = '2' AND origid = 666;
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 666;
SELECT * FROM graph WHERE latch = '1' AND origid = 666;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 666;
SELECT * FROM graph WHERE latch = '2' AND destid = 666;
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 666;
SELECT * FROM graph WHERE latch = '1' AND destid = 666;
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 666 and weight = 1;
SELECT * FROM graph WHERE latch = '2' AND origid = 666 and weight = 1;
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 666 and weight = 1;
SELECT * FROM graph WHERE latch = '1' AND origid = 666 and weight = 1;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 666 and weight = 1;
SELECT * FROM graph WHERE latch = '2' AND destid = 666 and weight = 1;
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 666 and weight = 1;
SELECT * FROM graph WHERE latch = '1' AND destid = 666 and weight = 1;
# Sanity check for no-search
SELECT * FROM graph WHERE latch = '' AND origid = 666;
SELECT * FROM graph WHERE latch = '0' AND origid = 666;
SELECT * FROM graph WHERE latch is NULL AND origid = 666;
SELECT * FROM graph WHERE latch = '' AND destid = 666;
SELECT * FROM graph WHERE latch = '0' AND destid = 666;
SELECT * FROM graph WHERE latch is NULL AND destid = 666;
DELETE FROM graph_base;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph_base;
DROP TABLE graph;
DROP TABLE IF EXISTS graph_base;
DROP TABLE IF EXISTS graph;
CREATE TABLE graph_base (
from_id INT UNSIGNED NOT NULL,
to_id INT UNSIGNED NOT NULL,
PRIMARY KEY (from_id,to_id),
INDEX (to_id)
) ENGINE=MyISAM;
CREATE TABLE graph (
latch VARCHAR(32) NULL,
origid BIGINT UNSIGNED NULL,
destid BIGINT UNSIGNED NULL,
weight DOUBLE NULL,
seq BIGINT UNSIGNED NULL,
linkid BIGINT UNSIGNED NULL,
KEY (latch, origid, destid) USING HASH,
KEY (latch, destid, origid) USING HASH
) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1);
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 1;
latch origid destid weight seq linkid
breadth_first NULL 1 1 2 2
breadth_first NULL 1 0 1 1
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 2;
latch origid destid weight seq linkid
breadth_first NULL 2 1 2 1
breadth_first NULL 2 0 1 2
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1;
latch origid destid weight seq linkid
breadth_first 1 NULL 1 2 2
breadth_first 1 NULL 0 1 1
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 2;
latch origid destid weight seq linkid
breadth_first 2 NULL 1 2 1
breadth_first 2 NULL 0 1 2
SELECT * FROM graph WHERE latch = '2' AND destid = 1;
latch origid destid weight seq linkid
2 NULL 1 1 2 2
2 NULL 1 0 1 1
SELECT * FROM graph WHERE latch = '2' AND destid = 2;
latch origid destid weight seq linkid
2 NULL 2 1 2 1
2 NULL 2 0 1 2
SELECT * FROM graph WHERE latch = '2' AND origid = 1;
latch origid destid weight seq linkid
2 1 NULL 1 2 2
2 1 NULL 0 1 1
SELECT * FROM graph WHERE latch = '2' AND origid = 2;
latch origid destid weight seq linkid
2 2 NULL 1 2 1
2 2 NULL 0 1 2
DELETE FROM graph_base;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph_base;
DROP TABLE graph;
# Regression test for https://bugs.launchpad.net/oqgraph/+bug/1196027
#-- These were returning NULL which is incorrect
#-- https://bugs.launchpad.net/oqgraph/+bug/1196027
--disable_warnings
DROP TABLE IF EXISTS graph_base;
DROP TABLE IF EXISTS graph;
--enable_warnings
# Create the backing store
CREATE TABLE graph_base (
from_id INT UNSIGNED NOT NULL,
to_id INT UNSIGNED NOT NULL,
PRIMARY KEY (from_id,to_id),
INDEX (to_id)
) ENGINE=MyISAM;
CREATE TABLE graph (
latch VARCHAR(32) NULL,
origid BIGINT UNSIGNED NULL,
destid BIGINT UNSIGNED NULL,
weight DOUBLE NULL,
seq BIGINT UNSIGNED NULL,
linkid BIGINT UNSIGNED NULL,
KEY (latch, origid, destid) USING HASH,
KEY (latch, destid, origid) USING HASH
) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1);
# All the following should return no result because no vertex 666 exists in the graph
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 1;
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 2;
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1;
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 2;
SELECT * FROM graph WHERE latch = '2' AND destid = 1;
SELECT * FROM graph WHERE latch = '2' AND destid = 2;
SELECT * FROM graph WHERE latch = '2' AND origid = 1;
SELECT * FROM graph WHERE latch = '2' AND origid = 2;
DELETE FROM graph_base;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph_base;
DROP TABLE graph;
DROP TABLE IF EXISTS graph_base;
DROP TABLE IF EXISTS graph;
CREATE TABLE graph_base (
from_id INT UNSIGNED NOT NULL,
to_id INT UNSIGNED NOT NULL,
weight FLOAT NOT NULL,
PRIMARY KEY (from_id,to_id),
INDEX (to_id)
) ENGINE=MyISAM;
CREATE TABLE graph (
latch VARCHAR(32) NULL,
origid BIGINT UNSIGNED NULL,
destid BIGINT UNSIGNED NULL,
weight DOUBLE NULL,
seq BIGINT UNSIGNED NULL,
linkid BIGINT UNSIGNED NULL,
KEY (latch, origid, destid) USING HASH,
KEY (latch, destid, origid) USING HASH
) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id', WEIGHT='weight';
INSERT INTO graph_base(from_id, to_id, weight) VALUES (1,2,16), (2,1,16);
INSERT INTO graph_base(from_id, to_id, weight) VALUES (2,3,256), (3,2,256);
INSERT INTO graph_base(from_id, to_id, weight) VALUES (3,4,65536), (4,3,65536);
INSERT INTO graph_base(from_id, to_id, weight) VALUES (2,4,768);
SELECT * FROM graph WHERE latch is NULL;
latch origid destid weight seq linkid
NULL 1 2 16 NULL NULL
NULL 2 1 16 NULL NULL
NULL 2 3 256 NULL NULL
NULL 3 2 256 NULL NULL
NULL 3 4 65536 NULL NULL
NULL 4 3 65536 NULL NULL
NULL 2 4 768 NULL NULL
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1;
latch origid destid weight seq linkid
dijkstras 1 NULL 784 4 4
dijkstras 1 NULL 272 3 3
dijkstras 1 NULL 16 2 2
dijkstras 1 NULL 0 1 1
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2;
latch origid destid weight seq linkid
dijkstras 2 NULL 768 4 4
dijkstras 2 NULL 256 3 3
dijkstras 2 NULL 16 2 1
dijkstras 2 NULL 0 1 2
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3;
latch origid destid weight seq linkid
dijkstras 3 NULL 1024 4 4
dijkstras 3 NULL 272 3 1
dijkstras 3 NULL 256 2 2
dijkstras 3 NULL 0 1 3
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 1;
latch origid destid weight seq linkid
dijkstras NULL 1 784 4 4
dijkstras NULL 1 272 3 3
dijkstras NULL 1 16 2 2
dijkstras NULL 1 0 1 1
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 2;
latch origid destid weight seq linkid
dijkstras NULL 2 768 4 4
dijkstras NULL 2 256 3 3
dijkstras NULL 2 16 2 1
dijkstras NULL 2 0 1 2
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 3;
latch origid destid weight seq linkid
dijkstras NULL 3 1024 4 4
dijkstras NULL 3 272 3 1
dijkstras NULL 3 256 2 2
dijkstras NULL 3 0 1 3
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and destid=3;
latch origid destid weight seq linkid
dijkstras 1 3 NULL 0 1
dijkstras 1 3 16 1 2
dijkstras 1 3 256 2 3
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and destid=4;
latch origid destid weight seq linkid
dijkstras 1 4 NULL 0 1
dijkstras 1 4 16 1 2
dijkstras 1 4 768 2 4
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=1;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=16;
latch origid destid weight seq linkid
dijkstras 1 NULL 16 2 2
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=16;
latch origid destid weight seq linkid
dijkstras 2 NULL 16 2 1
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=16;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=784;
latch origid destid weight seq linkid
dijkstras 1 NULL 784 4 4
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=784;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=784;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=256;
latch origid destid weight seq linkid
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=256;
latch origid destid weight seq linkid
dijkstras 2 NULL 256 3 3
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=256;
latch origid destid weight seq linkid
dijkstras 3 NULL 256 2 2
DELETE FROM graph_base;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph_base;
DROP TABLE graph;
# Regression test for https://bugs.launchpad.net/oqgraph/+bug/1196036
#-- bug with Djikstras algorithm - find reachable vertices (origid=X) returns weight=0 instead of weight=count of hops
--disable_warnings
DROP TABLE IF EXISTS graph_base;
DROP TABLE IF EXISTS graph;
--enable_warnings
# Create the backing store
CREATE TABLE graph_base (
from_id INT UNSIGNED NOT NULL,
to_id INT UNSIGNED NOT NULL,
weight FLOAT NOT NULL,
PRIMARY KEY (from_id,to_id),
INDEX (to_id)
) ENGINE=MyISAM;
CREATE TABLE graph (
latch VARCHAR(32) NULL,
origid BIGINT UNSIGNED NULL,
destid BIGINT UNSIGNED NULL,
weight DOUBLE NULL,
seq BIGINT UNSIGNED NULL,
linkid BIGINT UNSIGNED NULL,
KEY (latch, origid, destid) USING HASH,
KEY (latch, destid, origid) USING HASH
) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id', WEIGHT='weight';
INSERT INTO graph_base(from_id, to_id, weight) VALUES (1,2,16), (2,1,16);
INSERT INTO graph_base(from_id, to_id, weight) VALUES (2,3,256), (3,2,256);
INSERT INTO graph_base(from_id, to_id, weight) VALUES (3,4,65536), (4,3,65536);
INSERT INTO graph_base(from_id, to_id, weight) VALUES (2,4,768);
SELECT * FROM graph WHERE latch is NULL;
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1;
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2;
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3;
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 1;
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 2;
SELECT * FROM graph WHERE latch = 'dijkstras' AND destid = 3;
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and destid=3;
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and destid=4;
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=1; # <-- should return nothing
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=1; # <-- should return nothing
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=1; # <-- should return nothing
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=16;
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=16;
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=16; # <-- should return nothing
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=784;
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=784; # <-- should return nothing
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=784; # <-- should return nothing
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 1 and weight=256; # <-- should return nothing
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 2 and weight=256;
SELECT * FROM graph WHERE latch = 'dijkstras' AND origid = 3 and weight=256;
DELETE FROM graph_base;
FLUSH TABLES;
TRUNCATE TABLE graph_base;
DROP TABLE graph_base;
DROP TABLE graph;
......@@ -823,7 +823,8 @@ namespace open_query
EdgeWeight(),
make_dijkstra_visitor(
make_oqgraph_visit_dist(
boost::make_assoc_property_map(p), d,
boost::make_assoc_property_map(p),
boost::make_assoc_property_map(d),
static_cast<stack_cursor*>(cursor)
)
),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment