network animation with static nodes in python or even webgl

366 views Asked by At

So I have a particular task I need help with, but I was not sure how to do it. I have a model for the formation of ties between a fixed set of network nodes. So I want to set up a window or visualization that shows the set of all nodes on some sort of 2-dimensional or 3-dimensional grid. Then for each timestep, I want to update the visualization window with the latest set of ties between nodes. So I would start with a set of nodes positioned in space, and then with each timestep the visualization will gradually add the new edges.

The challenge here is that I know in something like networkx, redrawing the network at each timestep won't work. Many of the common network display algorithms randomly place nodes so that as to maximize the distance between thenm and better show the edges. So if I were to redraw the network at each timestep, the nodes would end up in different locations each time, and it would be hard to identify the pattern of network growth. That is why I want a set of static nodes, so I can see how the edges get added at each timestep.

I am looking to visualize about 100 nodes at a time. So I will start with a small number of nodes like 20 or so, and gradually build up to 100 nodes. After the model is validated, then I would build up to 1000 or 2000 nodes. Of course it is hard to visualize 1000 or 2000 node network, that is why I just want to make sure I can visualize the network when I just have 100 nodes in the simulation.

I was not sure if I could do this in webgl or something, or if there is a good way to do this in python. I can use Vispy for communication between python and webgl if needed.

1

There are 1 answers

0
Cyrille Rossant On BEST ANSWER

This looks like a good use-case for Vispy indeed. You'd need to use a PointVisual for the nodes, and a LineVisual for the edges. Then you can update the edges in real time as the simulation is executed.

The animation would also work in the IPython notebook with WebGL.

Note that other graphics toolkits might also work for you (although you'd not necessarily have GPU acceleration through OpenGL) if you specify static positions for the nodes. I think you can fix the nodes positions with d3js or networkx instead of relying on an automatic layout algorithm.