Temporal Random Walk
Considering a temporal network, we implement a framework that computes temporal random walk according to some sampling strategy.
Temporal network
A temporal network is a set of nodes and timestamped edges that exist within a period of time . This graph can be considered as a sequence of interactions, where each interaction is an event that comes in the form of a triplet , where and represent nodes in and is the time at which these nodes interacted with each other.
Temporal networks are encoded as dictionaries, where each key is a node in the graph and each corresponding value is a dictionary that maps for each timestep, a list of nodes which interacted with the key.
Temporal random walk
A temporal random walk is defined as a sequence of nodes in a temporal network. Such a walk exists between two nodes, if one can find a sequence of edges with non-decreasing timesteps that connects these two nodes.
Table of contents
1. Setup
Install dependencies
[~/]$ git clone https://github.com/simondelarue/TemporalRandomWalk.git
[~/]$ cd TemporalRandomWalk
[~/TemporalRandomWalk]$ python -m venv myvenv
[~/TemporalRandomWalk]$ source myvenv/bin/activate
(myvenv)[~/TemporalRandomWalk]$ pip install requirements.txt
2. Usage
Run python src/main.py
using the following arguments to chose data, size of test graph or sampling strategy:
Arguments
--data Data source {SF2H, HighSchool, ia-contact, ia-contacts_hypertext2009, fb-forum, ia-enron-employees}
--test_size Size of test dataset (in proportion of total number of edges)
--strategy Sampling strategy: \{linear, exponential, uniform\}
Example
$ python src/main.py --data SF2H --test_size 0.1 --strategy linear
Device : cpu
Preprocessing data ...
Splitting data ...
Creating stream graphs ...
Train graph
# nodes : 403
# edges : 133874
Test graph
# nodes : 201
# edges : 6648
Start edge: (306, 87, 145080)
Temporal random walk: [306, 87, 306, 87, 306, 87, 199, 79, 199, 79, 199, 79, 133, 165, 79, 199, 79, 199, 79, 133]
3. Datasets
In this work we use real-world datasets, where interactions between entities are encoded through events in the form of triplets , where and represent nodes in the graph, and is the time at which these nodes interacted with each other. We use the following datasets:
Dataset |
---|
SF2H |
HighSchool |
ia-contact |
ia-contacts-hypertext2009 |
ia-enron-employees |