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 2024: Betweenness Centrality: Week 12 #403

Merged
merged 40 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
cc41a7b
[centrality] fixed the documentation and linting issue
bedupako12mas Aug 12, 2024
0117e4a
[centrality] fixed pgr_betweennessCentrality.rst
bedupako12mas Aug 12, 2024
bb7cf58
[centrality] fixed pgr_betweennessCentrality.rst
bedupako12mas Aug 12, 2024
4f7f695
[centrality] minor fixes to docs
bedupako12mas Aug 12, 2024
0ffdec4
[centrality] minor changes to docs
bedupako12mas Aug 12, 2024
9603775
[centrality] minor changes to docs
bedupako12mas Aug 12, 2024
1491b97
[centrality] added availability of function
bedupako12mas Aug 12, 2024
d078f1c
[centrality] minor change
bedupako12mas Aug 12, 2024
03ee0b2
[centrality] added metrics-family to docs
bedupako12mas Aug 12, 2024
93cf1d2
(e_report) free memory of logs on function call
cvvergara Aug 12, 2024
1c1b5f2
(C/C++) Remove unnecessary pfree
cvvergara Aug 12, 2024
a8a31fe
(lint) Fix additional lint errors
cvvergara Aug 12, 2024
f55e204
asdfn(lint) Fix additional lint errors
cvvergara Aug 12, 2024
7e484e1
(CI) Adding workflow_dispatch where missing
cvvergara Aug 12, 2024
a9b90dd
(lint) Removing trailing spaces
cvvergara Aug 12, 2024
c358983
(lineGraph/pgtap) fix for update test
cvvergara Aug 12, 2024
3b48656
[centrality] fixed betweennessCentrality.c
bedupako12mas Aug 13, 2024
45e8991
[centrality] added signatures and fixed linting errors
bedupako12mas Aug 13, 2024
3420ead
[centrality] debug_macro.h
bedupako12mas Aug 13, 2024
5d8993c
[centrality] removed trailing whitespaces from edge_cases.pg
bedupako12mas Aug 13, 2024
69c6ead
[centrality] removed trailing whitespaces
bedupako12mas Aug 13, 2024
3530b48
[centrality] removed trailing whitespace and blank lines at EOF
bedupako12mas Aug 13, 2024
22cd118
[centrality] added metrics-family to experimental.rst
bedupako12mas Aug 13, 2024
8a9e921
[centrality] reverted back to the "old" code_checker.sh"
bedupako12mas Aug 13, 2024
9f3c4bb
[centrality] removed driver file in src directory
bedupako12mas Aug 13, 2024
e11145a
[centrality] added basic description. Need to paraphrase
bedupako12mas Aug 13, 2024
12b8409
[centrality] added explanation for results. Need to paraphrase
bedupako12mas Aug 13, 2024
0c3e0f9
[centrality] minor changes to docs and homework
bedupako12mas Aug 13, 2024
09abfe3
[centrality] added metrics to release notes
bedupako12mas Aug 13, 2024
a875373
[centrality] removed explanation TODO
bedupako12mas Aug 13, 2024
b18c85e
[centrality] updated NEWS.md
bedupako12mas Aug 13, 2024
8b4d010
[centrality] paraphrased the docs description
bedupako12mas Aug 15, 2024
43770f9
[centrality] minor changes and added comments
bedupako12mas Aug 16, 2024
12d5700
[centrality] removed the TODO: Paraphrase
bedupako12mas Aug 16, 2024
826cc5f
[centrality] made changes to docs
bedupako12mas Aug 16, 2024
5954b43
[centrality] minor doc changes
bedupako12mas Aug 16, 2024
0ec3671
[centrality] wrapped types_check.pg
bedupako12mas Aug 16, 2024
1a44149
[centrality] made doc and docqueries changes
bedupako12mas Aug 16, 2024
5557de6
[centrality] removed test.conf
bedupako12mas Aug 16, 2024
8c4e7bf
[centrality] fixed email
bedupako12mas Aug 16, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/boost_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ name: Boost supported versions
# - 1.56 is the minimum version we ask (Aug 2014)

on:
workflow_dispatch:
push:
paths:
- '.github/workflows/boost_version.yml'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/check-queries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ name: Check queries
# - the latest postgis version

on:
workflow_dispatch:
push:
paths:
- '.github/workflows/check-queries.yml'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ name: Build for Ubuntu with clang
# - postgis 3

on:
workflow_dispatch:
push:
paths:
- '.github/workflows/clang.yml'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tidy-check.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: clang-tidy check

