Code Documentation 3.6
Social Network Visualizer
Loading...
Searching...
No Matches
thread_local_state.h
Go to the documentation of this file.
1
21
22#ifndef SOCNETV_THREAD_LOCAL_STATE_H
23#define SOCNETV_THREAD_LOCAL_STATE_H
24
26
27#include <QVector>
28#include <QtGlobal>
29
31{
32 // Reused SSSP scratch — reset once per source via pss.resetPerSource().
34
35 // Partial betweenness centrality sums, indexed by vertex position.
36 // Each source contributes pss.delta[wi] for every intermediate vertex w != s
37 // instead of calling vertex->setBC() directly (which would race across threads).
38 // Post-loop: vertex[wi]->setBC( sum over all threads of partialBC[wi] )
39 QVector<qreal> partialBC;
40
41 // Partial stress centrality sums, indexed by vertex position.
42 // Each new shortest path through vertex ui increments partialSC[ui] by 1
43 // instead of calling vertex->setSC() directly.
44 // Post-loop: vertex[ui]->setSC( sum over all threads of partialSC[ui] )
45 QVector<qreal> partialSC;
46
47 // Sum of pss.sourceDistanceSum across all sources this thread has processed.
48 // Originates from BFS inner-loop "dist_w" accumulation (not used by Dijkstra).
49 // Reduced into graph.addToDistanceSum() after the parallel loop.
51
52 // Sum of per-source distances_sum_for_s (computeCentralities path only).
53 // This is the CC-denominator sum that also goes into graphSumDistance.
54 // Reduced into graph.addToDistanceSum() after the parallel loop.
56
57 // Total geodesic-path count across all sources this thread has processed.
58 // Replaces repeated graph.incGeodesicsCount() calls inside BFS / Dijkstra.
59 // Reduced via graph.addGeodesicsCount() after the parallel loop.
61
62 // Maximum geodesic distance (diameter) seen by this thread.
63 // Replaces graph.setDiameterCached() inside BFS / Dijkstra.
64 // Post-loop: graph.setDiameterCached( max over all threads of maxDiameter )
65 int maxDiameter = 0;
66
67 // Accumulated Power Centrality and Standardised Power Centrality sums.
68 // Replaces direct graph.sumPC += and graph.sumSPC += inside the source loop
69 // (those graph members are public but would race across threads).
70 // Reduced into graph.sumPC and graph.sumSPC after the parallel loop.
71 qreal totalSumPC = 0;
72 qreal totalSumSPC = 0;
73
74 // Initialise all per-vertex arrays to totalV slots.
75 // Must be called once per thread before the parallel source loop starts.
76 void allocate(int totalV)
77 {
78 pss.allocate(totalV);
79 partialBC.fill(0.0, totalV);
80 partialSC.fill(0.0, totalV);
81 }
82};
83
84#endif // SOCNETV_THREAD_LOCAL_STATE_H
Per-source scratch state for the Brandes SSSP / centrality computation.
Definition per_source_scratch.h:25
Definition thread_local_state.h:31
qreal totalCCDistanceSum
Definition thread_local_state.h:55
QVector< qreal > partialBC
Definition thread_local_state.h:39
QVector< qreal > partialSC
Definition thread_local_state.h:45
void allocate(int totalV)
Definition thread_local_state.h:76
PerSourceScratch pss
Definition thread_local_state.h:33
qreal totalSumSPC
Definition thread_local_state.h:72
int totalGeodesicsCount
Definition thread_local_state.h:60
int maxDiameter
Definition thread_local_state.h:65
qreal totalSumPC
Definition thread_local_state.h:71
qreal totalDistanceSum
Definition thread_local_state.h:50