A comprehensive generalization of the Friendship Paradox to weights and attributes

The Friendship Paradox is a simple and powerful statement about node degrees in a graph. However, it only applies to undirected graphs with no edge weights, and the only node characteristic it concerns is degree. Since many social networks are more complex than that, it is useful to generalize this phenomenon, if possible, and a number of papers have proposed different generalizations. Here, we unify these generalizations in a common framework, retaining the focus on undirected graphs and allowing for weighted edges and for numeric node attributes other than degree to be considered, since this extension allows for a clean characterization and links to the original concepts most naturally. While the original Friendship Paradox and the Weighted Friendship Paradox hold for all graphs, considering non-degree attributes actually makes the extensions fail around 50% of the time, given random attribute assignment. We provide simple correlation-based rules to see whether an attribute-based version of the paradox holds. In addition to theory, our simulation and data results show how all the concepts can be applied to synthetic and real networks. Where applicable, we draw connections to prior work to make this an accessible and comprehensive paper that lets one understand the math behind the Friendship Paradox and its basic extensions.


Introduction
The Friendship Paradox is a non-plural term, so it may initially be surprising that it actually comes in two versions: where friends' degrees are aggregated at the network level, naturally called "network-level," and where friends' degrees are aggregated at the node level, naturally called "node-level."To introduce the phenomenon broadly, the Friendship Paradox claims that in a simple connected undirected finite graph, the mean second-order degree, calculated at either the network or the node level, is no less than the first-order degree, with equality achieved only if the graph is regular.
It may be easy to get confused by the exact mechanics of the two phenomena from that broad introduction alone, so as part of this paper we formalize the concepts with algebra and make things straightforward to compute; this also makes introducing extensions easier.We call the network-level version the "list" version, and the node-level version the "singular" version-both names tie directly to how things are computed.To make it easy to see whether a phenomenon holds or fails, we look at the "gap" between a mean second-order quantity and a mean firstorder quantity as the single computation result.A version of the Friendship Paradox (including extensions) fails if its respective gap is negative and holds otherwise.The size of the gap doesn't affect that, so we are mostly concerned with the gap sign.
The original Friendship Paradox (which we also refer to as the FP) looks at node degrees and friend degrees.It is most often considered for undirected graphs, which is our focus too.
(Directed versions of FP have been studied as well [2,3], but they are much less tractable; to make our paper comprehensive, we explore this in the Supplementary Information.) The first extension of the basic phenomenon allows one to look beyond degrees and instead consider arbitrary numeric node attributes.It is natural, for instance, to ask whether the fact that friends have larger degrees, on average, may also somehow imply or be correlated with them potentially having more likes on their photos, with "total number of likes on one's photos" being an example of a numeric node attribute.In the literature, this extension is called the Generalized Friendship Paradox (GFP) [4], and its relevance to comparisons of non-degree attributes between people in social contexts has been considered by several papers [5,6].To make the generalization more explicit, here we can refer to this concept as the Attribute-based Friendship Paradox (AFP).It also comes in a list version and in a singular version, which we refer to as the LAFP and SAFP, and which have been studied by [4] and [7,8] respectively.We use the word attribute to denote the node characteristic we are looking at in all cases-in the case of AFP, the attribute is arbitrary; in the case of FP, the attribute is equal to node degree.
We can also suggest that each edge weight in a graph doesn't have to be equal to 1 (like it does in a simple graph), but is instead a positive integer.The distinction between the list and singular forms of the Friendship Paradox naturally carries over to the weighted case, and so in our framework we define both the LWFP and the SWFP.In this case, edge weights would naturally be taken into account, and the attributes would be equal to the weighted degrees.Edge weights would also be used in second-order calculations.The singular version of WFP has been studied in [3].
Finally, if we allow for edges to be weighted and for attributes to be unequal to degrees, we get two versions of the Weighted Attribute-based Friendship Paradox, a formulation that brings together aspects of these different generalizations.The attributes would be arbitrary, and edge weights would be considered in second-order calculations.
First, we introduce and discuss the two original versions of the Friendship Paradox, LFP and SFP.Then, we allow for edges to be weighted and discuss LWFP and SWFP.Finally, we allow attributes to be arbitrary on top of that and discuss LWAFP and SWAFP.In the interest of space, we discuss the unweighted attribute-based versions LAFP and SAFP in the Supplementary Information; LWAFP and SWAFP work perfectly well for the cases of no edge weights if we just take all edge weights to be 1.Because LWAFP and SWAFP consider an extension to both edge weights and attributes at once, we also call these two versions the Extended Friendship Paradox, or LEFP and SEFP.As mentioned, these work for the case of no edge weights; we will also discuss how to apply them to the case of no arbitrary node attributes.
To reiterate, the two original forms of the paradox combined with two independent sources of generalization-attributes and edge weights-mean that we have eight versions of the paradox in total: the original two (LFP and SFP), the attribute-based extensions (LAFP and SAFP), the weighted extensions (LWFP and SWFP), and the weighted attribute-based extensions (LWAFP and SWAFP).Given the lines of prior work that considered attributes and edge weights separately, our framework aims to bring it all together both with common nomenclature for these variants, and with the two general versions of the paradox-LEFP and SEFP, equivalent to LWAFP and SWAFP-but we will find a midway stop to talk about LWFP and SWFP useful.
We aim for this paper to be a one-stop venue for understanding the generalized phenomena from both a theory and a data perspective.Note that despite "Friendship" in the name, these algebraic concepts apply to networks across domains.Inherent high clustering of social networks does have certain implications, though, which we consider when looking at data.When discussing the two original versions of the Friendship Paradox, we are looking at simple connected undirected finite graphs.When working with the extensions that consider edge weights, we are looking at weighted undirected connected finite graphs, meaning that each edge weight is specified to be a positive integer (and all edge weights can still be 1).To make it explicit, all the graphs we consider still only have at most one edge between two nodes and do not have self-loops.
Many real-world networks are often not connected, but it is easy to see how the gaps can be calculated for the giant connected component (remove everything but the giant component) or for multiple components (iterate over nodes and their friends as usual).The only issue would arise for isolated nodes when looking at singular versions of the paradox: here, we couldn't find, say, the average degree of a node's friends because we'd have to be dividing by 0. In practice, we usually disregard isolates when looking at both the singular and the list versions of the paradox.
To deal with real-world cases where the edge weights are positive but not necessarily integers, it is simplest to multiply each edge weight by a constant that would make each edge weight an integer (the least common multiple of all the edge weight denominators would work as such a constant).This would not affect the gap sign or whether the paradox holds.Here we do assume that each initial edge weight is a rational number or can be approximated by a rational number (any degree of precision would work).Our arguments for the extensions can be generalized to explicitly allow for any positive (including irrational) edge weights, but restricting edge weights to be positive integers allows for simpler definitions and proofs which we favor due to accessibility.That said, the numbered gap equations and the correlation rules work for positive real weights too.
Understanding the extensions and knowing how to use them for "simpler" cases (e.g.no arbitrary node attributes) and for more complicated cases (e.g.irrational edge weights, disconnected graphs) lets us cover many applications of the basic premise of "the friends' quantity is larger than the nodes' quantity" to undirected networks from any domain.
In Section 2, we formalize the two original versions of the Friendship Paradox for undirected graphs and prove that they always hold.In Section 3, we allow for edge weights to be positive integers and prove that the two new versions also always hold.In Section 4, we add arbitrary node attributes on top of that, formalize the two extensions and prove under what conditions they hold and fail.To illustrate how things work, we apply the two extensions to a 3-node network in Section 5; we both consider and disregard provided edge weights and arbitrary attributes and see how the extensions accommodate that, for a total of 8 gap values.(We cover the example very briefly in the main text, with much more detail in the Supplementary Information.)We look at simulation results in Section 6 and at data results in Section 7. In the Supplementary Information, we consider FP for directed graphs and show that the 4 basic directed versionslist and singular, in-degree-and out-degree-based-do not hold in very simple cases.
In what follows, we define n as the number of nodes in a graph; the nodes are indexed 1 through n.The weight of the edge between nodes i and j is defined as e ij = e ji .(For completeness, e ij = e ji = 0 if i and j aren't connected by an edge.)The number of neighbors i has (the number of edges i is part of) is denoted d i for both unweighted and weighted graphs and is known as the degree of node i, and N (i) is the set of neighbors (or friends) of i.The sum of weights of edges that i is part of, j∈N (i) e ij , is denoted w i for both unweighted and weighted graphs and is known as the weighted degree of node i.Clearly, for unweighted graphs, If all d i are equal in a graph, we call the graph regular.If all w i are equal, we call the graph "weighted-regular."If the edge weights in a graph are not all 1, the graph can be regular but not "weighted-regular" and vice versa, whereas if the edge weights are all 1, regularity is of course equivalent to "weighted-regularity." See the Supplementary Information for an example of a graph which is "weighted-regular" but not regular.
A numeric attribute of i is denoted a i .When we say that a graph "has no attributes" or that we are not considering attributes, we will take a i = w i for each i.This will reduce to a i = d i for unweighted graphs (the original Friendship Paradox), but will take non-trivial edge weights into account when they are present.
Finally, we will refer to the degree sequence, the weighted degree sequence, and the attribute sequence of a graph.These are lists of their associated values (e.g. the degree sequence is a list of degrees) indexed in the same way the nodes are.

Friendship Paradox (FP)
The Friendship Paradox is colloquially expressed as "your friends have more friends than you do" after the title of Scott Feld's paper [1].It's a statement about nodes' degrees and friends' degrees.There are two natural formalizations of the statement and we provide and prove both below.

formal definition of the LFP gap
List second-order degree of node i is the list of degrees of i's friends; the length of such a list is d i .To get the mean second-order degree (list version) of the graph as a whole, we concatenate (join) all such lists and take the mean of that; we will express that mean as a fraction.To get the numerator, we sum each list and then sum the sums, and the denominator is the sum of the lengths of all the lists, for a final value of as the graph's mean second-order degree (list version).The LFP gap is the difference between the mean second-order degree (list version) and the "mean first-order degree" (which is just mean degree) in a graph.That is expressed as: In the expression above, nodes indexed i are "seeds" taking stock of their friends' degrees.
We can take a different approach and instead see how many times a friend's degree is featured in a seed's list second-order degree.A friend with degree d j is featured in d j seeds' calculations.
The gap can thus be rewritten as: Changing j to i and finding a common denominator, this is modified to: We will say that LFP fails if g LF P is negative and holds otherwise.
2.1.2g LF P = 0 for regular graphs and positive for all non-regular graphs We claim that the gap is non-negative across our domain (with equality achieved for regular graphs): g LF P ≥ 0.
First note that the gap is indeed zero for regular graphs where every node has degree d, since the concatenated list of "list second-order degrees" is of the form [d, d...d] (all nodes' friends have degree d) for a mean of d, and the list of nodes' degrees looks the same, with the only difference being that it may be shorter, for a mean of d.Now assume that the graph is non-regular.Since we are interested in the gap sign, let's look just at the numerator of g LF P : numerator of Reindex the degrees so that the following is true: Now we can see that the numerator of g LF P is positive by Chebyshev's sum inequality.The inequality is strict precisely because not all degrees are the same.
n i=1 b i , with equality achieved if at least one of the sequences is constant [9].
Recall that LFP fails if g LF P is negative and holds otherwise.Thus LFP always holds.
Intuitively, the average friends' degree being higher than the average degree here is due to the fact that if node i's degree is higher (say 10), i has 10 friends, and those 10 friends each add d i = 10 to the second-order list, resulting in 10 being present 10 times, while a lower degree of 5 would only be present 5 times.So, nodes with higher-than-average degrees are overrepresented in the friends' degree fraction (the mean second-order degree (list version)), and nodes with lower-than-average degrees are thus under-represented.Since each node contributes equally to the first-order calculation of the average degree in a graph, this makes the secondorder mean higher.This intuitive argument, if helpful, is easiest to apply to this most basic version of the Friendship Paradox, LFP.In the other cases, we will just rely on algebra to see things.

formal definition of the SFP gap
Singular second-order degree of node i is the mean of the degrees of i's friends, expressed as a fraction j∈N (i) d j d i (or, the mean of i's list second-order degree).The mean second-order degree (singular version) of the graph as a whole is the mean of such fractions for all nodes in a graph, expressed as The SFP gap is the difference between the mean second-order degree (singular version) and the mean degree in a graph.That is expressed as: The term n i=1 1 d i j∈N (i) d j deserves more attention.Note that if nodes x and y are connected by an edge, that edge contributes dx dy + dy dx to this term.If x and y are not connected by an edge, they do not influence each other's second-order values.Let's define the set of edges of the graph as E. We can now rewrite the gap as: We will say that SFP fails if g SF P is negative and holds otherwise.
2.2.2 g SF P = 0 for regular graphs and positive for all non-regular graphs We claim that the gap is non-negative across our domain (with equality achieved for regular graphs): g SF P ≥ 0.
First note that the gap is indeed zero for regular graphs where every node has degree d, since for each node, its singular second-order degree and its first-order degree are both equal to d, and so the second-order mean and the first-order mean are also both equal to d for a difference of 0.
Now assume that the graph is non-regular.
Following Kramer et al. [10], take the last definition of the gap: First note that for any r ∈ R, r + 1 r ≥ 2 by the AM-GM inequality.The inequality states that p+q 2 ≥ √ pq for any real p and q with equality achieved if p = q, and we take p = r and q = 1 r .Taking r = dx dy and 1 r = dy dx , we can say: Since the graph is non-regular and connected, for at least one edge (x, y), d x ̸ = d y and the AM-GM inequality is strict ( dx dy + dy dx > 2), so we can strengthen the overall inequality too: Note that the right-hand side is equal precisely to the mean degree.So, Recall that SFP fails if g SF P is negative and holds otherwise.Thus SFP always holds.
3 Weighted Friendship Paradox (WFP) Here, we allow for edges to be weighted, each weight being a positive integer, and see how that affects first-and second-order values and our calculations.Conceptually, we will try to stay as close as possible to the original versions of the paradox.
In the original FP, we used degree as the node attribute.In the weighted version, we use weighted degree, or the sum of the weights of the edges a node is part of.Also, if e ij > e ik , we want j to matter more than k in i's second-order calculations.To make phrasing more straightforward and closer to that of the Extended FP (next section), we will refer to weighted degree as the attribute of i, but still denote it w i .
The list second-order attribute of node i would still be the list of attributes of i's friends, but now, if j is a friend of i, w j would be present on the list e ij times and not necessarily once.
The length of such a list for i would be equal to the sum of the weights of the edges i is part of, or w i .The singular second-order attribute would still be the mean of the list second-order attribute.
So, we can define the LWFP gap, the difference between the mean second-order attribute (list version) and the mean attribute, as: And the SWFP gap, the difference between the mean second-order attribute (singular version) and the mean attribute, as: 3.0.1The WFP gaps are 0 for "weighted-regular" graphs and positive otherwise We claim that both gaps are 0 for "weighted-regular" graphs, i.e. graphs where all w i are equal, and positive otherwise, similar to the original FP.
To see why that is the case, it will actually be helpful to rewrite both gap formulas.Define N w (i) as the weighted neighborhood of i, which is the set of i's friends except that each friend j is represented e ij times.We can see that the gap expressions become: Now, compare these expressions to equations 1 and 2 for LFP and SFP gaps.The LWFP expression is almost identical to the LFP expression if we replace w with d, and same for the singular version of WFP.But the weighted expressions deal with N w (i) instead of N (i).To get around that, consider the following: we are only interested in seeds and friends, not the full structure of a network.For each seed i, for each of its friends j such that e ij > 1, we can split edge (i, j) into e ij new edges, and we can attach j to the first edge, and copies of j to the other edges.Now, the neighborhood we are looking at in WFP calculations is N (i).We can still use w i (now equal to d i given that each edge weight is 1) in the calculations, and we will still use each friend's attribute w j .We have thus transformed our LWFP and SWFP equations into something that is algebraically identical to equations 1 and 2. For FP, we showed that the gaps are 0 if all d i are the same and positive otherwise.Since algebraically we get our LWFP and SWFP expressions by replacing d with w in the FP equations, we know that the LWFP and SWFP gaps are zero if all w i are the same (i.e. if the graph is "weighted-regular"), and positive otherwise.

Extended Friendship Paradox (EFP)
We were already talking about node attributes in Section 3. There, the attributes were equal to weighted degrees.Now, we can relax that and say that each attribute is arbitrary and denoted a i .To get the gap formulations, we only need to replace the first-order quantities (that we are averaging) with a i , but we will build the gap formulas from scratch to make things very clear.
EFP is equivalent to the Weighted Attribute-based Friendship Paradox (WAFP).(To see how an attribute-based FP without edge weights is defined, see the Supplementary Information.) The attributes are indexed the same way as degrees and weighted degrees, and all these sequences have the same length, so we can precisely define a (weighted degree)-attribute correlation which will be useful.Note though that if sequence x consists of all the same values, the correlation between x and y (denoted r x,y ) is undefined, so we need to look at the case where all weighted degrees are equal and the case where all attributes are equal-meaning the two cases where the (weighted degree)-attribute correlation is undefined-separately.When the correlation between x and y is defined, it is equal to

formal definition of the LEFP gap
The list second-order attribute of node i is the list of attributes of its friends weighted by edge weight e ij for each friend j; in other words, for each friend j, i takes a j and appends it to its own list e ij times instead of just once.The length of such a list is j∈N (i) e ij , the weighted degree of i.
To get the mean second-order attribute (list version) of the graph as a whole, we take all such lists and take the mean of that; we will express that mean as a fraction.To get the numerator, we sum each list and then sum the sums, and the denominator is the sum of the lengths of all the lists.The LEFP gap is the difference between the mean second-order attribute (list version) and the mean attribute in a graph.That is expressed as: Let's change j∈N (i) e ij in the denominator to w i : In the expression above, nodes indexed i are "seeds" taking stock of their friends' degrees.
We can take a different approach and instead see how many times a friend's degree is featured in a seed's list second-order attribute.A friend with weighted degree w j (and attribute a j ) is featured in seeds' calculations w j times (some of these times might be for the same seed).The gap can thus be rewritten as: Changing j to i and finding a common denominator, this is modified to: We will say that LEFP fails if g LEF P is negative and holds otherwise.
4.1.2g LEF P = 0 for "weighted-regular" graphs and for graphs with no attribute variation First note that the gap is 0 if the weighted degree sequence or the attribute sequence is constant.
This is clear from a direct application of Chebyshev's sum inequality described above: if w i and the numerator of g LEF P is 0.
Now we can further assume that both weighted degrees and attributes have variation, meaning that the (weighted degree)-attribute correlation r w,a is defined.
4.1.3the sign of r w,a determines the sign of g LEF P for other graphs Note that if we subtract a constant c from each node's attribute, the gap value doesn't change, since each element in the second-order list and the first-order list drops by c, and so the difference between the second-order mean and the first-order mean stays the same.Let's subtract the mean of the attribute sequence from each attribute.Now the attribute sequence mean, which we will denote a, is 0, and the gap didn't change.
Taking a = 0, our gap formula becomes: with a positive coefficient The (weighted degree)-attribute correlation r w,a , given a = 0, is: with a positive denominator.
The sign of the correlation is thus determined by the sign of the numerator: From here, we get So, the sign of r w,a is equal to the sign of n i=1 w i a i .Since g LEF P is n i=1 w i a i multiplied by a positive number, the sign of r w,a is equal to the sign of g LEF P .
Recall that LEFP fails if g LEF P is negative and holds otherwise.LEFP holds in cases when r w,a is undefined (when the weighted degrees are all the same and/or the attributes are all the same).If r w,a is defined, LEFP fails if r w,a < 0 and holds otherwise.Note that the gap being 0 does not make a statement about a graph's "weighted-regularity" (or regularity like it does in the case of the original FP versions), since the LEFP gap is also 0 when r w,a = 0.

LEFP when not considering attributes
If we don't have arbitrary attributes and want to implement LWFP via LEFP, we may want to replace attributes with degrees in equation 5, since degrees are used in FP.That would be incorrect.Instead, we need to replace each attribute a i with the sum of weights of edges that i is part of, or i's weighted degree w i .See Section 3 for details on how WFP is set up.Using regular degrees as first-order values but using edge weights in second-order-value calculations is not LWFP or LFP which do not fail-it is a case of LWAFP with degrees as attributes, and the gap sign is equal to the sign of r w,d .See the Supplementary Information for an example of a graph where this correlation is negative and LWAFP fails.

LEFP failure when considering attributes
When we don't consider attributes and instead use weighted degrees as first-order values, the correlation r w,a reduces to r w,w and the paradox doesn't fail.If we do have arbitrary attributes, we can estimate how often the list version of the extended paradox may fail.Imagine you have a graph with a fixed weighted degree sequence w.Take and an arbitrary attribute assignment a.
Suppose r w,a is positive.Here, LEFP holds.Now flip the sign of all the attributes.This flips the sign of the correlation and the gap-LEFP fails.If the initial r w,a is negative, the flipped version leads to r w,a being positive.While zero r w,a correlation is possible too, and the opposite of that attribute sequence would also lead to a correlation of zero (and to both gaps being zero meaning the paradox holds), and it's possible to have constant attribute sequences or weighted degree sequences for which the gap is zero (and so the flipped-attributes gap is zero too), these cases are rare.Thus this thought experiment shows that LEFP, when considering arbitrary attributes, may fail in around 50% cases in theory.When we deal with real-world data, this number may be very different since the attributes may be positively or negatively correlated with weighted degrees.

singular version: SEFP 4.2.1 formal definition of the SEFP gap
The easiest way to get the singular second-order attribute of node i is to take the mean of the list second-order attribute of node i, which is a list of node i's friends attributes where each a j is represented e ij times.The length of this list is equal to j∈N (i) e ij and its mean is expressed as j∈N (i) e ij a j j∈N (i) e ij .The mean second-order attribute (singular version) of the graph as a whole is the mean of such fractions for all nodes in a graph, expressed as The SEFP gap is the difference between the mean second-order attribute (singular version) and the mean attribute in a graph.That is expressed as: Let's change j∈N (i) e ij to w i : In the expression above, index i refers to nodes (seeds) and index j to i's friends, and we look at the seeds' calculations of their second-order attributes.But we can also do the opposite and see how each node j's attribute features in its friends' second-order values.a j 's coefficient in the second-order mean is equal to 1 n times a cumbersome quantity, the weighted sum of j's friends' reciprocal weighted degrees: The equation above may be the one that works best when we actually want to compute the gap size.
We call j∈N (i) w j , the weighted sum of i's friends' reciprocal weighted degrees, γ i (gamma).(For an unweighted graph, a corresponding quantity encountered in literature is delta, the sum of i's friends' reciprocal degrees, j∈N (i) 1 [8].Gamma reduces to delta if all edge weights are 1.) We can now rewrite the previous expression as: Let's reindex j to i for a final formulation: We will say that SEFP fails if g SEF P is negative and holds otherwise.
4.2.2 g SEF P = 0 for "weighted-regular" graphs and for graphs with no attribute variation If all weighted degrees are the same and equal to w, each γ i is equal to j∈N (i) Looking at Equation 7, this makes the gap 0.
If all attributes the same and equal to a, using Equation 7, we have The sign of the gap is equal to the sign of n i=1 γ i − n.The sum of gammas n i=1 γ i is equal to e ij w j .In this sum of sums, the final coefficient of term 1 w j is w j , since each of j's friends k uses 1 w j in their calculation of γ k (their gamma) e jk times, and the sum of e jk over all such nodes k is w j .Since this argument applies to every j's reciprocal weighted degree 1 w j , the sum of all gammas is equal to n j=1 w j 1 Thus n j=1 γ j − n is equal to 0, the sign of the SEFP gap is "none" and the gap itself is 0.
Note also that if a graph is not "weighted-regular" (a case we just looked at), we have variation in gammas.We provide the proof in the Supplementary Information.Once we have established that there is variation in gammas, we can further assume that r γ,a is defined.

the sign of r γ,a determines the sign of g SEF P for other graphs
We saw before that subtracting the mean of the attribute sequence from each attribute makes the new attribute sequence mean 0 and doesn't change the gap.Taking a = 0, our gap formula becomes: with a positive coefficient 1 n .The correlation r γ,a , given a = 0, is: with a positive denominator.
The sign of the correlation is thus determined by the sign of the numerator: From here, we get So, the sign of r γ,a is equal to the sign of n i=1 γ i a i .Since g SEF P is n i=1 γ i a i multiplied by a positive number, the sign of r γ,a is equal to the sign of g SEF P .
Recall that SEFP fails if g SEF P is negative and holds otherwise.SEFP holds in cases when r γ,a is undefined (when the weighted degrees are all the same and/or the attributes are all the same).If r γ,a is defined, SEFP fails if r γ,a < 0 and holds otherwise.Note that the gap being 0 does not make a statement about a graph's "weighted-regularity" (or regularity like it does in the case of the original FP versions), since the SEFP gap is also 0 when when r γ,a = 0.

SEFP when not considering attributes
If we don't have arbitrary attributes and want to implement SWFP via SEFP, we, similarly to the logic in Section 4.1.4,need to use weighted degrees, and not simply degrees, in place of attributes.See the Supplementary Information for an example where SWAFP with degrees as attributes fails, which is equivalent to r γ,d being negative.

SEFP failure when considering attributes
When when we don't consider attributes, SEFP reduces to SWFP which doesn't fail according to the logic from Section 3.0.1.If we do have arbitrary attributes, we can estimate how often the singular version of the extended paradox may fail similar to how we did it for LEFP in Section 4.1.5.Imagine you have a graph with a fixed weighted degree sequence w and thus a fixed gamma sequence γ.Take an arbitrary attribute assignment a. Suppose r γ,a is positive.
Here, SEFP holds.Now flip the sign of all the attributes.This flips the sign of the correlation and the gap-SEFP fails.If the initial r γ,a is negative, the flipped version leads to r γ,a being positive.While zero r γ,a correlation is possible too, and the opposite of that attribute sequence would also lead to a correlation of zero (and to both gaps being zero meaning the paradox holds), and it's possible to have constant attribute sequences or weighted degree sequences for which the gap is zero (and so the flipped-attributes gap is zero too), these cases are rare.Thus this thought experiment shows that SEFP, when considering arbitrary attributes, may fail in around 50% cases in theory.When we deal with real-world data, this number may be very different since the attributes may be positively or negatively correlated with gammas.

How reductions work
Now that we have defined LEFP and SEFP, we want to be able to apply it to all kinds of graphs, whether or not they have edge weights or arbitrary attributes defined.
It is easiest to use Equations 5 and 6 for gap calculations.
Most importantly, if no arbitrary attributes are present, each attribute a i in the equations should be equal to the sum of weights of edges that i is part of, which is equal to w i and not d i .
(w i will reduce to d i for the case of no edge weights.) When no edge weights are defined, simply define them all to be 1.
It's also interesting to see what happens to the two correlation-based rules when we don't consider arbitrary attributes or edge weights.
We know that r w,a determines the sign of g LW AF P and r γ,a determines the sign of g SW AF P .
If we don't consider edge weights, we see that r d,a determines the sign of g LAF P and r δ,a determines the sign of g SAF P .(Delta of i is the sum of the reciprocal degrees of i's friends, ) If we don't consider arbitrary attributes, we see that r w,w determines the sign of g LW F P and r γ,w determines the sign of g SW F P .Since r w,w = 1 every time it's defined, and since LWFP holds whenever r w,w is not defined (when the graph is "weighted-regular"), we see that LWFP always holds (which we also know from algebra in Section 3.0.1).Conversely, since we know We can look at all the data presented, or we can ignore edge weights and/or node attributes.
We want to apply an extension (LEFP or SEFP) in every case.To keep track of what we are disregarding, we will use the names Friendship Paradox (an extension applied to the graph without weights or attributes), Attribute-based Friendship Paradox (an extension applied to the graph without weights), Weighted Friendship Paradox (an extension applied to the graph without attributes) and Weighted Attribute-based Friendship Paradox (EFP) (an extension applied to the graph as is).
We saw in Sections 2 and 3 that FP and WFP always hold.When considering attributes, though (whether or not we also consider edge weights), the paradox may fail depending on the signs of the correlations specified in Section 4. To illustrate this, in our example, the four versions that can fail do fail, but this is clearly not always the case.
We only provide the gap sizes (and signs) in this section-for an extended argument, see the Supplementary Information.

