Skip to content

Commit 2d398b3

Browse files
Merge pull request #402 from bedupako12mas/Centrality-Week11
Centrality Week 11
2 parents 906e104 + 466ffd4 commit 2d398b3

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

include/metrics/betweennessCentrality.hpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
4545
#include "cpp_common/pgr_base_graph.hpp"
4646
#include "cpp_common/interruption.hpp"
4747

48-
// TODO(arun) don't keep it here
4948
#include "cpp_common/pgr_alloc.hpp"
5049

50+
/**
51+
* @ brief The main file which calls the respective boost function
52+
*
53+
* Contains actual implementation of the function and the calling
54+
* of the respective boost function
55+
*/
56+
5157
namespace pgrouting {
5258
template <class G> class Pgr_metrics;
5359

@@ -68,26 +74,39 @@ pgr_betweennesscentrality(
6874
template <class G>
6975
class Pgr_metrics {
7076
public:
77+
/** @name betweennessCentrality
78+
* @{
79+
*
80+
*/
81+
82+
/** @brief betweennessCentrality function
83+
*
84+
* It does all the processing and returns the results.
85+
*
86+
* @param graph the graph containing the edges
87+
*
88+
* @see [boost::brandes_betweenness_centrality]
89+
* (https://www.boost.org/doc/libs/1_85_0/libs/graph/doc/betweenness_centrality.html)
90+
*/
7191
using Graph = typename G::B_G;
72-
using Vertex = typename G::V;
92+
using V = typename G::V;
93+
using E = typename G::E;
7394
typedef typename boost::graph_traits<Graph>::directed_category directed_category;
7495

7596
void betweennessCentrality(
7697
const G &graph,
7798
size_t &result_tuple_count,
7899
IID_t_rt **postgres_rows ) {
79100
std::vector<double> centrality(boost::num_vertices(graph.graph), 0.0);
80-
101+
// stores the centrality values for all vertices of the graph
81102
auto centrality_map = boost::make_iterator_property_map(centrality.begin(),
82-
boost::get(boost::vertex_index, graph.graph));
83-
103+
boost::get(boost::vertex_index, graph.graph));
84104

85105
/* abort in case of an interruption occurs (e.g. the query is being cancelled) */
86106
CHECK_FOR_INTERRUPTS();
87107
boost::brandes_betweenness_centrality(
88108
graph.graph,
89109
centrality_map);
90-
91110
if (boost::num_vertices(graph.graph) > 2) {
92111
boost::relative_betweenness_centrality(
93112
graph.graph,

0 commit comments

Comments
 (0)