Table of Contents

Random 35

> wdir <- "C:/Users/vlado/docs/papers/2022/ifcs2022/genova/data"
> setwd(wdir)
> library(jsonlite)
> source("https://raw.githubusercontent.com/bavla/ibm3m/master/ibm3m.R")
> R <- readTriplets3m('./random/test.tri',n=c(35,35,35))
> N <- c("1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h",
+   "i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z")
> labx <- paste('X',N,sep=''); laby <- paste('Y',N,sep='');
> labz <- paste('Z',N,sep='')
> info <- list(network="Random35",
+   title="Random test multiway network from IBM3M",
+   by="Vladimir Batagelj",
+   ref=paste("Batagelj, V., Ferligoj, A., Doreian, P.: Indirect Blockmodeling of 3-Way Networks.", 
+     "In: Selected Contributions in Data Analysis and Classification, Springer, 2007, 151-159."),
+   href="http://vlado.fmf.uni-lj.si/vlado/papers/ibm3mode.pdf",
+   creator="V. Batagelj",
+   date=date() )
> ways=list(X="first",Y="second",Z="third")
> nodes=list(X=data.frame(ID=labx),Y=data.frame(ID=laby),Z=data.frame(ID=labz))
> MN <- list(format="MWnets",info=info,ways=ways,nodes=nodes,links=R,data=list())
> write(toJSON(MN),"./random/random35arr.json")
> n <- length(labx); m <- sum(R)
> links <- matrix(nrow=m,ncol=4); s <- 0
> colnames(links) <- c("X","Y","Z","w")
> for(i in 1:n) for(j in 1:n) for(k in 1:n) 
+   if(R[i,j,k]!=0){s <- s+1; links[s,] <- c(i,j,k,R[i,j,k])}
> MN$links <- as.data.frame(links) 
> write(toJSON(MN),"./random/random35.json")
> str(MN)
List of 6
 $ format: chr "MWnets"
 $ info  :List of 7
  ..$ network: chr "Random35"
  ..$ title  : chr "Random test multiway network from IBM3M"
  ..$ by     : chr "Vladimir Batagelj"
  ..$ ref    : chr "Batagelj, V., Ferligoj, A., Doreian, P.: Indirect Blockmodeling of 3-Way Networks. In: Selected Contributions i"| __truncated__
  ..$ href   : chr "http://vlado.fmf.uni-lj.si/vlado/papers/ibm3mode.pdf"
  ..$ creator: chr "V. Batagelj"
  ..$ date   : chr "Sat Nov 26 20:22:29 2022"
 $ ways  :List of 3
  ..$ X: chr "first"
  ..$ Y: chr "second"
  ..$ Z: chr "third"
 $ nodes :List of 3
  ..$ X:'data.frame':   35 obs. of  1 variable:
  .. ..$ ID: chr [1:35] "X1" "X2" "X3" "X4" ...
  ..$ Y:'data.frame':   35 obs. of  1 variable:
  .. ..$ ID: chr [1:35] "Y1" "Y2" "Y3" "Y4" ...
  ..$ Z:'data.frame':   35 obs. of  1 variable:
  .. ..$ ID: chr [1:35] "Z1" "Z2" "Z3" "Z4" ...
 $ links :'data.frame': 12777 obs. of  4 variables:
  ..$ X: num [1:12777] 1 1 1 1 1 1 1 1 1 1 ...
  ..$ Y: num [1:12777] 1 1 1 1 1 1 1 1 1 1 ...
  ..$ Z: num [1:12777] 1 3 4 5 6 7 8 9 10 11 ...
  ..$ w: num [1:12777] 1 1 1 1 1 1 1 1 1 1 ...
 $ data  : list()

Clustering all ways

> wdir <- "C:/Users/vlado/docs/papers/2022/ifcs2022/genova/data"
> setwd(wdir)
> library(jsonlite)
> library(magrittr)
> source("https://raw.githubusercontent.com/bavla/Rnet/master/R/Pajek.R")
> source("https://raw.githubusercontent.com/bavla/ibm3m/master/multiway/MWnets.R")
> MN <- fromJSON("./random/random35.json")
> # str(MN)
> Cox <- projection(MN,"X","w")
> Sax <- salton(Cox); Dx <- as.dist(1-Sax)
> tx <- hclust(Dx,method="complete")
> plot(tx,hang=-1,cex=0.8,main="Random test X / Complete")
> Coy <- projection(MN,"Y","w")
> Say <- salton(Coy); Dy <- as.dist(1-Say)
> ty <- hclust(Dy,method="complete")
> plot(ty,hang=-1,cex=0.8,main="Random test Y / Complete")
> Coz <- projection(MN,"Z","w")
> Saz <- salton(Coz); Dz <- as.dist(1-Saz)
> tz <- hclust(Dz,method="complete")
> plot(tz,hang=-1,cex=0.8,main="Random test Z / Complete")

To do

3D visualization

Done: mwx3d



vlado/work/2m/mwn/random.txt · Last modified: 2022/12/14 16:19 by vlado
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki