@@ -19,7 +19,8 @@ void Projection::project(Graph*& in_graph, unsigned int distance)
1919
2020 unordered_map<unsigned int , Node*> map_node;
2121 unordered_map<unsigned int , set<pair<unsigned int , float >, comp_pair>> map_neighbor;
22-
22+ vector<unsigned int > shuffle;
23+
2324 index = 0 ;
2425 while (index < in_graph->size_list_nodes )
2526 {
@@ -30,14 +31,19 @@ void Projection::project(Graph*& in_graph, unsigned int distance)
3031 map_node[index]->main_index = in_graph->list_nodes [index]->main_index ;
3132
3233 for (auto & n : list_distance_neighbors)
34+ shuffle.push_back (n->index );
35+ random_shuffle (shuffle.begin (), shuffle.end ());
36+
37+ for (auto & index_neighbor : shuffle)
3338 {
34- projection_weight = similarity_projection (in_graph, index, n-> index );
39+ projection_weight = similarity_projection (in_graph, index, index_neighbor );
3540
3641 if (projection_weight > 0.0 )
37- map_neighbor[index].insert (make_pair (n-> index , projection_weight));
42+ map_neighbor[index].insert (make_pair (index_neighbor , projection_weight));
3843 }
3944
4045 index += in_graph->list_nodes [index]->nb_neighbors + 1 ;
46+ shuffle.clear ();
4147 }
4248
4349 graph_projection->create_graph (map_node, map_neighbor);
0 commit comments