All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PubWebGenerator.h
Go to the documentation of this file.
1 /*
2  * PubWebGenerator.h
3  *
4  * Created on: Apr 10, 2013
5  * Author: Henning
6  */
7 
8 #ifndef PUBWEBGENERATOR_H_
9 #define PUBWEBGENERATOR_H_
10 
11 #include "StaticGraphGenerator.h"
12 
13 #define _USE_MATH_DEFINES // to be able to use M_PI
14 #include <cmath>
15 
16 
17 
18 namespace NetworKit {
19 
20 const int MAX_RAND_VAL = 1000;
21 const float MAX_DENSE_AREA_RADIUS = 0.2f;
22 const float MIN_MAX_DENSE_AREA_FACTOR = 5.0f;
23 const edgeweight BASE_WEIGHT = 0.01f;
24 
25 typedef float distance; // TODO: use double, not float
26 typedef std::pair<node, node> edge;
27 
28 
29 struct circle {
30  float x;
31  float y;
32  float rad;
33 };
34 
59 
60  friend class DynamicPubWebGenerator;
61 
62 protected:
63  count n;
65  float neighRad;
67  std::vector<circle> denseAreaXYR;
68  std::vector<count> numPerArea;
69 
70  void determineNeighbors(Graph& g);
71  void moveNodeIntoUnitSquare(float& x, float& y);
72  float squaredDistanceInUnitTorus(float x1, float y1, float x2, float y2);
73  void chooseDenseAreaSizes();
74  void fillDenseAreas(Graph& g);
75  void spreadRemainingNodes(Graph& g);
76  void chooseClusterSizes();
77  void addNodesToArea(index area, count num, Graph& g);
78  bool isValidEdge(Graph& g, node u, node v, edgeweight& ew);
79 
80 public:
81  PubWebGenerator() {} // nullary constructor needed for Python Shell - do not use this to construct instance
82 
83  PubWebGenerator(count numNodes, count numberOfDenseAreas,
84  float neighborhoodRadius, count maxNumberOfNeighbors);
85 
86  virtual Graph generate();
87 
88 protected:
89 
93  void addNode(Graph& g);
94 
98  void removeRandomNode(Graph& g);
99 };
100 
101 } /* namespace NetworKit */
102 #endif /* PUBWEBGENERATOR_H_ */
PubWebGenerator()
Definition: PubWebGenerator.h:81
Generates a static graph that resembles an assumed geometric distribution of nodes in a P2P network...
Definition: PubWebGenerator.h:58
const float MIN_MAX_DENSE_AREA_FACTOR
Definition: PubWebGenerator.h:22
void spreadRemainingNodes(Graph &g)
Definition: PubWebGenerator.cpp:169
float neighRad
neighborhood radius
Definition: PubWebGenerator.h:65
void chooseDenseAreaSizes()
Definition: PubWebGenerator.cpp:157
std::pair< node, node > edge
Definition: PubWebGenerator.h:26
void chooseClusterSizes()
Definition: PubWebGenerator.cpp:179
count maxNeigh
maximum number of neighbors
Definition: PubWebGenerator.h:66
uint64_t index
Typedefs.
Definition: Globals.h:20
float rad
Definition: PubWebGenerator.h:32
void addNode(Graph &g)
Adds nodes randomly, distribution respects original one.
std::vector< count > numPerArea
number of points in each circular area
Definition: PubWebGenerator.h:68
Abstract base class for static graph generators.
Definition: StaticGraphGenerator.h:19
void moveNodeIntoUnitSquare(float &x, float &y)
Definition: PubWebGenerator.cpp:18
bool isValidEdge(Graph &g, node u, node v, edgeweight &ew)
Definition: PubWebGenerator.cpp:58
count n
number of nodes
Definition: PubWebGenerator.h:63
const float MAX_DENSE_AREA_RADIUS
Definition: PubWebGenerator.h:21
count numDenseAreas
number of areas with more nodes (denser)
Definition: PubWebGenerator.h:64
Definition: PubWebGenerator.h:29
virtual Graph generate()
Definition: PubWebGenerator.cpp:194
void determineNeighbors(Graph &g)
Definition: PubWebGenerator.cpp:82
float x
Definition: PubWebGenerator.h:30
uint64_t count
Definition: Globals.h:21
void fillDenseAreas(Graph &g)
Definition: PubWebGenerator.cpp:147
index node
Definition: Globals.h:23
void removeRandomNode(Graph &g)
Removes random node, uniform distribution.
Definition: PubWebGenerator.cpp:211
float distance
Definition: PubWebGenerator.h:25
std::vector< circle > denseAreaXYR
position of each circular dense area
Definition: PubWebGenerator.h:67
const edgeweight BASE_WEIGHT
Definition: PubWebGenerator.h:23
A graph (with optional weights) and parallel iterator methods.
Definition: Graph.h:79
float y
Definition: PubWebGenerator.h:31
float squaredDistanceInUnitTorus(float x1, float y1, float x2, float y2)
Definition: PubWebGenerator.cpp:31
void addNodesToArea(index area, count num, Graph &g)
Definition: PubWebGenerator.cpp:130
const int MAX_RAND_VAL
Definition: PubWebGenerator.h:20
double edgeweight
Definition: Globals.h:24
Definition: DynamicPubWebGenerator.h:25