Simulation
Since we are not interested in gap sizes and since the non-attribute-based versions of the paradox do not fail, we are mainly considering attribute-based versions here: WAFP (EFP) where we also look at edge weights, and AFP where we don't look at edge weights.We are interested in how increasing the expected value of an attribute-based correlation (say, r w,a ) affects how often the associated version of the paradox (in this case, LWAFP) fails.While degrees, weighted degrees, deltas and gammas aren't necessarily highly correlated, raising/lowering r d,a in our construction affects r w,a , r δ,a and r γ,a similarly, so we will focus on changing r d,a since degree is the most intuitive concept out of the four and changing attributes in one way is simpler than in four ways.
This simulation is not meant to be exhaustive, but merely illustrative.For each calculation, we will also confirm that the sign of the correlation we are looking at matches the sign of its associated gap.
We use a G n,p random graph generator with graph size n = 1000 and edge probability p = 1 50 (p = 1 50 was initially selected to get sparser-more computationally efficient-graphs that are still often connected for n = 1000, but we later discovered another good reason to settle on this, which we mention below).Because our domain is connected graphs, we discard disconnected graphs produced by G n,p .(We would also discard regular graphs and graphs that end up being "weighted-regular" once we assign edge weights, but in practice, we found neither disconnected, nor connected regular, nor connected "weighted-regular" graphs and so did not need to discard them.) We think of an edge weight as the strength of a connection between two nodes.While it's plausible that if one person has strong ties (edge weight >> 1) with two people, the two people also have a tie stronger than 1 (an extension of the strong triadic closure property [11]), to keep things simple, we assign weights to existing network edges independently and distribute them uniformly between 1 and 10 (restricting to integers).
We do 1000 runs of the simulation.A run includes creating n = 1000 nodes, labelling them 1 through 1000, determining which edges exist, confirming the graph is connected and not regular, determining the weight of each edge, confirming the graph is not "weighted-regular," and drawing an attribute sequence a of size 1000 from a standard normal distribution with mean 0 and s.d. 1 (N (0, 1)).For each condition listed below, we alter that sequence to make r d,a smaller or larger, and calculate the four gaps (g LAF P , g SAF P , g LW AF P , and g SW AF P ) and the four associated correlations (r d,a , r δ,a , r w,a , and r γ,a ).To summarize things across 1000 cases, for each condition we keep track of the 4 mean correlations and the proportion of cases where each of the paradoxes fails.

