Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1e1e728
[depthFirstSearch] Added boost functionality for undirected graphs
krashish8 Jun 1, 2020
240a39d
[depthFirstSearch] Included map header file, used in undirected graphs
krashish8 Jun 1, 2020
b7af0db
[depthFirstSearch] Removed Todo
krashish8 Jun 1, 2020
f61c0d6
[depthFirstSearch] Removed commented code
krashish8 Jun 1, 2020
a59b3b8
[depthFirstSearch] [doc] Edited the doc file
krashish8 Jun 2, 2020
57635e7
[depthFirstSearch] [doc] Added the description, characteristics and s…
krashish8 Jun 2, 2020
0ea987c
[depthFirstSearch] [doc] Added the parameters, inner query, and resul…
krashish8 Jun 2, 2020
149633c
[depthFirstSearch] [doc] Added additional examples
krashish8 Jun 2, 2020
0aaedaa
[depthFirstSearch] [doc] Added docqueries for single and multiple ver…
krashish8 Jun 3, 2020
25b2f72
[depthFirstSearch] [doc] Added docqueries for directed graphs
krashish8 Jun 3, 2020
a8d139d
[depthFirstSearch] [doc] Added docqueries for undirected graphs
krashish8 Jun 3, 2020
a32e55a
[depthFirstSearch] [doc] Edited query number
krashish8 Jun 3, 2020
ec70f79
[depthFirstSearch] [doc] Added docqueries when vertex is not present …
krashish8 Jun 3, 2020
b82d661
[depthFirstSearch] [doc] Added docqueries - equivalences between sign…
krashish8 Jun 3, 2020
edb3cdc
[depthFirstSearch] [doc] Added docqueries - equivalences between sign…
krashish8 Jun 3, 2020
821f4ca
[depthFirstSearch] [doc] Added the docqueries in doc
krashish8 Jun 4, 2020
a5c1824
[doc] Added name in contributors list
krashish8 Jun 4, 2020
79e1c43
[depthFirstSearch] [doc] Enabled documentation in the configuration file
krashish8 Jun 4, 2020
1de9e66
[depthFirstSearch] [doc] Added experimental warnings
krashish8 Jun 4, 2020
66e919e
[depthFirstSearch] [doc] Edited the heading portion
krashish8 Jun 4, 2020
92c001b
[depthFirstSearch] [doc] Fixed the query in "Vertex Out Of Graph" sec…
krashish8 Jun 4, 2020
9b37412
[depthFirstSearch] [doc] Added space before query number
krashish8 Jun 4, 2020
61f1a4b
[depthFirstSearch] [doc] Added comments in docqueries, changed query …
krashish8 Jun 4, 2020
4f0a1dc
[depthFirstSearch] [doc] Changed results file according to docqueries
krashish8 Jun 4, 2020
5cca189
[depthFirstSearch] [doc] Fixed error in documentation
krashish8 Jun 4, 2020
3abbee4
[depthFirstSearch] [doc] Edited the documentation
krashish8 Jun 4, 2020
1037a0e
[depthFirstSearch] [doc] Added one extra docquery
krashish8 Jun 4, 2020
7338884
[depthFirstSearch] [doc] Updated results of the queries
krashish8 Jun 4, 2020
08dd922
[depthFirstSearch] [doc] Updated the query number and added one query
krashish8 Jun 4, 2020
65f1f36
[depthFirstSearch] Added another sample table in queries
krashish8 Jun 5, 2020
ee5f6a2
[depthFirstSearch] Added all the queries for sample_table
krashish8 Jun 5, 2020
b29546c
[depthFirstSearch] Added the results for the queries
krashish8 Jun 5, 2020
09ff026
[depthFirstSearch] Added blank line in the query
krashish8 Jun 5, 2020
547c60f
[depthFirstSearch] Added the new tests in test.conf file
krashish8 Jun 5, 2020
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
4 changes: 2 additions & 2 deletions configuration.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ chinese | Y | Y | Y
spanningTree | Y | Y | Y
mincut | Y | Y | Y
version | Y | Y | Y
topologicalSort | Y | Y | Y
topologicalSort | Y | Y | Y
transitiveClosure | Y | Y | Y
breadthFirstSearch | Y | Y | Y
depthFirstSearch | Y | Y | N
depthFirstSearch | Y | Y | Y
#----------------------
# SQL only directories
#----------------------
Expand Down
202 changes: 185 additions & 17 deletions doc/depthFirstSearch/pgr_depthFirstSearch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,71 @@
Alike 3.0 License: https://creativecommons.org/licenses/by-sa/3.0/
****************************************************************************

