Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSoC 2023: Aniket Agarwal week 7 #322

Merged
merged 3 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions doc/ksp/pgr_KSP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Signatures
| pgr_KSP(`Edges SQL`_, `Combinations SQL`_, **K**, [**options**])
| **options:** ``[directed, heap_paths]``

| RETURNS SET OF |ksp-result|
| RETURNS SET OF ``(seq, path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)``
| OR EMPTY SET

.. index::
Expand All @@ -80,7 +80,7 @@ One to One

| pgr_KSP(`Edges SQL`_, **start_vid**, **end_vid**, **K**, [**options**])

| RETURNS SET OF |short-generic-result|
| RETURNS SET OF ``(seq, path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)``
| OR EMPTY SET

:Example: Get 2 paths from :math:`6` to :math:`17` on a directed graph.
Expand All @@ -100,7 +100,7 @@ One to Many

| pgr_KSP(`Edges SQL`_, **start_vid**, **end_vids**, **K**, [**options**])

| RETURNS SET OF |short-generic-result|
| RETURNS SET OF ``(seq, path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)``
| OR EMPTY SET

:Example: Get 2 paths from vertex :math:`6` to vertices :math:`\{10, 17\}` on a directed graph.
Expand All @@ -120,10 +120,10 @@ Many to One

| pgr_KSP(`Edges SQL`_, **start_vids**, **end_vid**, **K**, [**options**])

| RETURNS SET OF |short-generic-result|
| RETURNS SET OF ``(seq, path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)``
| OR EMPTY SET

:Example: Get 2 paths from vertices :math:`\{6, 1\}` to vertex :math:`17 on a directed graph.
:Example: Get 2 paths from vertices :math:`\{6, 1\}` to vertex :math:`17` on a directed graph.

.. literalinclude:: doc-ksp.queries
:start-after: --q4
Expand All @@ -140,7 +140,7 @@ Many to Many

| pgr_KSP(`Edges SQL`_, **start_vids**, **end_vids**, **K**, [**options**])

| RETURNS SET OF |short-generic-result|
| RETURNS SET OF ``(seq, path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)``
| OR EMPTY SET

:Example: Get 2 paths vertices :math:`\{6, 1\}` to vertices :math:`\{10, 17\}` on a directed graph.
Expand All @@ -160,7 +160,7 @@ Combinations

| pgr_KSP(`Edges SQL`_, `Combinations SQL`_, **K**, [**options**])

| RETURNS SET OF |short-generic-result|
| RETURNS SET OF ``(seq, path_id, path_seq, start_vid, end_vid, node, edge, cost, agg_cost)``
| OR EMPTY SET

:Example: Using a combinations table on an **directed** graph
Expand Down Expand Up @@ -327,7 +327,7 @@ Also get the paths in the heap.
:start-after: --q7
:end-before: --q8

:Example: Get 2 paths from vertices :math:`\{6, 1\}` to vertex :math:`17 on a **undirected** graph.
:Example: Get 2 paths from vertices :math:`\{6, 1\}` to vertex :math:`17` on a **undirected** graph.

.. literalinclude:: doc-ksp.queries
:start-after: --q8
Expand Down
21 changes: 20 additions & 1 deletion include/drivers/yen/ksp_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
File: ksp_driver.h

Copyright (c) 2015 Celia Virginia Vergara Castillo
Mail: vicky AT erosion.dev
Mail: vicky at erosion.dev

Copyright (c) 2023 Aniket Agarwal
Mail: aniketgarg187 at gmail.com

------

Expand Down Expand Up @@ -32,18 +35,34 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# include <cstddef>
using Edge_t = struct Edge_t;
using Path_rt = struct Path_rt;
using II_t_rt = struct II_t_rt;
#else
# include <stddef.h>
# include <stdint.h>
typedef struct Edge_t Edge_t;
typedef struct Path_rt Path_rt;
typedef struct II_t_rt II_t_rt;
#endif


