# Incidence matrix: 4 students x 3 courses
inc <- matrix(c(1, 1, 0,
1, 0, 1,
0, 1, 1,
1, 1, 1), 4, 3, byrow = TRUE)
rownames(inc) <- paste0("S", 1:4)
colnames(inc) <- paste0("C", 1:3)
# Student co-enrollment (weighted)
cograph::project_bipartite(inc, mode = "rows", method = "sum")
# Course overlap (Jaccard similarity)
cograph::project_bipartite(inc, mode = "columns", method = "jaccard")
# Newman's weighted projection
cograph::project_bipartite(inc, mode = "rows", method = "newman")
Run the code above in your browser using DataLab