Percolation-Based Detection of Anomalous Subgraphs in Complex Networks

. The ability to detect an unusual concentration of extreme observations in a connected region of a graph is fundamental in a number of use cases, ranging from traﬃc accident detection in road networks to intrusion detection in computer networks. This task is usually performed using scan statistics-based methods, which require explicitly ﬁnding the most anomalous subgraph and thus are computationally intensive. We propose a more scalable method in the case where the observations are assigned to the edges of a large-scale network. The rationale behind our work is that if an anomalous cluster exists in the graph, then the subgraph induced by the most individually anomalous edges should contain an unexpectedly large connected component. We therefore refor-mulate our problem as the detection of anomalous sample paths of a percolation process on the graph, and our contribution can be seen as a generalization of previous work on percolation-based cluster detection. We evaluate our method through extensive simulations.


Introduction
Detection of a significant connected subgraph in a larger background network is a ubiquitous task: such significant regions can be indicative of fraudulent behavior in social networks [15] or of the propagation of an intruder in a computer network [22], for instance. Therefore, being able to discern them from ambient noise has valuable applications in a number of settings. This anomaly detection problem is, however, remarkably challenging: the large size and complex structure of real-world graphs make the characterization of normal behavior difficult and the search for non-trivial substructures computationally expensive.
The aim of this paper is to propose a scalable method for anomalous connected subgraph detection in a graph with observations attached to its edges. The null distribution of the observations, or an approximation thereof, is assumed to be known. Building upon this knowledge, the degree of abnormality of each individual edge with respect to the model can be measured, and our goal is to detect a significant concentration of anomalous edges in a connected region of the graph. Usual methods for this task are built around scan statistics [14]. Such methods boil down to maximizing a scoring function over the set of connected regions of the graph, then rejecting the null hypothesis (i.e. absence of anomalous subgraph) if the maximum exceeds a certain threshold. This implies solving a combinatorial optimization problem over the class of all connected subgraphs, which is expensive due to the exponentially growing size of the latter.
In contrast, our approach does not require explicitly searching for the best candidate subgraph. Instead, we build on the following idea: under the null hypothesis, the most individually anomalous edges are randomly spread out over the graph. Therefore, removing all but the k most anomalous edges from the graph is equivalent to drawing k edges uniformly at random and extracting the subgraph induced by these edges. In other words, this procedure amounts to bond percolation on a graph. On the other hand, when an anomalous subgraph is present, the location of the individual anomalies is no longer random, and thus the largest connected component of the subgraph induced by the k most anomalous edges should contain an unexpectedly large connected component. This link between anomalous subgraph detection and percolation theory has already been introduced in the context of regular lattices [6,19,20], but to the best of our knowledge, it has not yet been studied for arbitrary graphs.
We argue that our method is more scalable than traditional ones while retaining an acceptable detection power, especially when seeking to detect small anomalous regions in large graphs. We assess this detection performance through numerical experiments on several realistic synthetic graphs.
The rest of this paper is structured as follows. In Sect. 2, we introduce the statistical framework for our problem and present some related work. Section 3 describes our detection method, while Sect. 4 is devoted to its empirical evaluation on simulated data. Finally, we discuss our results and some interesting leads for future work in Sect. 5, then briefly conclude in Sect. 6.

Problem Formulation and Related Work
We begin with a thorough formulation of our problem as a case of statistical hypothesis testing, then review the main existing approaches to it.

