https://github.com/carlosbergillos/ts2vg

Time series to visibility graphs.

https://github.com/carlosbergillos/ts2vg

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 1 committers (100.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.6%) to scientific vocabulary

Keywords

cli data-analysis graph igraph network networkx python snap time-series visibility-graph
Last synced: 5 months ago · JSON representation

Repository

Time series to visibility graphs.

Basic Info
Statistics
  • Stars: 102
  • Watchers: 3
  • Forks: 13
  • Open Issues: 4
  • Releases: 8
Topics
cli data-analysis graph igraph network networkx python snap time-series visibility-graph
Created over 5 years ago · Last pushed about 1 year ago
Metadata Files
Readme License

README.rst

.. |ts2vg| replace:: **ts2vg**

.. |cover| image:: https://raw.githubusercontent.com/CarlosBergillos/ts2vg/main/docs/source/images/cover_vg.png
   :width: 100 %
   :alt: Example plot of a visibility graph

.. _Examples: https://carlosbergillos.github.io/ts2vg/examples.html

.. _API Reference: https://carlosbergillos.github.io/ts2vg/api/index.html

.. sphinx-start

|ts2vg|: Time series to visibility graphs
===========================================

|pypi| |pyversions| |wheel| |license|

.. |pypi| image:: https://img.shields.io/pypi/v/ts2vg.svg
   :target: https://pypi.python.org/pypi/ts2vg

.. |pyversions| image:: https://img.shields.io/pypi/pyversions/ts2vg.svg
   :target: https://pypi.python.org/pypi/ts2vg

.. |wheel| image:: https://img.shields.io/pypi/wheel/ts2vg.svg
   :target: https://pypi.python.org/pypi/ts2vg

.. |license| image:: https://img.shields.io/pypi/l/ts2vg.svg
   :target: https://pypi.python.org/pypi/ts2vg

|cover|

