GClasses
|
Computes the number of times that the shortest-path between every pair of points passes over each edge and vertex.
#include <GGraph.h>
Public Member Functions | |
GBrandesBetweennessCentrality (size_t nodes) | |
~GBrandesBetweennessCentrality () | |
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.) More... | |
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.) More... | |
void | compute () |
Computes the betweenness for all nodes. (You must add all the edges before calling this.) This takes O(VE) time, where V is the number of vertices, and E is the number of edges. More... | |
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. More... | |
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". More... | |
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. More... | |
size_t | nodeCount () |
Returns the number of nodes in the graph. More... | |
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. More... | |
Static Public Member Functions | |
static void | test () |
Performs unit tests for this class. Throws an exception if there is a failure. More... | |
Protected Attributes | |
size_t | m_nodeCount |
std::vector< double > * | m_pEdgeBetweenness |
std::vector< size_t > * | m_pNeighbors |
double * | m_pVertexBetweenness |
GClasses::GBrandesBetweennessCentrality::GBrandesBetweennessCentrality | ( | size_t | nodes | ) |
GClasses::GBrandesBetweennessCentrality::~GBrandesBetweennessCentrality | ( | ) |
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.) This takes O(VE) time, where V is the number of vertices, and E is the number of edges.
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 |
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.
|
protected |
|
protected |
|
protected |
|
protected |