Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
4b845e3e
Commit
4b845e3e
authored
Jun 29, 2013
by
Andrew McDonnell
Browse files
Options
Browse Files
Download
Plain Diff
Fix for djikstras originating vertices returning no result.
parents
0cd1f495
d4185896
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
278 additions
and
11 deletions
+278
-11
mysql-test/suite/oqgraph/basic.result
mysql-test/suite/oqgraph/basic.result
+245
-0
mysql-test/suite/oqgraph/basic.test
mysql-test/suite/oqgraph/basic.test
+33
-5
storage/oqgraph/graphcore.cc
storage/oqgraph/graphcore.cc
+0
-6
No files found.
mysql-test/suite/oqgraph/basic.result
View file @
4b845e3e
...
...
@@ -1022,6 +1022,125 @@ latch origid destid weight seq linkid
dijkstras 12 11 NULL 0 12
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 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
SELECT * FROM graph WHERE latch='1' AND origid=1 AND destid=1;
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 1 1 10
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 (10,14);
INSERT INTO graph_base(from_id, to_id) VALUES (14,13);
...
...
@@ -1146,6 +1384,13 @@ dijkstras 1 NULL 0 2 2
dijkstras 1 NULL 0 1 1
SELECT * FROM graph WHERE latch='dijkstras' AND destid=1;
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
INSERT INTO graph_base (from_id,to_id) VALUES (4,6);
# And delete all references to node 5
...
...
mysql-test/suite/oqgraph/basic.test
View file @
4b845e3e
...
...
@@ -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
#-- '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
#-- linkid is the other end
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
=
3
;
...
...
@@ -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
=
12
AND
destid
=
10
;
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?
#--
...
...
@@ -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
SELECT
*
FROM
graph
WHERE
latch
=
'dijkstras'
AND
origid
=
10
AND
destid
=
13
;
#-- Unspecified arguments:
#-- 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)
#-- add some extra and check
SELECT
*
FROM
graph
WHERE
latch
=
'dijkstras'
AND
origid
=
1
;
INSERT
INTO
graph_base
(
from_id
,
to_id
)
VALUES
(
21
,
22
);
SELECT
*
FROM
graph
WHERE
latch
=
'dijkstras'
AND
origid
=
21
;
...
...
@@ -539,7 +568,6 @@ INSERT INTO graph_base(from_id, to_id) VALUES (4,16);
SELECT
*
FROM
graph
WHERE
latch
=
'dijkstras'
AND
origid
=
1
;
INSERT
INTO
graph_base
(
from_id
,
to_id
)
VALUES
(
17
,
18
);
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
;
--
echo
# Now we add a connection from 4->6
...
...
storage/oqgraph/graphcore.cc
View file @
4b845e3e
...
...
@@ -857,9 +857,7 @@ namespace open_query
}
break
;
case
BREADTH_FIRST
|
HAVE_DEST
:
#ifdef FIXME
case
DIJKSTRAS
|
HAVE_DEST
:
#endif
if
((
cursor
=
new
(
std
::
nothrow
)
stack_cursor
(
share
))
&&
(
orig
||
dest
))
{
boost
::
unordered_map
<
Vertex
,
Vertex
>
p
;
...
...
@@ -870,7 +868,6 @@ namespace open_query
d
[
*
dest
]
=
EdgeWeight
();
switch
(
ALGORITHM
&
op
)
{
#ifdef FIXME
case
DIJKSTRAS
:
dijkstra_shortest_paths_no_init
(
share
->
g
,
*
dest
,
make_lazy_property_map
(
p
,
identity_initializer
<
Vertex
>
()),
...
...
@@ -882,17 +879,14 @@ namespace open_query
closed_plus
<
EdgeWeight
>
(),
EdgeWeight
(),
make_dijkstra_visitor
(
make_dijkstra_visitor
(
make_oqgraph_visit_dist
(
boost
::
make_assoc_property_map
(
p
),
boost
::
make_assoc_property_map
(
d
),
static_cast
<
stack_cursor
*>
(
cursor
)
)
)
),
make_two_bit_judy_map
(
get
(
vertex_index
,
share
->
g
)));
break
;
#endif
case
BREADTH_FIRST
:
breadth_first_visit
(
share
->
g
,
*
dest
,
Q
,
make_bfs_visitor
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment