Commit e87960d3 authored by Andrew McDonnell's avatar Andrew McDonnell

Fix for spurious result when searching for non-existing vertex

parent 7644bed6
......@@ -212,7 +212,6 @@ latch origid destid weight seq linkid
breadth_first 7 NULL 0 1 7
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 8;
latch origid destid weight seq linkid
breadth_first 8 NULL 0 1 8
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 9;
latch origid destid weight seq linkid
breadth_first 9 NULL 0 1 9
......@@ -233,7 +232,6 @@ breadth_first 12 NULL 1 2 10
breadth_first 12 NULL 0 1 12
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 666;
latch origid destid weight seq linkid
breadth_first 666 NULL 0 1 666
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1 AND weight = 1;
latch origid destid weight seq linkid
breadth_first 1 NULL 1 3 3
......@@ -447,7 +445,6 @@ latch origid destid weight seq linkid
breadth_first NULL 7 0 1 7
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 8;
latch origid destid weight seq linkid
breadth_first NULL 8 0 1 8
SELECT * FROM graph WHERE latch = 'breadth_first' AND destid = 9;
latch origid destid weight seq linkid
breadth_first NULL 9 0 1 9
......@@ -607,7 +604,6 @@ latch origid destid weight seq linkid
2 7 NULL 0 1 7
SELECT * FROM graph WHERE latch = '2' AND origid = 8;
latch origid destid weight seq linkid
2 8 NULL 0 1 8
SELECT * FROM graph WHERE latch = '2' AND origid = 9;
latch origid destid weight seq linkid
2 9 NULL 0 1 9
......@@ -628,7 +624,6 @@ latch origid destid weight seq linkid
2 12 NULL 0 1 12
SELECT * FROM graph WHERE latch = '2' AND origid = 666;
latch origid destid weight seq linkid
2 666 NULL 0 1 666
SELECT * FROM graph WHERE latch = '2' AND origid = 1 AND weight = 1;
latch origid destid weight seq linkid
2 1 NULL 1 3 3
......@@ -842,7 +837,6 @@ latch origid destid weight seq linkid
2 NULL 7 0 1 7
SELECT * FROM graph WHERE latch = '2' AND destid = 8;
latch origid destid weight seq linkid
2 NULL 8 0 1 8
SELECT * FROM graph WHERE latch = '2' AND destid = 9;
latch origid destid weight seq linkid
2 NULL 9 0 1 9
......@@ -1061,7 +1055,6 @@ latch origid destid weight seq linkid
dijkstras 7 NULL 0 1 7
SELECT * FROM graph WHERE latch='dijkstras' AND origid=8;
latch origid destid weight seq linkid
dijkstras 8 NULL 0 1 8
SELECT * FROM graph WHERE latch='dijkstras' AND origid=9;
latch origid destid weight seq linkid
dijkstras 9 NULL 0 1 9
......@@ -1082,7 +1075,6 @@ dijkstras 12 NULL 0 2 10
dijkstras 12 NULL 0 1 12
SELECT * FROM graph WHERE latch='dijkstras' AND origid=666;
latch origid destid weight seq linkid
dijkstras 666 NULL 0 1 666
SELECT * FROM graph WHERE latch='dijkstras' AND destid=1;
latch origid destid weight seq linkid
dijkstras NULL 1 2 4 4
......@@ -1122,7 +1114,6 @@ latch origid destid weight seq linkid
dijkstras NULL 7 0 1 7
SELECT * FROM graph WHERE latch='dijkstras' AND destid=8;
latch origid destid weight seq linkid
dijkstras NULL 8 0 1 8
SELECT * FROM graph WHERE latch='dijkstras' AND destid=9;
latch origid destid weight seq linkid
dijkstras NULL 9 0 1 9
......@@ -1239,7 +1230,6 @@ latch origid destid weight seq linkid
1 7 NULL 0 1 7
SELECT * FROM graph WHERE latch='1' AND origid=8;
latch origid destid weight seq linkid
1 8 NULL 0 1 8
SELECT * FROM graph WHERE latch='1' AND origid=9;
latch origid destid weight seq linkid
1 9 NULL 0 1 9
......@@ -1260,7 +1250,6 @@ latch origid destid weight seq linkid
1 12 NULL 0 1 12
SELECT * FROM graph WHERE latch='1' AND origid=666;
latch origid destid weight seq linkid
1 666 NULL 0 1 666
SELECT * FROM graph WHERE latch='1' AND destid=1;
latch origid destid weight seq linkid
1 NULL 1 2 4 4
......@@ -1300,7 +1289,6 @@ latch origid destid weight seq linkid
1 NULL 7 0 1 7
SELECT * FROM graph WHERE latch='1' AND destid=8;
latch origid destid weight seq linkid
1 NULL 8 0 1 8
SELECT * FROM graph WHERE latch='1' AND destid=9;
latch origid destid weight seq linkid
1 NULL 9 0 1 9
......
......@@ -479,6 +479,15 @@ namespace boost
inline optional<graph_traits<oqgraph3::graph>::vertex_descriptor>
find_vertex(oqgraph3::vertex_id id, const oqgraph3::graph& g)
{
// Fix for https://bugs.launchpad.net/oqgraph/+bug/1196020 returning vertex even when not in graph
// Psuedocode for fix:
// if count(*) from g->TABLE where source=id or target=id > 0 then return id else return null
oqgraph3::cursor* found = new oqgraph3::cursor(const_cast<oqgraph3::graph*>(&g));
if (found->seek_to(id, boost::none) &&
found->seek_to(boost::none, id)) {
// id is neither a from or a to in a link
return optional<graph_traits<oqgraph3::graph>::vertex_descriptor>();
}
return id;
}
......
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