Skip to content
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ set(PgRouting_SOURCE_NAMES
"vrp_basic" # 2.0
"withPoints" # 2.2

"connectedComponentsV" # 2.5

# template generated name
#"funnyDijkstra"

Expand Down
63 changes: 63 additions & 0 deletions include/drivers/connectedComponentsV/connectedComponentsV_driver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*PGR-GNU*****************************************************************
File: connectedComponentsV_driver.h

Generated with Template by:
Copyright (c) 2015 pgRouting developers
Mail: project@pgrouting.org

Function's developer:
Copyright (c) 2015 Celia Virginia Vergara Castillo
Mail: vicky_vergara@hotmail.com

------

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

********************************************************************PGR-GNU*/

#ifndef INCLUDE_DRIVERS_CONNECTEDCOMPONENTSV_CONNECTEDCOMPONENTSV_DRIVER_H_
#define INCLUDE_DRIVERS_CONNECTEDCOMPONENTSV_CONNECTEDCOMPONENTSV_DRIVER_H_
#pragma once

#include "c_types/pgr_edge_t.h"
#include "c_types/general_path_element_t.h"

#ifdef __cplusplus
extern "C" {
#endif

/*********************************************************
TEXT,
BIGINT,
BIGINT,
********************************************************/


void
do_pgr_connectedComponentsV(
pgr_edge_t *data_edges,
size_t total_edges,
General_path_element_t **return_tuples,
size_t *return_count,
char ** log_msg,
char ** notice_msg,
char ** err_msg);


#ifdef __cplusplus
}
#endif

#endif // INCLUDE_DRIVERS_CONNECTEDCOMPONENTSV_CONNECTEDCOMPONENTSV_DRIVER_H_
13 changes: 13 additions & 0 deletions sql/connectedComponentsV/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

SET(LOCAL_FILES
connectedComponentsV.sql
)

# Do not modify bellow this line

foreach (f ${LOCAL_FILES})
configure_file(${f} ${f})
list(APPEND PACKAGE_SQL_FILES ${CMAKE_CURRENT_BINARY_DIR}/${f})
endforeach()

set(PgRouting_SQL_FILES ${PgRouting_SQL_FILES} ${PACKAGE_SQL_FILES} PARENT_SCOPE)
40 changes: 40 additions & 0 deletions sql/connectedComponentsV/connectedComponentsV.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*PGR-GNU*****************************************************************
File: connectedComponentsV.sql

Generated with Template by:
Copyright (c) 2016 pgRouting developers
Mail: project@pgrouting.org

Function's developer:
Copyright (c) 2017 Celia Virginia Vergara Castillo
Mail: vicky_vergara@hotmail.com

------

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

********************************************************************PGR-GNU*/

CREATE OR REPLACE FUNCTION pgr_connectedComponentsV(
TEXT, -- edges_sql
OUT seq INTEGER, -- seq
OUT component BIGINT, -- the lowest number of the node in the component
OUT n_seq INTEGER, -- nth_seq of the node in the component
OUT node BIGINT) -- the number of the node

RETURNS SETOF RECORD AS
'$libdir/${PGROUTING_LIBRARY_NAME}', 'connectedComponentsV'
LANGUAGE c IMMUTABLE STRICT;

32 changes: 32 additions & 0 deletions src/connectedComponentsV/doc/doc-pgr_connectedComponentsV.queries
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
BEGIN;
BEGIN
-- q1
SELECT * FROM pgr_connectedComponentsV(
'SELECT id, source, target, cost, reverse_cost FROM edge_table',
2, 3
);
seq | path_seq | node | edge | cost | agg_cost
-----+----------+------+------+------+----------
1 | 1 | 2 | 4 | 1 | 0
2 | 2 | 5 | 8 | 1 | 1
3 | 3 | 6 | 9 | 1 | 2
4 | 4 | 9 | 16 | 1 | 3
5 | 5 | 4 | 3 | 1 | 4
6 | 6 | 3 | -1 | 0 | 5
(6 rows)

-- q2
SELECT * FROM pgr_connectedComponentsV(
'SELECT id, source, target, cost, reverse_cost FROM edge_table',
2, 3,
FALSE
);
seq | path_seq | node | edge | cost | agg_cost
-----+----------+------+------+------+----------
1 | 1 | 2 | 2 | 1 | 0
2 | 2 | 3 | -1 | 0 | 1
(2 rows)

-- q3
ROLLBACK;
ROLLBACK
141 changes: 141 additions & 0 deletions src/connectedComponentsV/doc/pgr_connectedComponentsV.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
..
****************************************************************************
pgRouting Manual
Copyright(c) pgRouting Contributors

This documentation is licensed under a Creative Commons Attribution-Share
Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
****************************************************************************

.. _pgr_connectedComponentsV:

pgr_connectedComponentsV
===============================================================================

``pgr_connectedComponentsV`` — Returns the shortest path(s) using Dijkstra algorithm.
In particular, the Dijkstra algorithm implemented by Boost.Graph.

.. figure:: images/boost-inside.jpeg
:target: http://www.boost.org/libs/graph/doc/dijkstra_shortest_paths.html

Boost Graph Inside


Synopsis
-------------------------------------------------------------------------------

Dijkstra's algorithm, conceived by Dutch computer scientist Edsger Dijkstra in 1956.
It is a graph search algorithm that solves the shortest path problem for
a graph with non-negative edge path costs, producing a shortest path from
a starting vertex (``start_vid``) to an ending vertex (``end_vid``).
This implementation can be used with a directed graph and an undirected graph.

Characteristics
-------------------------------------------------------------------------------

The main Characteristics are:
- Process is done only on edges with positive costs.
- Values are returned when there is a path.

- When the starting vertex and ending vertex are the same, there is no path.

- The `agg_cost` the non included values `(v, v)` is `0`

- When the starting vertex and ending vertex are the different and there is no path:

- The `agg_cost` the non included values `(u, v)` is :math:`\infty`

- For optimization purposes, any duplicated value in the `start_vids` or `end_vids` are ignored.

- The returned values are ordered:

- `start_vid` ascending
- `end_vid` ascending

- Running time: :math:`O(| start\_vids | * (V \log V + E))`


Signature Summary
-----------------

.. code-block:: none

pgr_dijkstra(edges_sql, start_vid, end_vid)

RETURNS SET OF (seq, path_seq, node, edge, cost, agg_cost)
OR EMPTY SET


Signatures
-------------------------------------------------------------------------------

.. index::
single: connectedComponentsV(Minimal Use)

Minimal signature
.......................................

.. code-block:: none

pgr_connectedComponentsV(edges_sql, start_vid, end_vid)
RETURNS SET OF (seq, path_seq, node, edge, cost, agg_cost) or EMPTY SET

The minimal signature is for a **directed** graph from one ``start_vid`` to one ``end_vid``:

:Example:

.. literalinclude:: doc-pgr_connectedComponentsV.queries
:start-after: -- q1
:end-before: -- q2


.. index::
single: connectedComponentsV(Complete signature)

Complete Signature
.......................................

.. code-block:: none

pgr_connectedComponentsV(edges_sql, start_vid, end_vid, directed);
RETURNS SET OF (seq, path_seq, node, edge, cost, agg_cost) or EMPTY SET

This signature finds the shortest path from one ``start_vid`` to one ``end_vid``:
- on a **directed** graph when ``directed`` flag is missing or is set to ``true``.
- on an **undirected** graph when ``directed`` flag is set to ``false``.

:Example:

.. literalinclude:: doc-pgr_connectedComponentsV.queries
:start-after: -- q2
:end-before: -- q3



Description of the Signatures
-------------------------------------------------------------------------------

.. include:: pgRouting-concepts.rst
:start-after: basic_edges_sql_start
:end-before: basic_edges_sql_end

.. include:: pgr_dijkstra.rst
:start-after: pgr_dijkstra_parameters_start
:end-before: pgr_dijkstra_parameters_end

.. include:: pgRouting-concepts.rst
:start-after: return_path_start
:end-before: return_path_end


See Also
-------------------------------------------------------------------------------

* http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
* The queries use the :ref:`sampledata` network.

.. rubric:: Indices and tables

* :ref:`genindex`
* :ref:`search`

4 changes: 4 additions & 0 deletions src/connectedComponentsV/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ADD_LIBRARY(connectedComponentsV OBJECT
connectedComponentsV.c
connectedComponentsV_driver.cpp
)
Loading