Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrozanec committed Mar 27, 2024
1 parent 95b37fc commit df872ca
Show file tree
Hide file tree
Showing 5 changed files with 267 additions and 46 deletions.
221 changes: 206 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,211 @@ TS2G<sup>2</sup> stands for "timeseries to graphs and back". The library impleme

Many of the methods implemented in this library, are described in _Silva, Vanessa Freitas, et al. "Time series analysis via network science: Concepts and algorithms." Wiley Interdisciplinary Reviews: Data Mining and Knowledge Discovery 11.3 (2021): e1404._ Nevertheless, the library also includes additional techniques found in other works from the scientific literature.

This package is being developed as part of the [Graph-Massivizer](https://graph-massivizer.eu/) project.
The package is a joint effort between the [Jožef Stefan Institute](https://www.ijs.si/), the [University of Twente](https://www.utwente.nl/en/), the [Vrije Universiteit Amsterdam](https://vu.nl/en), the [University of Klagenfurt](https://www.aau.at/en/), the [University of Bologna](https://www.unibo.it/en), and [Peracton](https://peracton.com/).


### Timeseries to graph conversion

| | Method | Reference | Implementing strategy |
|---|-----------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| 1 | Natural Visibility Graph | [From time series to complex networks: The visibility graph.](https://www.pnas.org/doi/10.1073/pnas.0709247105) | NaturalVisibilityGraphStrategy |
| 2 | Horizontal Visibility Graph | [Horizontal visibility graphs: Exact results for random time series.](https://journals.aps.org/pre/abstract/10.1103/PhysRevE.80.046103) | HorizontalVisibilityGraphStrategy |
| 3 | Directed Horizontal Visibility Graph | [Time series irreversibility: a visibility graph approach.](https://link.springer.com/article/10.1140/epjb/e2012-20809-8) | DirectedHorizontalVisibilityGraphStrategy |
| 4 | Limited Penetrable Natural Visibility Graph | [Limited penetrable visibility graph for establishing complex network from time series](https://www.semanticscholar.org/paper/Limited-penetrable-visibility-graph-for-complex-Zhou-Jin/fe4a3d2f486021ee066f8a80472deef57d8aee71) | LimitedPenetrableNaturalVisibilityGraphStrategy |
| 5 | Limited Penetrable Horizontal Visibility Graph | [Multiscale limited penetrable horizontal visibility graph for analyzing nonlinear time series](https://www.nature.com/articles/srep35622) | LimitedPenetrableHorizontalVisibilityGraphStrategy |
| 6 | Limited Penetrable Directed Horizontal Visibility Graph | | LimitedPenetrableDirectedHorizontalVisibilityGraphStrategy |
#### Implemented features

<style type="text/css">
.tg {border-collapse:collapse;border-spacing:0;}
.tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
overflow:hidden;padding:10px 5px;word-break:normal;}
.tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
.tg .tg-7btt{border-color:inherit;font-weight:bold;text-align:center;vertical-align:top}
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
</style>
<table class="tg">
<thead>
<tr>
<th class="tg-7btt" rowspan="3">#</th>
<th class="tg-7btt" rowspan="3">Visibility Graph</th>
<th class="tg-7btt" colspan="3">Graph type</th>
<th class="tg-7btt" colspan="4">Constraints</th>
</tr>
<tr>
<th class="tg-7btt" rowspan="2">Undirected</th>
<th class="tg-7btt" rowspan="2">Directed</th>
<th class="tg-7btt" rowspan="2">Weighted</th>
</tr>
<tr>
<th class="tg-7btt">Penetration</th>
<th class="tg-7btt">Angle</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tg-7btt">1</td>
<td class="tg-0pky">Natural Visibility Graph</td>
<td class="tg-0pky">
X
</td>
<td class="tg-0pky">
<!-- directed -->
X
</td>
<td class="tg-0pky">
<!-- weighted -->
X
</td>
<td class="tg-0pky">
<!-- constraints:references: penetration -->
X
</td>
<td class="tg-0pky">
<!-- constraints:references: angle -->
X
</td>
</tr>
<tr>
<td class="tg-7btt">2</td>
<td class="tg-0pky">Horizontal Visibility Graph</td>
<td class="tg-0pky">
X
</td>
<td class="tg-0pky">
<!-- directed -->
X
</td>
<td class="tg-0pky">
<!-- weighted -->
X
</td>
<td class="tg-0pky">
<!-- constraints:references: penetration -->
X
</td>
<td class="tg-0pky">
<!-- constraints:references: angle -->
X
</td>
</tr>
<tr>
<td class="tg-7btt">3</td>
<td class="tg-0pky">Difference Visibility Graph</td>
<td class="tg-0pky">
<!-- undirected -->
</td>
<td class="tg-0pky">
<!-- directed -->
</td>
<td class="tg-0pky">
<!-- weighted -->
</td>
<td class="tg-0pky">
<!-- constraints:references: penetration -->
</td>
<td class="tg-0pky">
<!-- constraints:references: angle -->
</td>
</tr>
</tbody>
</table>


#### References table

<style type="text/css">
.tg {border-collapse:collapse;border-spacing:0;}
.tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
overflow:hidden;padding:10px 5px;word-break:normal;}
.tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
.tg .tg-7btt{border-color:inherit;font-weight:bold;text-align:center;vertical-align:top}
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
</style>
<table class="tg">
<thead>
<tr>
<th class="tg-7btt" rowspan="3">#</th>
<th class="tg-7btt" rowspan="3">Visibility Graph</th>
<th class="tg-7btt" colspan="3">Graph type</th>
<th class="tg-7btt" colspan="4">Constraints</th>
</tr>
<tr>
<th class="tg-7btt" rowspan="2">Undirected</th>
<th class="tg-7btt" rowspan="2">Directed</th>
<th class="tg-7btt" rowspan="2">Weighted</th>
</tr>
<tr>
<th class="tg-7btt">Penetration</th>
<th class="tg-7btt">Angle</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tg-7btt">1</td>
<td class="tg-0pky">Natural Visibility Graph</td>
<td class="tg-0pky">
<a href="https://www.pnas.org/doi/10.1073/pnas.0709247105">ref</a>
</td>
<td class="tg-0pky">
<!-- directed -->
<a href="https://link.springer.com/article/10.1140/epjb/e2012-20809-8">ref</a>
</td>
<td class="tg-0pky">
<!-- weighted -->
</td>
<td class="tg-0pky">
<!-- constraints:references: penetration -->
<a href="https://www.semanticscholar.org/paper/Limited-penetrable-visibility-graph-for-complex-Zhou-Jin/fe4a3d2f486021ee066f8a80472deef57d8aee71">ref</a>
</td>
<td class="tg-0pky">
<!-- constraints:references: angle -->
<a href="https://doi.org/10.1109/ACCESS.2016.2612242">ref</a>,
<a href="https://doi.org/10.1016/j.physa.2014.07.002">ref</a>
</td>
</tr>
<tr>
<td class="tg-7btt">2</td>
<td class="tg-0pky">Horizontal Visibility Graph</td>
<td class="tg-0pky">
<a href="https://journals.aps.org/pre/abstract/10.1103/PhysRevE.80.046103">ref</a>
</td>
<td class="tg-0pky">
<a href="https://link.springer.com/article/10.1140/epjb/e2012-20809-8">ref</a>
<!-- directed -->
</td>
<td class="tg-0pky">
<!-- weighted -->
<a href="https://doi.org/10.1109/ACCESS.2016.2612242">ref</a>
</td>
<td class="tg-0pky">
<!-- constraints:references: penetration -->
<a href="https://www.semanticscholar.org/paper/Limited-penetrable-visibility-graph-for-complex-Zhou-Jin/fe4a3d2f486021ee066f8a80472deef57d8aee71">ref</a>,
<a href="https://www.nature.com/articles/srep35622">ref</a>
</td>
<td class="tg-0pky">
<!-- constraints:references: angle -->
</td>
</tr>
<tr>
<td class="tg-7btt">3</td>
<td class="tg-0pky">Difference Visibility Graph</td>
<td class="tg-0pky">
<!-- undirected -->
</td>
<td class="tg-0pky">
<!-- directed -->
</td>
<td class="tg-0pky">
<!-- weighted -->
</td>
<td class="tg-0pky">
<!-- constraints:references: penetration -->
</td>
<td class="tg-0pky">
<!-- constraints:references: angle -->
</td>
</tr>
</tbody>
</table>

- Weighted Visibility Graphs
- Parametric Natural/Horizontal Visibility Graphs


| 6 | Limited Penetrable Directed Horizontal Visibility Graph | | LimitedPenetrableDirectedHorizontalVisibilityGraphStrategy |
| 6 | Limited Penetrable Directed Horizontal Visibility Graph | | LimitedPenetrableDirectedHorizontalVisibilityGraphStrategy |
| 6 | Limited Penetrable Directed Horizontal Visibility Graph | | LimitedPenetrableDirectedHorizontalVisibilityGraphStrategy |
| 6 | Limited Penetrable Directed Horizontal Visibility Graph | | LimitedPenetrableDirectedHorizontalVisibilityGraphStrategy |
| 6 | Limited Penetrable Directed Horizontal Visibility Graph | | LimitedPenetrableDirectedHorizontalVisibilityGraphStrategy |
### Graphs to timeseries conversion

Graphs are converted back to timeseries by sampling node values from the graph following different strategies. The following strategies have been implemented so far:
Expand All @@ -42,3 +225,11 @@ Graphs are converted back to timeseries by sampling node values from the graph f
- random walk with restart
- random walk with jump


## Publications

When using this work for research purposes, we would appreciate it if the following references could be included:


Below we provide a curated list of papers related to our research in this area:

Empty file removed tests/input/__init__.py
Empty file.
8 changes: 0 additions & 8 deletions tests/input/timeseries.py

This file was deleted.

30 changes: 30 additions & 0 deletions tests/test_timeseries_strategies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import unittest
from unittest.mock import Mock
from core.model import TimeseriesGraph
from timeseries.strategies import TimeseriesToGraphStrategy

class TestToGraphMethod(unittest.TestCase):

def test_to_graph(self):
class MockVisibilityConstraint:
def is_obstructed(self, timeseries, x1, x2, y1, y2):
return False # Mock always returns False for visibility

# Set up the test
self.strategy_instance = TimeseriesToGraphStrategy([MockVisibilityConstraint()])

# Call the to_graph method with the mock timeseries stream
result_graph = self.strategy_instance.to_graph([1, 2, 3, 4, 5])

# Check if the result is an instance of TimeseriesGraph
self.assertIsInstance(result_graph, TimeseriesGraph)

# Check if the graph has been constructed correctly
expected_nodes = [0, 1, 2, 3, 4]
expected_edges = [(0, 1, {'weight': 1}), (1, 2, {'weight': 1}),
(2, 3, {'weight': 1}), (3, 4, {'weight': 1})]
self.assertEqual(sorted(result_graph.graph.nodes()), expected_nodes)
self.assertEqual(sorted(result_graph.graph.edges(data=True)), expected_edges)

if __name__ == '__main__':
unittest.main()
Loading

0 comments on commit df872ca

Please sign in to comment.