{"id":13411999,"url":"https://github.com/CarlosBergillos/ts2vg","last_synced_at":"2025-03-14T17:31:27.143Z","repository":{"id":48185720,"uuid":"272304593","full_name":"CarlosBergillos/ts2vg","owner":"CarlosBergillos","description":"Time series to visibility graphs.","archived":false,"fork":false,"pushed_at":"2024-07-13T13:39:36.000Z","size":3733,"stargazers_count":83,"open_issues_count":4,"forks_count":12,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-10-02T07:46:53.768Z","etag":null,"topics":["cli","data-analysis","graph","igraph","network","networkx","python","snap","time-series","visibility-graph"],"latest_commit_sha":null,"homepage":"https://carlosbergillos.github.io/ts2vg","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CarlosBergillos.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-15T00:06:25.000Z","updated_at":"2024-09-09T20:54:48.000Z","dependencies_parsed_at":"2024-06-20T00:07:00.376Z","dependency_job_id":"87783020-85b3-4b45-a362-8880c9fe3812","html_url":"https://github.com/CarlosBergillos/ts2vg","commit_stats":{"total_commits":114,"total_committers":1,"mean_commits":114.0,"dds":0.0,"last_synced_commit":"cab95e261feedb13974ea5eb8c0453b5b5047c56"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarlosBergillos%2Fts2vg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarlosBergillos%2Fts2vg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarlosBergillos%2Fts2vg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CarlosBergillos%2Fts2vg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CarlosBergillos","download_url":"https://codeload.github.com/CarlosBergillos/ts2vg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243618714,"owners_count":20320281,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","data-analysis","graph","igraph","network","networkx","python","snap","time-series","visibility-graph"],"created_at":"2024-07-30T20:01:19.955Z","updated_at":"2025-03-14T17:31:22.133Z","avatar_url":"https://github.com/CarlosBergillos.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":".. |ts2vg| replace:: **ts2vg**\n\n.. |cover| image:: https://raw.githubusercontent.com/CarlosBergillos/ts2vg/main/docs/source/images/cover_vg.png\n   :width: 100 %\n   :alt: Example plot of a visibility graph\n\n.. _Examples: https://carlosbergillos.github.io/ts2vg/examples.html\n\n.. _API Reference: https://carlosbergillos.github.io/ts2vg/api/index.html\n\n.. sphinx-start\n\n|ts2vg|: Time series to visibility graphs\n===========================================\n\n|pypi| |pyversions| |wheel| |license|\n\n.. |pypi| image:: https://img.shields.io/pypi/v/ts2vg.svg\n   :target: https://pypi.python.org/pypi/ts2vg\n\n.. |pyversions| image:: https://img.shields.io/pypi/pyversions/ts2vg.svg\n   :target: https://pypi.python.org/pypi/ts2vg\n\n.. |wheel| image:: https://img.shields.io/pypi/wheel/ts2vg.svg\n   :target: https://pypi.python.org/pypi/ts2vg\n\n.. |license| image:: https://img.shields.io/pypi/l/ts2vg.svg\n   :target: https://pypi.python.org/pypi/ts2vg\n\n|cover|\n\n|\n\nThe Python |ts2vg| package provides high-performance algorithm\nimplementations to build visibility graphs from time series data,\nas first introduced by Lucas Lacasa et al. in 2008 [#Lacasa2008]_.\n\nThe visibility graphs and some of their properties (e.g. degree\ndistributions) are computed quickly and efficiently even for time\nseries with millions of observations.\nAn efficient divide-and-conquer algorithm is used to compute the graphs\nwhenever possible [#Lan2015]_.\n\n   \nInstallation\n------------\n\nThe latest released |ts2vg| version is available at the `Python Package Index (PyPI)`_\nand can be easily installed by running:\n\n.. code:: sh\n\n   pip install ts2vg\n\nFor other advanced uses, to build |ts2vg| from source Cython is required.\n\n\nSupported graph types\n---------------------\n\nMain graph types\n~~~~~~~~~~~~~~~~\n\n- Natural Visibility Graphs (NVG) [#Lacasa2008]_ (``ts2vg.NaturalVG``)\n- Horizontal Visibility Graphs (HVG) [#Lacasa2009]_ (``ts2vg.HorizontalVG``)\n\nAvailable variations\n~~~~~~~~~~~~~~~~~~~~\n\nAdditionally, the following variations of the previous main graph types are available:\n\n- Weighted Visibility Graphs (via the ``weighted`` parameter)\n- Directed Visibility Graphs (via the ``directed`` parameter)\n- Parametric Visibility Graphs [#Bezsudnov2014]_ (via the ``min_weight`` and ``max_weight`` parameters)\n- Limited Penetrable Visibility Graphs (LPVG) [#Zhou2012]_ [#Xuan2021]_ (via the ``penetrable_limit`` parameter)\n\n.. - Dual Perspective Visibility Graph [*planned, not implemented yet*]\n\nNote that multiple graph variations can be combined and used at the same time.\n\n\nDocumentation\n-------------\n\nUsage and reference documentation for |ts2vg| can be found at `carlosbergillos.github.io/ts2vg`_.\n\n\nBasic usage\n-----------\n\nTo build a visibility graph from a time series do:\n\n.. code:: python\n\n   from ts2vg import NaturalVG\n\n   ts = [1.0, 0.5, 0.3, 0.7, 1.0, 0.5, 0.3, 0.8]\n\n   vg = NaturalVG()\n   vg.build(ts)\n\n   edges = vg.edges\n\n\nThe time series passed (``ts``) can be any one-dimensional iterable, such as a list or a ``numpy`` 1D array.\n\nBy default, the input observations are assumed to be equally spaced in time.\nAlternatively, a second 1D iterable (``xs``) can be provided for unevenly spaced time series.\n\n\nHorizontal visibility graphs can be obtained in a very similar way:\n\n.. code:: python\n\n   from ts2vg import HorizontalVG\n\n   ts = [1.0, 0.5, 0.3, 0.7, 1.0, 0.5, 0.3, 0.8]\n\n   vg = HorizontalVG()\n   vg.build(ts)\n\n   edges = vg.edges\n\n\nIf we are only interested in the degree distribution of the visibility graph\nwe can pass ``only_degrees=True`` to the ``build`` method.\nThis will be more efficient in time and memory than storing the whole graph.\n\n.. code:: python\n\n   vg = NaturalVG()\n   vg.build(ts, only_degrees=True)\n\n   ks, ps = vg.degree_distribution\n\n\nDirected graphs can be obtained by using the ``directed`` parameter\nand weighted graphs can be obtained by using the ``weighted`` parameter:\n\n.. code:: python\n\n   vg1 = NaturalVG(directed=\"left_to_right\")\n   vg1.build(ts)\n\n   vg2 = NaturalVG(weighted=\"distance\")\n   vg2.build(ts)\n\n   vg3 = NaturalVG(directed=\"left_to_right\", weighted=\"distance\")\n   vg3.build(ts)\n\n   vg4 = HorizontalVG(directed=\"left_to_right\", weighted=\"h_distance\")\n   vg4.build(ts)\n\n\n.. **For more information and options see:** :ref:`Examples` and :ref:`API Reference`.\n\nFor more information and options see: `Examples`_ and `API Reference`_.\n\n\nInteroperability with other libraries\n-------------------------------------\n\nThe graphs obtained can be easily converted to graph objects\nfrom other common Python graph libraries such as `igraph`_, `NetworkX`_ and `SNAP`_\nfor further analysis.\n\nThe following methods are provided:\n\n.. -  :meth:`~ts2vg.graph.base.VG.as_igraph`\n.. -  :meth:`~ts2vg.graph.base.VG.as_networkx`\n.. -  :meth:`~ts2vg.graph.base.VG.as_snap`\n\n-  ``as_igraph()``\n-  ``as_networkx()``\n-  ``as_snap()``\n\nFor example:\n\n.. code:: python\n\n   vg = NaturalVG()\n   vg.build(ts)\n   \n   g = vg.as_networkx()\n\n\nCommand line interface\n----------------------\n\n|ts2vg| can also be used as a command line program directly from the console:\n\n.. code:: sh\n\n   ts2vg ./timeseries.txt -o out.edg \n\nFor more help and a list of options run:\n\n.. code:: sh\n\n   ts2vg --help\n\n\nContributing\n------------\n\n|ts2vg| can be found `on GitHub`_.\nPull requests and issue reports are welcome.\n\n\nLicense\n-------\n\n|ts2vg| is licensed under the terms of the `MIT License`_.\n\n.. _NumPy: https://numpy.org/\n.. _Cython: https://cython.org/\n.. _Python Package Index (PyPI): https://pypi.org/project/ts2vg\n.. _igraph: https://igraph.org/python/\n.. _NetworkX: https://networkx.github.io/\n.. _SNAP: https://snap.stanford.edu/snappy/\n.. _on GitHub: https://github.com/CarlosBergillos/ts2vg\n.. _MIT License: https://github.com/CarlosBergillos/ts2vg/blob/main/LICENSE\n.. _carlosbergillos.github.io/ts2vg: https://carlosbergillos.github.io/ts2vg/\n\n\nReferences\n----------\n\n.. [#Lacasa2008] Lucas Lacasa et al., \"*From time series to complex networks: The visibility graph*\", 2008.\n.. [#Lacasa2009] Lucas Lacasa et al., \"*Horizontal visibility graphs: exact results for random time series*\", 2009.\n.. [#Lan2015] Xin Lan et al., \"*Fast transformation from time series to visibility graphs*\", 2015.\n.. [#Zhou2012] T.T Zhou et al., \"*Limited penetrable visibility graph for establishing complex network from time series*\", 2012.\n.. [#Bezsudnov2014] I.V. Bezsudnov et al., \"*From the time series to the complex networks: The parametric natural visibility graph*\", 2014\n.. [#Xuan2021] Qi Xuan et al., \"*CLPVG: Circular limited penetrable visibility graph as a new network model for time series*\", 2021\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCarlosBergillos%2Fts2vg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCarlosBergillos%2Fts2vg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCarlosBergillos%2Fts2vg/lists"}