> wdir <- "C:/Users/vlado/docs/papers/2022/ifcs2022/genova/MWnets/students" > setwd(wdir) > library(jsonlite) > library(Polychrome) > library(magrittr) > source("https://raw.githubusercontent.com/bavla/ibm3m/master/multiway/MWnets.R") > IS <- fromJSON("./students.json") > str(IS) > n1 <- nrow(IS$nodes$prov); n2 <- nrow(IS$nodes$univ); n3 <- nrow(IS$nodes$prog) > C1 <- 1:n1; C2 <- 1:n2; C3 <- 1:n3 > F12 <- sapply(1:n1,function(u) pSum(IS,u,C2,"prov","univ",weight="w")) > F21 <- sapply(1:n2,function(v) pSum(IS,v,C1,"univ","prov",weight="w")) > table(F12) > table(F21) > PSum <- function(MN,u,C,way1,way2,...) pSum(MN,u,C,way1,way2,weight="w",...) > cores <- Gen2modeCore(IS,"prov","univ",PSum,PSum,1500,1500) > Cprov <- cores$core1; Cuniv <- cores$core2 > IS %>% + extract(c("prov","univ"),c("Cprov","Cuniv")) %>% + flatten("w",c("prov","univ","prog")) -> + IScore > str(IScore) > c11 <- glasbey.colors(11); CC <- col2rgb(c11)/255 > Col <- cbind(CC[1,IScore$links$prog],CC[2,IScore$links$prog],CC[3,IScore$links$prog]) > mwnX3D(IScore,"prov","univ","prog","w",lu="province",lv="long",lz="long",maxsize=0.85,col=Col,file="IScore1500.x3d") > Cou <- projection(IScore,"prov","w") > Sau <- salton(Cou); Du <- as.dist(1-Sau); Du[is.na(Du)] <- 1 > tu <- hclust(Du,method="ward") > plot(tu,hang=-1,cex=1,main="Students core - provinces / Ward") > Cov <- projection(IScore,"univ","w") > Sav <- salton(Cov); Dv <- as.dist(1-Sav); Dv[is.na(Dv)] <- 1 > tv <- hclust(Dv,method="ward") > plot(tv,hang=-1,cex=1,main="Students core - universities / Ward") > Coz <- projection(IScore,"prog","w") > Saz <- salton(Coz); Dz <- as.dist(1-Saz); Dz[is.na(Dz)] <- 1 > tz <- hclust(Dz,method="ward") > plot(tz,hang=-1,cex=1,main="Students core - programs / Ward") > I <- inv(tu$order); J <- inv(tv$order); K <- inv(tz$order) > mwnX3D(IScore,"prov","univ","prog","w",pu=I,pv=J,pz=K,lu="province",lv="long",lz="long",maxsize=0.85,col=Col,file="IScoreClus.x3d") > sum(IS$links$w) [1] 163222 > sum(IScore$links$w) [1] 38682 > sum(IScore$links$w)/sum(IS$links$w) [1] 0.2369901 > (17*16*11)/(107*79*11) [1] 0.03217792
Click a link (cube) for its identification (province, university, program)!