74 std::function<
double(
double)> h,
int dimension = 2) {
85 for (
int i = 0; i < weights.
size(); i++) {
86 nodes[i] = G.newNode();
87 nodeWeights[nodes[i]] = weights[i];
88 for (
int j = 0; j < dimension; j++) {
89 cord[nodes[i]][j] = dist(rng);
93 for (
node v : nodes) {
95 double distance = 0.0;
96 for (
int i = 0; i < dimension; i++) {
97 distance += (cord[v][i] - cord[w][i]) * (cord[v][i] - cord[w][i]);
99 distance = sqrt(distance);
101 if ((nodeWeights[v] + nodeWeights[w]) * h(distance) > threshold) {
127 int alpha = 2,
int dimension = 2) {
128 randomGeographicalThresholdGraph<D>(
129 G, weights, dist, threshold, [alpha](
double d) {
return 1 / pow(d, alpha); }, dimension);
Declaration and implementation of Array class and Array algorithms.
Includes declaration of graph class.
Basic declarations, included by all source files.
The parameterized class Array implements dynamic arrays of type E.
INDEX size() const
Returns the size (number of elements) of the array.
Data type for general directed graphs (adjacency list representation).
Class for the representation of nodes.
node succ() const
Returns the successor in the list of all nodes.
RegisteredArray for nodes, edges and adjEntries of a graph.
void randomGeographicalThresholdGraph(Graph &G, Array< int > &weights, D &dist, double threshold, std::function< double(double)> h, int dimension=2)
Creates a random geometric graph where edges are created based on their distance and the weight of no...
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
long unsigned int randomSeed()
Returns a random value suitable as initial seed for a random number engine.
The namespace for all OGDF objects.