Skip to content

Commit c21f156

Browse files
Merge pull request #403 from bedupako12mas/Centrality-Week12
Centrality week12
2 parents 2d398b3 + 8c4e7bf commit c21f156

File tree

99 files changed

+589
-1121
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+589
-1121
lines changed

.github/workflows/boost_version.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ name: Boost supported versions
2727
# - 1.56 is the minimum version we ask (Aug 2014)
2828

2929
on:
30+
workflow_dispatch:
3031
push:
3132
paths:
3233
- '.github/workflows/boost_version.yml'

.github/workflows/check-queries.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ name: Check queries
1212
# - the latest postgis version
1313

1414
on:
15+
workflow_dispatch:
1516
push:
1617
paths:
1718
- '.github/workflows/check-queries.yml'

.github/workflows/clang.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ name: Build for Ubuntu with clang
1111
# - postgis 3
1212

1313
on:
14+
workflow_dispatch:
1415
push:
1516
paths:
1617
- '.github/workflows/clang.yml'

.github/workflows/tidy-check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: clang-tidy check
22

33
on:
4+
workflow_dispatch:
45
pull_request:
56
branches-ignore:
67
- 'gh-pages'

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ To see all issues & pull requests closed by this release see the [Git closed
1212
milestone for 3.7.0
1313
](https://github.com/pgRouting/pgrouting/issues?utf8=%E2%9C%93&q=milestone%3A%22Release%203.7.0%22)
1414

15+
**New experimental functions**
16+
17+
* Metrics
18+
19+
* pgr_betweennessCentrality
20+
1521
**Official functions changes**
1622

1723
* [#2605](https://github.com/pgRouting/pgrouting/pull/2605) Standarize

doc/metrics/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

22
SET(LOCAL_FILES
3+
metrics-family.rst
34
pgr_betweennessCentrality.rst
4-
)
5+
)
56

67
foreach (f ${LOCAL_FILES})
78
configure_file(${f} "${PGR_DOCUMENTATION_SOURCE_DIR}/${f}")
89
list(APPEND LOCAL_DOC_FILES ${PGR_DOCUMENTATION_SOURCE_DIR}/${f})
910
endforeach()
1011

1112
set(PROJECT_DOC_FILES ${PROJECT_DOC_FILES} ${LOCAL_DOC_FILES} PARENT_SCOPE)
12-

doc/metrics/metrics-family.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
..
2+
****************************************************************************
3+
pgRouting Manual
4+
Copyright(c) pgRouting Contributors
5+
6+
This documentation is licensed under a Creative Commons Attribution-Share
7+
Alike 3.0 License: https://creativecommons.org/licenses/by-sa/3.0/
8+
****************************************************************************
9+
10+
|
11+
12+
13+
14+
Metrics - Family of functions
15+
===============================================================================
16+
17+
.. rubric:: Experimental
18+
19+
.. include:: experimental.rst
20+
:start-after: begin-warn-expr
21+
:end-before: end-warn-expr
22+
23+
.. index experimental from here
24+
25+
* :doc:`pgr_betweennessCentrality` - Calculates relative betweenness centrality using Brandes Algorithm
26+
27+
.. index experimental to here
28+
29+
30+
.. toctree::
31+
:hidden:
32+
33+
pgr_betweennessCentrality
34+
35+
See Also
36+
-------------------------------------------------------------------------------
37+
38+
.. rubric:: Indices and tables
39+
40+
* :ref:`genindex`
41+
* :ref:`search`

doc/metrics/pgr_betweennessCentrality.rst

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,42 @@
1313
``pgr_betweennessCentrality``
1414
===============================================================================
1515

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

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

2222
Boost Graph Inside
2323

2424
.. rubric:: Availability
25-
.. TODO: Add availability
25+
26+
* Version 3.7.0
27+
28+
* New **experimental** function:
29+
30+
* ``pgr_betweennessCentrality``
2631

2732
Description
2833
-------------------------------------------------------------------------------
2934

30-
The Brandes Algorithm for utilises the sparse nature of graphs to evaluating the
31-
betweenness centrality score of all edges/vertices.
32-
We use Boost's implementation which runs in :math:`\Theta(VE)` time and uses :math:`\Theta(VE)` space.
35+
The Brandes Algorithm takes advantage of the sparse graphs for evaluating the
36+
betweenness centrality score of all vertices.
37+
38+
39+
Betweenness centrality measures the extent to which a vertex lies on the
40+
shortest paths between all other pairs of vertices. Vertices with a high
41+
betweenness centrality score may have considerable influence in a network by the
42+
virtue of their control over the shortest paths passing between them.
43+
44+
The removal of these vertices will affect the network by disrupting the
45+
it, as most of the shortest paths between vertices pass through them.
46+
47+
This implementation work for both directed and undirected graphs.
48+
49+
- Running time: :math:`\Theta(VE)`
50+
- Running space: :math:`\Theta(VE)`
51+
- Throws when there are no edges in the graph
3352

3453
Signatures
3554
-------------------------------------------------------------------------------
@@ -41,16 +60,38 @@ Signatures
4160

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

44-
| Returns set of ```(seq, vid, centrality)```
45-
| OR EMPTY SET
63+
| Returns set of ``(vid, centrality)``
4664
47-
.. TODO: Fix this when docqueries are made
48-
49-
:Example: For a directed subgraph with edges :math:`\{1, 2, 3, 4\}`.
65+
:Example: For a directed graph with edges :math:`\{1, 2, 3, 4\}`.
5066

5167
.. literalinclude:: betweennessCentrality.queries
5268
:start-after: -- q1
53-
:end-before: Implicit Cases (directed)
69+
:end-before: -- q2
70+
71+
.. rubric:: Explanation
72+
73+
* The betweenness centrality are between parenthesis.
74+
* The leaf vertices have betweenness centrality :math:`0`.
75+
* Betweenness centrality of vertex :math:`6` is higher than of vertex :math:`10`.
76+
77+
* Removing vertex :math:`6` will create three graph components.
78+
* Removing vertex :math:`10` will create two graph components.
79+
80+
.. graphviz::
81+
82+
digraph G {
83+
5, 7, 15 [shape=circle;style=filled;width=.5;color=deepskyblue;fontsize=8;fixedsize=true;];
84+
6, 10 [shape=circle;style=filled;width=.5;color=green;fontsize=8;fixedsize=true;];
85+
5 [pos="0,0!";label="5 (0)"];
86+
6 [pos="0,1!"label="6 (0.5)"];
87+
7 [pos="0,2!"label="7 (0)"];
88+
10 [pos="1,1!"label="10 (0.25)"];
89+
15 [pos="2,1!"label="15 (0)"];
90+
5 -> 6 [dir=both;label="1 "];
91+
6->7 [dir=both;label="4 "];
92+
10->6 [label="3"];
93+
15->10 [label="4"];
94+
}
5495

5596
Parameters
5697
-------------------------------------------------------------------------------
@@ -83,26 +124,23 @@ Result columns
83124
:width: 81
84125
:widths: auto
85126
:header-rows: 1
86-
127+
87128
* - Column
88129
- Type
89130
- Description
90-
* - ``seq``
91-
- ``INTEGER``
92-
- Sequential Value starting from ``1``
93131
* - ``vid``
94132
- ``BIGINT``
95133
- Identifier of the vertex
96134
* - ``centrality``
97-
- ``FLOAT``
98-
- relative betweenness centrality score of the vertex (will be in range [0,1])
135+
- ``FLOAT``
136+
- Relative betweenness centrality score of the vertex (will be in range [0,1])
99137

100138
See Also
101139
-------------------------------------------------------------------------------
102140

103-
* Boost `centrality
141+
* Boost's `betweenness_centrality
104142
<https://www.boost.org/doc/libs/1_84_0/libs/graph/doc/betweenness_centrality.html>`_
105-
* Queries uses the :doc:`sampledata` network.
143+
* Queries use the :doc:`sampledata` network.
106144

107145
.. rubric:: Indices and tables
108146

doc/src/experimental.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ Experimental Functions
8383
:start-after: index from here
8484
:end-before: index to here
8585

86+
:doc:`metrics-family`
87+
88+
.. include:: metrics-family.rst
89+
:start-after: index experimental from here
90+
:end-before: index experimental to here
91+
8692
:doc:`TRSP-family`
8793

8894
.. include:: TRSP-family.rst
@@ -96,6 +102,7 @@ Experimental Functions
96102
transformation-family
97103
components-family
98104
ordering-family
105+
metrics-family
99106

100107
.. rubric:: categories
101108

@@ -121,7 +128,6 @@ Experimental Functions
121128
- :doc:`pgr_transitiveClosure`
122129
- :doc:`pgr_lengauerTarjanDominatorTree`
123130
- :doc:`pgr_hawickCircuits`
124-
- :doc:`pgr_betweennessCentrality`
125131

126132
.. toctree::
127133
:hidden:
@@ -137,7 +143,6 @@ Experimental Functions
137143
pgr_transitiveClosure
138144
pgr_lengauerTarjanDominatorTree
139145
pgr_hawickCircuits
140-
pgr_betweennessCentrality
141146

142147

143148
See Also

doc/src/release_notes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ To see all issues & pull requests closed by this release see the `Git closed
4343
milestone for 3.7.0
4444
<https://github.com/pgRouting/pgrouting/issues?utf8=%E2%9C%93&q=milestone%3A%22Release%203.7.0%22>`__
4545

46+
.. rubric:: New experimental functions
47+
48+
* Metrics
49+
50+
* pgr_betweennessCentrality
51+
4652
.. rubric:: Official functions changes
4753

4854
* `#2605 <https://github.com/pgRouting/pgrouting/pull/2605>`__ Standarize

docqueries/metrics/betweennessCentrality.pg

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,4 @@ SELECT * FROM pgr_betweennessCentrality(
66
'SELECT id, source, target, cost, reverse_cost
77
FROM edges where id < 5'
88
) ORDER BY vid;
9-
/* Implicit Cases (directed) */
10-
SELECT * FROM pgr_betweennessCentrality(
11-
'SELECT id, source, target, cost, reverse_cost
12-
FROM edges where id < 2'
13-
) ORDER BY vid;
14-
15-
SELECT * FROM pgr_betweennessCentrality(
16-
'SELECT id, source, target, cost, reverse_cost
17-
FROM edges where id < 3'
18-
) ORDER BY vid;
19-
20-
SELECT * FROM pgr_betweennessCentrality(
21-
'SELECT id, source, target, cost, reverse_cost
22-
FROM edges where id < 4'
23-
) ORDER BY vid;
24-
25-
SELECT * FROM pgr_betweennessCentrality(
26-
'SELECT id, source, target, cost, reverse_cost
27-
FROM edges where id < 5'
28-
) ORDER BY vid;
29-
30-
/* Explicit Cases (undirected) */
31-
SELECT * FROM pgr_betweennessCentrality(
32-
'SELECT id, source, target, cost, reverse_cost
33-
FROM edges where id < 2', directed => false
34-
) ORDER BY vid;
35-
36-
SELECT * FROM pgr_betweennessCentrality(
37-
'SELECT id, source, target, cost, reverse_cost
38-
FROM edges where id < 3', directed => false
39-
) ORDER BY vid;
40-
41-
SELECT * FROM pgr_betweennessCentrality(
42-
'SELECT id, source, target, cost, reverse_cost
43-
FROM edges where id < 4', directed => false
44-
) ORDER BY vid;
45-
46-
SELECT * FROM pgr_betweennessCentrality(
47-
'SELECT id, source, target, cost, reverse_cost
48-
FROM edges where id < 5', directed => false
49-
) ORDER BY vid;
50-
51-
/* Explicit Cases (directed) */
52-
SELECT * FROM pgr_betweennessCentrality(
53-
'SELECT id, source, target, cost, reverse_cost
54-
FROM edges where id < 2', directed => true
55-
) ORDER BY vid;
56-
57-
SELECT * FROM pgr_betweennessCentrality(
58-
'SELECT id, source, target, cost, reverse_cost
59-
FROM edges where id < 3', directed => true
60-
) ORDER BY vid;
61-
62-
SELECT * FROM pgr_betweennessCentrality(
63-
'SELECT id, source, target, cost, reverse_cost
64-
FROM edges where id < 4', directed => true
65-
) ORDER BY vid;
66-
67-
SELECT * FROM pgr_betweennessCentrality(
68-
'SELECT id, source, target, cost, reverse_cost
69-
FROM edges where id < 5', directed => true
70-
) ORDER BY vid;
9+
/* -- q2 */

0 commit comments

Comments
 (0)