graph_analysis
RandomDraw.hpp
Go to the documentation of this file.
1 #ifndef GRAPH_ANALYSIS_PERCOLATION_STRATEGIES_RANDOM_DRAW_HPP
2 #define GRAPH_ANALYSIS_PERCOLATION_STRATEGIES_RANDOM_DRAW_HPP
3 
4 #include <map>
5 #include <stdint.h>
6 #include "../../GraphElement.hpp"
7 
8 namespace graph_analysis {
9 namespace percolation {
10  class RandomNumberGenerator;
11 
12 namespace strategies {
13 
22 {
24  std::map<GraphElementId, double> mProbabilityDensity;
25 
28  bool mUpdated;
29  mutable double mProbabilityDensitySum;
30  RandomNumberGenerator* mRandomNumberGenerator;
31 
32 public:
37  RandomDraw(uint32_t seed = 0);
38 
39  ~RandomDraw();
40 
46  void setProbabilityDensity(GraphElementId id, double density);
47 
52  double getProbabilityDensitySum() const;
53 
58  double getProbability(GraphElementId id) const;
59 
63  void removeItem(GraphElementId id);
64 
69  GraphElementId drawItem() const;
70 };
71 
72 } // end namespace strategies
73 } // end namespace percolation
74 } // end namespace graph_analysis
75 #endif // GRAPH_ANALYSIS_PERCOLATION_STRATEGIES_RANDOM_DRAW_HPP
uint32_t GraphElementId
Definition: GraphElement.hpp:21
double getProbabilityDensitySum() const
Definition: RandomDraw.cpp:30
Randomly draws items from a given set, based on given probability densities. Uses RandomNumberGenerat...
Definition: RandomDraw.hpp:21
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
Percolation deals with a changing graph, i.e., nodes and edges that disappear from the graph...
GraphElementId drawItem() const
Definition: RandomDraw.cpp:83
double getProbability(GraphElementId id) const
Definition: RandomDraw.cpp:46
void setProbabilityDensity(GraphElementId id, double density)
Definition: RandomDraw.cpp:24
Definition: RandomNumberGenerator.hpp:14
void removeItem(GraphElementId id)
Definition: RandomDraw.cpp:68
RandomDraw(uint32_t seed=0)
Definition: RandomDraw.cpp:12