> setwd("C:/test/cores") > library(jsonlite) > library(Polychrome) > source("https://raw.githubusercontent.com/bavla/ibm3m/master/multiway/MWnets.R") > MN <- fromJSON("https://raw.githubusercontent.com/bavla/ibm3m/master/data/AirEu2013Ext.json") > str(MN) > MN$nodes$line$short <- substr(MN$nodes$line$ID,1,4) > core <- relCore(MN,"airA","airB","line") > w1 <- (1:450)[core==13]; w2 <- (1:450)[core==13] > Score <- extract(MN,c("airA","airB"),c("w1","w2")) > act <- as.integer(names(table(Score$links$line))) > Rcore <- extract(Score,"line","act") > c27 <- glasbey.colors(27); CC <- col2rgb(c27)/255 > Col <- cbind(CC[1,Rcore$links$line],CC[2,Rcore$links$line],CC[3,Rcore$links$line]) > s <- rep(0,27) > for(i in 1:27) s[i] <- sum(Rcore$links$line==i) > q <- inv(order(s)) > mwnX3D(Rcore,"airA","airB","line","w",pz=q,lu="long",lv="long",maxsize=0.85,col=Col,file="AirCore13.x3d") > ts <- c(1,20,10,26,27,19,24,9,7,8,21,13,18,4,2,15,11,23,6,22,5,16,3,12,14,17,25,28) > t <- inv(ts) > mwnX3D(Rcore,"airA","airB","line","w",pu=t,pv=t,pz=q,lu="long",lv="long",maxsize=0.85,col=Col,file="AirCore13s.x3d") > qs <- c(1,5,10,19,3,7,12,4,16,13,21,8,20,6,11,18,17,2,23,9,15,24,25,14,22,27,26) > qq <- inv(qs) > mwnX3D(Rcore,"airA","airB","line","w",pu=t,pv=t,pz=qq,lu="long",lv="long",maxsize=0.85,col=Col,file="AirCore13f.x3d") > (Na <- Rcore$nodes$airA$long[ts]) > (Nc <- Rcore$nodes$line$ID[qs])
All airports / clustered, 3D layout
> Cou <- projection(MN,"airA","w") > Sau <- salton(Cou); Du <- as.dist(1-Sau); Du[is.na(Du)] <- 1 > tu <- hclust(Du,method="ward") > plot(tu,hang=-1,cex=0.2,main="EU airports - airports / Ward") > Coz <- projection(MN,"line","w") > Saz <- salton(Coz); Dz <- as.dist(1-Saz); Dz[is.na(Dz)] <- 1 > tz <- hclust(Dz,method="ward") > plot(tz,hang=-1,cex=0.8,main="EU airports - companies / Ward") > I <- inv(tu$order); K <- inv(tz$order) > CC <- col2rgb(createPalette(37,c("#ff0000","#00ff00","#0000ff")))/255 > Col <- cbind(CC[1,MN$links$line],CC[2,MN$links$line],CC[3,MN$links$line]) > mwnX3D(MN,"airA","airB","line","w",maxsize=0.85,pu=I,pv=I,pz=K,lu="long",lv="long",col=Col,file="EUair.x3d")
> row.names(Cou) <- MN$nodes$airA$long > Saul <- salton(Cou); Dul <- as.dist(1-Saul); Dul[is.na(Dul)] <- 1 > tul <- hclust(Dul,method="ward") > svg("airports.svg",width=18,height=8) > plot(tul,hang=-1,cex=0.2,main="EU airports - airports / Ward") > dev.off()