|

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 [#Lacasa2008]_.

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 [#Lan2015]_.

   
Installation
------------

The latest released |ts2vg| version is available at the `Python Package Index (PyPI)`_
and can be easily installed by running:

.. code:: sh

   pip install ts2vg

For other advanced uses, to build |ts2vg| from source Cython is required.


Supported graph types
---------------------

Main graph types
~~~~~~~~~~~~~~~~

- Natural Visibility Graphs (NVG) [#Lacasa2008]_ (``ts2vg.NaturalVG``)
- Horizontal Visibility Graphs (HVG) [#Lacasa2009]_ (``ts2vg.HorizontalVG``)

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 [#Bezsudnov2014]_ (via the ``min_weight`` and ``max_weight`` parameters)
- Limited Penetrable Visibility Graphs (LPVG) [#Zhou2012]_ [#Xuan2021]_ (via the ``penetrable_limit`` parameter)

.. - Dual Perspective Visibility Graph [*planned, not implemented yet*]

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:

.. code:: python

   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:

.. code:: python

   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.

.. code:: python

   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:

.. code:: python

   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:** :ref:`Examples` and :ref:`API Reference`.

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:

.. -  :meth:`~ts2vg.graph.base.VG.as_igraph`
.. -  :meth:`~ts2vg.graph.base.VG.as_networkx`
.. -  :meth:`~ts2vg.graph.base.VG.as_snap`

-  ``as_igraph()``
-  ``as_networkx()``
-  ``as_snap()``

For example:

.. code:: python

   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:

.. code:: sh

   ts2vg ./timeseries.txt -o out.edg 

For more help and a list of options run:

.. code:: sh

   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`_.

.. _NumPy: https://numpy.org/
.. _Cython: https://cython.org/
.. _Python Package Index (PyPI): https://pypi.org/project/ts2vg
.. _igraph: https://igraph.org/python/
.. _NetworkX: https://networkx.github.io/
.. _SNAP: https://snap.stanford.edu/snappy/
.. _on GitHub: https://github.com/CarlosBergillos/ts2vg
.. _MIT License: https://github.com/CarlosBergillos/ts2vg/blob/main/LICENSE
.. _carlosbergillos.github.io/ts2vg: https://carlosbergillos.github.io/ts2vg/


References
----------

.. [#Lacasa2008] Lucas Lacasa et al., "*From time series to complex networks: The visibility graph*", 2008.
.. [#Lacasa2009] Lucas Lacasa et al., "*Horizontal visibility graphs: exact results for random time series*", 2009.
.. [#Lan2015] Xin Lan et al., "*Fast transformation from time series to visibility graphs*", 2015.
.. [#Zhou2012] T.T Zhou et al., "*Limited penetrable visibility graph for establishing complex network from time series*", 2012.
.. [#Bezsudnov2014] I.V. Bezsudnov et al., "*From the time series to the complex networks: The parametric natural visibility graph*", 2014
.. [#Xuan2021] Qi Xuan et al., "*CLPVG: Circular limited penetrable visibility graph as a new network model for time series*", 2021

Owner

  • Name: Carlos Bergillos
  • Login: CarlosBergillos
  • Kind: user
  • Location: Barcelona

🌍🛩

GitHub Events

Total
  • Watch event: 15
  • Issue comment event: 4
  • Push event: 5
  • Pull request event: 2
  • Fork event: 1
Last Year
  • Watch event: 15
  • Issue comment event: 4
  • Push event: 5
  • Pull request event: 2
  • Fork event: 1

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 114
  • Total Committers: 1
  • Avg Commits per committer: 114.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Carlos Bergillos c****a@e****u 114
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 12
  • Total pull requests: 27
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 4 days
  • Total issue authors: 12
  • Total pull request authors: 3
  • Average comments per issue: 4.0
  • Average comments per pull request: 0.22
  • Merged pull requests: 23
  • Bot issues: 0
  • Bot pull requests: 6
Past Year
  • Issues: 0
  • Pull requests: 2
  • Average time to close issues: N/A
  • Average time to close pull requests: 2 days
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 2.5
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • SunderlandAJ-1130 (1)
  • ACatAC (1)
  • Yuheng0912 (1)
  • nhaboudal (1)
  • JTJest (1)
  • sahaj432 (1)
  • ondrish (1)
  • zoubaihan (1)
  • taulokoka (1)
  • jjruby09 (1)
  • ajb5d (1)
  • rnjv (1)
Pull Request Authors
  • CarlosBergillos (19)
  • dependabot[bot] (6)
  • DerAndereJohannes (2)
Top Labels
Issue Labels
Pull Request Labels
dependencies (6)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 6,590 last-month
  • Total dependent packages: 5
  • Total dependent repositories: 2
  • Total versions: 9
  • Total maintainers: 1
pypi.org: ts2vg

Build visibility graphs from time series data.

  • Homepage: https://carlosbergillos.github.io/ts2vg
  • Documentation: https://carlosbergillos.github.io/ts2vg
  • License: MIT License Copyright (c) 2020 Carlos Bergillos Varela Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • Latest release: 1.2.4
    published over 1 year ago
  • Versions: 9
  • Dependent Packages: 5
  • Dependent Repositories: 2
  • Downloads: 6,590 Last month
Rankings
Dependent packages count: 1.9%
Downloads: 7.1%
Average: 8.1%
Stargazers count: 9.1%
Forks count: 10.9%
Dependent repos count: 11.5%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/docs.yml actions
  • JamesIves/github-pages-deploy-action v4 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/package-pypi.yml actions
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
  • pypa/cibuildwheel v2.12.0 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/package-test-pypi.yml actions
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
  • pypa/cibuildwheel v2.12.0 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/tests.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
docs_requirements.txt pypi
  • Babel ==2.11.0
  • Jinja2 ==3.0.3
  • MarkupSafe ==2.1.2
  • Pygments ==2.15.0
  • Sphinx ==3.5.4
  • alabaster ==0.7.13
  • beautifulsoup4 ==4.11.1
  • certifi ==2023.7.22
  • charset-normalizer ==3.0.1
  • docutils ==0.16
  • idna ==3.4
  • imagesize ==1.4.1
  • packaging ==23.0
  • pydata-sphinx-theme ==0.6.3
  • pytz ==2022.7.1
  • requests ==2.31.0
  • snowballstemmer ==2.2.0
  • soupsieve ==2.3.2.post1
  • sphinxcontrib-devhelp ==1.0.2
  • sphinxcontrib-htmlhelp ==2.0.0
  • sphinxcontrib-jsmath ==1.0.1
  • sphinxcontrib-qthelp ==1.0.3
  • sphinxcontrib-serializinghtml ==1.1.5
  • sphinxcontrib.applehelp ==1.0.3
  • urllib3 ==1.26.18
pyproject.toml pypi
setup.py pypi