Once you have successfully installed pathpy
, as a first step we can work through a basic (temporal) network analysis and visualisation example. Here, we assume that your are working in a jupyter
notebook, but feel free to use any python
-friendly development environment like, e.g. pyCharm or Visual Studio Code.
Assuming that you have installed jupyter
, we first start a new notebook server. Open a terminal window and type:
This will bring up your system's default browser. Click the New
button to create an empty python 3 notebook. In this notebook, we first need to import pathpy
. In the first empty cell of the notebook enter the following code and run the cell, e.g. by pressing Shift+Enter
:
We can create a toy example (directed) network by adding the following code and then running the cell:
The print
statement will output a default string representation of the instance, which provides basic information on the type of the network and the number of nodes and links. To visualize this network, we can simply type the name of the variable in a new jupyter
cell and execute it:
In jupyter
, this will output a basic network visualisation that is actually interactive, i.e. you can drag nodes with the mouse, you can pan and you can zoom with the mouse wheel. To calculate node centralities, we can use the functions in the module pathpy.algorithms.centralities
. To calculate the betweenness centralities of all nodes, we can write:
Executing this cell will print a dictionary that contains the betweenness centralities of all nodes. We can easily use this centralities to influence the visualisation of the network by means of pathpy
's styling mechanism. For instance, to scale the sizes of nodes according to their betweenness centrality we can write:
For more advanced network analysis and visualisation features, including pathpy
's templating mechanism that gives you the full power of CSS and JavaScript, we refer the reader to this three hour hands-on tutorial.