  We test the Friends-of-Friends (FoF) grouping algorithm, which depends on two
linking lengths (LLs), plane-of-sky and line-of-sight (LOS), normalized to the
mean nearest neighbor separation of field galaxies. We argue, on theoretical
grounds, that LLs should be $b_\perp \simeq 0.11$, and $b_\parallel \simeq 1.3$
to recover 95% of all galaxies with projected radii within the virial radius
$r_{200}$ and 95% of the galaxies along the LOS. We then predict that 80 to 90%
of the galaxies in FoF groups should lie within their parent real-space groups
(RSGs), defined within their virial spheres. We test the FoF extraction for
16x16 pairs of LLs, using subsamples of galaxies, doubly complete in distance
and luminosity, of a flux-limited mock SDSS galaxy catalog. We find that
massive RSGs are more prone to fragmentation, while the fragments typically
have low estimated mass, with typically 30% of groups of low and intermediate
estimated mass being fragments. Group merging rises drastically with estimated
mass. For groups of 3 or more galaxies, galaxy completeness and reliability are
both typically better than 80% (after discarding the fragments). Estimated
masses of extracted groups are biased low, by up to a factor 4 at low richness,
while the inefficiency of mass estimation improves from 0.85 dex to 0.2 dex
when moving from low to high multiplicity groups. The optimal LLs depend on the
scientific goal for the group catalog. We propose $b_\perp \simeq 0.07$, with
$b_\parallel \simeq 1.1$ for studies of environmental effects, $b_\parallel
\simeq 2.5$ for cosmographic studies and $b_\parallel \simeq 5$ for followups
of individual groups.
