Code Documentation 3.8
Social Network Visualizer
Loading...
Searching...
No Matches
thread_local_state.h
Go to the documentation of this file.
1
23
24#ifndef SOCNETV_THREAD_LOCAL_STATE_H
25#define SOCNETV_THREAD_LOCAL_STATE_H
26
28
29#include <QVector>
30#include <QtGlobal>
31
33{
34 // Reused SSSP scratch — reset once per source via pss.resetPerSource().
36
37 // Partial betweenness centrality sums, indexed by vertex position.
38 // Each source contributes pss.delta[wi] for every intermediate vertex w != s
39 // instead of calling vertex->setBC() directly (which would race across threads).
40 // Post-loop: vertex[wi]->setBC( sum over all threads of partialBC[wi] )
41 QVector<qreal> partialBC;
42
43 // Partial stress centrality sums, indexed by vertex position.
44 // Each vertex ui that is a direct predecessor of some w on the final settled shortest-path
45 // DAG from a source increments partialSC[ui] by 1 - accumulated in the same Brandes
46 // back-propagation loop that computes partialBC, from pss.Ps/pss.sigma, not during relaxation.
47 // Post-loop: vertex[ui]->setSC( sum over all threads of partialSC[ui] )
48 QVector<qreal> partialSC;
49
50 // Sum, across all sources this thread has processed, of each source's final-distance sum
51 // (accumulated in the APSP write-back loop from tls.pss.dist[], after SSSP has fully
52 // settled - correct for both BFS and Dijkstra).
53 // Reduced into graph.addToDistanceSum() after the parallel loop.
55
56 // Maximum geodesic distance (diameter) seen by this thread. qreal, not int: on a weighted
57 // graph this is routinely fractional, same as totalDistanceSum.
58 // Post-loop: graph.setDiameterCached( max over all threads of maxDiameter )
59 qreal maxDiameter = 0;
60
61 // Accumulated Power Centrality and Standardised Power Centrality sums.
62 // Replaces direct graph.sumPC += and graph.sumSPC += inside the source loop
63 // (those graph members are public but would race across threads).
64 // Reduced into graph.sumPC and graph.sumSPC after the parallel loop.
65 qreal totalSumPC = 0;
66 qreal totalSumSPC = 0;
67
68 // Initialise all per-vertex arrays to totalV slots.
69 // Must be called once per thread before the parallel source loop starts.
70 void allocate(int totalV)
71 {
72 pss.allocate(totalV);
73 partialBC.fill(0.0, totalV);
74 partialSC.fill(0.0, totalV);
75 }
76};
77
78#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:33
QVector< qreal > partialBC
Definition thread_local_state.h:41
QVector< qreal > partialSC
Definition thread_local_state.h:48
void allocate(int totalV)
Definition thread_local_state.h:70
PerSourceScratch pss
Definition thread_local_state.h:35
qreal totalSumSPC
Definition thread_local_state.h:66
qreal totalSumPC
Definition thread_local_state.h:65
qreal totalDistanceSum
Definition thread_local_state.h:54
qreal maxDiameter
Definition thread_local_state.h:59