Weighted directed clustering: interpretations and requirements for heterogeneous, inferred, and measured networks

Weights and directionality of the edges carry a large part of the information we can extract from a complex network. However, many network measures were formulated initially for undirected binary networks. The necessity to incorporate information about the weights led to the conception of the multiple extensions, particularly for definitions of the local clustering coefficient discussed here. We uncover that not all of these extensions are fully-weighted; some depend on the degree and thus change a lot when an infinitely small weight edge is exchanged for the absence of an edge, a feature that is not always desirable. We call these methods ``hybrid'' and argue that, in many situations, one should prefer fully-weighted definitions. After listing the necessary requirements for a method to analyze many various weighted networks properly, we propose a fully-weighted continuous clustering coefficient that satisfies all the previously proposed criteria while also being continuous with respect to vanishing weights. We demonstrate that the behavior and meaning of the Zhang--Horvath clustering and our new continuous definition provide complementary results and significantly outperform other definitions in multiple relevant conditions. Using synthetic and real-world examples, we show that when the network is inferred, noisy, or very heterogeneous, it is essential to use the fully-weighted clustering definitions.

The clustering coefficient (CC) was originally introduced for binary undirected networks to quantify strong connectedness within a local neighborhood. It was defined as the fraction of all possible triangles that were realized i.e. the ratio between all triangles to which node i participates (n ∆,i ) and the total number of triangles that could theoretically be made given its degree d i , which is the number of triplets (n T,i ): From a neighbor-centric perspective, it can be seen perhaps more intuitively as the probability that two neigh-arXiv:2105.06318v2 [cs.SI] 29 Aug 2021 bors of a node are connected. However, as network science expanded, more and more graphs were encountered, where directedness and edge weights play a central role.
Generalizations of the clustering coefficient were therefore introduced to account for asymmetry in the connections between pairs of nodes or heterogeneity in their strength.
The importance of clustering, including its directed variants, to understand complex dynamics on networks has been stressed in multiple studies [1][2][3][4]. This is notably the case for the middleman motif which is a marker of feedforward loops in transcriptional networks, and of information transfer redundancy e.g. in neuroscience. More generally, such motifs will influence the evolution of dynamical processes on the networks, for instance synchronization patterns, and have been shown to characterize families of networks such as transcription or language networks [2]. Finally, clustering is used in other measurements to access the small-world propensity of networks [5] and the choice of a specific definition can therefore influence whether the network of interest will register as small-world or not.
In many applications network topology and weights are measured only up to certain precision [6,7]. For example, in neuroscience, the functional connectivity networks measured using the indirect inference of connections from the recorded activity [8,9]. Accepting the inevitability of noise in a network brings forward new requirements on the network measures, namely that they are stable to the noise and do not change dramatically if the weights are perturbed or weak connections are randomly omitted.
There is no agreement among the researchers which weighted extension of the clustering coefficient definition is most appropriate. The three predominantly used methods at the moment [10][11][12] differ in many properties of their definitions. Part of the reason for the absence of a single best weighted clustering lies in a different interpretation of weights in various datasets. Consequently, a different weighted extension might be most appropriate for various data and specific scientific questions. However, to understand which method to use when and why we need to understand their differences precisely.
The difficulty of extending graph measures to weighted networks is not specific to the clustering coefficient but can occur whenever ratios of degrees or path-length are involved. We will therefore also discuss a second clustering-related measure, called the closure coefficient and introduced as the fraction of all open walks of length 2 starting from node i that are part of a triangle [13]. This will also enable us to discuss the complementarity of closure and clustering as the former provides an important complement to analyze the tendency of nodes to form 3 and 4-cliques.
We introduce here a distinction between fully-weighted and hybrid definitions and discuss why, for several classes of networks, fully-weighted and directed definitions should be preferred to other clustering definitions that are currently used for network analysis. We also propose a new definition that obeys additional conditions, including continuity of the results with respect to infinitesimal changes in edge weights, which has significant consequences for the resilience to noise in inferred networks. We demonstrate why fully-weighted methods are essential for measured and inferred networks, that are pervasive in biological fields such as neuroscience, and for networks dealing with flows of information, money, or goods that display a very broad weight distribution.