#ifdef __cplusplus
extern "C" {
#endif

void pgr_do_ksp(
Edge_t*, size_t,
II_t_rt*, size_t,
int64_t*, size_t,
int64_t*, size_t,
size_t,
bool,
bool,
Path_rt**,
size_t*,
char**,
char**,
char**);

void do_pgr_ksp(
Edge_t *data_edges,
size_t total_edges,
Expand Down
74 changes: 0 additions & 74 deletions include/drivers/yen/v4ksp_driver.h

This file was deleted.

52 changes: 34 additions & 18 deletions pgtap/ksp/ksp/types_check.pg
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,41 @@ SELECT has_function('pgr_ksp');
SELECT has_function('pgr_ksp',ARRAY['text','bigint','bigint','integer','boolean','boolean']);
SELECT function_returns('pgr_ksp',ARRAY['text','bigint','bigint','integer','boolean','boolean'],'setof record');

SELECT CASE
WHEN min_version('3.6.0') THEN
set_eq(
$$SELECT proargnames from pg_proc WHERE proname = 'pgr_ksp'$$,
$$VALUES
('{"","","","directed","heap_paths","seq","path_id","path_seq",start_vid,end_vid,"node","edge","cost","agg_cost"}'::TEXT[]),
('{"","","","","directed","heap_paths","seq","path_id","path_seq",start_vid,end_vid,"node","edge","cost","agg_cost"}'::TEXT[])
$$
)
ELSE
set_eq(
$$SELECT proargnames from pg_proc WHERE proname = 'pgr_ksp'$$,
$$SELECT '{"","","","","directed","heap_paths","seq","path_id","path_seq","node","edge","cost","agg_cost"}'::TEXT[] $$
)
END;

SELECT set_eq(
$$SELECT proargnames from pg_proc WHERE proname = 'pgr_ksp'$$,
$$VALUES
('{"","","","directed","heap_paths","seq","path_id","path_seq",start_vid,end_vid,"node","edge","cost","agg_cost"}'::TEXT[]),
('{"","","","","directed","heap_paths","seq","path_id","path_seq",start_vid,end_vid,"node","edge","cost","agg_cost"}'::TEXT[])
$$
);

SELECT set_eq(
$$SELECT proallargtypes FROM pg_proc WHERE proname = 'pgr_ksp'$$,
$$VALUES
('{25,25,23,16,16,23,23,23,20,20,20,20,701,701}'::OID[]),
('{25,20,20,23,16,16,23,23,23,20,20,20,20,701,701}'::OID[]),
('{25,20,2277,23,16,16,23,23,23,20,20,20,20,701,701}'::OID[]),
('{25,2277,20,23,16,16,23,23,23,20,20,20,20,701,701}'::OID[]),
('{25,2277,2277,23,16,16,23,23,23,20,20,20,20,701,701}'::OID[])
$$
);

SELECT CASE
WHEN min_version('3.6.0') THEN
set_eq(
$$SELECT proallargtypes FROM pg_proc WHERE proname = 'pgr_ksp'$$,
$$VALUES
('{25,25,23,16,16,23,23,23,20,20,20,20,701,701}'::OID[]),
('{25,20,20,23,16,16,23,23,23,20,20,20,20,701,701}'::OID[]),
('{25,20,2277,23,16,16,23,23,23,20,20,20,20,701,701}'::OID[]),
('{25,2277,20,23,16,16,23,23,23,20,20,20,20,701,701}'::OID[]),
('{25,2277,2277,23,16,16,23,23,23,20,20,20,20,701,701}'::OID[])
$$
)
ELSE
set_eq(
$$SELECT proallargtypes FROM pg_proc WHERE proname = 'pgr_ksp'$$,
$$SELECT '{25,20,20,23,16,16,23,23,23,20,20,701,701}'::OID[] $$
)
END;

SELECT finish();
ROLLBACK;
2 changes: 0 additions & 2 deletions src/ksp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
ADD_LIBRARY(ksp OBJECT
ksp.c
ksp_driver.cpp
v4ksp.c
v4ksp_driver.cpp

withPoints_ksp.c
withPoints_ksp_driver.cpp
Expand Down
Loading