on:
workflow_dispatch:
pull_request:
branches-ignore:
- 'gh-pages'
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ To see all issues & pull requests closed by this release see the [Git closed
milestone for 3.7.0
](https://github.com/pgRouting/pgrouting/issues?utf8=%E2%9C%93&q=milestone%3A%22Release%203.7.0%22)

**New experimental functions**

* Metrics

* pgr_betweennessCentrality

**Official functions changes**

* [#2605](https://github.com/pgRouting/pgrouting/pull/2605) Standarize
Expand Down
4 changes: 2 additions & 2 deletions doc/metrics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

SET(LOCAL_FILES
metrics-family.rst
pgr_betweennessCentrality.rst
)
)

foreach (f ${LOCAL_FILES})
configure_file(${f} "${PGR_DOCUMENTATION_SOURCE_DIR}/${f}")
list(APPEND LOCAL_DOC_FILES ${PGR_DOCUMENTATION_SOURCE_DIR}/${f})
endforeach()

set(PROJECT_DOC_FILES ${PROJECT_DOC_FILES} ${LOCAL_DOC_FILES} PARENT_SCOPE)

41 changes: 41 additions & 0 deletions doc/metrics/metrics-family.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
..
****************************************************************************
pgRouting Manual
Copyright(c) pgRouting Contributors

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

|



Metrics - Family of functions
===============================================================================

.. rubric:: Experimental

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

.. index experimental from here

* :doc:`pgr_betweennessCentrality` - Calculates relative betweenness centrality using Brandes Algorithm

.. index experimental to here


.. toctree::
:hidden:

pgr_betweennessCentrality

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

.. rubric:: Indices and tables

* :ref:`genindex`
* :ref:`search`
78 changes: 58 additions & 20 deletions doc/metrics/pgr_betweennessCentrality.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,42 @@
``pgr_betweennessCentrality``
===============================================================================

``pgr_betweennessCentrality`` - Returns the relative betweeness centrality of
all vertices in a graph using Brandes Algorithm.
``pgr_betweennessCentrality`` - Calculates the relative betweeness centrality
using Brandes Algorithm

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

Boost Graph Inside

.. rubric:: Availability
.. TODO: Add availability

* Version 3.7.0

* New **experimental** function:

* ``pgr_betweennessCentrality``

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

The Brandes Algorithm for utilises the sparse nature of graphs to evaluating the
betweenness centrality score of all edges/vertices.
We use Boost's implementation which runs in :math:`\Theta(VE)` time and uses :math:`\Theta(VE)` space.
The Brandes Algorithm takes advantage of the sparse graphs for evaluating the
betweenness centrality score of all vertices.


Betweenness centrality measures the extent to which a vertex lies on the
shortest paths between all other pairs of vertices. Vertices with a high
betweenness centrality score may have considerable influence in a network by the
virtue of their control over the shortest paths passing between them.

The removal of these vertices will affect the network by disrupting the
it, as most of the shortest paths between vertices pass through them.

This implementation work for both directed and undirected graphs.

- Running time: :math:`\Theta(VE)`
- Running space: :math:`\Theta(VE)`
- Throws when there are no edges in the graph

Signatures
-------------------------------------------------------------------------------
Expand All @@ -41,16 +60,38 @@ Signatures

pgr_betweennessCentrality(`Edges SQL`_, [``directed``])

| Returns set of ```(seq, vid, centrality)```
| OR EMPTY SET
| Returns set of ``(vid, centrality)``

.. TODO: Fix this when docqueries are made

:Example: For a directed subgraph with edges :math:`\{1, 2, 3, 4\}`.
:Example: For a directed graph with edges :math:`\{1, 2, 3, 4\}`.

.. literalinclude:: betweennessCentrality.queries
:start-after: -- q1
:end-before: Implicit Cases (directed)
:end-before: -- q2

.. rubric:: Explanation

* The betweenness centrality are between parenthesis.
* The leaf vertices have betweenness centrality :math:`0`.
* Betweenness centrality of vertex :math:`6` is higher than of vertex :math:`10`.

* Removing vertex :math:`6` will create three graph components.
* Removing vertex :math:`10` will create two graph components.

.. graphviz::

digraph G {
5, 7, 15 [shape=circle;style=filled;width=.5;color=deepskyblue;fontsize=8;fixedsize=true;];
6, 10 [shape=circle;style=filled;width=.5;color=green;fontsize=8;fixedsize=true;];
5 [pos="0,0!";label="5 (0)"];
6 [pos="0,1!"label="6 (0.5)"];
7 [pos="0,2!"label="7 (0)"];
10 [pos="1,1!"label="10 (0.25)"];
15 [pos="2,1!"label="15 (0)"];
5 -> 6 [dir=both;label="1 "];
6->7 [dir=both;label="4 "];
10->6 [label="3"];
15->10 [label="4"];
}

Parameters
-------------------------------------------------------------------------------
Expand Down Expand Up @@ -83,26 +124,23 @@ Result columns
:width: 81
:widths: auto
:header-rows: 1

* - Column
- Type
- Description
* - ``seq``
- ``INTEGER``
- Sequential Value starting from ``1``
* - ``vid``
- ``BIGINT``
- Identifier of the vertex
* - ``centrality``
- ``FLOAT``
- relative betweenness centrality score of the vertex (will be in range [0,1])
- ``FLOAT``
- Relative betweenness centrality score of the vertex (will be in range [0,1])

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

* Boost `centrality
* Boost's `betweenness_centrality
<https://www.boost.org/doc/libs/1_84_0/libs/graph/doc/betweenness_centrality.html>`_
* Queries uses the :doc:`sampledata` network.
* Queries use the :doc:`sampledata` network.

.. rubric:: Indices and tables

Expand Down
9 changes: 7 additions & 2 deletions doc/src/experimental.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ Experimental Functions
:start-after: index from here
:end-before: index to here

:doc:`metrics-family`

.. include:: metrics-family.rst
:start-after: index experimental from here
:end-before: index experimental to here

:doc:`TRSP-family`

.. include:: TRSP-family.rst
Expand All @@ -96,6 +102,7 @@ Experimental Functions
transformation-family
components-family
ordering-family
metrics-family

.. rubric:: categories

Expand All @@ -121,7 +128,6 @@ Experimental Functions
- :doc:`pgr_transitiveClosure`
- :doc:`pgr_lengauerTarjanDominatorTree`
- :doc:`pgr_hawickCircuits`
- :doc:`pgr_betweennessCentrality`

.. toctree::
:hidden:
Expand All @@ -137,7 +143,6 @@ Experimental Functions
pgr_transitiveClosure
pgr_lengauerTarjanDominatorTree
pgr_hawickCircuits
pgr_betweennessCentrality


See Also
Expand Down
6 changes: 6 additions & 0 deletions doc/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ To see all issues & pull requests closed by this release see the `Git closed
milestone for 3.7.0
<https://github.com/pgRouting/pgrouting/issues?utf8=%E2%9C%93&q=milestone%3A%22Release%203.7.0%22>`__

.. rubric:: New experimental functions

* Metrics

* pgr_betweennessCentrality

.. rubric:: Official functions changes

* `#2605 <https://github.com/pgRouting/pgrouting/pull/2605>`__ Standarize
Expand Down
63 changes: 1 addition & 62 deletions docqueries/metrics/betweennessCentrality.pg
Original file line number Diff line number Diff line change
Expand Up @@ -6,65 +6,4 @@ SELECT * FROM pgr_betweennessCentrality(
'SELECT id, source, target, cost, reverse_cost
FROM edges where id < 5'
) ORDER BY vid;
/* Implicit Cases (directed) */
SELECT * FROM pgr_betweennessCentrality(
'SELECT id, source, target, cost, reverse_cost
FROM edges where id < 2'
) ORDER BY vid;

SELECT * FROM pgr_betweennessCentrality(
'SELECT id, source, target, cost, reverse_cost
FROM edges where id < 3'
) ORDER BY vid;

SELECT * FROM pgr_betweennessCentrality(
'SELECT id, source, target, cost, reverse_cost
FROM edges where id < 4'
) ORDER BY vid;

SELECT * FROM pgr_betweennessCentrality(
'SELECT id, source, target, cost, reverse_cost
FROM edges where id < 5'
) ORDER BY vid;

/* Explicit Cases (undirected) */
SELECT * FROM pgr_betweennessCentrality(
'SELECT id, source, target, cost, reverse_cost
FROM edges where id < 2', directed => false
) ORDER BY vid;

SELECT * FROM pgr_betweennessCentrality(
'SELECT id, source, target, cost, reverse_cost
FROM edges where id < 3', directed => false
) ORDER BY vid;

SELECT * FROM pgr_betweennessCentrality(
'SELECT id, source, target, cost, reverse_cost
FROM edges where id < 4', directed => false
) ORDER BY vid;

SELECT * FROM pgr_betweennessCentrality(
'SELECT id, source, target, cost, reverse_cost
FROM edges where id < 5', directed => false
) ORDER BY vid;

/* Explicit Cases (directed) */
SELECT * FROM pgr_betweennessCentrality(
'SELECT id, source, target, cost, reverse_cost
FROM edges where id < 2', directed => true
) ORDER BY vid;

SELECT * FROM pgr_betweennessCentrality(
'SELECT id, source, target, cost, reverse_cost
FROM edges where id < 3', directed => true
) ORDER BY vid;

SELECT * FROM pgr_betweennessCentrality(
'SELECT id, source, target, cost, reverse_cost
FROM edges where id < 4', directed => true
) ORDER BY vid;

SELECT * FROM pgr_betweennessCentrality(
'SELECT id, source, target, cost, reverse_cost
FROM edges where id < 5', directed => true
) ORDER BY vid;
/* -- q2 */
Loading
Loading