Introduction and dataset
After reading data into Raphtory we can now make use of the graph representation to ask some interesting questions. This example will use a dataset from SocioPatterns, comprising different behavioral interactions between a group of 22 baboons over a month.
If you want to read more about the dataset, you can check it out in this paper: V. Gelardi, J. Godard, D. Paleressompoulle, N. Claidière, A. Barrat, "Measuring social networks in primates: wearable sensors vs. direct observations", Proc. R. Soc. A 476:20190737 (2020).
In the below code loads this dataset into a dataframe and does a small amount of preprocessing to prepare it for loading into Raphtory. This includes dropping rows with blank fields and mapping the values of the behavior category into a weight which can be aggregated. The mapping consists of the following conversions:
- Affiliative (positive interaction) →
+1 - Agonistic (negative interaction) →
-1 - Other (neutral interaction) →
0
Next we load this dataframe into Raphtory using the load_edges() function, modelling it as a weighted multi-layer graph, with a layer per unique behavior.