---
title: Horizontal Visibility Algorithm
url: https://www.emergentmind.com/topics/horizontal-visibility-algorithm
type: topic
---

# Horizontal Visibility Algorithm

The horizontal visibility algorithm is a mapping from an ordered numerical sequence to a graph in which each datum becomes a vertex and two vertices are adjacent precisely when every intermediate datum is strictly lower than both endpoints. In the standard formulation, an Horizontal Visibility Graph (HVG) is associated with an ordered set of non-negative reals, and the mapping converts temporal order and relative magnitude into a noncrossing graph structure that is analytically tractable and useful for time-series analysis, combinatorics, and graph theory [1010.1850].

## 1. Definition and basic construction

Given an ordered sequence \(X=(x_1,x_2,\ldots,x_n)\), the HVG \(G=(V,E)\) has one vertex for each \(x_i\). There is an edge between \(x_i\) and \(x_j\) with \(i<j\) if for every \(k\) satisfying \(i<k<j\),
\[
x_k < \min\{x_i,x_j\}.
\]
Equivalently, two data points “see” each other horizontally if all intermediate points are strictly lower. In the time-series literature this same criterion is also written as \(x_i,x_j>x_n\) for all \(i<n<j\) [1010.1850].

This construction is always connected because each node is adjacent to its nearest temporal neighbors. The resulting graph is an undirected graph in the basic setting, although directed versions orient edges from earlier to later indices and define in-degree and out-degree accordingly [1902.03435]. The algorithm is simpler than the original visibility-graph construction and became important in part because exact topological results can be derived for several classes of sequences [1002.4526].

In applications, the graph is interpreted as a reduced representation of the series. Degree, clustering, path length, motifs, and related graph observables are then used as descriptors of the generating dynamics. This suggests that the HVG is not merely a visualization device but a mathematically constrained encoding of order statistics.

## 2. Structural characterization in graph theory

A central theorem gives a complete graph-theoretic characterization: a graph is an HVG if and only if it is outerplanar and has a Hamilton path [1010.1850]. Here, outerplanarity means that the graph can be embedded in the plane without edge crossings with all vertices incident to the unbounded face, and the Hamilton path is the path visiting vertices in sequence order.

This result has several immediate consequences. First, HVGs are noncrossing graphs in the sense of algebraic combinatorics. Second, the class of HVGs is exactly the class of outerplanar Hamiltonian-path graphs, so the visibility condition is equivalent to a purely graph-theoretic description [1010.1850]. Third, maximal HVGs coincide with maximal outerplanar graphs; in particular, when the graph is maximal outerplanar its number of edges is \(2n-3\) [1010.1850].

The characterization also yields an algorithmic corollary: HVG recognition is linear-time. The argument given is that recognizing outerplanar graphs can be done in \(O(n)\) time and checking for a Hamilton path in an outerplanar graph can also be done in \(O(n)\) time, so one can determine in linear time whether a given graph is an HVG [1010.1850].

A common misconception is to identify HVGs with planar graphs in general or even with outerplanar graphs in general. The exact theorem excludes both simplifications: the Hamilton-path condition is essential, and arbitrary planar graphs lie far outside the HVG class. The visibility rule therefore defines a narrow and rigid subclass of sparse graphs.

## 3. Words, visible pairs, and enumeration

A distinctive feature of the foundational combinatorial treatment is the reinterpretation of ordered sets as words. If \(x=x_1x_2\ldots x_n\) is regarded as a word over an alphabet, then a pair \((x_i,x_j)\) with \(i<j\) is called a visible pair if all intermediate letters satisfy
\[
x_{i+1},\ldots,x_{j-1}<\min\{x_i,x_j\}.
\]
The number of visible pairs in the word equals the number of edges in the associated HVG [1010.1850].

This correspondence allows the use of generating functions. For words of length \(n\) over an alphabet of size \(k\), the generating function for the total number of visible pairs is
\[
F_k(x,q)=\sum_{n\ge 0}\sum_{x\in [k]^n} q^{vis(x)}x^n.
\]
Using this framework, the asymptotic average number of edges in HVGs formed from random words on \([k]\) is
\[
\left(2-\frac{\psi(k+1)+\gamma}{k}\right)n,
\]
where \(\psi\) is the digamma function and \(\gamma\) is the Euler–Mascheroni constant [1010.1850].