pgr_depthFirstSearch
pgr_depthFirstSearch - Experimental
===============================================================================

``pgr_depthFirstSearch`` — Returns the traversal order(s) using Depth
First Search algorithm.
``pgr_depthFirstSearch`` — Returns the traversal order(s) using Depth First
Search algorithm. In particular, the Depth First Search algorithm and the
Undirected DFS algorithm implemented by Boost.Graph.

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

Boost Graph Inside

.. include:: experimental.rst
:start-after: begin-warn-expr
:end-before: end-warn-exp

.. rubric:: Availability

Description
-------------------------------------------------------------------------------

Visits the nodes in Depth First Search ordering from a root vertex to
a particular depth.
Depth First Search algorithm is a well known traversal algorithm which starts
from a start vertex (``start_vid``) and visits all the nodes in a graph in the
depth-first search traversal order. An optional non-negative maximum depth
parameter (``max_depth``) can be specified to get the results upto a particular
depth.

**The main Characteristics are:**

- Works on both Undirected and Directed Graphs.
- The implementation works for both undirected and directed graphs.
- Provides the Depth First Search traversal order from a source node to
a particular max depth level.
a particular maximum depth level.
- For optimization purposes, any duplicated values in the `start_vids` are
ignored.
- The returned values are ordered in ascending order of `start_vid`.
- If the starting vertex does not exist, empty row is returned.
- Depth First Search Running time: :math:`O(E + V)`

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

.. rubric:: Summary

.. code-block:: none

pgr_depthFirstSearch(Edges SQL, Root vid [, max_depth] [, directed])
pgr_depthFirstSearch(Edges SQL, Root vids [, max_depth] [, directed])
pgr_depthFirstSearch(edges_sql, start_vid [, max_depth] [, directed])
pgr_depthFirstSearch(edges_sql, start_vids [, max_depth] [, directed])

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

.. rubric:: Using defaults

.. code-block:: none

pgr_depthFirstSearch(TEXT edges_sql, BIGINT start_vid)

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

:Example: From start vertex :math:`2` on a **directed** graph

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

.. index::
single: depthFirstSearch(Single vertex)
Expand All @@ -51,15 +81,17 @@ Single vertex

.. code-block:: none

pgr_depthFirstSearch(Edges SQL, Root vid [, max_depth] [, directed])
pgr_depthFirstSearch(TEXT edges_sql, BIGINT start_vid,
BIGINT max_depth := 9223372036854775807, BOOLEAN directed := true)

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

:Example: The Minimum Spanning Tree having as root vertex :math:`2`
:Example: From start vertex :math:`2` on an **undirected** graph

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

.. index::
single: depthFirstSearch(Multiple vertices)
Expand All @@ -69,20 +101,156 @@ Multiple vertices

.. code-block:: none

pgr_depthFirstSearch(Edges SQL, Root vids [, max_depth] [, directed])
pgr_depthFirstSearch(TEXT edges_sql, ARRAY[ANY_INTEGER] start_vids,
BIGINT max_depth := 9223372036854775807, BOOLEAN directed := true)

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

:Example:
:Example: From start vertices :math:`\{11, 12\}` with :math:`depth <= 2`
on a **directed** graph

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

.. Parameters, Inner query & result columns

.. depthFirstSearch-information-start

Parameters
-------------------------------------------------------------------------------

=================== ====================== =================================================
Parameter Type Description
=================== ====================== =================================================
**edges_sql** ``TEXT`` SQL query described in `Inner query`_.
**start_vid** ``BIGINT`` Identifier of the start vertex of the tree.

- Used on `Single Vertex`_.

**start_vids** ``ARRAY[ANY-INTEGER]`` Array of identifiers of the start vertices.