Simulation conditions
In condition 0, each of our attributes remains as is (drawn from N (0, 1)).The expected degreeattribute correlation is 0 and so we expect LAFP to fail in around 50% of the 1000 cases.(Recall that it's the LAFP gap sign that is equal to the r d,a sign.) In positive-numbered conditions j (j ∈ {1, 2, ...100}), attribute a i is the sum of the original number drawn from N (0, 1) and j 100 d i .As we move towards higher-indexed conditions, the degree-attribute correlation r d,a increases in expectation.We expect LAFP to fail less often.
In negative-numbered conditions j (j ∈ {−1, −2, ...−100}), attribute a i is similarly the sum of the original number drawn from N (0, 1) and j 100 d i .Here, as we move towards lower-indexed conditions, r d,a decreases in expectation.We expect LAFP to fail more often.Making r d,a higher or lower will also affect r δ,a , r w,a , and r γ,a .All four parameters are highly correlated in our construction.r d,δ has mean 0.973 and s.d.0.0013 across the 1000 Figure 2: The proportion of cases in which each paradox fails resembles a step function with j as the argument-that is why in the top panel we restrict j to [−3, 3] so the shift is more apparent.Since positive j implies a positive degree-attribute correlation which, in our construction, is tightly linked to other correlations being positive, and correlation needs to be just slightly greater than or equal to 0 for an attribute-based version of the paradox to hold, it makes sense that the gaps become positive and the proportion of failure drops to 0 in a step-like fashion.A contributing factor is that given our construction, the standard deviation of the 1000 correlations for each condition is low (< 0.035 and highest at j = 0).See the Supplementary Information for a plot of the standard deviation.(Note also that in the top panel, the minute details of the lines' behavior around 0 are due to randomness which is highest at j = 0. Here, the lines seemingly all cross around −0.5, but that isn't the case in each run of the simulation.We expect the proportion of failure to be 0.5 at j = 0 for each line, but it's not guaranteed to be precisely that in a simulation.) The correlation spread is highest at j = 0 when the attributes are independent of the degrees: the standard deviation is around 0.032 for r d,a , r δ,a , r w,a and r γ,a .It's interesting to see the relationship between correlation values and gap values for that specific example (where attributes are distributed normally), since the correlations (plotted on the x-axis) would both vary and have different signs.See the results of that in Figure 3   networks and found r d,a , r δ,a , r w,a and r γ,a , and the LAFP, SAFP, LWAFP and SWAFP gap sizes for each.The LAFP gap signs follow the r d,a signs, the SAFP gap signs follow the r δ,a signs, the LWAFP gap signs follow the r w,a signs, and SWAFP gap signs follow the r γ,a signs.Furthermore, the correlation between the x-axis quantity and the y-axis quantity is 0.9994 for all four pairs (the exact values are slightly different).But the correlation may not be as high for less symmetric cases such as real-world data.While we aren't interested in gap sizes on their own, it is interesting to see a strong linear relationship between them and their associated correlations in this specific case.Note: for illustration purposes we only plot the results for 100 networks out of 1000.

Data
Our simulation results are very straightforward because our construction is very simple.Realworld data is messier and it's interesting to see how gap sizes and their associated correlations behave in those cases.Here again, we are only interested in the gap sizes insofar as they relate to correlations and so focus on LAFP, SAFP, LWAFP, and SWAFP, but we'd also like to report that all the LFP, SFP, LWFP, and SWFP gaps we find in the data discussed below are positive.

Facebook100
We have found the Facebook100 dataset useful in the past (see [12,13] for details on this data).
Each of the 100 networks is a 2005 snapshot of Facebook friendships within a US university.Each network is connected; the average network size is 12083.16;each network has an average degree and the average average degree across the networks is 76.78.Nodes are people.They have attributes such as gender ("female," "male," or "not reported"), graduation year (including "not reported") and other (anynonymized) attributes such as high school and major.The average proportion of nodes with no reported gender is 0.0767 across the 100 networks.The average proportion of nodes with no reported year of graduation is 0.137 across the 100 networks.Facebook100 is useful because it gives us a chance to create something like Figure 3, but for real-world data where the graph size and other parameters change, but the context stays the same.
The only thing Facebook100 does not have is edge weights since Facebook friendships are not weighted.Using the principle of homophily, we can suppose that people with the same graduation year may have stronger ties and assign to edges between two such people a weight of 2. Any other two nodes connected by an edge (including pairs where both nodes have unreported year of graduation) would have an edge of weight 1. Across the 100 networks, the average proportion of edges that get a weight of 2 is 0.457.
We'd also like to create a numeric attribute for each node, since the existing attributes are not reported for all the nodes and/or are categorical in nature.We will use "prop own," the proportion of a node's friends that share its gender value (including "not reported").Each network would have an average attribute and the average average attribute across the 100 networks is 0.496.
We computed r d,a , r δ,a , r w,a and r γ,a , and the LAFP, SAFP, LWAFP and SWAFP gap sizes for each network and created Figure 4 which is analogous to Figure 3.The 400 LFP, SFP, LWFP and SWFP gaps are all positive as well.LAFP fails (the gap is negative) in 60 out of 100 cases, SAFP fails in 66, LWAFP fails in 50 and SWAFP fails in 49.None of the gaps are zero.The failure rate is not quite 50% like we would see with simulated networks and pure random attribute assignment where expected r d,a , r δ,a , r w,a and r γ,a would all be zero.For Facebook100 and our attribute construction, average r d,a = −0.0124,average r δ,a = −0.0148,average r w,a = −0.00269and average r γ,a = −0.000119.Clearly, if these averages were higher or lower, we'd expect the associated paradox to fail less/more often.
Figure 4: Gap sizes and their associated correlations for the Facebook100 data.Like in Figure 3 that looked at random graphs, the LAFP gap signs follow the r d,a signs, the SAFP gap signs follow the r δ,a signs, the LWAFP gap signs follow the r w,a signs, and SWAFP gap signs follow the r γ,a signs.But here the correlation between the x-axis quantity and the y-axis quantity is lower than 0.9994 (but still very high): 0.986 for r d,a and g LAF P (red circles), 0.983 for r δ,a and g SAF P (blue triangles), 0.990 for r w,a and g LW AF P (green circles), 0.986 for r γ,a and g SW AF P (black triangles).
Figure 4 shows that the gap and its associated correlation are themselves highly correlated even in a real-world example.One should note, though, that in principle the gap-correlation cor-relation could be much lower than 1 (if the networks in question come from different contexts, etc.).As an example, take the network in Figure 1.As we saw in Section 5, the LAFP gap is equal to − 1 4 for this network, and the degree-attribute correlation r d,a is equal to −0.866.Now, alter that network by changing the attribute of node A (a A ) from 2 to 3 and by adding node D that has attribute 0 and is attached only to B. (See the Supplementary Information for an image of this network.)The new LAFP gap is equal to mean([0, 3, 1, 0, 0, 0])−mean([3, 0, 1, 0]) = − 1 3 and the new r d,a is equal to −0.471.Now, the vector of gaps for these two networks, (− 1 4 , − 1 3 ), and the vector of r d,a 's for these two networks, (−0.866, −0.471), have correlation −1.What's important is that within any single network, the attribute-based gap signs are equal to the signs of their associated correlations as we showed in the theory part of the paper (Section 4).

Configuration model
An important way in which a real social network is different from one generated by G n,p is the presence of homophily/clustering.We can find a "middle ground" between a random network and a Facebook100 network by removing the social structure from the Facebook100 network with a configuration model.
A configuration model takes in a sequence of nodes and a node-indexed degree sequence and creates edges between nodes such that each node has the degree specified in the degree sequence.Using that, we can retain nodes' degrees but make their friendships more random.
Note that the configuration model may generate self-loops and parallel edges.We will remove self-loops and duplicate edges, and then check that the graph is still connected.If it's not, we will redo the procedure.If it is, we will settle on this graph and create a new degree sequence from it (some degrees may be lower since we may have removed some edges).
We still want the graph to be weighted, and we want the weights to be distributed randomly too (and not based on node similarity like they previously were).For each Facebook100 net-work, we know the proportion of edges that were of weight 2 (call it p 2 ).For each edge in the configuration model network, we assign it a weight of 2 with probability p 2 , and a weight of 1 with probability 1 − p 2 .
As for attributes, our original attributes-the proportion of friends that have the same gender value-are based on the social structure of the graph.Rewiring the edges will change that number for each node.Our goal with the configuration model, though, is to see how removing the social structure alone changes the gaps and the correlations, so we will keep each node's attribute unchanged from the original network to the configuration model.
Once we run the configuration model for every network, we can create plots that compare the original gap sizes/correlation values to the new ones.All such plots are shown in the Supplementary Information.We find that the list gaps and correlations mostly remain very similar to the originals (with the scatter plots being close to the x = y line), but the singular gaps and correlations trend upward (the slope of a best-fit line is greater than 1).In terms of the network topology, that is mirrored in r d,δ and r w,γ being much higher for the configuration model graphs than for the original graphs.Since delta and gamma describe a node's immediate neighborhood, both r d,δ and r w,γ are measures of local properties in a graph.It makes sense that changing them affects the singular gaps (and their associated correlations) which deal with node-specific second-order values, and doesn't affect the list gaps (and their associated correlations) which are about network-level second-order values.Why removing social structure from a social-network graph (and why raising n or p for G n,p ) raises r d,δ and r w,γ is beyond the scope of this paper, but we provide these results for completeness and as a precursor for potential future research.

Conclusion
In this paper we showed that even though the Friendship Paradox may initially be a confusing concept, it and its basic generalizations are very tractable mathematically, and allowing for edge weights and arbitrary node attributes can be covered in two extensions-one network-level and one node-level.Additionally, for the attribute-based versions of the paradox, we showed how the gap signs follow simple correlation-based rules.We have also provided simulation and data results that further one's understanding of the theory behind the 8 versions of the Friendship Paradox.

Figure 1 :
Figure 1: This is a weighted undirected graph G on 3 nodes.The weight of each edge, when not 1, is listed on the edge.The nodes are labeled A through C. Each node has a numeric attribute a i associated with it, and it's listed in blue next to each node.
(we plot 100 points of each kind instead of 1000).All 4000 LFP, SFP, LWFP and SWFP gaps are positive.LAFP fails in 503 out of 1000 cases (the gap is negative), SAFP fails in 511, LWAFP fails in 484 and SWAFP fails in 490.None of the gaps are zero.This confirms our logic in Sections 4.1.5and 4.2.5 where we concluded that attribute-based versions fail around 50% of the time given random attribute assignment.

Figure 3 :
Figure 3: We created a standard normal attribute sequence for each of the 1000 G 1000, 1 50