II. INTERPRETATION AND PURPOSE OF WEIGHTED CLUSTERING
A. Desired properties of weighted clustering coefficients Weighted measures are crucial for many network types where the binary connectivity is either uninformative (fully connected network) or displays similar or lower heterogeneity compared to the weighted structure. In this study, we focus on two classes of real-world networks: inferred or measured networks where there can be a large number of spurious (false positive) edges with small weights; and networks associated with flows of information or goods, which often display broad weight distributions. This is notably the case for many networks in neuroscience, and more generally in information, transportation, or other social and economic networks. Weights are essential to understand the dynamical processes that occur in these networks, requiring measures that go beyond the binary structure.
There could be multiple requirements for weighted clustering coefficients [14] depending on the particular question of interest and on the network properties. The main requirements that we considered necessary for a weighted clustering coefficient are: • consistency with the binary definition (for binary networks, it should give back the classical result), • linearity (scaling by α all edges involving node i and all edges in triangles including node i scales C i by α), • continuity (weak influence of the addition or deletion of edges having very small weights, meaning that an edge with infinitesimally small weight should be equivalent to the absence of that edge).
Compared to a previously proposed list of conditions [14], we added a continuity condition but did not include a requirement of a specific normalization factor (the global max(w)) as long as the normalization condition is fulfilled since only the normalization matters. We omitted the last two conditions of Saramäki's paper (invariance under weight permutation and ignorance of weights not participating in any triangle). Although they might be of interest for some specific applications, we do not consider them to be generally desired properties for a clustering coefficient. We also did not require that all weights in a triangle should be accounted for because this condition is necessarily met if the continuity condition is fulfilled.
Continuity can be expressed mathematically as follow: for a graph G(V, E), if a weighted edge (u, v, w) with u, v ∈ V and weight w ∈ R is added to this graph to form a new graph G (V, E ), with E = E + {(u, v, w)}, then the clustering measure is continuous if and only if . This condition in crucial to ensure a reasonable behavior of the clustering coefficient in inferred networks.
Though some definitions of previously proposed weighted clustering coefficient definitions obey most of the required properties, none of them completely fulfill the continuity condition -despite previous claims [15]. This is why we will later propose a new definition that fulfills all aforementioned conditions. An extensive comparison of the properties fulfilled by different clustering definitions can be found in Appendix B.

