Abstract
In this work we present a simple and fast computational method, the visibility algorithm, that converts a time series into a graph. The constructed graph inherits several properties of the series in its structure. Thereby, periodic series convert into regular graphs, and random series do so into random graphs. Moreover, fractal series convert into scale-free networks, enhancing the fact that power law degree distributions are related to fractality, something highly discussed recently. Some remarkable examples and analytical tools are outlined to test the method's reliability. Many different measures, recently developed in the complex network theory, could by means of this new approach characterize time series from a new point of view.
Keywords: Brownian motion, complex systems, fractals
In this article we present a tool in time series analysis: the visibility graph. This algorithm maps a time series into a network. The main idea is to study to which extent the techniques and focus of graph theory are useful as a way to characterize time series. As will be shown below, this network inherits several properties of the time series, and its study reveals nontrivial information about the series itself.
For illustrative purposes, in Fig. 1 we present a scheme of the visibility algorithm. In the upper zone we plot the first 20 values of a periodic series by using vertical bars (the data values are displayed above the plot). Considering this as a landscape, we link every bar (every point of the time series) with all those that can be seen from the top of the considered one (gray lines), obtaining the associated graph (shown in the lower part of the figure). In this graph, every node corresponds, in the same order, to series data, and two nodes are connected if visibility exists between the corresponding data, that is to say, if there is a straight line that connects the series data, provided that this “visibility line” does not intersect any intermediate data height.
Fig. 1.
Example of a time series (20 data values) and the associated graph derived from the visibility algorithm. In the graph, every node corresponds, in the same order, to series data. The visibility rays between the data define the links connecting nodes in the graph.
More formally, we can establish the following visibility criteria: two arbitrary data values (ta, ya) and (tb, yb) will have visibility, and consequently will become two connected nodes of the associated graph, if any other data (tc, yc) placed between them fulfills:
We can easily check that by means of the present algorithm, the associated graph extracted from a time series is always:
Connected: each node sees at least its nearest neighbors (left and right).
Undirected: the way the algorithm is built up, there is no direction defined in the links.
Invariant under affine transformations of the series data: the visibility criterion is invariant under rescaling of both horizontal and vertical axes, and under horizontal and vertical translations (see Fig. 2).
In a recent work (1), Zhang and Small (ZS) introduced another mapping between time series and complex networks. Although the philosophy is similar to this work (to encode the time series in a graph to characterize the series by using graph theory), fundamental differences exist between both methods, mainly in what refers to the range of applicability (ZS only focus on pseudoperiodic time series, associating each series cycle to a node and defining links between nodes by temporal correlation measures, whereas the visibility graph can be applied to every kind of time series) and the graph connectedness (in ZS the giant component is assured only ad hoc; meanwhile, the visibility graph is always connected by definition).
Fig. 2.
The visibility graph of a time series remains invariant under several transformation of the time series. (a) Original time series with visibility links. (b) Translation of the data. (c) Vertical rescaling. (d) Horizontal rescaling. (e) Addition of a linear trend to the data. As can be seen in the bottom diagram, in all these cases the visibility graph remains invariant.
The key question is to know whether the associated graph inherits some structure of the time series, and consequently whether the process that generated the time series may be characterized by using graph theory. In a first step we will consider periodic series. As a matter of fact, the example plotted in Fig. 1 is nothing but a periodic series with period 4. The associated visibility graph is regular, as long as it is constructed by periodic repetition of a pattern. The degree distribution of this graph is formed by a finite number of peaks related to the series period, much in the vein of the Fourier power spectrum of a time series. Generically speaking, all periodic time series are mapped into regular graphs, the discrete degree distribution being the fingerprint of the time series periods. In the case of periodic time series, its regularity seems therefore to be conserved or inherited structurally in the graph by means of the visibility map.
As an opposite to periodic series, in a second step we will tackle a series R(t) of 106 data values extracted from an uniform distribution in [0, 1]. Although one would expect in a first moment a Poisson degree distribution in this case [as for uncorrelated random graphs (2)], a random time series has indeed some correlation, because it is an ordered set. In fact, let kt be the connectivity of the node associated with the data t. If kt is large (related to the fact that the data have a large value and that consequently they have large visibility), one would expect that kt+1 would be relatively small, because the time series is random and two consecutive data values with a large value are not likely to occur. It is indeed because of these “unlikely” large values (the hubs) that the tail of the degree distribution deviates from the Poisson distribution. Two large values in the series data can be understood as two rare events in the random process. The time distribution of these events is indeed exponential (3), therefore we should expect the tail of the degree distribution in this case to be exponential instead of Poissonian, as long as the form of this tail is related to the hub's distribution.
In the left side of Fig. 3 we depict the first 250 values of R(t). In the right side we plot the degree distribution P(k) of its visibility graph. The tail of this distribution fits an exponential distribution quite well, as expected. Note, at this point, that time series extracted randomly from other distributions than uniform have also been addressed. In every case the algorithm captures the random nature of the series, and the particular shape of the degree distribution of the visibility graph is related to the particular random process.
Fig. 3.
Random series. (Left) First 250 values of R(t), where R is a random series of 106 data values extracted from U[0,1]. (Right) Degree distribution P(k) of the visibility graph associated with R(t) (plotted in semilog). Although the beginning of the curve approaches the result of a Poisson process, the tail is clearly exponential. This behavior is due to data with large values (rare events), which are the hubs.
Hitherto, ordered (periodic) series convert into regular graphs, and random series convert into exponential random graphs; order and disorder structure in the time series seem to be inherited in the topology of the visibility graph. Thus, the question arises: What kind of visibility graph is obtained from a fractal time series? This question is in itself interesting at the present time. Recently, the relationship between self-similar and scale-free networks (4–8) has been intensively discussed (9–12). Although complex networks (5) usually exhibit the small-world property (13) and consequently cannot be size-invariant, it has been recently shown (9) that by applying fitted box-covering methods and renormalization procedures, some real networks actually exhibit self-similarity. So, whereas self-similarity seems to imply scale freeness, the opposite is not true in general.
To explore these issues in more detail, the following two fractal series will be considered: the well known Brownian motion B(t) and the Conway series (14). Whereas the Brownian motion represents a well known case of self-affinity [indeed, the following relation holds: B(t) = a1/2B(t/a)], the Conway series a(n) − n/2 is the recursively generated fractal series from:
|
|
In Fig. 4 we have plotted the behavior of these series, the degree distribution P(k) of their respective visibility graphs and their mean path length L(N) as a function of the series length. First, both series have visibility graphs with degree distributions that correspond to power laws of the shape P(k) ∼ k−α, where we get different exponents in each case: this result enhances the fact that, in the context of the visibility algorithm, power law degree distributions [that is, scale-free networks (6–9)] arise naturally from fractal series. Moreover, this relation seems to be robust as long as the preceding examples show different kinds of fractality: whereas B(t) stands for a stochastic self-affine fractal, the Conway series is a deterministic series recursively generated. However, whereas the Brownian visibility graph seems to evidence the small-world effect (Fig. 4 Upper Right) as L(N) ∼ log(N), the Conway series shows in turn a self-similar relation (Fig. 4 Lower Right) of the shape L(N) ∼ Nβ. This fact can be explained in terms of the so-called hub repulsion phenomenon (11): visibility graphs associated with stochastic fractals such as the Brownian motion or generic noise series do not evidence repulsion between hubs (in these series it is straightforward that the data with highest values would stand for the hubs, and these data would have visibility between each other), and consequently will not be fractal networks according to Song et al. (11). However, the Conway series actually evidence hub repulsion: this series is concave-shaped and, consequently, the highest data values will not in any case stand for the hubs; the latter ones would be located most likely in the monotonic regions of the series, which are indeed hidden from each other (effective repulsion) across the series local maxima. The Conway visibility graph is thus fractal.
Fig. 4.
Fractal series. (Upper from left to right) First 4,000 data values from a Brownian series of 106 data values. (Center) The degree distribution of the visibility graph associated with the Brownian motion. This one is a power law P (k) ∼ k−α with α = 2.00 ± 0.01. (Right) Plot of the mean path length of this network as a function of the network size N. The best fitting provides a logarithmic scaling L(N) = 1.21 + 0.51 log(N). This network shows small-world effect in addition to being scale-free. (Lower from left to right) First 105 data values from a Conway series of 4 · 106 data values. (Center) The degree distribution of the visibility graph associated with the Conway series. This one is a power law P (k) ∼ k−α with α = 1.2 ± 0.1. The mean path length as a function of the size N is depicted in Right. The best fitting provides a power law scaling L(N) = 0.76N0.38. Then, this network is scale-invariant.
Because a fractal series is characterized by its Hurst exponent, we may argue that the visibility graph can actually distinguish different types of fractality, something that will be explored in detail in further work. Note at this point that some other fractal series have been also studied [Q series (15), Stern series (16), and Thue–Morse series (17), etc.] with similar results. Moreover, observe that if the series under study increases its length, the resulting visibility graph can be interpreted in terms of a model of network growth and may eventually shed light into the fractal network formation problem.
To cast light into the relation between fractal series and power law distributions, in Fig. 5Left, we present a deterministic fractal series generated by iteration of a simple pattern of three points. The series starts (step 0) with three points (A, B, and C) of coordinates (0, 1), (1, 1/3), and (2, 1/3), respectively. In step p, we introduce 2p + 1 new points with height 3−p−1 and distanced 3−p. The series form a self-similar set: applying an isotropic zoom of horizontal scale 3p and vertical scale 3p to the pattern of order p, we recover the original pattern.
Fig. 5.
Simple deterministic fractal. (Left) Fractal series obtained by iteration of the original pattern (points A, B, and C) with p = 10 steps. (Right) Values of Kr (circles) and Kl (squares) as a function of the fractal size, related to Eqs. 3 and 5. Note that the plot is log-linear; the relation is thus exponential. The straight lines correspond to the approximations deduced in Eqs. 4 and 6.
Note that this time series is not data uniformly spaced as in the previous examples. However, its usefulness is set on the fact that it is simple enough to handle it analytically, that is, to find the degree distribution of its visibility graph. The main idea is to find a recurrence behavior in the way that a given node increases its connectivity when the fractal step (that is, the fractal size) is increased (18). Then we calculate how many nodes (self-similar to it) appear in each step, and from both relations we come to a degree distribution for these kinds of nodes.
First, from a quick visual exploration of Fig. 5 Left one comes to the conclusion that nodes A and B have typically the same degree. However, the degree of node C can be decomposed in two terms: the left degree (due to visibility of nodes at the left of C) and the right degree. The degree of A and B is the same as the right degree of C (statistically speaking, A and B increase their connectivity as the fractal size increases much in the way as the right part of C). Thereby, the degree of C provides the whole information of the system. We will quote Kr(C, n) the right degree of node C in a n-step fractal (respectively, Kl(C, n) stands for the left degree).
Applying the visibility criterion, one can geometrically find that
![]() |
where μ is the Moëbius function. Note that this summation agrees with the number of irreducible polynomials of degree at most n over the Galois field GF(2) (19), something which deserves an in-depth investigation. This expression can be approximated by
However, there is a recurrence in the left degree that reads
whose leading term is
The node C will thus have a degree K(C) = Kr(C, n) + Kl(C, n). In Fig. 5 Right we plot the values of Kr (circles) and Kl (squares) as a function of the fractal size (the number of iterations n). Numerical values are plotted as the outer circles and squares, whereas the inner circles and squares come from plotting Eqs. 3 and 5. Note that both formulas reproduce the numerical data. The straight lines correspond to the approximation Eqs. 4 and 6. Now, in a generic step p, 2p nodes that are self-similar to C appear (by construction). Those nodes will have a degree that, for large values of n − p, can be approximated to K(C, n − p) ≃ 2n− p. Defining f(K) as the degree distribution, we get that f(K(C, n − p)) = 2p, and with the change of variable u ≡ 2n− p, it is easy to come into:
that is, the degree distribution related to the C nodes is a power law. Although this simple example does not provide a general explanation of why fractality is traduced into power law distributions, it may stand as a generic way of dealing with deterministic fractal series generated by iteration.
Once the visibility method has been presented, some remarks can be stated: note that typically two series that only differ by an affine transformation will have the same visibility graph; in this sense the algorithm absorbs the affine transformation. Furthermore, it is straightforward to see that some information regarding the time series is inevitably lost in the mapping from the fact that the network structure is completely determined in the (binary) adjacency matrix. For instance, two periodic series with the same period as T1 = {…, 3, 1, 3, 1, …} and T2 = {…, 3, 2, 3, 2, …} would have the same visibility graph, albeit being quantitatively different. Although the spirit of the visibility graph is to focus on time series structural properties (periodicity, fractality, etc.), the method can be trivially generalized by using weighted networks (where the adjacency matrix is not binary and the weights determine the slope of the visibility line between two data values), if we eventually need to quantitatively distinguish time series like T1 and T2, for instance.
Although in this article we have only tackled undirected graphs, note that one could also extract a directed graph (related to the temporal axis direction) in such a way that for a given node one should distinguish two different connectivities: an ingoing degree kin, related to how many nodes see a given node i, and an outgoing degree kout, that is the number nodes that node i sees. In that situation, if the direct visibility graph extracted from a given time series is not invariant under time reversion [that is, if P(kin) ≠ P(kout)], one could assert that the process that generated the series is not conservative. In a first approximation we have studied the undirected version and the directed one will be eventually addressed in further work.
There are some direct applications of the method that can be put forward. The relation between the exponent of the degree distributions and the Hurst exponent of the series will be addressed in further work. In particular, it turns out that the method presented here constitutes a reliable tool to estimate Hurst exponents, as far as a functional relation between the Hurst exponent of a fractal series and the degree distribution of its visibility graph holds (J.C.N., B.L., L.L., and F.B., unpublished work). Note that the estimation of Hurst exponents is an issue of major importance in data analysis that is yet to be completely solved (see, for instance, ref. 20). Fractional Brownian motions, a concept of great interest in a large variety of fields ranging from electronic devices to biology, will also be considered in relation with the preceding point.
Moreover, the ability of the algorithm to detect not only the difference between random and chaotic series but also the spatial location of inverse bifurcations in chaotic dynamical systems is another fundamental issue that will also be at the core of further investigations (unpublished work). Finally, the visibility graph characterizes nontrivial time series and, in that sense, the method may be relevant in specific problems of different garments, such as human behavior time series recently put forward (21).
In summary, a algorithm that converts time series into graphs is presented. The structure of the time series is conserved in the graph topology: periodic series convert into regular graphs, random series into random graphs, and fractal series into scale-free graphs. Such characterization goes beyond the preceding points, since different graph topologies arise from apparently similar fractal series. In fact, the method captures the hub repulsion phenomenon associated with fractal networks (11) and thus distinguishes scale-free visibility graphs evidencing the small-world effect from those showing scale invariance. With the visibility algorithm, a natural bridge between complex networks theory and time series analysis has now been built.
Acknowledgments.
We thank the editor and two anonymous referees for their comments. This work was supported by Spanish Ministry of Science Grant FIS2006-08607.
Footnotes
The authors declare no conflict of interest.
This article is a PNAS Direct Submission. A.-L.B. is a guest editor invited by the Editorial Board.
References
- 1.Zhang J, Small M. Phys Rev Lett. 2006;96:238701. doi: 10.1103/PhysRevLett.96.238701. [DOI] [PubMed] [Google Scholar]
- 2.Bollobás B. Modern Graph Theory. New York: Springer; 1998. [Google Scholar]
- 3.Feller W. An Introduction to Probability Theory and Its Applications. New York: Wiley; 1971. [Google Scholar]
- 4.Barabási AL, Albert R. Science. 1999;286:509. doi: 10.1126/science.286.5439.509. [DOI] [PubMed] [Google Scholar]
- 5.Albert R, Barabási AL. Rev Mod Phys. 2002;74:47–92. [Google Scholar]
- 6.Newman MEJ. SIAM Rev. 2003;45:167–256. [Google Scholar]
- 7.Dorogovtsev S, Mendes JFF. Adv Phys. 2002;51:4. [Google Scholar]
- 8.Bocaletti S, Latora V, Moreno Y, Chávez M, Hwang DU. Phys Rep. 2006;424:175–308. [Google Scholar]
- 9.Song C, Havlin S, Makse HA. Nature. 2005;433:392. doi: 10.1038/nature03248. [DOI] [PubMed] [Google Scholar]
- 10.Goh KI, Salvi G, Kahng B, Kim D. Phys Rev Lett. 2006;96:018701. doi: 10.1103/PhysRevLett.96.018701. [DOI] [PubMed] [Google Scholar]
- 11.Song C, Havlin S, Makse HA. Nat Phys. 2006;2:275. [Google Scholar]
- 12.Kim JS, Goh KI, Salvi G, Oh E, Kahng B, Kim D. Phys Rev E. 2007;75:016110. doi: 10.1103/PhysRevE.75.016110. [DOI] [PubMed] [Google Scholar]
- 13.Watts DJ, Strogatz SH. Nature. 1998;393:440–442. doi: 10.1038/30918. [DOI] [PubMed] [Google Scholar]
- 14.Conway J. Some Crazy Sequences; Lecture presented at AT&T Bell Labs; 15 July; Murray Hill, NJ. 1988. [Google Scholar]
- 15.Hofstadter D. Gödel, Escher, Bach. New York: Vintage Books; 1980. pp. 137–138. [Google Scholar]
- 16.Stern MA. J Reine Angew Math. 1858;55:193–220. [Google Scholar]
- 17.Schroeder MR. Fractals, Chaos, and Power Laws. New York: Freeman; 1991. [Google Scholar]
- 18.Barabási A-L, Ravasz E, Vicsek T. Physica A. 2001;299:559564. [Google Scholar]
- 19.Hicks KH, Mullen GL, Sato I. Finite Fields with Applications to Coding Theory, Cryptography and Related Areas (Oaxaca, 2001) Berlin: Springer; 2002. Distribution of irreducible polynomials over F2; pp. 177–186. [Google Scholar]
- 20.Karagiannis T, Molle M, Faloutsos M. IEEE Internet Comput. 2004;8:5. [Google Scholar]
- 21.Vázquez A, Gama Oliveira J, Deszö Z, Goh K, Kondor I, Barabási AL. Phys Rev E. 2006;73:036127. doi: 10.1103/PhysRevE.73.036127. [DOI] [PubMed] [Google Scholar]






