void add2cluster_recursive(int i, int n, std::vector<int>& cluster, std::vector<bool>& counted, CellList& cell_list, clstrrule_t cluster_function, arg_t args) { counted[i] = true; cluster.push_back(i); std::vector<int> nbr; cell_list.getNeighborsOf(i, nbr); for (unsigned int j=0; j<nbr.size(); j++) { if(!(counted[nbr[j]])) { if (cluster_function(i, nbr[j], args)) { add2cluster_recursive( nbr[j], n, cluster, counted, cell_list, cluster_function, args); } } } }