====== General multiway cores ======
[[.:nodep|Node property functions]]; [[.:gcores|Generalized multi-relational cores]]; [[.:x3d:airmw|MW European airports]]; [[.:x3d:olymw|MW Olympics]]
===== General multiway cores =====
MWcore <- function(MN,P,trace=FALSE){
C <- lapply(P$cways$cw, \(x) 1:nrow(MN$nodes[[x]])); names(C) <- P$cways$cw
repeat{
exit <- TRUE
for(i in 1:(length(P)-1)){
cip <- P[[i]]$cip; p <- P[[i]]$p; thresh <- P[[i]]$t
R <- c(); r <- cip[1]
for(v in C[[r]]) {
pv <- p(MN,v,cip,C)
if(pv < thresh) {R <- union(R,v); exit <- FALSE}
}
if(length(R)>0) C[[r]] <- setdiff(C[[r]],R)
if(trace) cat(i,P[[i]]$cwp[1],r,":",cip,"/",thresh,"\n",R,"\n")
}
if(exit) break
}
return(C)
}
listCore <- function(MN,C,P,sorted=TRUE){
ci <- P[["cways"]]$ci
for(i in 1:(length(P)-1)){
cip <- P[[i]]$cip; p <- P[[i]]$p; thresh <- P[[i]]$t
iu <- P[[i]]$cwp[1]; N <- MN$nodes[[iu]]$ID
nw <- length(N); r <- cip[1]; core <- list();
for(v in 1:nw) if(v %in% C[[r]]) core[[N[v]]] <- p(MN,v,cip,C)
cat(i,iu,":",thresh, nw, cip,"\n")
T <- unlist(core,use.name=TRUE); if(sorted) T <- rev(sort(T))
print(T)
}
}