Problem Formulation -Statistical Hypothesis Testing
Consider an undirected and connected graph G = (V, E), where V (resp. E) is the set of vertices (resp. edges) of G. Letting |A| denote the number of elements of a set A, we write m = |E|, and we use E and [m] = {1, . . . , m} interchangeably to represent the set of edges. We further write 2 A for the set of all subsets of A and 1{·} for the indicator function of an event.
Let Λ ⊂ 2 E denote the class of subsets of E whose induced subgraph in G is connected. Given a signal X = (X 1 , . . . , X m ) ∈ R m observed on the edges of G and a known probability distribution F 0 , the null hypothesis is defined as For each S ∈ Λ, we further define the alternative where X |S is the restriction of X to S and F S is a joint probability distribution. F S is only assumed to be different from F ⊗|S| 0 , and it can differ in various ways. In many applications, the observations in S are simply larger than expected (consider for instance network intrusion detection, where the presence of an intruder results in additional activity in a connected region of the network). The problem considered in this paper can be formulated as That is, we want to know whether there exists a connected subgraph of G inside of which the observations X i are drawn from an alternative distribution. Note that we only care about detection, leaving the reconstruction of S aside.

Related Work -Scan Statistics and Beyond
A lot of existing work deals with a specific instance of the problem defined above, namely elevated mean detection on a graph. In this setting, the observations are independent standard centered normal random variables under the null, while X i has mean μ S 1{i ∈ S} under the alternative H S (for some μ S > 0). Theoretical conditions for detectability in this case are stated in [1]. A closely related problem arises when the observations are associated with vertices rather than edges, and this setting was studied in [3][4][5]. However, these papers focus on statistical analysis and do not provide computationally tractable tests.
From a more practical perspective, the most common approach to anomalous subgraph detection is based on scan statistics. Broadly speaking, this method consists in defining a scoring function f : 2 E → R, computing the test statistic t = max S∈Λ f (S), then rejecting H 0 if t exceeds a given threshold. This amounts to finding the most anomalous subset S * in Λ, and then rejecting the null hypothesis if S * is anomalous enough. Defining f requires some hypotheses on the class of alternative distributions {F S }. For instance, when F S has a parametric form, f (S) can be defined as the likelihood ratio between H S and H 0 . In the more general case considered here, however, finding a suitable scoring function is non-trivial. Moreover, computing t implies maximizing f over the combinatorial class Λ, which quickly becomes computationally intensive as the graph grows. Therefore, most related work focuses on making the computation of scan statistics more efficient. Ways to achieve this include the following: Restriction of the Class Λ. The easiest way to speed up the computation is to simply reduce the size of the search space by considering only a subset of Λ. Such restriction can be based on domain-specific knowledge [17,18,22,25] or more general heuristics [24].

Convex Relaxation.
Another classical approach to combinatorial optimization consists in solving a convex relaxation of the problem, and then projecting the solution back onto the original search space. This method was applied to scan statistics [2,26,27], using elements of spectral graph theory [9] to find a relaxed form of the connectivity constraint. Similar ideas were also used in a slightly different context [29][30][31], where the class Λ consists of subgraphs with low cut size rather than connected ones. Algorithmic Approaches. Finally, efficient optimization algorithms have been used to find exact or approximate values for the scan statistic, including simulated annealing [11,12], greedy algorithms [28], primal-dual algorithms [28], branch and bound algorithms [32] and dynamic programming algorithms [33].
Despite the popularity of scan statistics, other ideas have also been considered in the literature. We focus on one of these alternative approaches, namely the Largest Open Cluster (LOC) test, which was first studied in the context of object detection in images [19,20]. The idea of this method is to represent an image as a two-dimensional lattice, each node carrying a random variable standing for the value of the associated pixel. Then, after deleting from the lattice every vertex whose pixel value is lower than a suitable threshold, the largest remaining connected component is expected to be small if there is no object in the image. On the other hand, if an object is present, an unexpectedly large connected component should remain in the thresholded lattice. The theory behind the LOC test has since been extended to lattices of arbitrary dimension [6], but to the best of our knowledge, the underlying idea of using percolation theory to detect anomalous connected subgraphs has not yet been applied to complex, arbitrary-shaped networks.

Local Anomaly Detection and Percolation Theory
We now describe our method, first introducing some necessary notions of percolation theory, then highlighting their relevance to our anomaly detection problem. Finally, we provide a detailed description of our testing procedure.

