Connection patterns

Network Analysis in the Tidyverse

Massimo Franceschet

Prof. of Data Science, University of Udine (Italy)

The adjacency matrix (part 1)

An undirected network

 

as_adjacency_matrix(g)
    1    2    3    4    5    6
1   0    1    0    0    1    0
2   1    0    1    1    0    0
3   0    1    0    1    1    1
4   0    1    1    0    0    0
5   1    0    1    0    0    0
6   0    0    1    0    0    0
Network Analysis in the Tidyverse

The adjacency matrix (part 2)

A weighted network

 

as_adjacency_matrix(g, 
                    attr="weight")
     1    2    3    4    5    6
1    0    1    0    0    2    0
2    1    0    2    3    0    0
3    0    2    0    4    5    1
4    0    3    4    0    0    0
5    2    0    5    0    0    0
6    0    0    1    0    0    0
Network Analysis in the Tidyverse

Working with adjacency matrices

# get the adjacency matrix of network g
A = as_adjacency_matrix(g)

# get the weighted adjacency matrix of weighted network g A = as_adjacency_matrix(g, attr = "weight")
# first row of matrix A
A[1, ]

# first column of matrix A
A[, 1]

# diagonal of matrix A diag(A)
Network Analysis in the Tidyverse

Pearson similarity

An undirected network

 

as_adjacency_matrix(g)
     [,1] [,2] [,3] [,4] [,5] [,6]
[1,]    0    1    0    0    1    0
[2,]    1    0    1    1    0    0
[3,]    0    1    0    1    1    1
[4,]    0    1    1    0    0    0
[5,]    1    0    1    0    0    0
[6,]    0    0    1    0    0    0
Network Analysis in the Tidyverse

Let's try some examples!

Network Analysis in the Tidyverse

Preparing Video For Download...