Chapter 12 Temporal

In the previous chapter we built a graph with dynamic edges. Let’s build a fully dynamic graph where both nodes and edges appear when they are first created.

12.1 Collect

We again collect tweets in a slightly different manner but feel free to use data from a previous chapter. We specify type as mixed in order to get a mix of popular and recent tweets.

## Searching for tweets...
## Finished collecting tweets!

12.3 Visualise

Again, we unpack the network and prepare nodes and edges for our visualisation. Then we define a rescale functiion to ensure our treatment of the date time columns are consistent across nodes and edges.

rtweet returns date time but sigmajs expects milliseconds; it needs to be converted.

Next we prepare the data, we define the t argument of our rescale function defined above as a constant so as to make sure we apply the same scale to both nodes and edges.

Now the actual visualisation, then again, we set cumsum = FALSE, and add a button (linked to two events add_nodes and add_edges) to let you trigger the visualisation. before then you should see a blank canvas.

We forgot the layout and we do not color the nodes, let’s compute the layout and the clusters to color nodes.

## Found # 325 clusters

So we transformed our date time to milliseconds and rescaled to span 10 seconds. The problem with this is that we, in a way, lose track of time in the visualisation itself. It’d be great to add a ticker to display, say, the date.

Let’s explain how this is done in sigmajs; we simply create a table that maps dates to our milliseconds delay. To do so we extract the dates from our net object, we then rescale those dates just like we did for the nodes and edges.

dates delay
2018-08-06 0.0000
2018-08-07 749.5644
2018-08-08 1810.6870
2018-08-09 2724.6452
2018-08-10 3723.9730
2018-08-11 4691.6773

Now, how do we use this mapping table in sigmajs?