Some Notions of Percolation Theory
An interesting aspect of the LOC test is that the behavior of its test statistic under the null hypothesis can be described using percolation theory. Therefore, we first review some useful results from this field, which motivate our approach. For more details, see for example [10] and references therein. Since our primary interest is in signals associated with edges, we focus on bond percolation, where edges of a connected graph with n vertices are occupied uniformly at random with probability p or unoccupied with probability 1 − p.
Let C(p) denote the size of the largest connected component of this graph at occupation probability p. The main focus of percolation theory is to find the limit of C(p) as n becomes large. Extremal values of p yield obvious results: for p = 0, C(p) = 1 for any n and for p = 1, lim n→∞ C(p) = ∞. For intermediate values of p, however, there are two possible regimes. If p is small enough, only small connected components are present and C(p)/n converges in probability to 0. On the other hand, larger values of p lead to the emergence of a giant connected component, which contains a constant fraction of the vertices. The transition between the two regimes happens for a critical value of p called the percolation threshold p c . Note that p c depends on the graph structure and can be vanishingly small. Although this phase transition is only well-defined in the limit of an infinite graph, a somewhat similar behavior can be observed in the finite case [8,16]. In particular, define the percolation process {C(p)} 0≤p≤1 as follows: assign to each edge e an independent random variable U e , uniformly distributed on [0, 1]. Then, keeping the U e fixed, let p vary on [0, 1], deleting e from the graph whenever U e > p. A tightly related process is obtained by considering the imbedded Markov chain {G k } k≥0 , where G k is the subgraph induced by the edges associated with the k smallest random variables. Letting C k denote the size of the largest connected component of G k , {C k } k≥0 can be seen as a discretized version of {C(p)} 0≤p≤1 . Even for finite graphs, sample paths of these two processes do not deviate significantly from the mean trajectory, making them suitable candidates for anomaly detection.

Application to Anomalous Subgraph Detection
We now motivate the idea of mapping a signal X onto a sample path of the percolation process. For i ∈ [m], define P i = 1 − F 0 (X i ) as the upper tail p-value associated with X i . Define also, for k ∈ {0, . . . , m}, the subgraph G k induced by the edges associated with the k smallest p-values, and let S k denote the size of its largest connected component. Under the null hypothesis, the random variables {P i } are independent and uniformly distributed on [0, 1]. Therefore, S k has the same distribution as C k for all k ∈ {0, . . . , m}. Under the alternative H S , however, the distribution of the variables {P i } i∈S is altered, which induces a deviation in the process {S k } 0≤k≤m with respect to the normal percolation process. Our test aims to detect this deviation. Figure 1 illustrates the normal and anomalous behaviors of the percolation process for three graph models: a two-dimensional square lattice, an Erdős-Rényi random graph [13] and a Barabási-Albert preferential attachment graph [7]. For each model, a graph with 1024 vertices and approximately 2000 edges is generated, and the mean and standard deviation of the fraction of vertices in the largest connected component for each value of p is estimated using 10000 Monte Carlo simulations. Then, for each graph, we generate a subtree S containing a fraction δ of the vertices, assign to each edge e an independent Gaussian random variable X e ∼ N (μ1{e ∈ S}, 1) and compute the associated sample path of the percolation process. This experiment was repeated 1000 times for each graph, and the mean sample path for different values of δ and μ is displayed. The two regimes of the percolation process can be observed, and the shape and location of the phase transition both clearly depend on the graph model. While the separation between the two regimes is quite clear for the lattice and the Erdős-Rényi graph, it is much blurrier for the Barabási-Albert model, which yields more complex structures -most interestingly, heavy-tailed degree distributions. Since such properties are often found in real-world networks, it is important to qualify their impact on the feasibility of percolation-based cluster detection. Figure 1 shows that although the anomalous sample paths become harder to distinguish as the phase transition gets hazier, the normal trajectories are concentrated enough to make even small deviations visible, which motivates our approach.

