GithubHelp home page GithubHelp logo

jwill1994 / visibility_graph Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rgarcia-herrera/visibility_graph

0.0 0.0 0.0 21 KB

Algorithm to create graphs from time series.

License: GNU General Public License v3.0

Python 100.00%

visibility_graph's Introduction

Visibility Graph Algorithm

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.node[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."

image

"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:"

image

visibility_graph's People

Contributors

rgarcia-herrera avatar suta0001 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.