Later work sharpened the combinatorics of the class. For data sequences without equal entries, HVGs are completely determined by their ordered degree sequence, and distinct HVGs on \(N\) vertices arising from pairwise distinct data have different ordered degree sequences [2111.02723]. The same work shows that HVGs for data sequences without equal entries are counted by the Catalan numbers,
\[
|G_{N,\neq}| = C_{N-1} = \frac{1}{N}\binom{2N-2}{N-1},
\]
whereas HVGs allowing equal entries are counted by the large Schröder numbers,
\[
|G_N| = r_{N-2},
\]
for \(N\ge 2\) [2111.02723].

These results place HVGs inside classical Catalan- and Schröder-enumerated families. A common overstatement is that the degree sequence always determines the graph. The precise statement is narrower: this uniqueness holds for HVGs generated by data sequences with all entries distinct [2111.02723].

## 4. Exact results for random, periodic, and chaotic series

For i.i.d. random series, the HVG has a universal exponential degree distribution,
\[
P(k)=\frac{1}{3}\left(\frac{2}{3}\right)^{k-2}, \qquad k\ge 2,
\]
independently of the probability distribution from which the series was generated. The mean degree is \(\langle k\rangle=4\), the local clustering coefficient satisfies \(C(k)=2/k\), the mean path length scales as
\[
L(N)\sim 2\log N + 2(\gamma-1),
\]
and the probability that two nodes at distance \(n\) are connected is
\[
P(n)=\frac{2}{n(n+1)}.
\]
These exact results make HVGs analytically solvable for uncorrelated randomness and provide a direct reference model for detecting non-random structure [1002.4526].

For periodic series with period \(T\) and no repeated values within a period, the mean degree is
\[
\bar{k}(T)=4\left(1-\frac{1}{2T}\right),
\]
which can be inverted to estimate the period. On this basis a graph-theoretical noise reduction filter introduces a threshold \(f\) and connects \(x_i\) and \(x_j\) when
\[
x_i,x_j > x_n + f \qquad \forall\, i<n<j.
\]
Plateaus in the filtered mean degree \(\bar{k}(f)\) reveal the intrinsic period of noisy periodic signals, and the method can avoid false periodicity indications in certain chaotic cases where autocorrelation is misleading [1108.1693].

In deterministic dynamics, the HVG formalism supports deeper analytical programs. In the Feigenbaum scenario, period-doubling and band-splitting attractor cascades generate families of graphs whose degree distributions, mean distances, clustering coefficients, and entropy can be derived analytically; the corresponding renormalization-group scheme has fixed-point graphs, and the graph entropy emulates the Lyapunov exponent independently of its sign [1201.2514]. For type-I intermittency, the alternation of laminar episodes and chaotic bursts produces a mixed graph structure in which the variance of the degree distribution scales as
\[
\sigma_k^2 \sim \epsilon^{-0.5},
\]
matching the characteristic scaling of the mean laminar length, while block entropies over degree sequences inherit the power-law scaling of the Lyapunov exponent [1301.4850].

Other statistical descriptors have also proved discriminative. Tetradic motif frequencies in HVGs derived from multifractal binomial measures converge to
\[
\left(\frac{2}{3},0,\frac{8}{99},\frac{8}{33},\frac{1}{99},0\right),
\]
while for fractional Gaussian noises they depend nonlinearly on the Hurst exponent and series length, and in heartbeat-rate data they distinguish healthy subjects, congestive heart failure subjects, and atrial fibrillation subjects [1811.03794]. In turbulent-flow data, HVGs of velocity time series show universal degree distributions at high Reynolds numbers, whereas acceleration-series degree distributions have stretched exponential forms with a Reynolds-number-dependent fitting parameter, together with a transitional behavior in several network features [1512.08200].

Taken together, these results explain why degree distributions became a prominent discriminator between randomness and chaos in the early HVG literature: the random benchmark is exact, while many deterministic regimes yield systematic and interpretable departures.

## 5. Generalizations and domain-specific variants

