pathpy / pathpy

An OpenSource python package for the analysis of time series data on networks using higher-order and multi-order graphical models.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unclear implementation of temporal edge

IngoScholtes opened this issue · comments

Not sure whether this is a bug or whether I am misunderstanding the interface. In any case, the current interface is unclear because time attributes (start, end, timestamp) used to create temporal edges are not included in the resulting TemporalEdge objects:

See following code:

>>> tn = pp.TemporalNetwork()
>>> tn.add_edge('a', 'b', timestamp=1)
>>> tn.add_edge('b', 'c', timestamp=2)
>>> tn.add_edge('b', 'd', timestamp=5)
>>> for e in tn.edges:
>>>     print(e)
>>>     print(e['timestamp'])
>>>     print('---')
Uid:		0x2005aa510b8
Type:		TemporalEdge
Source node:	TemporalNode a
Target node:	TemporalNode b
None
---
Uid:		0x2005aa51160
Type:		TemporalEdge
Source node:	TemporalNode b
Target node:	TemporalNode c
None
---
Uid:		0x2005aa513c8
Type:		TemporalEdge
Source node:	TemporalNode b
Target node:	TemporalNode d
None
---

Do I understand correctly that one should iterate through tedges instead?

>>> for start, end, e in tn.tedges:
>>>     print(tn.edges[e])
>>>     print(start)
>>>     print(end)
>>>     print('---')
Uid:		0x2005aa510b8
Type:		TemporalEdge
Source node:	TemporalNode a
Target node:	TemporalNode b
1
2.0
---
Uid:		0x2005aa51160
Type:		TemporalEdge
Source node:	TemporalNode b
Target node:	TemporalNode c
2
3.0
---
Uid:		0x2005aa513c8
Type:		TemporalEdge
Source node:	TemporalNode b
Target node:	TemporalNode d
5
6.0
---

Currently network.edges return a set with the temporal edges i.e. each occurs only once, while tedges return a list of order timestamped edges similar to pathpy2:

tn = pp.TemporalNetwork()
tn.add_edge('a', 'b', timestamp=1,uid = ab)
tn.add_edge('a', 'b', timestamp=4, uid = ab)

print(tn.edges)
{Edge ab}

print(tn.edges)
[(1, 2, 'ab'): Edge ab, (4, 5 ,'ab'): Edge ab}

We can return the timestamped edges via the command network.edges but this will change completely the interface compared to all the other objects using the same property.

I see. I think that design is fine, but the question is how we can access the time properties that were set in the temporal edge creation. Shouldn't the temporal edge have a timestamp, begin, end attribute as well?

Folllowing a clarification from Jürgen, I now see that each TemporalEdge object represents all time-stamped occurrences of that edge. Need to improve the documentation, but closing this for now.