Skip to main content

From time series to graph thru visibility algorithm.

Project description

This python package is an implementation of the algorithm described in the article: From time series to complex networks: The visibility graph.

Installation

Install library, perhaps within a virtualenv:

$ pip install visibility_graph

Application Programming Interface

Pass series as a list, visibility_graph will return a networkX undirected graph. Nodes contain the magnitudes on their timepoints.:

>>> from visibility_graph import visibility_graph
>>> series = [0.87, 0.49, 0.36, 0.83, 0.87]
>>> g = visibility_graph( series )
>>>
>>> g.nodes()
[0, 1, 2, 3, 4]
>>> g.edges()
[(0, 1), (0, 4), (1, 2), (2, 3), (3, 4)]
>>>
>>> g.nodes[1]
{'mag': 0.49}

Series to edgelist

A command line script is provided:

$ series2edgelist.py series.csv

where series.csv is a file containing one time point per line. One can specify more than one series file:

$ series2edgelist.py series1.csv series2.csv seriesN.csv

The script will also read a series from the standard input:

$ cat series.csv | series2edgelist.py

Edgelist will be printed to the standard output. So it might be wise to:

$ cat series.csv | series2edgelist.py > series.edgelist

The gist

“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.”

https://www.pnas.org/cms/10.1073/pnas.0709247105/asset/e257d3b5-ab8e-4e0f-b9ff-c46bdd3d865b/assets/graphic/zpq0080896800001.jpeg

“More formally, we can establish the following visibility criteria: two arbitrary data values (t a, y a) and (t b, y b) will have visibility, and consequently will become two connected nodes of the associated graph, if any other data (t c, y c) placed between them fulfills:”

https://www.pnas.org/cms/10.1073/pnas.0709247105/asset/b73d0eba-8ff8-46f0-aca5-705e29ad21d2/assets/graphic/zpq01308-9680-m01.jpeg

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

visibility_graph-0.5.1.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

visibility_graph-0.5.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file visibility_graph-0.5.1.tar.gz.

File metadata

  • Download URL: visibility_graph-0.5.1.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for visibility_graph-0.5.1.tar.gz
Algorithm Hash digest
SHA256 f2497d859916c3a0925926d93eab2690b1f675a506e3cda192aefff620cdf799
MD5 77ef6281d8b8c5c6ed33e86f1f87fb33
BLAKE2b-256 ab69e017fa74c058ce97d7b2f2783f07cd55fef1d4e02c8351d42e8df4a7ace0

See more details on using hashes here.

File details

Details for the file visibility_graph-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for visibility_graph-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c2f3e928027abfbbbef4ee96d52ae896b436fa676fd4e3fb477b82e748981031
MD5 b00f7f9983617acf1ed3914b22d6a7ba
BLAKE2b-256 52549384f368e6e3ed9e5505c7826c33b0ee08007740db51a1d149a6cad7022e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page