Putting It All Together -Description of Our Test
We now proceed with the description of our test. First, define where E 0 denotes the expected value under H 0 . K can be understood as the index corresponding to the onset of the phase transition. Since we aim to detect the appearance of an unexpectedly large connected component in the early steps of the percolation process, the test statistic we use is This statistic is equivalent to the area under a piecewise constant interpolation of the sequence of points {(k, S k )} 0≤k≤K , and is therefore expected to be higher than usual in the presence of an anomalous subgraph.
Estimation of K and calibration of the test are both done through Monte Carlo simulation: using the Newman-Ziff algorithm [23], N random sample paths of the imbedded Markov chain are computed. Let {S (i) k } 0≤k≤m denote the trajectory of the largest connected component's size for the ith realization of the process. We get the following estimates: Finally, the empirical p-value can be expressed aŝ

Experiments
In order to assess the power of our test, we ran it on several synthetic graphs containing random anomalous trees. This section describes the procedure we used to generate the dataset, then presents our results and their interpretation.

Generation of the Dataset
The dataset is generated using the stochastic Kronecker graph model [21]. Kronecker graphs exhibit similar structural properties as real-world networks, most importantly power law-distributed degrees and small diameter. Hence, this model allows us to evaluate our test in a somewhat realistic setting. Two parameter matrices are used: Θ 1 = [0.9 0.5; 0.5 0.3] (core-periphery network) and Θ 2 = [0.9 0.2; 0.2 0.9] (hierarchical network). For a given matrix and for i ∈ {12, 13, 14, 15}, we generate an undirected graph through i iterations of the Kronecker product, and only the largest connected component of this graph is kept in order to obtain a connected network with approximately 2 i vertices. Using this procedure, 10 graphs are generated for each pair of parameters (Θ, i). Thus, we evaluate our test on graphs with sizes ranging from a few thousands to a few tens of thousands of vertices, which covers a wide scope of potential use cases. For each synthetic graph, anomalies are then generated as follows: given δ ∈ (0, 1), a random subtree S containing a fraction δ of the vertices is drawn. Then, a random observation X e ∼ N(μ1{e ∈ S}, 1) is independently drawn for each edge e of the graph (where μ is a fixed signal strength). For a given graph and a pair of parameters (δ, μ), 1000 anomalous signals X = (X 1 , . . . , X m ) are generated. 1000 signals are also drawn from the null distribution (that is, X ∼ N (0, I m ), where I m is the m × m identity matrix) for comparison. Finally, for each graph, the null distribution of the test statistic is estimated using 10000 random realizations of the percolation process. Using the obtained histogram, the empirical p-values associated with the normal and anomalous samples are derived, and we construct the Receiver Operating Characteristic (ROC) curve for each pair (δ, μ). This procedure exposes the influence of various parameters on the performance of our test, namely the graph size, the generator matrix, the size δ of the anomalous region and the signal strength μ.

Detectability Conditions -Empirical Study
Our results are displayed in Table 1 and Figs. 2 and 3. Our main interest is in finding out which parameters have the strongest influence on the power of the test, and we provide some key observations and interpretations below. Influence of the Graph Size. The first thing we notice in Figs. 2 and 3 is that for a given pair of parameters (δ, μ), the performance of the test consistently improves as the size of the graph increases. One possible explanation for this comes from percolation theory: before the phase transition, the size of the largest connected component is sublinear in the size of the graph. This implies that, for a fixed ratio of vertices in the anomalous component, the difference between the size of the latter and the expected size of the largest component grows with the graph size. Therefore, the anomalous component becomes more visible as the graph grows. Note, however, that some structural properties of our synthetic graphs (e.g. density) might not remain identical for different values of i. It is thus difficult to pinpoint the actual influence of the sole number of vertices. Trade-Off Between δ and μ. As could be intuitively expected, our test performs better for higher values of δ and μ. More interestingly, these two parameters are intertwined: what makes an anomalous subgraph detectable is not only the number of vertices it contains (which is controlled by δ), but also the presence of a sufficient fraction of its edges among the most individually anomalous edges of the graph (which is controlled by μ). In terms of experimental results, this translates to poor performance when at least one of these parameters is too low. However, there seems to be a range of values of δ and μ in which a decrease in one can be made up for by an increase in the other. In particular, this implies that even small subgraphs can be detected by our test as long as the signal is strong enough. This is useful in "needle-in-a-haystack" scenarios such as network intrusion detection, where the anomalies one looks for are often localized.
Influence of the Graph Structure. As evidenced by Fig. 1, structural properties of the graph heavily influence the normal behavior of the percolation process, in turn affecting the viability of percolation-based cluster detection. This explains the observable difference in detection power between the two kinds of graphs we consider. Further analysis shows that the generator Θ 1 yields more heavy-tailed degree distributions, which is a plausible cause for the performance gap.

