Class DynTopHarmonicCloseness

Inheritance Relationships

Base Types

Class Documentation

class DynTopHarmonicCloseness : public NetworKit::Algorithm, public NetworKit::DynAlgorithm

Manages the list of the k nodes with the highest closeness centrality in a dynamic graph.

Public Functions

DynTopHarmonicCloseness(const Graph &G, count k = 1, bool useBFSbound = false)

Constructs the DynTopHarmonicCloseness class. This class implements dynamic algorithms for harmonic top-k closeness centrality. The implementation is based on the static algorithms by Borassi et al. (complex networks) and Bergamini et al. (large-diameter networks).

Parameters:
  • G – The graph.

  • k – The number of top nodes.

  • useBFSbound – Whether to use the algorithm for networks with large diameter

~DynTopHarmonicCloseness() override
virtual void run() override

Computes the k most central nodes on the initial graph.

inline std::vector<node> topkNodesList(bool includeTrail = false)

Returns a list with the k most central nodes. WARNING: closeness centrality of some nodes below the top-k could be equal to the k-th closeness, we call them trail. Set the parameter includeTrail to true to also include those nodes but consider that the resulting vector could be longer than k.

Parameters:

includeTrail – Whether or not to include trail nodes.

Returns:

The list of the top-k nodes.

inline std::vector<edgeweight> topkScoresList(bool includeTrail = false)

Returns a list with the k highest closeness centralities. WARNING: closeness centrality of some nodes below the top-k could be equal to the k-th closeness, we call them trail. Set the parameter includeTrail to true to also include those centrality values but consider that the resulting vector could be longer than k.

Parameters:

includeTrail – Whether or not to include trail centrality value.

Returns:

The closeness centralities of the k most central nodes.

std::vector<std::pair<node, edgeweight>> ranking(bool includeTrail = false)

Returns the ranking of the k most central nodes in the graph. WARNING: closeness centrality of some nodes below the top-k could be equal to the k-th closeness, we call them trail. Set the parameter includeTrail to true to also include those nodes but consider that the resulting vector could be longer than k.

Parameters:

includeTrail – Whether or not to include trail nodes.

Returns:

The ranking.

void reset()
virtual void update(GraphEvent event) override

Updates the list of the k nodes with the highest closeness in G.

Parameters:

event – The edge modification event.

virtual void updateBatch(const std::vector<GraphEvent> &batch) override

Updates the list of k nodes with the highest closeness in G after a batch of updates.

Parameters:

batch – A vector of edge modification events.

Protected Functions

std::pair<edgeweight, bool> BFScut(node v, edgeweight x, count n, count r, std::vector<uint8_t> &visited, std::vector<count> &distances, std::vector<node> &pred, count &visitedEdges)

Runs a pruned BFS from the node u. The search is aborted once the closeness centrality of u must be smaller than x.

Parameters:
  • v – The start node.

  • x – The closeness centrality of the k-th most central node.

  • n – The number of nodes in the graph.

  • r – The number of reachable nodes (or an upper bound in directed graphs) for each node.

  • visited – The vector containing the visited status.

  • distances – The vector containing the distances.

  • pred – The vector containing the predecessor of each node.

  • visitedEdges – The number of visited edges.

Returns:

void BFSbound(node x, std::vector<double> &S2, count *visEdges)

Computes the exact closeness centrality of the node x and stores upper bounds for all other nodes in S2.

Parameters:
  • x – The start node.

  • S2 – The upper bounds for all other nodes.

  • visEdges – The number of visited edges.

void addEdge(const GraphEvent &event)

Handles an edge insertion.

Parameters:

event – The graph event.

void removeEdge(const GraphEvent &event)

Handles an edge removal.

Parameters:

event – The graph event.

void computeReachableNodes()

Computes the number of reachable nodes or an upper bound in directed graphs.

void computeReachableNodesDirected()

Computes an upper bound for the number of reachable nodes for each node in a directed graph.

void computeReachableNodesUndirected()

Computes the number of reachable nodes in an undirected graph.

void updateReachableNodesAfterInsertion(node u, node v)

Recomputes the number of reachable nodes in an undirected graph after inserting an edge between u and v.

Parameters:
  • u – The first node.

  • v – The second node.

void updateReachableNodesAfterDeletion(const GraphEvent &event)

Recomputes the number of reachable nodes in an undirected graph after removing an edge between u and v.

Parameters:
  • u – The first node.

  • v – The second node.

void init()

Protected Attributes

const Graph &G
count n
count k
bool useBFSbound
count trail
double minCloseness
count nMinCloseness
std::vector<node> topk
std::vector<edgeweight> topkScores
std::vector<edgeweight> allScores
std::vector<uint8_t> isExact
std::vector<uint8_t> isValid
std::vector<edgeweight> cutOff
std::vector<uint8_t> exactCutOff
DynConnectedComponents *comps
bool hasComps = false
Partition component
DynWeaklyConnectedComponents *wComps
bool hasWComps = false
std::vector<count> r
std::vector<count> rOld
std::vector<count> reachL