Skip to content

Commit

Permalink
sort node positions in random geometric models
Browse files Browse the repository at this point in the history
  • Loading branch information
benmaier committed Oct 21, 2019
1 parent b20f9b0 commit bc0dee2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions _sixdegrees/random_geometric_kleinberg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ vector < set < size_t > * > random_geometric_kleinberg_neighbor_set(
r.push_back( random_number(generator)*double(N) );
}

// sort position so one knows that the node position 0 is the
// first in [0,N] and so forth
sort(r.begin(), r.end());

vector < edge_distance > distances;

// loop over all pairs and compute
Expand Down Expand Up @@ -360,6 +364,10 @@ vector < set < size_t > * > theoretical_random_geometric_kleinberg_neighbor_set(
r.push_back( random_number(generator)*double(N) );
}

// sort position so one knows that the node position 0 is the
// first in [0,N] and so forth
sort(r.begin(), r.end());

// loop over all pairs and draw according to the right probability
// (this is a lazy slow algorithm running in O(N^2) time
for (size_t i = 0; i < N-1; ++i)
Expand Down
4 changes: 4 additions & 0 deletions _sixdegrees/random_geometric_small_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ vector < set < size_t > * > random_geometric_small_world_neighbor_set(
r.push_back( random_number(generator)*double(N) );
}

// sort position so one knows that the node position 0 is the
// first in [0,N] and so forth
sort(r.begin(), r.end());

// loop over all pairs and draw according to the right probability
// (this is a lazy slow algorithm running in O(N^2) time
size_t SR_edges = 0;
Expand Down
2 changes: 1 addition & 1 deletion sandbox/kleinberg_random_geometric_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import scipy.sparse as sprs
import progressbar

N = 10000
N = 1000
k = 7
mu = -1

Expand Down

0 comments on commit bc0dee2

Please sign in to comment.