void FoF::find_friends_of_friends (const Zbin &zbin, Cluster &cluster, double rfriend){ //! Function to find the galaxies linked to existing cluster members. /**< Loop through cluster members */ for(int i = 0; i < cluster.mem.size(); i++) { find_friends(zbin, gal_list[cluster.mem[i].num], rfriend); } // end of cluster member loop }
void find_friends(std::vector<std::string> const &friends, std::unordered_set<int> &visited, int i) { visited.insert(i); for (int j = 0; j < friends[i].size(); ++j) { if (!visited.count(j) && friends[i][j] == 'Y') { find_friends(friends, visited, j); } } }
int friend_circles(std::vector<std::string> const &friends) { int circles = 0; std::unordered_set<int> visited; for (int i = 0; i < friends.size(); ++i) { if (!visited.count(i)) { circles++; find_friends(friends, visited, i); } } return circles; }
void FoF::friends_of_friends (int bin_num) { //! Funciton that find friends-of-friends in a given redshift bin. cluster_count = -1; Zbin zbin = zbin_list[bin_num]; double rfriend = zbin.rfriend; /**< Loop through galaxies */ for(int i = 0; i < gal_list.size(); i++) { /**< Modify rfriend for spectroscopic mode*/ if (mode == "spec") rfriend = zbin_list[gal_list[i].bin].link_r / gal_list[i].da; /**< Check if galaxy is already in a cluster (f-loop)*/ if(!gal_list[i].in_cluster[zbin.num] && bin_check(zbin, gal_list[i])) { find_friends(zbin, gal_list[i], rfriend); /**< Check if galaxy is now in a cluster (fof-loop)*/ if(gal_list[i].in_cluster[zbin.num]) find_friends_of_friends(zbin, list_of_clusters[cluster_count], rfriend); } } //end of galaxy loop }