Discussion and Future Work
We now discuss the main properties of our test, identifying some limitations and providing leads for future work.  Theoretical Guarantees. From a theoretical perspective, our setting is more complex than that of [6]: we consider arbitrary networks instead of regular lattices, and our test statistic depends on the whole sample path of the percolation process rather than the marginal behavior at a given occupation probability. Therefore, the search for theoretical guarantees for our test was left out of the scope of this work, although it would certainly be of great interest.
Computational Cost. The main advantage of our method is its computational efficiency. Indeed, computing the empirical p-value for a given graph and an observed signal only requires N + 1 runs of the Newman-Ziff algorithm, which has a very low cost. In contrast, a scan statistic-based test would require N + 1 runs of a combinatorial optimization algorithm (one for the observed data and N additional runs to estimate the distribution of the test statistic under the null). Even with a very efficient optimization method, this is significantly more intensive. In terms of complexity, our test requires sorting the observations X i , running the Newman-Ziff algorithm N + 1 times, computing the mean sample path and the index K, and summing the first K values for each of the N + 1 trajectories, resulting in O(m(log m + N )) operations. Note that the algorithm can be further optimized using the fact that the test statistic depends only on the first K steps of the percolation process. Although the exact value of K depends on the graph, we empirically observe that it is generally smaller than the number of vertices |V|. Therefore, early stopping of the Newman-Ziff algorithm and partial sorting can reduce the complexity to O(m + |V|(N + log |V|)).
Detection Power. The expected downside of our method's low computational cost is a loss in detection power. Our simulations show, however, that the proposed test can detect reasonably small anomalous subgraphs in large enough ambient graphs, which is our main goal here. Moreover, it does not rely on prior knowledge of the alternative distribution and can be used with only a rough estimate of F 0 , which improves its usability in realistic settings. Although the influence of some factors on the performance of the test was left out of the scope of this work, a wider analysis would be an interesting topic for future work. These factors include the density of the graph and the shape of the anomalous subgraph. More specifically, we only evaluated our test in the case of random anomalous trees, which provides general results but no insight into the influence of the diameter and the density of the anomalous subgraph.

Conclusion
By extending previous work on percolation-based cluster detection to a more general setting, we propose a computationally efficient test to detect an anomalous connected subgraph in an edge-weighted network. The underlying intuition is that it is often possible to find out whether such a subgraph is present without explicitly finding it: instead of enumerating all possible candidates, a much faster method can be obtained by looking for properties of the whole graph which are affected by the apparition of an anomalous cluster. Our work suggests that percolation theory can provide such properties.
Since it scales easily to large graphs and does not rely on extensive knowledge of the null and alternative distributions of the observed signal, we argue that our method is applicable to real-world problems. Moreover, we show through extensive simulations that its detection power remains acceptable, and that it can in particular detect small anomalous regions in large graphs. Therefore, we think the link between cluster detection and percolation theory deserves further exploration, both from a theoretical and applied point of view.