A major extension is the limited penetrable horizontal visibility graph, denoted LPHVG(\(\rho\)). In this variant, two nodes are connected when there exist at most \(\rho\) intermediate data points \(x_q\) in \((i,j)\) such that \(x_q\ge \min(x_i,x_j)\). The classical HVG is recovered at \(\rho=0\). For bi-infinite i.i.d. random series, the degree distribution is
\[
P(k)=
\begin{cases}
\frac{1}{2\rho+3}\left(\frac{2\rho+2}{2\rho+3}\right)^{k-2(\rho+1)}, & k\ge 2\rho+2,\\
0, & \text{otherwise},
\end{cases}
\]
with mean degree \(\langle k\rangle=4(\rho+1)\). Directed and image variants, DLPHVG(\(\rho\)) and ILPHVG\(_n(\rho)\), extend the framework to irreversibility analysis and to matrices or spatial fields, respectively [1711.05158]. Earlier exact results on LPHVG emphasized the same universal exponential law, exact clustering expressions, and a long-distance visibility probability
\[
P_\rho(n)=\frac{2\rho(\rho+1)+2}{n(n+1)},
\]
and used deviations from the random theory to distinguish chaotic and empirical series from uncorrelated randomness [1710.09877].

For multivariate time series, the multilayer horizontal visibility graph introduces cross-horizontal visibility between lagged timestamps of different components. In this construction, intra-layer edges are standard HVG edges within each component, while inter-layer edges are added when pairs of observations in different series satisfy a cross-visibility criterion across intermediate times. The method is described as parameter-free, does not require data pre-processing, and uses multilayer topological measures together with a ratio-degree feature
\[
r_i^{\alpha \preceq \beta}=\frac{k_i^{\alpha \prec \beta}}{k_i^\alpha}
\]
to characterize joint structure. The reported experiments indicate that inter-layer edges preserve information that would be lost in single-layer and multiplex representations, while also complementing the information in intra-layer edges [2301.02333].

Specialized variants also appeared in application-driven settings. The Temporary Horizontal Visibility Graph (THVG) modifies HVG for information-source impact networks by using a temporal window \(t\) and source ratings. A directed link from node \(i\) to node \(j\) is established when
\[
A_{ij}=
\begin{cases}
1, & \text{if } S_i>S_j \text{ and } (j-i)<t,\\
0, & \text{otherwise}.
\end{cases}
\]
In the reported cybersecurity-news application, THVG is more effective than the usual HVG design method by \(7\!-\!9\%\) in F-measure, \(7\!-\!10\%\) in completeness, and \(6\!-\!8\%\) in accuracy [1910.07340].

Beyond numerical time series, the compactified horizontal visibility graph was proposed for language networks. Word occurrences are first mapped to an HVG using a weight derived from the standard deviation of distances between repeated occurrences, after which all occurrences of the same word are merged into a single node and multiple edges are collapsed. The resulting networks are reported to be scale free, and among the highest-degree nodes appear not only function words relevant to text structure communication but also words that determine the informational structure of the text [1302.4619].

## 6. Computation, online algorithms, and scope

The original structural characterization already implies linear-time recognition of whether a given graph is an HVG [1010.1850]. More recent work addressed the transformation problem itself in streaming settings. The LOT framework formulates two online requirements—efficient update and efficient elimination—and gives a linear-time online method for both natural and horizontal visibility graph transformations on sliding windows. For HVG, the update traverses the current window from the back, maintains the maximum value seen so far, and adds edges to the newest node whenever
\[
\min(s_i,s_T)>s_{\max}=\max(s_{i+1},\ldots,s_{T-1}).
\]
With an adjacency dictionary representation, node elimination and graph update are both \(O(N)\) per step, and a monotonic-stack optimization preserves linear time while improving practical efficiency [2311.12389].

This computational development matters because much of the HVG literature presumes offline access to complete sequences, whereas many practical data sources are streams. The LOT results suggest that HVG-based analysis can be used in latency-sensitive settings without rebuilding the graph from scratch at every update.

The scope of HVG methods is broad but not unlimited. The strongest exact theorems are concentrated in specific regimes: i.i.d. random series, periodic sequences, several self-similar deterministic constructions, and the combinatorics of the graph class itself. Application papers repeatedly show discriminative performance—for example in chaos-versus-randomness tests, irreversibility detection, multivariate dependence analysis, turbulence, heartbeat dynamics, information-source influence, and language networks—but the underlying guarantees differ across variants and domains [1002.4526]. A plausible implication is that HVG is best understood as a family of rigorously constrained mappings whose interpretive power is highest when empirical use is anchored to the corresponding exact theory.

In contemporary usage, the horizontal visibility algorithm occupies a distinctive position among time-series-to-network transformations. Its central attraction is the coexistence of three features that rarely coincide: a local geometric rule, a complete graph-theoretic characterization, and a substantial body of exact results linking graph observables to stochastic, periodic, and nonlinear dynamical structure.

Source: https://www.emergentmind.com/topics/horizontal-visibility-algorithm