B. State of the art for weighted clustering
First we introduce and classify the existing weighted clustering coefficient definition. For all clustering definitions in the main text, we use the following notation: A is an adjacency matrix, W = {w ij } is the normalized weight matrix, obtained from the original weight matrix Hybrid definitions were the first extensions of the binary clustering coefficients definitions. They combine properties associated with weighted connectivity matrix (i.e. intensity of the triangle) with properties that could be already obtained from adjacency matrix (i.e. node degrees). These definitions move from an integer counting the number of triangles (n ∆ ) to a sum of real numbers (computed as a function of edge weights) that we call "intensities" of triangles (I ∆ ). The choice of a particular function for the intensity of the triangles determines the properties of the clustering coefficient.
Two popular hybrid weighted clustering were given by the teams of Barrat [10] and Onnela [11].
For a node i in a graph, the definition from [10] quantifies the fraction of the node's strength that is invested in triangles (see Appendix C 1 for more details): where s i = j =i w ij is the strength of the node, w i is the average weight of the edges involving i, and w ∆ i = j =k wij +w ik 2n∆,i a ij a ik a jk is the average weight of edges involving i that are part of a triangle computed over all triangles to which node i participates. In terms of triangle intensity, this definition was originally written: thus defining the intensity of triangle ∆ ijk as I B ∆ijk = wij +w ik 2wi a ij a ik a jk as the function of two of the triangle's weights and the average weight of the edges connected to node i, w i . Proposed a bit later Onnela's definition [11] scales the binary clustering by the average intensity of the triangles (see Appendix C 2 for more details): with the triangle intensity defined as I O ∆ijk = (w ij w ik w jk ) 1/3 and the average intensity taken over all triangles to which i participates.
For all hybrid methods the denominator relies on the node's degree, meaning that the addition or deletion of edges will always significantly affect the clustering coefficient even if the edge has an infinitely small weight. Such methods can thus lead to inaccurate results when applied to the inferred networks, where a significant fraction of edges are false positives with small weights. In the following we will also demonstrate that they cannot reliably detect the most strongly clustered nodes in structured networks. Only fully-weighted definitions can rise up to these challenges.
Fully-weighted definitions are variants of the clustering coefficient that do not include any binary measures (anything that can be derived from the adjacency matrix alone, e.g. degrees). In addition to substituting the number of triangles by the sum of triangle intensities, they also move away from counting triplets -defining the maximum number of possible triangles max(n ∆,i ) = n T,i = d i (d i − 1). Instead, they introduce the triplet intensity (I T ) such that, for a node i, I T,i is as a real-valued function of the weights associated to i.
One of the first fully-weighted definition for the clustering coefficient was provided by Zhang and Horvath [12] to analyze gene co-expression networks: Note, that the fact that the definition can be expressed as a function of the binary clustering does not contradict the fully-weighted nature of the measure, as it stems from a simple recombination of the terms. This definition can be interpreted as the ratio of the summed intensities I Z ∆ijk = w ij w ik w jk of the triangles ∆ ijk = (i, j, k) to the maximal possible summed intensities I Z(max) ∆ijk = I Z T ijk = w ij w ik if all existing triplets T ijk were closed by an edge of weight 1 (the maximal possible weight in the normalized network). This way, if i is involved in a single triangle, the clustering coefficient is equal to the weight of the edge closing the triplet centered on i (see also Table I).
Though this definition does not fulfill the continuity property, we will show that it still provides a consistent interpretation of weighted clustering, as discussed in [16], and is well suited to tackle networks with a large fraction of false positives.
Other fully-weighted definitions that were proposed and discussed since [15,17,18] do not bring significant additions compared to Zhang-Hovart's definition while actually losing some of its properties and its straightforward interpretation. They are not considered further in this study -see Appendix A for further explanations. For an undirected graph G, we define the new continuous clustering of node i as: We define the weighted intensity of triangles and triplets, respectively I ∆ijk = 3 √ w ij w jk w ik and I T ijk = √ w ji w ik , using the geometric mean of the weights involved. Thank to this, one strong weight in a triangle or triplet cannot compensate the presence of smaller weights, contrary to what may happen if one uses the arithmetic mean. This provides the desired property that the intensity of triangles and triplets will go to zero if even a single edge weight goes to zero. Note that, though the triangle intensity is defined as the geometric mean of the three weights involved, it is the square of this intensity that is used in the definition. The reason for this choice is twofold: to assign higher influence to large triangles and to ensure the linearity of the coefficient. Importantly, this definition of the triangle intensity I ∆ assigns the same role to all participating edges. The new clustering could be interpreted as the ratio of the triangle intensity that is invested in strong triangles (given by the sum of the squared intensities of triangles, which increases the importance of strong triangles) to the triplet intensity, which would represent the maximum possible triangle intensity if all weights connecting adjacent nodes were equal to one.
The new continuous definition fulfils all the conditions we put forward above, and to he best of our knowledge it is the only one to do so. Similarly to previous definitions, the new clustering coefficient can also be rewritten in terms of node properties: where , the fractional weight matrix and strength for any α ∈ R.
Same as for the previous definitions, the continuous clustering can be interpreted as a function of intensities and the binary clustering: with means I ∆ijk and I T ijk and variance taken over all the triangles or triplets the node i participate in respectively. In the limit where all triangles associated to node i have similar intensities, we can neglect the variance term, i . In this case, contrary to the Zhang-Horvath definition (Eq. 5) the absolute value of the intensity matters, not only its ratio to the maximum possible intensity. For a given average triangle intensity, the positive contribution of the variance implies that nodes with more variable intensities, i.e. at least one triangle with a high intensity, will have higher clustering coefficients than nodes with identical triangles of average-intensity.
Finally, the global clustering can also be defined in a straightforward fashion. For simplicity, we define I ∆,i = j =k I 2 ∆ijk and I T,i = j =k I T ijk , leading to C i = I ∆,i /I T,i . Using this definition, the continuous global clustering is obtained via the formula: D. Directed weighted clustering Fagiolo [19] proposed how to generalize clustering to Table II. Definitions of the continuous intensities for each partial mode pattern in directed graph. Column 1: pattern names; column 2: patterns illustration; column 3: number of triangles for node i; column 4: number of triplets for node i; column 5: continuous intensities of the triangles for node i; column 6: continuous intensities of triplets for node i. The clustering coefficients associated to each mode m are given by C   Table II) that can exist in these networks, and adapted Onnela's definition [11] as the first weighted directed clustering coefficient. Barrat's definition [10] was generalized to directed graphs in [20] following the same distinction into Fagiolo's cycle, middleman, fan-in, and fan-out motifs.
Similarly, the Zhang-Horvath [12] and continuous definitions can be generalized in a straightforward manner for directed networks. For it, we only need to redefine the intensities of each directed triangle and triplet motif as shown in Table II for the continuous definition and in Table VII for Zhang-Horvath. This simply requires replacing A by W in all expressions of n (m) ∆,i and a by w in all expressions of n (m) T,i . As the total directed clustering is defined as the sum of all modes, we can write it as: Finally, the continuous clustering can be extended for each directed mode (see Table II) and, for the total directed clustering, this leads to: As for the undirected case, the global clustering coefficient associated to each directed pattern can be obtained via the formula: C

