Commit d4185896 authored by Andrew McDonnell's avatar Andrew McDonnell

Fix for djikstras not working on destid (because of #if 0) same as for bug 1196027

parent d1650f82
...@@ -1022,6 +1022,125 @@ latch origid destid weight seq linkid ...@@ -1022,6 +1022,125 @@ latch origid destid weight seq linkid
dijkstras 12 11 NULL 0 12 dijkstras 12 11 NULL 0 12
dijkstras 12 11 1 1 10 dijkstras 12 11 1 1 10
dijkstras 12 11 1 2 11 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 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 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 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 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 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 0 1 6
SELECT * FROM graph WHERE latch='dijkstras' AND origid=7;
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
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 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 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 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
dijkstras NULL 1 1 3 3
dijkstras NULL 1 1 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 3 4 4
dijkstras NULL 2 2 3 3
dijkstras NULL 2 1 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 2 4 2
dijkstras NULL 3 1 3 4
dijkstras NULL 3 1 2 1
dijkstras NULL 3 0 1 3
SELECT * FROM graph WHERE latch='dijkstras' AND destid=4;
latch origid destid weight seq linkid
dijkstras NULL 4 3 4 2
dijkstras NULL 4 2 3 1
dijkstras NULL 4 1 2 3
dijkstras NULL 4 0 1 4
SELECT * FROM graph WHERE latch='dijkstras' AND destid=5;
latch origid destid weight seq linkid
dijkstras NULL 5 1 3 7
dijkstras NULL 5 1 2 6
dijkstras NULL 5 0 1 5
SELECT * FROM graph WHERE latch='dijkstras' AND destid=6;
latch origid destid weight seq linkid
dijkstras NULL 6 2 3 7
dijkstras NULL 6 1 2 5
dijkstras NULL 6 0 1 6
SELECT * FROM graph WHERE latch='dijkstras' AND destid=7;
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
SELECT * FROM graph WHERE latch='dijkstras' AND destid=10;
latch origid destid weight seq linkid
dijkstras NULL 10 2 3 12
dijkstras NULL 10 1 2 11
dijkstras NULL 10 0 1 10
SELECT * FROM graph WHERE latch='dijkstras' AND destid=11;
latch origid destid weight seq linkid
dijkstras NULL 11 2 3 10
dijkstras NULL 11 1 2 12
dijkstras NULL 11 0 1 11
SELECT * FROM graph WHERE latch='dijkstras' AND destid=12;
latch origid destid weight seq linkid
dijkstras NULL 12 2 3 11
dijkstras NULL 12 1 2 10
dijkstras NULL 12 0 1 12
# legacy string number # legacy string number
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=1; SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=1;
latch origid destid weight seq linkid latch origid destid weight seq linkid
...@@ -1081,6 +1200,125 @@ latch origid destid weight seq linkid ...@@ -1081,6 +1200,125 @@ latch origid destid weight seq linkid
1 12 11 NULL 0 12 1 12 11 NULL 0 12
1 12 11 1 1 10 1 12 11 1 1 10
1 12 11 1 2 11 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 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 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 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 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 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 0 1 6
SELECT * FROM graph WHERE latch='1' AND origid=7;
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
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 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 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 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
1 NULL 1 1 3 3
1 NULL 1 1 2 2
1 NULL 1 0 1 1
SELECT * FROM graph WHERE latch='1' AND destid=2;
latch origid destid weight seq linkid
1 NULL 2 3 4 4
1 NULL 2 2 3 3
1 NULL 2 1 2 1
1 NULL 2 0 1 2
SELECT * FROM graph WHERE latch='1' AND destid=3;
latch origid destid weight seq linkid
1 NULL 3 2 4 2
1 NULL 3 1 3 4
1 NULL 3 1 2 1
1 NULL 3 0 1 3
SELECT * FROM graph WHERE latch='1' AND destid=4;
latch origid destid weight seq linkid
1 NULL 4 3 4 2
1 NULL 4 2 3 1
1 NULL 4 1 2 3
1 NULL 4 0 1 4
SELECT * FROM graph WHERE latch='1' AND destid=5;
latch origid destid weight seq linkid
1 NULL 5 1 3 7
1 NULL 5 1 2 6
1 NULL 5 0 1 5
SELECT * FROM graph WHERE latch='1' AND destid=6;
latch origid destid weight seq linkid
1 NULL 6 2 3 7
1 NULL 6 1 2 5
1 NULL 6 0 1 6
SELECT * FROM graph WHERE latch='1' AND destid=7;
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
SELECT * FROM graph WHERE latch='1' AND destid=10;
latch origid destid weight seq linkid
1 NULL 10 2 3 12
1 NULL 10 1 2 11
1 NULL 10 0 1 10
SELECT * FROM graph WHERE latch='1' AND destid=11;
latch origid destid weight seq linkid
1 NULL 11 2 3 10
1 NULL 11 1 2 12
1 NULL 11 0 1 11
SELECT * FROM graph WHERE latch='1' AND destid=12;
latch origid destid weight seq linkid
1 NULL 12 2 3 11
1 NULL 12 1 2 10
1 NULL 12 0 1 12
INSERT INTO graph_base(from_id, to_id) VALUES (11,13); INSERT INTO graph_base(from_id, to_id) VALUES (11,13);
INSERT INTO graph_base(from_id, to_id) VALUES (10,14); INSERT INTO graph_base(from_id, to_id) VALUES (10,14);
INSERT INTO graph_base(from_id, to_id) VALUES (14,13); INSERT INTO graph_base(from_id, to_id) VALUES (14,13);
...@@ -1146,6 +1384,13 @@ dijkstras 1 NULL 0 2 2 ...@@ -1146,6 +1384,13 @@ dijkstras 1 NULL 0 2 2
dijkstras 1 NULL 0 1 1 dijkstras 1 NULL 0 1 1
SELECT * FROM graph WHERE latch='dijkstras' AND destid=1; SELECT * FROM graph WHERE latch='dijkstras' AND destid=1;
latch origid destid weight seq linkid latch origid destid weight seq linkid
dijkstras NULL 1 4 7 18
dijkstras NULL 1 3 6 17
dijkstras NULL 1 3 5 16
dijkstras NULL 1 2 4 4
dijkstras NULL 1 1 3 3
dijkstras NULL 1 1 2 2
dijkstras NULL 1 0 1 1
# Now we add a connection from 4->6 # Now we add a connection from 4->6
INSERT INTO graph_base (from_id,to_id) VALUES (4,6); INSERT INTO graph_base (from_id,to_id) VALUES (4,6);
# And delete all references to node 5 # And delete all references to node 5
......
...@@ -131,6 +131,7 @@ SELECT linkid as `from`, destid as `to` FROM graph where latch='0' and destid = ...@@ -131,6 +131,7 @@ SELECT linkid as `from`, destid as `to` FROM graph where latch='0' and destid =
#-- We include 'origid' in the set of reachable nodes i.e. as a 'loop', with weight 0 #-- We include 'origid' in the set of reachable nodes i.e. as a 'loop', with weight 0
#-- 'seq' is the counted distance of the search, thus, the loop link will always have seq 1 #-- 'seq' is the counted distance of the search, thus, the loop link will always have seq 1
#-- if there are two reachable neighbours, they will have seq 2,3 and so on #-- if there are two reachable neighbours, they will have seq 2,3 and so on
#-- linkid is the other end
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 1; 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 = 'breadth_first' AND origid = 2;
SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 3; SELECT * FROM graph WHERE latch = 'breadth_first' AND origid = 3;
...@@ -500,6 +501,37 @@ SELECT * FROM graph WHERE latch='1' AND origid=11 AND destid=10; ...@@ -500,6 +501,37 @@ SELECT * FROM graph WHERE latch='1' AND origid=11 AND destid=10;
SELECT * FROM graph WHERE latch='1' AND origid=11 AND destid=12; SELECT * FROM graph WHERE latch='1' AND origid=11 AND destid=12;
SELECT * FROM graph WHERE latch='1' AND origid=12 AND destid=10; SELECT * FROM graph WHERE latch='1' AND origid=12 AND destid=10;
SELECT * FROM graph WHERE latch='1' AND origid=12 AND destid=11; SELECT * FROM graph WHERE latch='1' AND origid=12 AND destid=11;
SELECT * FROM graph WHERE latch='1' AND origid=1;
SELECT * FROM graph WHERE latch='1' AND origid=2;
SELECT * FROM graph WHERE latch='1' AND origid=3;
SELECT * FROM graph WHERE latch='1' AND origid=4;
SELECT * FROM graph WHERE latch='1' AND origid=5;
SELECT * FROM graph WHERE latch='1' AND origid=6;
SELECT * FROM graph WHERE latch='1' AND origid=7;
#-- FIXME This is returning one result set, suspect this is a bug...?
#-- https://bugs.launchpad.net/oqgraph/+bug/1196020
SELECT * FROM graph WHERE latch='1' AND origid=8;
SELECT * FROM graph WHERE latch='1' AND origid=9;
SELECT * FROM graph WHERE latch='1' AND origid=10;
SELECT * FROM graph WHERE latch='1' AND origid=11;
SELECT * FROM graph WHERE latch='1' AND origid=12;
#-- FIXME This is returning one result set, suspect this is a bug...?
#-- https://bugs.launchpad.net/oqgraph/+bug/1196020
SELECT * FROM graph WHERE latch='1' AND origid=666;
SELECT * FROM graph WHERE latch='1' AND destid=1;
SELECT * FROM graph WHERE latch='1' AND destid=2;
SELECT * FROM graph WHERE latch='1' AND destid=3;
SELECT * FROM graph WHERE latch='1' AND destid=4;
SELECT * FROM graph WHERE latch='1' AND destid=5;
SELECT * FROM graph WHERE latch='1' AND destid=6;
SELECT * FROM graph WHERE latch='1' AND destid=7;
#-- FIXME This is returning one result set, suspect this is a bug...?
#-- https://bugs.launchpad.net/oqgraph/+bug/1196020
SELECT * FROM graph WHERE latch='1' AND destid=8;
SELECT * FROM graph WHERE latch='1' AND destid=9;
SELECT * FROM graph WHERE latch='1' AND destid=10;
SELECT * FROM graph WHERE latch='1' AND destid=11;
SELECT * FROM graph WHERE latch='1' AND destid=12;
#-- What if we add two equally valid two-hop paths? #-- What if we add two equally valid two-hop paths?
#-- #--
...@@ -525,10 +557,7 @@ INSERT INTO graph_base(from_id, to_id) VALUES (10,11); ...@@ -525,10 +557,7 @@ INSERT INTO graph_base(from_id, to_id) VALUES (10,11);
#-- We note is _appears_ to use the lowered valued node id if there are two equal paths #-- We note is _appears_ to use the lowered valued node id if there are two equal paths
SELECT * FROM graph WHERE latch='dijkstras' AND origid=10 AND destid=13; SELECT * FROM graph WHERE latch='dijkstras' AND origid=10 AND destid=13;
#-- Unspecified arguments: #-- add some extra and check
#-- If destid unspecified, it returns all possible destinations
#-- Destinations further away are returned first
#-- Note also, weight==0 (as opposed to 1 or NULL in all other cases)
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1; SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
INSERT INTO graph_base(from_id, to_id) VALUES (21,22); INSERT INTO graph_base(from_id, to_id) VALUES (21,22);
SELECT * FROM graph WHERE latch='dijkstras' AND origid=21; SELECT * FROM graph WHERE latch='dijkstras' AND origid=21;
...@@ -539,7 +568,6 @@ INSERT INTO graph_base(from_id, to_id) VALUES (4,16); ...@@ -539,7 +568,6 @@ INSERT INTO graph_base(from_id, to_id) VALUES (4,16);
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1; SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
INSERT INTO graph_base(from_id, to_id) VALUES (17,18); INSERT INTO graph_base(from_id, to_id) VALUES (17,18);
SELECT * FROM graph WHERE latch='dijkstras' AND origid=1; SELECT * FROM graph WHERE latch='dijkstras' AND origid=1;
#-- If origid unspecified, it returns no result - i.e. origid is mandatory
SELECT * FROM graph WHERE latch='dijkstras' AND destid=1; SELECT * FROM graph WHERE latch='dijkstras' AND destid=1;
--echo # Now we add a connection from 4->6 --echo # Now we add a connection from 4->6
......
...@@ -857,9 +857,7 @@ namespace open_query ...@@ -857,9 +857,7 @@ namespace open_query
} }
break; break;
case BREADTH_FIRST | HAVE_DEST: case BREADTH_FIRST | HAVE_DEST:
#ifdef FIXME
case DIJKSTRAS | HAVE_DEST: case DIJKSTRAS | HAVE_DEST:
#endif
if ((cursor= new (std::nothrow) stack_cursor(share)) && (orig || dest)) if ((cursor= new (std::nothrow) stack_cursor(share)) && (orig || dest))
{ {
boost::unordered_map<Vertex, Vertex> p; boost::unordered_map<Vertex, Vertex> p;
...@@ -870,7 +868,6 @@ namespace open_query ...@@ -870,7 +868,6 @@ namespace open_query
d[ *dest ] = EdgeWeight(); d[ *dest ] = EdgeWeight();
switch (ALGORITHM & op) switch (ALGORITHM & op)
{ {
#ifdef FIXME
case DIJKSTRAS: case DIJKSTRAS:
dijkstra_shortest_paths_no_init(share->g, *dest, dijkstra_shortest_paths_no_init(share->g, *dest,
make_lazy_property_map(p, identity_initializer<Vertex>()), make_lazy_property_map(p, identity_initializer<Vertex>()),
...@@ -882,17 +879,14 @@ namespace open_query ...@@ -882,17 +879,14 @@ namespace open_query
closed_plus<EdgeWeight>(), closed_plus<EdgeWeight>(),
EdgeWeight(), EdgeWeight(),
make_dijkstra_visitor( make_dijkstra_visitor(
make_dijkstra_visitor(
make_oqgraph_visit_dist( make_oqgraph_visit_dist(
boost::make_assoc_property_map(p), boost::make_assoc_property_map(p),
boost::make_assoc_property_map(d), boost::make_assoc_property_map(d),
static_cast<stack_cursor*>(cursor) static_cast<stack_cursor*>(cursor)
) )
)
), ),
make_two_bit_judy_map(get(vertex_index, share->g))); make_two_bit_judy_map(get(vertex_index, share->g)));
break; break;
#endif
case BREADTH_FIRST: case BREADTH_FIRST:
breadth_first_visit(share->g, *dest, Q, breadth_first_visit(share->g, *dest, Q,
make_bfs_visitor( make_bfs_visitor(
......
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