- Used on `Multiple Vertices`_.
- For optimization purposes, any duplicated value is ignored.
=================== ====================== =================================================

Optional Parameters
...............................................................................

=================== =========== =========================== =================================================
Parameter Type Default Description
=================== =========== =========================== =================================================
**max_depth** ``BIGINT`` :math:`9223372036854775807` Upper limit for depth of node in the tree

- When value is ``Negative`` then **throws error**

**directed** ``BOOLEAN`` ``true`` - When ``true`` Graph is considered `Directed`
- When ``false`` the graph is considered as `Undirected`.
=================== =========== =========================== =================================================

Inner query
-------------------------------------------------------------------------------

.. rubric:: edges_sql

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

Result Columns
-------------------------------------------------------------------------------

.. result columns start

Returns SET OF ``(seq, depth, start_vid, node, edge, cost, agg_cost)``

=============== =========== ====================================================
Column Type Description
=============== =========== ====================================================
**seq** ``BIGINT`` Sequential value starting from :math:`1`.
**depth** ``BIGINT`` Depth of the ``node``.

- :math:`0` when ``node`` = ``start_vid``.

**start_vid** ``BIGINT`` Identifier of the start vertex.

- In `Multiple Vertices`_ results are in ascending order.

**node** ``BIGINT`` Identifier of ``node`` reached using ``edge``.
**edge** ``BIGINT`` Identifier of the ``edge`` used to arrive to ``node``.

- :math:`-1` when ``node`` = ``start_vid``.

**cost** ``FLOAT`` Cost to traverse ``edge``.
**agg_cost** ``FLOAT`` Aggregate cost from ``start_vid`` to ``node``.
=============== =========== ====================================================

.. result columns end


Additional Examples
-------------------------------------------------------------------------------

The examples of this section are based on the :doc:`sampledata` network.

The examples include the traversal with starting vertices as 6, 8 and 15 in a
directed and undirected graph, for both single vertex and multiple vertices.

**Directed Graph**

:Examples: For queries marked as ``directed`` with ``cost`` and ``reverse_cost`` columns

The examples in this section use the following:

* :ref:`fig1`

.. literalinclude:: doc-pgr_depthFirstSearch.queries
:start-after: -- q5
:end-before: -- q6

**Undirected Graph**

:Examples: For queries marked as ``undirected`` with ``cost`` and ``reverse_cost`` columns

The examples in this section use the following:

* :ref:`fig2`

.. literalinclude:: doc-pgr_depthFirstSearch.queries
:start-after: -- q7
:end-before: -- q8

**Vertex Out Of Graph**

:Example: For queries in which starting vertex is not present in the graph

.. literalinclude:: doc-pgr_depthFirstSearch.queries
:start-after: -- q9
:end-before: -- q10

Equivalences between signatures
...............................................................................

:Examples: For queries marked as ``directed`` with ``cost`` and ``reverse_cost`` columns

The examples in this section use the following:

* :ref:`fig1`

.. literalinclude:: doc-pgr_depthFirstSearch.queries
:start-after: -- q11
:end-before: -- q12

:Examples: For queries marked as ``undirected`` with ``cost`` and ``reverse_cost`` columns

The examples in this section use the following:

* :ref:`fig2`

.. literalinclude:: doc-pgr_depthFirstSearch.queries
:start-after: -- q13
:end-before: -- q14


See Also
Expand Down
2 changes: 2 additions & 0 deletions doc/src/pgRouting-introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Individuals (in alphabetical order)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Aasheesh Tiwari, Aditya Pratap Singh, Adrien Berchet,
Ashish Kumar,
Cayetano Benavent,
Gudesa Venkata Sai Akhil,
Hang Wu,
Expand Down Expand Up @@ -79,6 +80,7 @@ Individuals (in alphabetical order)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Aasheesh Tiwari, Aditya Pratap Singh, Adrien Berchet, Akio Takubo, Andrea Nardelli, Anthony Tasca, Anton Patrushev, Ashraf Hossain,
Ashish Kumar,
Cayetano Benavent, Christian Gonzalez,
Daniel Kastl, Dave Potts, David Techer, Denis Rykov,
Ema Miyawaki,
Expand Down
Loading