GClasses

GClasses::GBrandesBetweennessCentrality Class Reference

Computes the number of times that the shortest-path between every pair of points passes over each edge and vertex. More...

#include <GGraph.h>

List of all members.

Public Member Functions

 GBrandesBetweennessCentrality (size_t nodes)
 ~GBrandesBetweennessCentrality ()
size_t nodeCount ()
 Returns the number of nodes in the graph.
void addDirectedEdge (size_t from, size_t to)
 Adds a directed edge to the graph. (You must call this to add all the edges before calling compute.)
void addDirectedEdgeIfNotDupe (size_t from, size_t to)
 Adds a directed edge if the specified edge does not already exist. (This method is inefficient if there are a lot of edges. If you want efficiency, keep track of the edges yourself.)
void compute ()
 Computes the betweenness for all nodes. (You must add all the edges before calling this.)
double vertexBetweenness (size_t vertex)
 Returns the betweenness of the specified vertex. (You must call compute before calling this.) Note that for undirected graphs, you should divide this value by 2.
double edgeBetweennessByVertex (size_t vertex1, size_t vertex2)
 Returns the betweenness of the edge specified by two vertices. "compute" must be called before this method is called. Note that for undirected graphs, you should divide the value this returns by 2, since every edge will be counted in both directions. Throws an exception if there is no edge between vertex1 and vertex2. Note that this method is not as efficient as "edgeBetweennessByNeighbor".
double edgeBetweennessByNeighbor (size_t vertex, size_t neighborIndex)
 Returns the betweenness of the edge specified by vertex and neighborIndex. Note that neighborIndex is not the same as the other vertex. It is the enumeration value of each neighbor of the first vertex. To obtain the value for neighborIndex, you should call "neighborIndex" by passing in both vertices. "compute" must be called before this method is called. Note that for undirected graphs, you should divide the value this returns by 2, since every edge will be counted in both directions.
size_t neighborIndex (size_t from, size_t to)
 Returns the index of the specified neighbor "to" (by iterating over all the neighbors of "from" until it finds "to"). Returns INVALID_INDEX if not found.

Static Public Member Functions

static void test ()
 Performs unit tests for this class. Throws an exception if there is a failure.

Protected Attributes

size_t m_nodeCount
std::vector< size_t > * m_pNeighbors
double * m_pVertexBetweenness
std::vector< double > * m_pEdgeBetweenness

Detailed Description

Computes the number of times that the shortest-path between every pair of points passes over each edge and vertex.


Constructor & Destructor Documentation

GClasses::GBrandesBetweennessCentrality::GBrandesBetweennessCentrality ( size_t  nodes)
GClasses::GBrandesBetweennessCentrality::~GBrandesBetweennessCentrality ( )

Member Function Documentation

void GClasses::GBrandesBetweennessCentrality::addDirectedEdge ( size_t  from,
size_t  to 
)

Adds a directed edge to the graph. (You must call this to add all the edges before calling compute.)

void GClasses::GBrandesBetweennessCentrality::addDirectedEdgeIfNotDupe ( size_t  from,
size_t  to 
)

Adds a directed edge if the specified edge does not already exist. (This method is inefficient if there are a lot of edges. If you want efficiency, keep track of the edges yourself.)

void GClasses::GBrandesBetweennessCentrality::compute ( )

Computes the betweenness for all nodes. (You must add all the edges before calling this.)

double GClasses::GBrandesBetweennessCentrality::edgeBetweennessByNeighbor ( size_t  vertex,
size_t  neighborIndex 
)

Returns the betweenness of the edge specified by vertex and neighborIndex. Note that neighborIndex is not the same as the other vertex. It is the enumeration value of each neighbor of the first vertex. To obtain the value for neighborIndex, you should call "neighborIndex" by passing in both vertices. "compute" must be called before this method is called. Note that for undirected graphs, you should divide the value this returns by 2, since every edge will be counted in both directions.

double GClasses::GBrandesBetweennessCentrality::edgeBetweennessByVertex ( size_t  vertex1,
size_t  vertex2 
)

Returns the betweenness of the edge specified by two vertices. "compute" must be called before this method is called. Note that for undirected graphs, you should divide the value this returns by 2, since every edge will be counted in both directions. Throws an exception if there is no edge between vertex1 and vertex2. Note that this method is not as efficient as "edgeBetweennessByNeighbor".

size_t GClasses::GBrandesBetweennessCentrality::neighborIndex ( size_t  from,
size_t  to 
)

Returns the index of the specified neighbor "to" (by iterating over all the neighbors of "from" until it finds "to"). Returns INVALID_INDEX if not found.

size_t GClasses::GBrandesBetweennessCentrality::nodeCount ( )

Returns the number of nodes in the graph.

static void GClasses::GBrandesBetweennessCentrality::test ( ) [static]

Performs unit tests for this class. Throws an exception if there is a failure.

double GClasses::GBrandesBetweennessCentrality::vertexBetweenness ( size_t  vertex)

Returns the betweenness of the specified vertex. (You must call compute before calling this.) Note that for undirected graphs, you should divide this value by 2.


Member Data Documentation