III. THE ADVANTAGES OF FULLY-WEIGHTED DEFINITIONS
In this section we discuss the sensitivity to the weightencoded topological features and stability to noise in network measurements of the different clustering methods. A previous study [14] already noted the fact that previous definitions did not fulfill the continuity condition by analyzing the behavior of the different coefficients for nodes that participate to a single-triangle. Table I illustrates some of these cases and shows that the new continuous definition is the only one to behave as expected.
Yet, we note that the definition of Zhang and Horvath is also very resilient to noise because, except for the corner-cases associated to single triangles, its behavior is continuous in all other situations. Moreover, contrary to what was asserted in [14], it provides a perfectly sensible behavior given its interpretation of clustering as the ratio of the triangle intensity I Z ∆ijk = w ij w ik w jk to its maximum possible intensity given the weights of node i: I Because the definitions from Barrat's and Onnela's [10,11] teams are the most well-known and (to the best of our knowledge) the only methods implemented in popular graph libraries, we restrict our comparison to Zhang-Horvath's and these two definitions. A more comprehensive discussion of other definitions of the weighted clustering coefficient can be found in Appendix A. A. Sensitivity to weight-encoded topological features Here we investigate how weighted structures can be detected ore missed using different clustering definitions. As an example we consider a weighted core-periphery graph, Figure 1. There, core nodes are characterized by both a dense binary connectivity and large weights, whereas periphery nodes display both sparser connectivity (though they still have large degrees) and weaker weights, for more details in the see Appendix E 1. We generate 10 realizations of the network and consider distribution of clustering coefficients of different types of nodes. Continuous definition leads to distinct clustering of different type of nodes, making the true structure of the network clearly visible already in the clustering distributions. Because of their hybrid nature, Barrat's and Onnela's definitions cannot capture this underlying structure as it is mostly encoded in the weights and not at all in the degrees (core nodes are not binary hubs). Though it is purely weighted, the Zhang-Horvath definition is also not suited to detect this type of weighted structure because its interpretation of a node's clustering only accounts for the relative triangle intensity given the node's weights.
The continuous clustering is sensitive to any topological property that is encoded via specific weight distri-butions. Furthermore, contrary to the Zhang-Horvath definition, it accounts not only for the ratio of the triangle intensity over the triplet intensity (how strong are the triangles compared the maximum possible value given the node's weights) but also for the absolute value of the intensity: a weak triangle, even if it corresponds to the highest possible value given the node's weights, will decrease the node's clustering in the continuous definition whereas it increases it with the Zhang-Horvath method. In that sense, the continuous clustering provides a more global evaluation of the clustering coefficient compared to Zhang-Horvath that provides a more local information.
The definition from Barrat et al. has several limitations because it is close to being weight-insensitive [11,21]. It is particularly unsuitable for assessing networks with a potentially large number of low-weight spurious connections or very heterogeneous weight distributions. For this reason, we will mostly leave this clustering aside in the rest of this study.

B. Continuity and resilience to noise
Stability of a network measure to noise is of a particular importance for networks that are obtained via experimental measurements since these are often subject to noise and statistical biases, notably for inferred net-   Table I, here we demonstrate that they are not just corner cases, but occur in larger, realworld networks.
We illustrate the impact of spurious edges on measured clustering coefficients using the example of Watts-Strogatz small-world networks. We consider different topologies for the subnetwork formed by the spurious edges: either an Erdős-Renyi random network (Figure 2 A.), associated to uncorrelated noise, or a scalefree network (Figure 2 B.), which would correlate noise with certain nodes in the network. Additionally, weights on the spurious edges could be much smaller than the weight of the actual edges (Figure 2 C.) or have an overlapping distribution (Figure 2 D.). Both fully-weighted methods are unaffected by low-noise (conditions A+C and B+C) and are also less influenced by the spurious edges when they weights are large enough to overlap with the real weight distribution (conditions A+D and B+D). On other hand, because hybrid methods explicitly depend on the nodes' degrees, they are very susceptible to the presence of spurious edges - Figure 2 G, H.
The difference in behavior between the methods can be easily explained by a first-order expansion. We consider change in the clustering coefficient of a node i with degree d i after addition of a spurious edge e = (i, v) with weight 1. For Barrat's and Onnela's methods, the new clustering coefficient becomes: meaning that, for both methods, the coefficients will deviate from the original clustering C O/B i by a noninfinitesimal value, even when the perturbation was infinitesimal -see Appendix C for complete derivation.
On the other hand, the continuous clustering becomes showing only an infinitesimal deviation to the similarly infinitesimal perturbation. Similarly, except for the single-triangle cases discussed in I, the Zhang-Horvath clustering becomes It is worth noting that one continuity issue, associated to nodes participating in only one triangle, occurs for all definitions but the continuous one. Since this situation is pervasive in networks with low degree or binary clustering, using the continuous clustering definition can be of particular importance in such cases -see Appendix F 4.

A. Mouse mesoscale connectome
In neuroscience, the networks on different scales give a vital piece of information to understand the brain better. Unsurprisingly, connectomics, the mapping of the connections in the nervous system, gained significant attention and developed dramatically over the last years. Most of the networks in neuroscience are weighted, with all obtained connectivities are either measured or inferred, making them a typical example for the challenges discussed above. The mouse mesoscale connectome [22] is a fascinating example of such networks, both because it provides information about the entire mouse brain and because it contains an evaluation of the probability of false positives for all connections.
Here, we investigate how the choice of the clustering coefficient definition can alter the results. The network is very inhomogeneous, with broadly varying degrees, Figure 3 A. The edges in the mesoscale connectome are assigned p-values that quantify their probability to correspond to real physical connection (p denotes the probability of the connection to be a spurious edge). They have therefore different significance levels, with only 13% of all edges having p-values smaller than 0.01, i.e. only 13% of all edges have a probability to be spurious that is lower than 1%. We consider a thresholding procedure, where at each level of the threshold (p max ), only the edges with smaller p-values are kept. This procedure can be seen as an attempt to remove spurious edges, though no correct threshold level is known. Compared to the hybrid method, both fully-weighted definitions are much less sensitive to thresholding, Figure 3 B, C. Thus we see that the resilience to noise we showed analytically and on toy networks is relevant for a real-world network. Furthermore, the resilience is not limited to the general shape of the distribution but indeed preserves the precise values and ranks: a larger fraction of the nodes displaying high clustering in the full graph are still among the highest ranking nodes in the thresholded graphs when fully-weighted method's are used compared to the hybrid method, Figure 3 E.
Clustering coefficient is a network measure that captures features beyond purely local parameters, such as degree or strength. However, as we see for the mouse connectome, the hybrid method strongly correlates with the average weight associated with a node i: s i /d i . At the same time, the fully-weighted definitions are much less correlated with it, Figure 3 D. As a result, they can bring more independent information regarding weighted network structure than the hybrid method. This trend is even stronger for the Zhang-Horvath definition, which does not account for the absolute intensity of triangles. In contrast, the continuous definition provides some intermediate behavior as the intensity of triangles often correlates, if only in part, with the average weight associated with the node.
Finally, though the continuous and Zhang-Horvath definition often provide somewhat similar results, they may differ significantly, e.g. for cerebellar cortex on Figure 3 F. Combining the results of both methods can thus be informative, for example to single out nodes that possess only weak connections (and will therefore register as weakly clustered for the continuous definition) yet connect to other nodes that are strongly connected (thus registering as strongly clustered for Zhang-Horvath).

B. Decentralized social media: the Fediverse
The Fediverse is a set of federated social media that can communicate via a collection of common protocols, the most well-known being ActivityPub. This network can be seen as a set of alternatives to corporate platforms such as Facebook or Twitter. Social media on the Fediverse usually promote ideas of decentralization, interoperability, free/libre and open-source software (FLOSS), and the absence of algorithmic filters in favor of human curation and moderation.
We analyze here a snapshot of this network that was obtained in 2018 by Zignani et al. For each instance I 1 , an edge towards another instance I 2 means that at least one user on I 1 follows at least one member of I 2 . The precise value of the weight associated to this edge gives the fraction of all followers from the source instance that are associated to members of the target instance. The weights are thus a proxy to characterize the fraction of the community's attention that is associated to content produced by another community; this means of course that, for each node, it's outgoing strength s o is equal to one. Note that in this network, information flow occurs in the direction opposite to that of the edge, because the directed edge denotes that the source is paying attention to what the target posts.
The network snapshot contains 3,825 nodes corresponding mostly to instances running Mastodon, one of the most prominent microblogging platforms on the Fediverse. These 3,825 nodes represent more than half of the entire network and are connected via 81,371 edges. Chord diagram of connections between locations shows The network displays strong structural clustering, most nodes with non-zero in-and out-degrees displaying binary clustering values close two one, whereas the expected value for an Erdős-Renyi network with the same number of edges would be almost zero (dotted line). E. The median values of the fan-out clustering for different instance sizes show that the strong heterogeneity of the network can have a notable influence for the Onnela method (yellow) whereas Zhang-Horvath (dark brown) and continuous methods (orange) display much weaker correlation with the size of the instance. F. The fan-in motifs have intensities that are several orders of magnitude lower than fan-out and display weaker dependency on the instance size. The binary (gray) clustering coefficient misses the difference between fan-out and fan-in, which predominantly relies on the weights' effect.
that, besides the fact that the position of most instances is unspecified (UNS), the largest hosting countries are Japan, the USA, and France, with Japanese and French communities interacting mostly among themselves, Figure 4 A, B. The network is both very sparse and strongly heterogeneous, with a median degree of 5 but node degrees and sizes varying over 3 to 5 orders of magnitude. This broad distribution has notable implications for different clustering definitions. For the Zhang-Horvath, it increases the likelihood of running into the corner-cases of single triangles, increasing the average clustering compared to the other methods. For Onnela's definition, it strongly correlates clustering values to the degree (and thus to the size) of the instance.
As for the mouse network, all weighted methods lead to results that differ strongly from the binary clustering, Figure 4 (D and E). Some of the results from the hybrid method tends to correlate strongly with some 1st order properties of the nodes (Figure 4 E) while the fullyweighted methods bring more independent information. The Fediverse network displays a peculiar feature as its fan-out and fan-in clustering differ significantly despite the usual correlation between these two patterns, as can be seen from the comparison of Figure 4 E and F.

C. Using local clustering to infer dynamical properties
Analysis of clustering coefficient for different structured patterns offer a way to obtain a precise idea of the critical dynamical patterns within a network. To determine the significance of a particular pattern we compare its prominence in the original network with it in a nullmodel networks obtained via appropriate randomization. For the mouse brain, as a randomized control, we take the original network and only shuffle the weights, thus preserving the weights distribution and binary structure. Comparing the actual values in the original graphs to that of randomized graphs, we can see the importance of looking at fully-weighted measures.
Both Zhang-Horvath and continuous definitions identify the preference of the mouse brain network for redundant information flows, whereas the hybrid method of Onnela does not capture this feature. Redundant information transfer in the brain is indeed associated to situations where a signal can be transferred not only directly from one node to another, but also indirectly via a third (middleman) node, as can be seen in middleman, fan-in and fan-out patters (cf . Table II). This overexpression of Figure 5. Different structures of clustering patterns and information flow in the mouse brain and the Fediverse. The original clustering values are compared to graphs with the same adjacency matrix but shuffled edge weights (mouse, 10 uniformly shuffled networks; Fediverse, 200 graphs shuffled across all out-going edges of each node to preserve out-strength normalization). The contours show different density levels of the point clouds associated to the original/shuffled pairs of clustering coefficients. A. The Zhang-Horvath and continuous definitions capture the redundancy of information flow in the mouse brain (middleman and fan-in/fan-out motifs are higher in the original graph). However, the Onnela method does not capture this feature. B. For the Fediverse, only fan-out and middleman motifs are significantly stronger than in the random graphs. Patterns where the original values are significantly greater (resp. smaller) than the randomized ones are marked by the + (resp. −) and the initial of the method (brown, Z for Zhang; orange, C for continuous; yellow, O for Onnela). The original clustering is considered to be significantly higher (resp. lower) if 75% of the points where above (resp. below) the dotted identity line. Additional * denotes one-sided fractions greater than 95%. redudant patterns is visible, for the fully-weighted methods, in the high values of middleman and fan-in/fan-out motifs in Figure 5 A.
The situation for the Fediverse is significantly more complex. Indeed, 98 % of all edges belong to at least one triangle, some are involved in up to thousands of triangles. A deeper understanding of the clustering requires precisely investigation of how the weight distribution correlates with specific patterns of triangles. For instance, though fan-in and fan-out patterns co-occur and are thus usually correlated, the Fediverse displays an unexpected discrepancy between the weight associated to both patterns, as seen on Figure 5 B, which notably differentiates it from the mouse connectome (see also Appendix F 3).

V. DISCUSSION
In this work, we introduced new directed weighted definitions for clustering analysis. Using analytic derivations, generated networks models and real data, we showed that the behavior of fully-weighted measures displayed enhanced sensitivity, selectivity, and robustness compared to hybrid measures. To facilitate access to these measures, all clustering methods were implemented in Python and made compatible with the three main libraries in this language (networkx, igraph, and graph-tool) [24].
We highlighted the importance of continuity as a crucial notion for networks with highly heterogeneous weight distribution or numerous spurious edges with low weights. In the previous studies, slight variations on this notion had been introduced mathematically [15] and hinted at by the study of corner cases [14]. However, the continuity property was inadvertently considered only in particular classes of networks [15] (disregarding, for example, small degree cases), erroneously marking previous methods as continuous. The other study [14] asserted discontinuity of previous measures simply as a feature, without discussing its implications or ways to avoid it. Our new proposal of fully continuous clustering methods based on simple mathematical principles and requirements is, therefore, the first to fully solve the issue of continuity. In addition, we show in Appendix D that these principles can be extended to other measures such as the local closure.
We discussed how each weighted definition is associated to a specific interpretation of weighted clustering as a function of the binary clustering, triangle, and triplet intensities (see Appendix B and Table VI for a summary). In turns, these interpretations are associated to specific properties for each clustering coefficient. Combining mathematical analysis and concrete examples, we asserted that fully-weighted measures out-perform hybrid ones to evaluate clustering in networks with large numbers of spurious edges with small weights. We expanded the results from previous studies comparing existing weighted definitions [14][15][16]21], extending their definition to directed networks and providing complete mathematical justifications to previous observations regarding linearity and continuity.
Our analyses show that either of the fully weighted definitions may be preferred depending on the network properties. For networks with large degrees, the Zhang-Horvath definition may be preferred if the number of lowweight spurious edges is very high as it is least susceptible to noise. In networks with heterogeneous weight distributions where the absolute value of triangle strength is of interest, we showed that the continuous definition provides more relevant results than that of Zhang and Horvath. Indeed, in networks involving fluxes of good or matter as well as for information processing (e.g. in brain or telecommunication networks), one may be interested in the absolute amount that can be transferred between nodes, making nodes with small weights of little relevance. A similar issue occurs for networks where many nodes participate to a single triangle (see Appendix F 4) making the Zhang-Horvath clustering non-continuous. In such networks, the use of the Zhang-Horvath definition is likely to assign high clustering to single-triangle nodes with low-weights, whereas the continuous definition will not, as was shown on Figure 1.
Finally, we illustrate the usefulness of weighted clustering methods to investigate clustering on the example of a connectome and a decentralized social network. The fully-weighted methods were especially suitable to reveal key differences in their weighted structural properties. Indeed, we showed that middleman, fan-in, and fan-out patterns, characteristic of pathways enabling redundant information transfer between nodes, were overexpressed in the mouse brain. In the Fediverse, the methods revealed an unexpected discrepancy between fan-in and fan-out modes, probably associated with social interaction patterns that would mandate further investigation.
The authors define a multitude of generalized clustering coefficients based on the use of an arbitrary function h : R 2 → R such that: More specifically, Wang et al. [15] argue in favor of the use of a specific version using the harmonic mean: However, this definition suffers from three major shortcomings: • despite what is asserted by the authors, it does not fulfill the continuity condition; • it is not locally linear, meaning that two nodes that have the same neighborhood but with all weights differing by a factor λ will not have the ratio of their clustering coefficients equal to λ; • it introduces an undesired asymmetry in the definition of the triangle intensity: for a given triangle ∆ ijk , the computed intensity will be different for each node as it depends on which one is considered as i. Multiple properties of the main definitions for the clustering coefficient are listed in Table IV. These properties depend on the definitions of triangle and triplet intensity that are recapitulated in Table V. X X For a triangle ∆ = (i, j, k), I∆ = IT f (w jk ) X Continuous X Table IV. Comparison of the different properties of the different clustering coefficients. Zhang-Horvath and the continuous definitions fulfill the maximum number of desirable properties. An X means that the method possesses this property.
Definition Upon addition to a graph G(N, E) of an edge (i, v) of weight , giving G (N, E = E +{(i, v)}, one can compute the evolution of the initial clustering coefficient C B i to its new value C B i by rewriting the definition from [10] as in [14]: From this, we can deduce the following relationship between Barrat's definition and the binary clustering coefficient C bin i : with n ∆,i the number of triangles to which node i participates and w ∆ i the average weight associated to edges connected to i and participating in a triangle.
Notice that this expression also explains why the definition from Barrat is so close to the binary clustering: for networks where weights are either rather homogeneous or where they are not strongly correlated to triangles, w ∆ i and w i become very close as the number of triangles per node increases.
Using equation C2, the new clustering can be defined as:

Onnela
As for the other definitions, the clustering from [11] can be defined as a function of the binary clustering: From this, one can define the evolution upon addition of an edge (i, v) of weight as:

Directed versions of the clustering coefficients
To generalize the Zhang-Horvath definition of clustering [12] for directed graphs we use the same approach as proposed in Fagiolo [19]. These definitions are visible in Table VII together with the directed definitions associated to Barrat [10] and Onnela [11], respectively defined in [20] and [19]. and a "distance" (corresponding to the Euclidean distance from the source to the target node).  Edge count Figure 6. Distribution of in/out-degrees (respectively in orange/yellow) and weights in the mouse connectome.

Fediverse mesoscale network
The network was obtained from [23] 2 . It contains 3,825 nodes representing servers (instances) that are connected via 81,371 edges. Each node is associated two attributes: a "name", corresponding to the server domain, and a "size", S i , corresponding to the number of users registered on that server. Edges are associated four attributes: "num follows", defined a F ij , the number of followers from i to j, "follow/size" defined as F ij /S i , a "weight" given by w ij = F ij /F i , the ratio between the number of followers from i to j divided by the total number of followers from i, and a "distance" giving the Euclidean distance between the two servers on the latitude/longitude plane.   Edge count Figure 7. Distribution of in/out-degrees (respectively in orange/yellow) and weights in the Fediverse instances.

Closure in the shuffled networks
The results obtained for the local closure confirm those obtained using the clustering coefficient for the mouse brain and Fediverse networks, as show on Figure 8. Namely, we see an overexpression of fan-in and fan-out patterns for the mouse and a discrepancy between those two patterns for the Fediverse.

Networks with a high number of single-node triangles
The presence of nodes participating to a single triangle is frequently in very sparse networks such as collaboration or gene/protein interaction networks.
Table X details several such networks: NetScience: co-authorship in the network science community 3 CompGeo: collaborations in computational geometry 4 CE-CX: a graph of gene associations inferred from coexpression pattern of two genes (based on highdimensional gene expression data) for C. elegans CE-HT: gene associations inferred from highthroughput protein-protein interactions for C. elegans HS-HT: gene associations inferred from highthroughput protein-protein interactions for Homo sapiens SC-HT: gene associations inferred from highthroughput protein-protein interactions for S. cerevisiae Gene functional association networks [28] were downloaded from https://networkrepository.com/bio.php.  Table X. Number of nodes (N), edges (E), and fraction of single-triangle (1-T) nodes in several collaboration and gene association networks. Figure 8. Different structures of local closure in the mouse brain and Fediverse. The panels compare the local closure of directed patterns for the mouse brain (A) and Fediverse (B). The original values are compared to the averages over an ensemble of graphs with the same adjacency matrix but shuffled edge weights. For mouse: 10 uniformly shuffled networks, for Fediverse: 200 shuffling across all out-going edges of a each node (to preserve out-strength normalization). A. The local closure also shows an increase for patterns promoting redundancy of information flow in the mouse brain (fan-in/fan-out motifs are higher in the original graph). B. For the Fediverse, only fan-out is significantly stronger than in the random graphs. Patters where the original values are significantly greater (smaller) than the randomized ones are marked by the + (resp. −) and initial of the method (brown, Z for Zhang; orange, C for continuous; yellow, O for Onnela). The original closure is considered to be significantly higher (resp. lower) if 75% of the points where above (resp. below) the dotted identity line. Additional * denotes one-sided fractions greater than 95%.