Build visibility graphs from time series data.
Project description
The Python ts2vg package provides high-performance algorithm implementations to build visibility graphs from time series data, as first introduced by Lucas Lacasa et al. in 2008 [1].
The visibility graphs and some of their properties (e.g. degree distributions) are computed quickly and efficiently even for time series with millions of observations. An efficient divide-and-conquer algorithm is used to compute the graphs whenever possible [3].
Installation
The latest released ts2vg version is available at the Python Package Index (PyPI) and can be easily installed by running:
pip install ts2vg
For other advanced uses, to build ts2vg from source Cython is required.
Supported graph types
Main graph types
Available variations
Additionally, the following variations of the previous main graph types are available:
Weighted Visibility Graphs (via the weighted parameter)
Directed Visibility Graphs (via the directed parameter)
Parametric Visibility Graphs [5] (via the min_weight and max_weight parameters)
Limited Penetrable Visibility Graphs (LPVG) [4] [6] (via the penetrable_limit parameter)
Note that multiple graph variations can be combined and used at the same time.
Documentation
Usage and reference documentation for ts2vg can be found at carlosbergillos.github.io/ts2vg.
Basic usage
To build a visibility graph from a time series do:
from ts2vg import NaturalVG
ts = [1.0, 0.5, 0.3, 0.7, 1.0, 0.5, 0.3, 0.8]
vg = NaturalVG()
vg.build(ts)
edges = vg.edges
The time series passed (ts) can be any one-dimensional iterable, such as a list or a numpy 1D array.
By default, the input observations are assumed to be equally spaced in time. Alternatively, a second 1D iterable (xs) can be provided for unevenly spaced time series.
Horizontal visibility graphs can be obtained in a very similar way:
from ts2vg import HorizontalVG
ts = [1.0, 0.5, 0.3, 0.7, 1.0, 0.5, 0.3, 0.8]
vg = HorizontalVG()
vg.build(ts)
edges = vg.edges
If we are only interested in the degree distribution of the visibility graph we can pass only_degrees=True to the build method. This will be more efficient in time and memory than storing the whole graph.
vg = NaturalVG()
vg.build(ts, only_degrees=True)
ks, ps = vg.degree_distribution
Directed graphs can be obtained by using the directed parameter and weighted graphs can be obtained by using the weighted parameter:
vg1 = NaturalVG(directed="left_to_right")
vg1.build(ts)
vg2 = NaturalVG(weighted="distance")
vg2.build(ts)
vg3 = NaturalVG(directed="left_to_right", weighted="distance")
vg3.build(ts)
vg4 = HorizontalVG(directed="left_to_right", weighted="h_distance")
vg4.build(ts)
For more information and options see: Examples and API Reference.
Interoperability with other libraries
The graphs obtained can be easily converted to graph objects from other common Python graph libraries such as igraph, NetworkX and SNAP for further analysis.
The following methods are provided:
as_igraph()
as_networkx()
as_snap()
For example:
vg = NaturalVG()
vg.build(ts)
g = vg.as_networkx()
Command line interface
ts2vg can also be used as a command line program directly from the console:
ts2vg ./timeseries.txt -o out.edg
For more help and a list of options run:
ts2vg --help
Contributing
ts2vg can be found on GitHub. Pull requests and issue reports are welcome.
License
ts2vg is licensed under the terms of the MIT License.
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for ts2vg-1.2.4-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cd73dd54112f6e2672df9c6448e335369df6918bbe2ec9e0c6e6a7757fe78ec |
|
MD5 | fb91535081423891489a97ec0bc4b931 |
|
BLAKE2b-256 | f6d83877ce9d8cb4ef271e191281d5d352ed75371f4aeed0ab20de930ce950bf |
Hashes for ts2vg-1.2.4-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 308a5e9aff8e010fc518e08903dd585cf22c3ff8355f5b3a5959c33762559905 |
|
MD5 | af8e6aa5df3be26221c2bb253dadc218 |
|
BLAKE2b-256 | 02b893aeb67800eb5e9fe9e709058cce7437985a070e7b82358cc26a0ec1245d |
Hashes for ts2vg-1.2.4-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d30ef6ea87c7a365918a3759cb687a91a0432ac985ce759ece61f5fb1ca4aed |
|
MD5 | 2cb4149ab4e96f38c56ca4ca2ec3ff0c |
|
BLAKE2b-256 | 2e46fda87e7d2fa5c32174c67ad9ee847f2f9774b1ad03a7f2c38a0ebe68c4e2 |
Hashes for ts2vg-1.2.4-cp312-cp312-musllinux_1_2_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46ee6bb234b0bef52687c61446da1a6e287091b7ccee1015e089951c2075d62b |
|
MD5 | 22ad46e294431e0f2fc380a14a9644bf |
|
BLAKE2b-256 | ce405f8d6f3b2ab0bee9eead4b9f4fc350e33bb4267956347f2158206c38b91c |
Hashes for ts2vg-1.2.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 276dc621e7a380fc4d496dff41b6deb47e0bd61e0d9ea2b437b11ff4d74acae1 |
|
MD5 | 17ee5607936728196bf6088b6a30b883 |
|
BLAKE2b-256 | 349de1e010ab69e7e78bf45f6c75870f2898182d2a6526b415e11891d10ff6e2 |
Hashes for ts2vg-1.2.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f02d4d26ee34ed714e3980a347eb4bdb3aca860bbcb302776be193073b9f4e4 |
|
MD5 | e21ef18ae495e5a48cc3cb44ab7f0764 |
|
BLAKE2b-256 | 7de789c3afa0acecae071f837b5d556157284e804978ae20ad454545eb47b0d8 |
Hashes for ts2vg-1.2.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96582848572d60d47cb91e99320d49a2bbc6e584bf4a3c59a8a64c828c16c088 |
|
MD5 | 3bec5ea01cda13975144b2a5d27bc24f |
|
BLAKE2b-256 | 06f274cd51d0a422bb9ec92cf742609162914a4cc5fe769a219325dcae6b8101 |
Hashes for ts2vg-1.2.4-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef8f5d16165a8e1e77e3800db36bb459869b9fd17821b69ca17aed0cf454ab99 |
|
MD5 | 18a3188ee4bde25d984c8785b235e00a |
|
BLAKE2b-256 | 5141b3244e715fd553b847533d224a7097511b2ae67c631cafb1f25a36bfe2e3 |
Hashes for ts2vg-1.2.4-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24aadc970ddc2d88cc50550fbb3a1777f5536928f7c009f2834fef07aec2e853 |
|
MD5 | 6343a5b9247fd4ecf3ffc7d05eff9d85 |
|
BLAKE2b-256 | 8b06ac188c28384839a8586902c15a87cd57ec9e712b22181d80bf547167bc76 |
Hashes for ts2vg-1.2.4-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c76c6c051138c5658c14211f4485ab98b9c924411b356718f3ddb83e3aea97ef |
|
MD5 | 44ba3ff2c3a34555a676f70f01fd8cdf |
|
BLAKE2b-256 | 9cad856d12a63e39f63b2e2db49a089f7a262bd2978ce6be091d75051d7c5a4a |
Hashes for ts2vg-1.2.4-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ba8e7b5be946719e5e2eaff856de73ca05d43d359437d80902d171a2a825c6e |
|
MD5 | e92482998d753b7a7b4d2ed026cd80b4 |
|
BLAKE2b-256 | 3e87d33244203522f3b0761ccf6bc54d11c43e1f05b8d2e62694ef70829f25b2 |
Hashes for ts2vg-1.2.4-cp311-cp311-musllinux_1_2_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 948cda910c0307291cf51ba2bb34757b229b1885b9990919aade05915b5c8434 |
|
MD5 | 2f3091bb0edc8db3782304bdb150b9e4 |
|
BLAKE2b-256 | 1a9727b3b4462dcc746a9c4da60ed8953cb720d7d32583e3cde95270a5b32dc9 |
Hashes for ts2vg-1.2.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65eaf3aaa655924c854eea658af3a4666b3940517db65e98988e23f78d99c654 |
|
MD5 | 612dca4573cea624169873a61530cfdd |
|
BLAKE2b-256 | 1c1728d34c25620235d5ff648dc2d21e2f0662217cb85dc674c18ec668b44d54 |
Hashes for ts2vg-1.2.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03c49466c98644f320e19016e62882947ea0722283b280a0cff998d76651eac0 |
|
MD5 | 155ae61ed54fa227f0a4c44400ff9be2 |
|
BLAKE2b-256 | bd9594e4ac795407f105252e0df8664551c7eeaf1ff499e53959fb5752533bc6 |
Hashes for ts2vg-1.2.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1d3fdcc92faaa3d97660a7bf6c1780735a8b67a9daba2217265fbaf32450f79 |
|
MD5 | f730a14ca5a9be12cad52c458e02ab6a |
|
BLAKE2b-256 | b0a3e02847070f25247197e4d05162a675c68e7394629466b97cefd4a397ba81 |
Hashes for ts2vg-1.2.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e3111dd79ff4c7a883d5b05f66650abf06b7c722c8319e4f0e15c292870c274 |
|
MD5 | 86d54598480e18c26f253322b62b3bb7 |
|
BLAKE2b-256 | a1c1b616f3673d13924b180ae2ee0ddc105843f4a17f579b2278f37c4264bd46 |
Hashes for ts2vg-1.2.4-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3876d79f7a6160070c19a016251e751a11a786ea18757c7cb260eea68a1dbbb |
|
MD5 | 94a58b3dabfc1a2a9d05a45ecf580062 |
|
BLAKE2b-256 | 34ee607d5909c458afa9cfcd809888e52234db95b884ea576de8c0ab4825b1c6 |
Hashes for ts2vg-1.2.4-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e3788a75bf8da7756ebc77b390811555d59007a915af19d723569568af384e7 |
|
MD5 | 556af25cb3d3bc2d95af296e71c9e53d |
|
BLAKE2b-256 | 8cf60880e43c6c4c66f1428bf8f92644b6523deeb846eb7c412c968c0f4f7fd6 |
Hashes for ts2vg-1.2.4-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18fa3ff74ebbfcf0f163725a0b6d30704e375b784bd3e538de2f2f91643add56 |
|
MD5 | 87e454660c8ba4a0e945d768cdc6354b |
|
BLAKE2b-256 | 4b523ee223e651409ddd03df464896ce8f42aee3903808481f38f6aef8817ffd |
Hashes for ts2vg-1.2.4-cp310-cp310-musllinux_1_2_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 237f516d517a71e74f5eb27b4626482baff7d24d881a98babd478d6921a3b950 |
|
MD5 | df7a9d904167cddcc4f9e60d8fcbed4f |
|
BLAKE2b-256 | 68fb561d368042b65cad2a7aa68404711049577e85e3b1852e4a9d5b59b303a0 |
Hashes for ts2vg-1.2.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa86a6db0469885e12430c3eeeb7b8393f9444076203769ac6e947119479ab6f |
|
MD5 | b89f7f2a117696c1921d8bcf4f53b239 |
|
BLAKE2b-256 | 765dd90aec1ae1ad591017d8fe2fbd4b641578e40da2ed3d91fa24be77e456ff |
Hashes for ts2vg-1.2.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f1f06810d6513821bc0beb169924e4fc804356514e6035854c12d50ddede839 |
|
MD5 | ea1ed270a0c73aeeb01e62282c3df189 |
|
BLAKE2b-256 | d620578d14254a4ca97b8ba8fcc3267b53d8f9654299c24ae03b39d391378a9b |
Hashes for ts2vg-1.2.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a1e4534fee32a377786193688b26434f3409a689ddcb86e4fb54b28b26bb279 |
|
MD5 | 686e93f33c313daf873d75187870016d |
|
BLAKE2b-256 | 911cec57fead4c06981a1bf151e5c3f98cdcf0ef82c263417c30644652582fa1 |
Hashes for ts2vg-1.2.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35e624aba334274788afc2566ff2e317a5ff17c42f16c8d3272bacab3eb1ae64 |
|
MD5 | 11ff834131933799ba345e42118c7427 |
|
BLAKE2b-256 | 02b50b24454c1c490e4ff10eec5ce1719b3e7ce6da4bd55dc70c9295532dbbc1 |
Hashes for ts2vg-1.2.4-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfb263ed97595c1227532743359462e66d35567029fb991ea8afb814dede0e04 |
|
MD5 | 65b07d845d6adda9580ad817bba10af7 |
|
BLAKE2b-256 | fe5caee8239dd3089018df80bb159e921e052d69bbde2145cf2ceb4aa07ca876 |
Hashes for ts2vg-1.2.4-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0000199b83effd9a78adad90fd9c54e7b2cf871949e230850e223ccd86f445a7 |
|
MD5 | ee7181bd395aec7aea0a5db6abe7c143 |
|
BLAKE2b-256 | 24ca38c91340f2a00539cf898cafafc90dd7b2f4826f1d46c23165e8d9b06196 |
Hashes for ts2vg-1.2.4-cp39-cp39-musllinux_1_2_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78ba9cb668d4c8387758fbef64f0afa330c856e99f2e605b04a139144988299f |
|
MD5 | 2ef9fb4a3d2c3d3ea0b91277b1aa0b4f |
|
BLAKE2b-256 | 8fde665f910b7c537aa153695f42ef374712ff960962ef5f5d9f7bcf6e510260 |
Hashes for ts2vg-1.2.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a01ce7a214578fca102405fa7a0cd86f0eb8b32fcd26ef2228c793117c86ca4 |
|
MD5 | d15bd04c7c4fb278995f9cbec997d21f |
|
BLAKE2b-256 | 52d8e8e31fbde4e023402e0da88712449b1168c9343800c2328861f40392331b |
Hashes for ts2vg-1.2.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fedfe1abb7cd3e016013af225ee248252076cb76c728dad5f92246e3225ba958 |
|
MD5 | 93542219c97352bc082c9e1ab3d15466 |
|
BLAKE2b-256 | 33b5f88c324b882a311ac8663be3a927225381f229e3f29d1b557a1ec639a761 |
Hashes for ts2vg-1.2.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ef5836726065c2a3c39b682cc87d9861dcb32bacc8308dd3898fa81d3ced970 |
|
MD5 | e44e9663ad9884d24879fa11676f4842 |
|
BLAKE2b-256 | 3f8e7326cf07d085ea33c090803f4ab011a8a8470d9b027cd0917df981235fd2 |
Hashes for ts2vg-1.2.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b56d82fb8d44759e9a1807177dc576048ce536a380cd36cd914bcf447f1389aa |
|
MD5 | b17311aa84c6e5577c7e0f06ae929a07 |
|
BLAKE2b-256 | d9dfdf4202cf41ac4945bae873662c0747243de89a75e7073d4b260a9f949d95 |