Skip to content

New function pgr contraction dead end #2793

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

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
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
* New name and order of optional parameters.
* Deprecated signature pgr_contraction(text,bigint[],integer,bigint[],boolean)

**New proposed functions**

* Contraction

* [#2790](https://github.com/pgRouting/pgrouting/issues/2790): pgr_contractionDeadEnd

## pgRouting 3.7

Expand Down
2 changes: 2 additions & 0 deletions doc/_static/page_history.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ var titles = [


var newpages = [
{v: '3.8', pages: ['pgr_contractionDeadEnd']},

{v: '3.7', pages: ['metrics-family', 'pgr_betweennessCentrality']},

{v: '3.4', pages: ['TRSP-family', 'pgr_withPointsVia', 'pgr_trsp_withPoints', 'pgr_trspVia_withPoints',
Expand Down
1 change: 1 addition & 0 deletions doc/contraction/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
SET(LOCAL_FILES
contraction-family.rst
pgr_contraction.rst
pgr_contractionDeadEnd.rst
)

foreach (f ${LOCAL_FILES})
Expand Down
201 changes: 11 additions & 190 deletions doc/contraction/contraction-family.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,21 @@ Contraction - Family of functions

.. official-end

.. include:: proposed.rst
:start-after: warning-begin
:end-before: end-warning

.. proposed-start

* :doc:`pgr_contractionDeadEnd`

.. proposed-end

.. toctree::
:hidden:

pgr_contraction
pgr_contractionDeadEnd


Introduction
Expand All @@ -48,196 +59,6 @@ Allowing the user to:
- Decide the order of the contraction algorithms and set the maximum number of
times they are to be executed.

Dead end contraction
-------------------------------------------------------------------------------

Contraction of the leaf nodes of the graph.

Dead end
..............................................................................

A node is considered a **dead end** node when

* On undirected graphs:

* The number of adjacent vertices is 1.

* On directed graphs:

* The number of adjacent vertices is 1.
* There are no outgoing edges and has at least one incoming edge.
* There are no incoming edges and has at least one outgoing edge.


When the conditions are true then the `Operation: Dead End Contraction`_ can be
done.

Dead end vertex on undirected graph
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

- The green nodes are `dead end`_ nodes
- The blue nodes have an unlimited number of edges.

.. graphviz::

graph G {
u, v [shape=circle;style=filled;width=.4;color=deepskyblue];
a, b [style=filled; color=green];
G [shape=tripleoctagon;width=1.5;style=filled;
color=deepskyblue;label = "Rest of the Graph"];

rankdir=LR;
G -- {u, v} [dir=none, weight=1, penwidth=3];
u -- a [color=black];
u -- a [color=darkgray];
v -- b;
}

.. list-table::
:width: 80
:widths: auto
:header-rows: 1

* - Node
- Adjacent nodes
- Number of adjacent nodes
* - :math:`a`
- :math:`\{u\}`
- 1
* - :math:`b`
- :math:`\{v\}`
- 1


Dead end vertex on directed graph
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

- The green nodes are `dead end`_ nodes
- The blue nodes have an unlimited number of incoming and/or outgoing edges.

.. graphviz::

digraph G {
u, v, w, x, y [shape=circle;style=filled;width=.4;color=deepskyblue];
a, b, c, d, e [style=filled; color=green];
G [shape=tripleoctagon;width=1.5;style=filled;
color=deepskyblue;label = "Rest of the Graph"];

rankdir=LR;
G -> {u, v, w} [dir=none, weight=1, penwidth=3];
{x, y} -> G [dir=none, weight=1, penwidth=3];
u -> a -> u;
v -> b;
{w, v} -> c;
d -> x;
e -> {x, y};
}


.. list-table::
:width: 80
:widths: auto
:header-rows: 1

* - Node
- Adjacent nodes
- Number of adjacent nodes
- Number of incoming edges
- Number of outgoing edges
* - :math:`a`
- :math:`\{u\}`
- 1
-
-
* - :math:`b`
- :math:`\{v\}`
- 1
-
-
* - :math:`c`
- :math:`\{v, w\}`
- 2
- 2
- 0
* - :math:`d`
- :math:`\{x\}`
- 1
-
-
* - :math:`e`
- :math:`\{x, y\}`
- 2
- 0
- 2


From above, nodes :math:`\{a, b, d\}` are dead ends because the
number of adjacent vertices is 1. No further checks are needed for those nodes.

On the following table, nodes :math:`\{c, e\}` because the
even that the number of adjacent vertices is not 1 for

* :math:`c`

* There are no outgoing edges and has at least one incoming edge.

* :math:`e`

* There are no incoming edges and has at least one outgoing edge.

Operation: Dead End Contraction
...............................................................................

The dead end contraction will stop until there are no more dead end nodes.
For example from the following graph where :math:`w` is the `dead end`_ node:

.. graphviz::

digraph G {
u, v [shape=circle;style=filled;width=.4;color=deepskyblue];
w [style=filled; color=green];
"G" [shape=tripleoctagon;style=filled;
color=deepskyblue; label = "Rest of the Graph"];

rankdir=LR;
G -> u [dir=none, weight=1, penwidth=3];
u -> v -> w;
}


After contracting :math:`w`, node :math:`v` is now a `dead end`_ node and is
contracted:

.. graphviz::

digraph G {
u [shape=circle;style=filled;width=.4;color=deepskyblue];
v [style=filled; color=green, label="v{w}"];
"G" [shape=tripleoctagon;style=filled;
color=deepskyblue; label = "Rest of the Graph"];

rankdir=LR;
G -> u [dir=none, weight=1, penwidth=3];
u -> v;
}

After contracting :math:`v`, stop. Node :math:`u` has the information of nodes
that were contrcted.

.. graphviz::

digraph G {
u [style=filled; color=green, label="u{v,w}"];
"G" [shape=tripleoctagon;style=filled;
color=deepskyblue; label = "Rest of the Graph"];

rankdir=LR;
G -> u [dir=none, weight=1, penwidth=3];
}

Node :math:`u` has the information of nodes that were contracted.


Linear contraction
-------------------------------------------------------------------------------
In the algorithm, linear contraction is represented by 2.
Expand Down
5 changes: 1 addition & 4 deletions doc/contraction/pgr_contraction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,14 @@ The main Characteristics are:
- Currently there are two types of contraction methods included in this
function:

- Dead End Contraction. See :doc:`contraction-family`.
- Dead End Contraction. See :doc:`pgr_contractionDeadEnd`.
- Linear Contraction. See :doc:`contraction-family`.

|Boost| Boost Graph Inside

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

.. index::
single: contraction

.. admonition:: \ \
:class: signatures

Expand Down
Loading