{'fraction_non_alphanumeric': 0.023451028250078335, 'fraction_numerical': 0.015897884130151557, 'mean_word_length': 4.596492847254269, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
How does environment affect the morphology of radio AGN?

Galaxies hosting Active Galactic Nuclei (AGN) with bent radio jets are used as tracers of dense environments, such as galaxy groups and clusters. The assumption behind using these jets is that they are bent under ram pressure from a dense, gaseous medium through which the host galaxy moves. However, there are many AGN in groups and clusters with jets that are not bent, which leads us to ask: why are some AGN jets affected so much by their environment while others are seemingly not? We present the results of an environmental study on a sample of 185 AGN with bent jets and 191 AGN with unbent jets in which we characterize their environments by searching for neighboring galaxies using a Friends-of-Friends algorithm. We find that AGN with bent jets are indeed more likely to reside in groups and clusters, while unbent AGN are more likely to exist in singles or pairs. When considering only AGN in groups of 3 or more galaxies, we find that bent AGN are more likely to exist in halos with more galaxies than unbent AGN. We also find that unbent AGN are more likely than bent AGN to be the brightest group galaxy. Additionally, groups hosting AGN with bent jets have a higher density of galaxies than groups hosting unbent AGN. Curiously, there is a population of AGN with bent jets that are in seemingly less dense regions of space, indicating they may be embedded in a cosmic web filament. Overall, our results indicate that bent doubles are more likely to exist in in larger, denser, and less relaxed environments than unbent doubles, potentially linking a galaxy's radio morphology to its environment.


INTRODUCTION
Radio galaxies have very distinct morphologies, extending far from the optical host galaxy in two straight, biconical jets pointed in opposite directions. However, there are jets whose morphologies deviate from this norm, appearing bent instead of straight. The general consensus is that these jets are likely bent by ram pressure from the gaseous medium in which they are embedded (Burns & Owen 1980;Jones & Owen 1979;Blanton et al. 2000;Freeland et al. 2008;Freeland & Wilcots 2011;Wing & Blanton 2011;Morsony et al. 2013). This hypothesis is supported by the fact that these radio galaxies are prevalent in dense environments, such as galaxy clusters (Owen & Rudnick 1976;Blanton et al. 2000Blanton et al. , 2001Silverstein et al. 2018;Mingo et al. 2019). Indeed, they have been used to identify galaxy clusters at higher redshifts (Blanton et al. 2015;Golden-Marx et al. 2021).
These objects have had a variety of names, such as head-tail radio sources, Wide Angle Tail (WAT)/Narrow Angle Tail (NAT) sources, or bent double lobed sources (Owen & Rudnick 1976;Ekers 1978;Begelman et al. 1979;Blanton et al. 2000;Wing & Blanton 2011). The WAT/NAT designation is one that depends on the degree of bending, with NATs being extremely bent and WATs being less bent. Several studies have found that WATs are likely to be the brightest cluster/group galaxy, indicating that they are at or near the center of their larger host halo (Sakelliou & Merrifield 2000;Blanton et al. 2001). However, many more recent studies have found that they exist in a wide array of environments, many of them existing well beyond the virial radius of the nearest cluster (Garon et al. 2019;de Vos et al. 2021;Golden-Marx et al. 2021).
Studies have found AGN with bent jets in less dense environments, as well. There have been many bent AGN, especially WATs that are not as bent as NATS, found in galaxy groups (Ekers 1978;Freeland et al. 2008;Freeland & Wilcots 2011). Edwards et al. (2010) discovered a bent AGN in a filament, and other studies have found populations of bent doubles in pairs or isolated environments that are less likely to have an intergalactic medium (IGM) dense enough to exert ram pressure to bend the jets (Blanton et al. 2001;Garon et al. 2019).
Unbent double lobed radio sources are also found in dense environments (Worpel et al. 2013;Ching et al. 2017;Garon et al. 2019), yet they are not affected by the surrounding medium in the same way that bent double lobed AGN are. This could be indicative of a difference in the gas density and dynamics of the environments of these two kinds of galaxies. Additionally, it could indicate that bent and unbent AGN exist in different types of cluster or group galaxies -while unbent AGN typically exist in the brightest group or cluster galaxies (Pasini et al. 2021), bent AGN may exist in other galaxies that are moving through their environment at higher velocities, allowing for their jets to be bent by ram pressure. Alternatively, the medium in environments where bent jets are found could be undergoing bulk motion, causing the jets to appear bent. Comparing environments of bent and unbent AGN could help us understand the mechanisms responsible for bending of AGN jets. Wing & Blanton (2011) found that bent AGN were more often found in clusters and denser environments than unbent galaxies. However, it is still unclear what further differences exist between bent and unbent AGN in dense environments and why some AGN in dense environments are bent while others are not.
There exist large samples of radio galaxies that have been morphologically classified. For example, the Radio sources associated with Optical Galaxies and having Unresolved or Extended morphologies (ROGUE) catalog (Kozie l-Wierzbowska et al. 2020) uses observations from a variety of radio and optical surveys to create a catalog of radio sources of various morphologies. Additionally, large samples of bent doubles have been identified using image recognition techniques (Proctor 2006) on data from the Faint Images of the Radio Sky at Twenty-cm (FIRST; Becker et al. 1995) survey, but still little is known about their environment. However, deep photometric surveys like the Dark Energy Camera Legacy Survey (DECaLS; Dey et al. 2019) and the unblurred coadds of Wide-field Infrared Survey Explorer images (unWISE; Lang 2014), which reach galaxies with absolute magnitudes r<23, reveal many galaxies that could potentially neighbor the AGN hosts.
Throughout the literature, Friends of Friends (FoF) algorithm have been used to identify galaxy groups and to better understand the environments of galaxies (Huchra & Geller 1982;Tempel et al. 2014;Duarte & Mamon 2014). Most of these studies rely on spectroscopic redshifts due to their low uncertainties and high precision. However, spectroscopic redshifts are observationally expensive. Few studies have attempted to adapt FoF algorithms to use photometric redshifts (Liu et al. 2008;Jian et al. 2014), which are much less costly observationally but have higher uncertainties that can potentially lead to contamination in the group finding results. Nonetheless, a FoF algorithm that relies on photometric redshifts can still prove useful in understanding the environments of bent doubles and comparing them to those of unbent doubles.
The goal of this study is to use an FoF algorithm combined with photometric redshifts from unWISE and DE-CaLS (Lang 2014;Dey et al. 2019;Zou et al. 2019) to identify galaxies neighboring bent and unbent doubles, and then to use these galaxies to classify the environments of these two groups of AGN. This will aid in the understanding of how the environment affects the morphology of radio AGN, and give us a better idea of what kind of environments are being probed by bent double lobed AGN as opposed to unbent AGN. In Section 2, we outline the radio and optical data used in this study and how we selected our bent and unbent samples. In Section 3, we go into detail about how our FoF algorithm works and how it incorporates photometric redshifts to find neighbors, as well as how we calibrated parameters for the FoF algorithm and tested it using the cosmological simulation Illustris TNG. In Section 4, we outline the broad results of our FoF algorithm on the data by taking measurements of the frequency of AGN in different environments, galaxy density of these environments, and r-band magnitude gaps. In Section 5, we discuss these results and in Section 6, we outline our main conclusions for this study. Throughout this paper, we use cosmological parameters from the WMAP9 results (Hinshaw et al. 2013), H 0 = 69.3 km s −1 Mpc −1 and Ω 0 = 0.287.

DATA
We carried out this study using a sample of 185 visually confirmed bent double lobed AGN and 191 visually confirmed FRI and FRII AGN that are not bent. Of these samples, all of the unbent AGN and 83 bent AGN were identified in the ROGUE catalog (Kozie l-Wierzbowska et al. 2020), which combines FIRST (Becker et al. 1995), NRAO VLA Sky Survey (NVSS; Condon et al. 1998), and Sloan Digital Sky Survey (SDSS; Abazajian et al. 2009) spectroscopy to identify radio sources and categorize them morphologically. Examples from the final sample of bent and unbent doubles can be seen in Figure 1 and the distributions of in-   To better understand what kinds of environments bent double lobed AGN occupy, we use an FoF algorithm combined with photometric redshifts (Zou et al. 2019) derived from two deep all-sky surveys, the DECaLS (Dey et al. 2019) and unWISE, (Lang 2014) which reach magnitudes of r < 23. To determine halo membership in redshift-space, we use photometric redshifts and stellar masses derived from the g, r, and z bands from DECaLS and the W1 and W2 bands from un-WISE (Zou et al. 2019).

Bent and Unbent Double Selection
Of the sample of 185 bent doubles used for this study, 102 were chosen from a larger sample of 882 galaxies identified in the FIRST survey by the automated image recognition techniques of Proctor (2006), which categorized radio galaxies as bent based on their morphology in FIRST. From this sample, 261 sources had optical counterparts that overlapped with the FIRST source whose spectroscopic redshifts were measured in SDSS DR7. We select these galaxies because we know their location in redshift space very precisely, so that when we perform our FoF algorithm, we know exactly what redshift we should be comparing to.
From this sample, we visually identified bent doubles based on the radio morphology with respect to the host galaxy. Examples of galaxies that have been visually selected are shown in the left two panels of Figure 1. The radio contours are in white and the location of the host galaxy is circled in red. This visual identification left us with an initial sample of 160 visually confirmed bent doubles with measured spectroscopic redshifts. The 101 radio galaxies identified by Proctor (2006) that we left out of our sample either did not visually resemble bent doubles or were not associated with the SDSS source. While it can be difficult to determine the precise morphology for many of our bent sources due to resolution limitations, we can say that at least 75% of the bent double sources in our sample are WATs, which is slightly higher than Bhukta et al. (2021)  For unbent AGN and the rest of our bent AGN sample, we used the ROGUE catalog (Kozie l-Wierzbowska et al. 2020), which morphologically classified radio counterparts in FIRST and NVSS for galaxies with observed spectra in SDSS DR7. From their sample, we looked only at FRI and FRII galaxies and selected 191 unbent AGN based on a visual confirmation of the radio contours in FIRST with respect to the optical host galaxy. Of these, 64 are FRI radio galaxies and 127 are FRII radio galaxies. The right images in Figure 1 are two examples from this sample. We also selected an additional 83 bent doubles by looking at galaxies they identified as WATs or NATs. These galaxies did not appear in the selection from Proctor (2006) possibly due to the fact that the ROGUE catalog relies not only on FIRST, but also on NVSS, to identify AGN. It is possible that, without these additional observations, Proctor (2006) was unable to identify these sources as bent AGN.
While both samples were visually classified, they were selected using slightly different radio criteria. The bent sample from Proctor (2006) only used FIRST contours, while galaxies selected from the ROGUE catalog used both FIRST and NVSS, which resulted in a slightly lower redshift distribution. In order to avoid redshiftdependent differences between the two samples, we limit the rest of this analysis to only those galaxies below a redshift of 0.5, beyond which there are no unbent AGN in our sample. This reduced our sample of 243 bent AGN to a total of 185 bent doubles. The FIRST Flux distributions can be found in Figure 2 and shows that  . Absolute r-band magnitude as a function of photometric redshift for the bent and unbent samples, as well as all identified group members. The blue line signifies an r=21 limiting apparent magnitude. The majority of radio galaxies are below an absolute magnitude of -22, making up the brightest galaxies. It is important to note that only galaxies below z = 0.5 are considered in this study.
these samples are similar in their fluxes. The redshift distributions of both samples can be found in Figure 3 and are fairly consistent with each other to minimize redshift-dependent differences between the two populations.

DECaLS and unWISE
DECaLS and unWISE are two surveys that provide deep (r < 23) photometric data across the sky in the g, r, and z bands for DECaLS and the W1 and W2 filters for unWISE (Dey et al. 2019). To determine halo membership, we use the work of Zou et al. (2019), which measures the k-corrected absolute magnitudes, stellar mass, and photometric redshifts for galaxies observed by DECaLS and unWISE. In both plots, the red dashed line represents an uncertainty of 0.04, which is what we have chosen as our redshift uncertainty cutoff. This results in many fainter (r>20) galaxies being excluded from this analysis, which can be seen in Figure 4 . Figure 4 plots the k-corrected absolute magnitudes of the unbent and bent double sample, as well as all of the group members identified by the FoF algorithm. For reference the blue line represents an apparent magnitude of r = 21. While DECaLS and unWISE do reach r < 23, we find that the galaxies with low photometric errors tend to be the brighter galaxies, as can be seen in Figure  5. Therefore, when applying a photometric error cutoff, we tend to exclude many of the dimmer galaxies that fall between 21 < r < 23. Also of note is that the radio galaxies are on the whole much brighter than the other galaxies occupying the same halos.
3. DEVELOPING AND TESTING THE GROUP FINDING ALGORITHM

Defining the Algorithm
We use a Friends of Friends algorithm to identify possible galactic neighbors using their positions in the sky and measured photometric redshifts from DECaLS and unWISE (Zou et al. 2019). This method has been used throughout the literature to identify potential galaxy groups, though it is usually only applied to galaxies with measured spectroscopic redshifts (Tempel et al. 2014;Duarte & Mamon 2014). Errors on photometric redshifts are typically larger than potential group or even cluster velocity dispersions, making them particularly susceptible to false positives (i.e. falsely identifying a galaxy as a group member). In order to minimize the likelihood of false positives, we use a probability motivated approach when considering the locations of galaxies in redshift-space, while using the FoF method when considering galaxy positions in the plane of the sky.
We calibrated and tested the algorithm on mock images created using the Illustris TNG300 simulation, which simulated a box of cosmic space that is 300 Mpc long on each side. This allowed us to sample a wide variety of different environments and see how the FoF algorithm performed on each of them.
3.1.1. FoF: Plane of the sky A typical FoF algorithm starts at the position of an initial galaxy and searches within a predetermined radius, known as the linking length, for nearby neighboring galaxies. When a neighboring galaxy is found within one linking length of the original galaxy, another search is done for additional galaxies within one linking length of the neighboring galaxy. This process is repeated for all galaxies that fall within one linking length of another galaxy until no more have been detected. Our FoF algorithm starts at the bent double and only includes galaxies that fulfill the redshift criteria outlined in Section 3.1.2.
There are a variety of linking lengths in the literature (Duarte & Mamon 2014), but many of these are established using data sets that vary drastically from ours in their completeness, largely due to the fact that they rely on spectroscopic observations instead of photometric observations. Spectroscopic observations allow them to scale the linking length by the number density of galaxies, calculated precisely due to the fact that spectroscopic redshifts have much lower uncertainties than photometric redshifts. Because we are relying on photometric redshifts, such scaling becomes unreliable. Therefore, we have chosen a static value of 300 kpc, which is motivated by the distribution of the distance to the nearest group galaxy as given by Illustris (see Section 3.3.2). This linking length will include the major-ity of the galaxies in the same group as the bent double based on the plot in Figure 6. We also set a maximum distance from the bent double at 2 Mpc, as groups are unlikely to extend that far and if the algorithm does attempt to go that far, it is likely due to a false positive detection (Tempel et al. 2014;Silverstein et al. 2018).

Probability based: Redshift space
Because typical photometric redshift uncertainties tend to be much larger than expected redshift variations due to galaxy group/cluster velocity dispersions, we could not apply the FoF algorithm in redshift space. Instead, we devised a method of measuring the relative probability that two galaxies are at the same redshift based upon their uncertainties and set a cutoff, where any galaxies that fell below this were not considered to be at the redshift of the bent double.
We first assumed that the probability density functions P could be described by normal distributions with the mean µ being the measured redshift and the standard deviation σ being the uncertainties on said redshift. By multiplying the probability density functions for the bent double and the potential neighbor and normalizing by the maximum probability, we found the probability that these two galaxies reside at the same redshift.
The maximum possible probability was calculated by multiplying the probability distributions, assuming they had the same redshift µ o with their measured uncertainties σ 1 and σ 2 . The choice of µ o is less relevant than the choices of the uncertainties.
The final probability was taken by multiplying the real probability density functions using µ and σ as the measured redshift and redshift uncertainty and dividing by P max : Spectroscopic measurements of the bent double were always used for P (µ 1 , σ 1 ) since these redshifts were all more accurate than photometric redshifts. Therefore, the redshifts of potential neighbor galaxies were always compared to the redshift of the bent double, as opposed to being compared to one another. If the final probability that the potential neighbor was at the redshift of the bent double was less than 0.2 (motivated in Section 3.3.3), it was removed from the group to reduce the number of potential false positives as much as possible. Figure 6. The distribution of 3D distances to the nearest neighbor for all galaxies in groups of at least 5 members in the Illustris TNG300 simulations. This histogram only takes into account galaxies that would be observable by DECaLS at a redshift of roughly z = 0.1. The vertical lines show different characteristics of this distribution which were tested as linking lengths for our FoF algorithm.

Creating Mock Catalogs from Illustris TNG
To understand how well our algorithm performs and tune various parameters, we carried out a series of tests using mock data created from the Illustris TNG300 simulations, which evolves a cubic volume with 300 Mpc on every side (Nelson et al. 2019). We used catalogs of subhalos (potential galaxy analogs) and groups of dark matter subhalos produced by the Illustris team as our starting point for generating mock observational data. We then ran the FoF algorithm described above to tune the parameters and find the best balance between high percent completeness for each individual group and low percent of false group member identifications.
We started this analysis by creating a mock catalog of galaxy positions and assigning photometric redshift measurements based on their positions in the simulation volume. Using the subhalo catalog from the z = 0.10 snapshot of the TNG300 simulation volume, we narrowed our search by selecting only subhalos with absolute r-band magnitudes < −16 in order to immediately eliminate any subhalos that would not be visible with DECaLS. The entire simulation volume was then projected along the z-axis such that the front end was assigned z = 0.10 and redshifts were calculated for each subhalo using their position in the simulation volume along the z-axis. From here, right ascensions and declinations were calculated for each galaxy based on their position in the xy plane of the simulation and their calculated redshift.
Our next goal was to make this idealized catalog seem more like real DECaLS data. We started by calculating apparent r-band magnitudes for each subhalo and then assigning a redshift uncertainty based on real uncertainties from DECaLS, which vary with r, as shown in Figure 5. Using a 2D histogram of DECaLS photometric redshift uncertainties and r-band magnitudes, we applied a Gaussian kernel density estimate to smooth the histogram (as seen in Figure 5) and then, for each simulation subhalo, sampled from a range of uncertainties based on their calculated apparent r-band magnitudes. We then added a small offset to the redshift, based on the randomly assigned uncertainty. After this, we applied an apparent magnitude cutoff of r = 21.6. While DECaLS technically goes as deep as r = 23, after applying a photometric redshift uncertainty cutoff of 0.04, very few galaxies fell above a magnitude of 21.6 due to the fact that fainter galaxies had higher redshift errors, as can be seen in Figure 5. In Figure 4, the absolute magnitudes are plotted for our real sample of FoF-selected group galaxies and the bent/unbent host galaxies as a function of redshift, with the blue line representing the absolute magnitude for a galaxy of apparent magnitude r = 21 at various redshifts.
Once a final catalog of simulation subhalos was created, we then updated the group catalog to only consider subhalos that were in our final catalog, and set another cutoff such that our FoF algorithm only considered groups in which there were at least 4 subhalos that fulfilled the criteria outlined above. This allowed us to exclude groups of 3 or fewer that may have had large spatial separations and thus would not have been picked up by any FoF algorithm.

Testing Group Finding Algorithm Parameters
The parameters that had to be tested and tuned for the group finding algorithm are: the linking length, the photometric redshift uncertainty cutoff, and the cutoff for the probability that two galaxies are at the same redshift. To tune these parameters, we carried out a series of tests in which, for each group in the Illustris group catalog, we selected a random group member and ran the group finding algorithm starting at that galaxy. We then compared the results of the group finding algorithm to the real group catalog in order to determine how well the algorithm did.
It was essential to select the parameters that resulted in groups that minimize the number of interlopers and maximize the completeness. Therefore, we specified and measured a couple of quantities for each group. The first, dubbed the false positive rate, is defined as the percentage of galaxies, out of those identified by the algorithm, that were not real group members. The second, the completeness, is defined as the percentage of galaxies, out of the real group members, that were correctly Figure 7. Results of FoF testing in Illustris when varying the linking length (top), probability cutoff (middle), and photometric redshift uncertainty cutoff (bottom). The solid gold vertical lines represent the parameter value selected for the FoF algorithm in all three cases. The blue lines show how the fraction of groups with 100% completeness (solid) and over 70% completeness change as the parameter is varied, while the red lines show how the fraction of groups with 0% false positives (solid) and less than 30% false positives (dashed) change as the parameter is varied. Parameters were selected by balancing the completeness and false positive rate as much as possible. In these plots, the parameters that were held constant were the final parameters while the third was varied.  . A cumulative histogram of photometric uncertainties from DECaLS. The red line is drawn at an uncertainty of 0.04, which is the redshift uncertainty cutoff for the FoF algorithm. This winds up including 70% of the galaxies in DECaLS, with the rest falling above that cutoff. detected by the algorithm. These values tend to be correlated with one another since, if the algorithm considers more galaxies as group members, it will be able to correctly identify more group galaxies that may be on the edges of the group, but it will also likely identify more false positives, as well. Therefore, it is important to strike a reasonable balance between these two effects when calibrating parameter values.
We ran the group finding algorithm on the entire group catalog multiple times to understand how each parameter affects the accuracy of the group finding results. To begin with, we selected initial values for each parameter and measured the completeness and false positive rate for each group. Then, we began to vary one parameter at a time and looked at how the distribution of completeness and the false positive rate for all of the groups changed, selecting the one that had the best balance between the two. We would then update that parameter value, keep it static, and begin varying the next parameter. This process was repeated for each of the three parameters until we found a set of values that maximized completeness while minimizing false positives. Then, we started over again, only now using the updated parameters as initial static values and then varying one parameter at a time to see if there were any changes. Figure 7 shows how the completeness and false positive rate changed as we varied each parameter, with the solid gold lines indicating the final choice of parameter.
Each of the three parameters that we varied came with its own unique set of challenges, which are summarized in the subsections below.

Photometric Redshift Uncertainty
The biggest downside to performing a FoF algorithm on data that uses photometric redshift measurements as opposed to spectroscopic ones is that these tend to have much higher uncertainties due to the fact that they rely heavily on SED-fitting of broadband filters. Because of this, we imposed an uncertainty cutoff for our photometric redshift error measurements. Before we carried out tests with Illustris, however, we began by examining how different uncertainty cutoffs affect how many galaxies we exclude from this analysis. This helped us decide on a range of values over which we performed testing with Illustris.
Comparisons between DECALS photometric redshifts and SDSS spectroscopic redshifts can be found in Figure 8, where we can see the overall scatter increase at higher redshifts. We also looked at the distribution of photometric redshift uncertainties for DECaLS galaxies, which can be seen in Figure 9, to understand how imposing a redshift cutoff would impact our final sample. Ideally, we would only be using galaxies whose photometric redshift uncertainties were low to minimize the number of false positives identified by the algorithm. However, too low of a cutoff would leave out a large percentage of galaxies in DECaLS. Therefore, we decided to run the FoF tests on Illustris while varying the uncertainty cutoff between 0.02 and 0.05.
The results of the final test are summed up by Figure  7, which shows how these quantities vary over a range of uncertainty cutoffs. Figure 9 shows the cumulative distribution of photometric redshift uncertainties for galaxies observed in DECaLS. We selected a redshift cutoff of 0.04 in the end due to the fact that it provides a good balance between accuracy of the FoF tests without excluding too many galaxies from our analysis. This ends up including roughly 70% of the galaxies in DECaLS.

Linking Length
Next, we needed to calibrate the linking length needed for our analysis. It is important to note that, for our analysis, we want to consider as many galaxies near our AGN as possible so we can get an accurate idea of the environments they are in. Additionally, the fact that we are using photometric redshifts as opposed to spectroscopic redshifts means that scaling the linking length by the number density of galaxies in our sample, as many other studies using spectroscopic redshifts have done, will be difficult. Therefore, we use a static value for the linking length that has been tuned using Illustris TNG300.
In order to find the best value for the linking length, we measure the distance to the nearest galaxy for each simulation subhalo in a group. This distribution can be found in Figure 6, where we have also plotted the mean and median for the distribution, as well as what those values would be in 2D space. This leaves us with 4 potential values for the linking length. We ran the FoF algorithm on the constructed Illustris catalog projected onto the sky using linking lengths that spanned from 190 to 320 kpc, which roughly coincided to the lowest and highest values shown in Figure 6. We chose a value of 300 kpc to strike a balance between including a large fraction of group members without falsely identifying too many galaxies not associated with the group as group members.

Probability Metric
Because our particular FoF algorithm only uses a probability-based metric along the line of sight, we must be sure that this metric results in both complete and accurate groups. In order to do this, we ran the FoF algorithm on the simulation groups using minimum probability metrics that ranged from 0 (i.e. no redshift consideration) to 0.8. We found that a probability metric of 0.2 resulted in the best balance between low false positive rate and a high completeness, making this the value we decided to use for the probability metric.

RESULTS
A color-mass diagram is plotted in Figure 10 to showcase general characteristics of the radio galaxies and galaxies that reside in the same halos as them. Unsurprisingly, for the most part, both the bent and unbent AGN hosts reside in massive, red galaxies. This fits with the unified model of AGN in which accretion flows that launch radio jets exist in environments similar to the centers of massive elliptical galaxies (Heckman & Best 2014). We also see an overdensity of group members that reside in the red cloud, indicating that these galaxies are either quenched or in dust-obscured systems. This is not unexpected, as galaxies in dense environments (such as the groups or clusters that many of the radio galaxies in our sample are probing) are more likely to be red and quenched early-type galaxies.

The Frequency of AGN in Different Environments
We look into the properties of bent and unbent environments by comparing how often the galaxies hosting AGN are alone or in pairs, if they are the brightest galaxy in their group with 3 or more galaxies, or if they are in a group with 3 or more galaxies and are not the brightest galaxy. This information is summarized in Table 1. We choose these three categories to first identify how many galaxies are in underdense environments, such as singles or pairs. We then separate groups of 3 or more galaxies into groups where AGN are the brightest and groups where the AGN is not the brightest. If the AGN host is the Brightest Group Galaxy (BGG), it is very likely that it has undergone an evolution defined largely by hierarchical structure formation of merging galaxies (De Lucia & Blaizot 2007), where it has been able to grow more massive than a typical large elliptical galaxy by accreting satellite galaxies that fall into the gravitational potential of the group (Gozaliasl et al. 2019;Pasini et al. 2021).
One of the most significant differences between the bent and unbent populations shown in Table 1 is the percentage that are alone or in pairs versus in groups of three or more galaxies. We looked at pairs and singles because galaxies in these environments are likely not embedded in a dense IGM like those in groups of three or more (Garon et al. 2019). In our study, 16.6% of bent doubles are in pairs, while 27.8% of unbent doubles are Figure 10. A color-mass plot using k-corrected absolute magnitudes from DECaLS of unbent and bent doubles, along with galaxies identified as group members. Figure 11. Normalized distributions of the number of galaxies occupying the same groups as bent and unbent radio galaxies. This distribution only includes groups with at least 3 members and excludes all groups with more than 100 members. This results in us excluding 7 groups hosting bent doubles and 2 groups hosting unbent doubles.
in pairs. Therefore, while it is unlikely to find a bent AGN alone or in a pair, they do exist, just not to the extent that unbent AGN do.
While the percentage of groups where the radio galaxies are the brightest is similar between the bent and unbent samples, a larger difference arises when looking at how many AGN hosts are alone/in pairs, or are not the BGG. These numbers become more stark when only considering galaxies in groups of 3 or more members. In 25.3% of the groups with bent AGN, the AGN host galaxy was not the brightest group galaxy, while this number was reduced to 8.1% when considering unbent AGN. This shows that AGN with unbent morphologies are less likely than bent AGN to exist in groups of three or more galaxies without being the BGG.
We performed a Pearson's chi-squared test to the data in Table 1 in order to see if the differences noted above are real, or if they could have been observed by chance. We found that we can reject the null hypothesis that this was a chance observation of the same population with a confidence level of over 99.99% and a p-value of 10 −5 .
To summarize these comparisons, unbent AGN are more likely to exist alone or in a pair than bent AGN. When in groups of three or more galaxies, unbent AGN are very likely to be the brightest cluster galaxy. For bent AGN, while they are still fairly likely to be the BGG, there is still a large population of bent AGN that exist in groups without being the BGG.

Group Membership
When we refer to the size of the group, we are referring to the number of group members identified by the FoF algorithm. The distribution of group membership for groups of three or more galaxies can be seen for groups occupied by both bent and unbent radio galaxies in Figure 11. The overall shapes of these distributions is somewhat similar, but it is clear that the unbent sample is skewed towards lower membership, while the bent sample reaches higher membership. Using the k-sample Anderson Darling test, we find that the null hypothesis can be rejected at a confidence level of 99.99%, indicating that these are two distinct populations.

Group Radius
We estimate the projected group radius using the equation below.
This is the mean square of r i , the comoving distance between a galaxy i to the group center calculated using astropy's cosmology package (Astropy Collaboration et al. 2013. This equation is similar to that used by Tempel et al. (2014) to estimate the group extent. Distributions of radii for groups hosting bent and unbent radio AGN can be found in Figure 12, which shows that bent AGN are more likely to exist in groups with larger radii. We performed an Anderson-Darling test to determine the likelihood that these two distributions could be derived from the same parent population and found that we could reject the null hypothesis to a confidence level of 3-σ, obtaining a p-value of less than 0.002. It is worth noting that the actual difference in radius of these two samples is fairly small, with the average group hosting bent AGN having a radius of 332 kpc and the average group hosting an unbent AGN having a radius of 259 kpc. It is also worth noting that the majority of all groups in our sample have radii below 500 kpc, providing quantitative justification for using 500 kpc as the radius within which we use to calculate the group density.

Group Density
We use multiple proxies as tracers of the density in galaxy groups: the number density of galaxies projected within 0.5 Mpc, between 0.5 and 2 Mpc of the group center, and the distance to the nearest group member. These distances are measured in the plane of the sky and we only consider galaxies with photometric redshift measurements that meet the probability criterion outlined in Section 3.2. By using these static values as opposed to the density to the nth nearest neighbor, we are better able to probe a wide range of environments, from pairs of galaxies to groups that are on the verge of being clusters. Additionally, these measurements are less affected by potential false positives that could be identified by our algorithm.
The maximum projected distance a group member can be found from the bent double is 2 Mpc due to the constraints placed on the algorithm (outlined in Section 3.1.1. and 4.3). However, there are very few groups that actually reach this cutoff, and most groups do not extend too far beyond 0.5 Mpc (Tempel et al. 2014;Riggs et al. 2021). Therefore, when measuring the galaxy density of the core of the group, we consider all galaxies within 0.5 Mpc of the group center. This is partially motivated by the richness metric used by various studies in which the number of galaxies below an absolute magnitude threshold within 0.5 Mpc of a galaxy cluster or group center are counted (Allington-Smith et al. 1993;Zirbel 1997;Wing & Blanton 2011). A more recent study of clustering in galaxy groups found that most galaxy groups reach peak clustering at a radius of 0.5 Mpc, beyond which, the clustering falls off (Riggs et al. 2021). For the galaxy density of the surrounding environment, we consider all galaxies between 0.5 and 2 Mpc, as galaxies at these distances from the group center are less likely to be gravitationally coupled to the group. Figure 13 shows the results of our group finding algorithm for groups hosting both bent and unbent galaxies. When considering the density of the inner 0.5 Mpc of the group, there is a clear distinction between bent and unbent doubles: bent doubles are more likely to reside in halos that are denser than their unbent counterparts. We performed a series of statistical tests in order to ensure that these two histograms are not being drawn from the same sample. Using the Anderson-Darling k sample test, we found that the null hypothesis that these two samples are drawn from the same population can be rejected with a statistical significance of 0.1%. We also used the Mann-Whitney-Wilcoxon Test, which tests the location of separate distributions and compares them to see how similar the distributions themselves are. This test rejected the null hypothesis that these two distribu-tions are the same with a reported p-value of less than 0.01. These separate statistical tests give us a reasonable degree of confidence when stating that bent doubles are indeed found in more dense groups than unbent doubles.
When considering the density of the larger environment, the difference between bent and unbent doubles is less stark, but still present. We can reject the null hypothesis using the Anderson-Darling test at roughly 1.1% significance and using the Mann-Whitney-Wilcoxon Test with a p value of less than 0.01. This shows that even the larger environments, out to 2 Mpc, are more dense for bent AGN, if only slightly.
We also examine the distances to the nearest neighbor for galaxies in groups. Measuring the distance to the nearest neighbor for every galaxy in the group is another way to learn about the group environment and how densely packed galaxies in this environment are to one another. This is a proxy for the number density of galaxies in these groups, but it considers every galaxy in the group and is not bound by the limitations of selecting a static aperture size within which the density is measured. This means that calculating the nearest neighbor for every galaxy in the group will include group members that exist beyond 0.5 Mpc from the center of the group, making it a proxy for the density of the group as a whole instead of just the core of the group where we expect it to be at its most dense. However, it is important to note that this metric is particularly sensitive to false positives and incompleteness, as a single false positive or missed group galaxy can throw off the nearest neighbor distance for many group members. Therefore, while this metric can be another proxy for the group density, it is important to note that these caveats may lead to it not being the most accurate proxy in this study.
The results of measuring the distances to the nearest neighbor for the entire sample can be found in Figure  14. There is a great deal of overlap between the two distributions and, while both the mean and median distance to the nearest neighbor for the bent sample are lower than the unbent sample, it is typically by 10-20 kpc. However, according the the Mann-Whitney and Anderson-Darling tests, the null hypothesis can be rejected at a statistically significant level with a p-value less than 0.01 for the Mann-Whitney test and a significance of roughly 0.7% for Anderson-Darling. It is important to note that the significance level of this measurement is not as high as those of the group densities, mainly because this particular metric is very sensitive to false positives and incompleteness of the group sample. Therefore, it is important to take the results of this metric with a grain of salt. That being said, these results are consistent with the results from the densities discussed (Left) Magnitude difference between the brightest and second brightest group galaxies, (middle) difference between brightest and third brightest group galaxies, (right) difference between the brightest and fourth brightest group galaxies. For all three metrics, the unbent sample sits at a higher magnitude difference.
earlier: bent doubles tend to exist in groups that have higher number densities than do unbent doubles.

Magnitude Gap
Because we are working with less precise photometric redshifts, we are unable to precisely measure the group dynamics. However, we can use the r-band magnitude gap to understand the dynamical history and age of the groups (discussed further in Section 5.1). The r-band magnitude difference between the first and second brightest group galaxies can reveal something about the merger history of the group, and thus its dynamical age. Because galaxy groups are formed via hierarchical structure formation, the BGG will tend to gain mass via mergers with satellites (D'Onghia et al. 2005;De Lucia & Blaizot 2007;Oogi et al. 2016). This evolution leads BGGs to be statistically more massive, and thus brighter than the next brightest group galaxy, and has been shown to correlate with the r-band magnitude gap (Yang et al. 2008;Shen et al. 2014;Solanes et al. 2016;Dalal et al. 2021). In this study, we use the r-band magnitude gap as a proxy for the dynamical ages of the galaxy groups in our sample.
In Figure 15, we plot the Gaussian Kernel Density Estimates (KDEs) of the r-band magnitude differences using the difference between the first and second (m 12 ), the first and third (m 13 ), and the first and fourth (m 14 ) brightest group galaxies. Our justification for using multiple metrics is both because this is what has been used in the literature (Solanes et al. 2016) and to help offset any issues introduced by false positives. For all three metrics, the median magnitude gap is higher for the unbent sample by roughly 0.4 mag, and after applying the Anderson-Darling test, we can reject the null hypothesis that these distributions are the same to a statistical significance level of roughly 0.2%. The Mann-Whitney test corroborates this with p-values of roughly 10 −3 . These results indicate that bent AGN tend to exist in groups with lower magnitude gaps than their unbent counterparts. 4.6. How do group finding parameters affect the overall results?
One of the downsides to using an FoF algorithm is the fact that the linking length is generally a difficult parameter to tune, and can result in very different looking environments depending on the choice. Additionally, our group finding algorithm requires that we set a cutoff for the photometric redshift and a cutoff for the relative probability that two galaxies are at the same redshift, for a total of three selectable parameters. While the parameters were chosen in a systematic manner to optimize the balance between completeness and false positive rate, it is prudent to examine the robustness of the main results across a range of parameter values.
We performed the group finding algorithm on the real data two additional times: once with all of the parameters increased and once with them decreased. We varied the linking length by 100 kpc, the z uncertainty cutoff by 0.01, and the probability cutoff by 0.15. Tuning these parameters to their extreme values should result in the largest differences between our test groups and the groups we get using the original parameter values. With these test groups, we carried out the same statistical analyses on distributions of group membership, group and environmental density, and magnitude differences.
For both tests, we found that, even with the parameters at different values, the overall results stay the same. The only difference is that the results are not quite as statistically significant. The largest difference is that the magnitude gap in the low parameter case goes from a significance level of 0.2% to 3.4%. So, even in the most extreme cases, the statistical significance only changes by a few percent, indicating that our results are robust.

DISCUSSION
In this study, we have compared the environments of bent and unbent double lobed radio AGN in order to learn more about what could be causing the bending of bent doubles and why we do not see the same effect on unbent AGN. An AGN's radio jets could be bent by the ram pressure of the surrounding IGM (Begelman et al. 1979;Morsony et al. 2013). How much the jets are bent depends on the density of the gas through with the AGN host galaxy is moving and the velocity of the AGN host galaxy relative to the IGM. It is also possible that a recent group or cluster merger could cause the IGM to become more turbulent and provide the ram pressure necessary to bend the jets out to large distances from the cluster center (Sakelliou & Merrifield 2000;Blanton et al. 2001;de Vos et al. 2021). Therefore, we would expect to see these kinds of galaxies existing in denser environments and moving much more rapidly compared to their unbent counterparts. Our results indicate that this could, indeed, be the case for this sample of bent doubles.
From this work, we can say to a statistically significant degree that AGN with bent jets are more likely than unbent AGN to exist in groups of 3+ members, tend to exist in larger, denser, and richer environments, and tend to exist in environments with lower r-band magnitude gaps than unbent galaxies, indicating that they exist in dynamically younger environments that may have undergone a recent merger. These results correspond well with the results of Garon et al. (2019) andde Vos et al. (2021), which showed that, while bent AGN tend to exist in fairly dense environments, they are not always located directly towards the center of the nearest group or cluster and instead can exist in different kinds of environments.
Measuring the density of the IGM in groups directly is very difficult, due to the fact that it likely exists in a hard-to-observe state known as the warm-hot intergalactic medium (WHIM; Cen & Ostriker 2006), which typically exists at 10 5 -10 7 K. While there have been previous X-ray (Sanderson et al. 2013) and Sunyaev-Zel'dovich effect (SZ effect;Lim et al. 2017) measurements of hot gas in galaxy groups, both of these fall below the expected cosmological baryon fraction in groups. This is potentially due to the fact that current X-ray and SZ effect observations only probe the hottest gas in these environments and are not sensitive to cooler gas that is difficult to observe. Because of this, we use the number density of galaxies themselves as a proxy for the density of the IGM gas, which is ultimately what is responsible for bending AGN jets under the assumption of ram pressure.
There could potentially be other reasons for AGN jets being bent, such as interactions with nearby galaxies or the interactions between the AGN jet and the ISM within the host galaxy causing bent jet morphologies, such as sharp bending near the host galaxy. Precession of the SMBH could also cause twisting bent jet morphologies that could result in an S-shaped jet (Falceta-Gonçalves et al. 2010;Roberts et al. 2018). However, we attempt to take these into account when visually selecting bent AGN, only looking for those with smooth bending in one direction.
Based on our visual selection, most of the galaxies in our sample would be considered WATs. These types of bent AGN are typically found in the BGG/BCG (Sakelliou & Merrifield 2000;Blanton et al. 2001). However, there are other recent studies that have found that they can exist outside of the nearest group or cluster, potentially indicating that they may be embedded in a filamentary structure or that the impact of the cluster/group medium is widespread (Garon et al. 2019;de Vos et al. 2021). In this study, we found that 62.3% of bent doubles are the BCG/BGG. This is consistent with the value of 55% from Golden-Marx et al. (2021), who studied mostly WATs in cluster environments. The fact that this fraction is as high as it is may be in part due to the visual sample largely being made up of WATs as opposed to NATs, which generally do not exist in the BCG/BGG. Additionally, BCGs/BGGs already have a high likelihood of being bright radio galaxies in the first place, making them more easily detectable as bent doubles. However, it is still worth noting the large fraction of bent doubles that are either isolated, in pairs, or in groups without being the BCG/BGG.
One effect we are unable to take into account is the projection of the jets along the line of sight. The only way we are able to observe a jet as bent is if the relative motion between the galaxy and the IGM has a substantial component perpendicular to the line of sight. If it is directed towards or away from us, however, we would be unable to directly see the bending in the radio observations. Additionally, the viewing angle of the jet can affect how it appears to us. If the viewing angle is close to 0 • and the jets are pointed directly at us, then it would be difficult to discern any kind of bending due to relativistic beaming or appear to be much more bent than they are. Alternatively, if the viewing angle is less than 90 • while still being able to resolve two separate lobes, the jets will appear to be more bent, potentially making a WAT look like a NAT. A deeper discussion of how projection affects the morphology we assign a radio galaxy is beyond the scope of this paper.

Dynamical histories of groups with bent and unbent AGN
Hierarchical structure formation drives much of the evolution of BCGs and BGGs, causing them to grow in mass and luminosity, especially compared to the next brightest galaxies in the group (D'Onghia et al. 2005;De Lucia & Blaizot 2007;Oogi et al. 2016). This leads to the r-band magnitude gap between first and second brightest galaxy growing over time as the BCG continues to accrete mass and luminosity (Yang et al. 2008;Shen et al. 2014;Solanes et al. 2016;Dalal et al. 2021). Therefore, the r-band magnitude gap can be used as a tracer for the dynamical age and the current dynamics of a cluster or group (Shen et al. 2014;Lopes et al. 2018), with larger magnitude gaps indicating groups that are more settled and whose BGGs have had more time to accrete mass. On the other hand, smaller magnitude gaps could indicate that a group has recently formed or merged with another group, which could lead to the group being less dynamically relaxed and could potentially result in turbulence in the IGM or galaxies with higher velocities, making conditions ideal for AGN jets to bend. This could also indicate a recent merger may have caused the BGG to be offset from the group center (Sakelliou & Merrifield 2000). The fact that 62.3% of bent doubles are the BGG could indicate that they exist in recently merged systems and are moving through a dense, turbulent medium towards the new group center. It is worth noting, however, that the findings of Wing & Blanton (2013) indicate that there is not a significant difference in the substructure of clusters hosting bent and unbent doubles, supporting the idea that clustercluster mergers are not solely responsible for bending AGN jets.
We find that, using a variety of metrics, groups hosting AGN with bent jets have lower r-band magnitude gaps, implying that they exist in groups that have formed more recently and whose BGGs have not had the time to grow appreciably due to hierarchical structure formation, or that they are part of groups that have recently merged, causing the two brightest galaxies to be similar in luminosity.

Bent doubles in singles and pairs
A dense environment is likely to play an important role in bending the jets for the most part, but there is still a number of AGN with bent jets in our sample that seemingly exist outside of groups or clusters. This is consistent with with the results of Garon et al. (2019), who found that bent AGN are not necessarily always located near known clusters, but still tend to exist in overdensities of 28ρ crit (highly bent) and 18ρ crit (less bent) from 50 -350 kpc. Wing & Blanton (2011) also found that, while most galaxies hosting bent AGN existed in overdense regions, there were still a few that existed in environments with very few nearby neighbors. Edwards et al. (2010) found a bent double located in a cosmic web filament and was able to use it to measure the density of gas in the filament and de Vos et al. (2021) found that NAT radio sources can exist out to 10R 500 of a nearby cluster. It could be that many of these bent doubles in singles and pairs are on the outskirts of a larger group or cluster and are embedded in a filament similar to that found in Edwards et al. (2010) or those observed by de Vos et al. (2021). Deeper, more complete spectroscopic observations of isolated bent doubles and any potential neighboring galaxies could provide us with a more complete picture of their environments, helping to better reveal the causes bending in very sparse environments.

Unbent doubles that are not the BGG/BCG
We find that 5.9% of unbent AGN in groups are not the BCG/BGG. There is evidence that a radio galaxy's position in a group/cluster depends on factors of the radio source itself, such as the radio luminosity , with fainter radio galaxies existing further from the group/cluster center. Studies have also found AGN with unbent jets outside of the brightest cluster galaxy, even in higher redshift clusters (Moravec et al. 2020). The fact that these galaxies are not bent might appear surprising, as we would expect a group/cluster member that is not the brightest galaxy to likely be moving through the group or cluster and thus be susceptible to ram pressure from the surrounding medium that would lead to bending. It could be possible that these particular galaxies are in environments with lower IGM densities, or that the jets are powerful enough to overcome the influence of ram pressure from the surrounding medium. Additionally, bending should decrease at higher distances from the cluster center, so the fact that there are some galaxies that are unbent and not located at the center of the cluster is not surprising (Garon et al. 2019). There is also a chance that these galaxies could actually host bent jets that are moving directly towards or away from us such that we are unable to see the bending.

CONCLUSIONS
Using a group finding algorithm that combines FoF methods and probabilistic methods, we performed a study of the environments surrounding AGN with radio jets that are either bent or unbent. For an AGN's jets to bend, its host galaxy is likely moving through a dense reservoir of gas whose ram pressure is causing the jets to bend back. However, there are also AGN with unbent jets that exist in dense environments. This study compared the environments around samples containing these two kinds of galaxies in order to better understand why some galaxies have bent AGN jets and others do not.
The main takeaways of this study are listed below: • The results of our group finding algorithm show that 16.6% of the bent double host galaxies in our sample are in singles or in pairs, while this number rises to 27.8% for unbent doubles. This indicates that unbent galaxies are more likely to exist in less dense environments where their jets will not necessarily interact with the surrounding medium enough to be bent, but that there is a subset of bent doubles that also exist in this environment. What could be responsible for bending their jets is yet to be determined, but they could be in small overdensities of the IGM or in cosmic web filaments.
• The results of the group finding algorithm also show that 25.3% of bent doubles in groups of at least 3 galaxies are not the brightest galaxy, while this number is 8.1% for unbent doubles. Bent doubles are less likely to be the BGG in the centers of groups, meaning that more of them may be satellites moving quickly through the IGrM.
• In groups of 3 or more members, bent doubles are more likely to exist in halos with a higher number of galaxies.
• Groups hosting bent AGN tend to have higher radii than those hosting unbent AGN.
• The inner 0.5 Mpc of groups with bent doubles tend to be more dense than those with unbent doubles. This could mean that there is also more gas in the IGrM that is causing these jets to bend.
• Groups hosting bent doubles tend to have lower r-band magnitude gaps than groups with unbent doubles. This could be an indication that groups with bent doubles are less dynamically relaxed or are younger than groups with unbent doubles.
• Of all unbent doubles, 5.9% exist in groups without being the brightest group galaxy. This could be due to projection Further improving our understanding of the differences between the environments inhabited by bent and unbent doubles would require additional information. First of all, more accurate and complete spectroscopy of galaxy group members or neighboring galaxies would allow for a more complete census of the environments surrounding the radio galaxies, as well as the dynamical state of their environments. Furthermore, deep X-ray observations of these groups would allow us to probe for a hot gaseous intergalactic medium that may be responsible for bending some of the AGN. eROSITA will likely provide important constraints for the galaxies in our sample and beyond.
Additionally, upcoming deep and high resolution radio surveys such as the VLA Sky Survey (VLASS; Lacy et al. 2020), the LOFAR Two-metre Sky Survey (LoTSS; Shimwell et al. 2017), the Meerkat Galaxy Cluster Legacy Survey (MGCLS; Knowles et al. 2022), and eventually the Square Kilometre Array (SKA) will provide imaging of even more bent and unbent radio AGN jets, giving us a much larger sample of galaxies to work with. Machine learning techniques could be developed to aid in the morphology classification of these sources, allowing the number of bent AGN detected to increase by a large margin.