# Overview: Friends of Friends

The Friends of Friend algorithm is linking together particles that have a neighbor in the group that is closer than the so-called linking length which is a free parameter. We do this by first doing this linking on each task. This is done by binning particles to a grid (whose size is set by the linking length; up to a user specified maximum $N_{\rm grid}$) and then searching only in neighboring gridcells for friends. Once this is done we merge the groups over tasks by communicating particles that fall within a linking length of the boundary. If we can guarantee that no group is shared between two tasks we only have to do this once (and there is a flag one can set for this to save time), but in general we do the merging until we guarantee that we have found all groups. In the end all particles have been assigned a FoFID which we use to bin up whatever quantity one wants (by a class provided by the user or using the fiducial one) and produce a catalogue of FoFGroups.

# Availiable methods

    template<class T, int NDIM, class FoFHaloClass = FoFHalo<T,NDIM> >
void FriendsOfFriends(
T *part,
size_t NumPart,
double fof_distance,
int nmin_FoF_group,
bool periodic_box,
std::vector<FoFHaloClass> & FoFGroups);


If you want to bin up things that are not provided in the fiducial class see FoF.h for how to make your own FoFHaloClass to do the binning. To only do one single merge you can set FML::FOF::merging_in_parallel_default = true and if you want to limit how many grid-cells we use you can set FML::FOF::FoF_Ngrid_max.