R Under development (unstable) (2023-08-20 r84995 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ################################################### > ### chunk number 1: preliminaries > ################################################### > > library(classGraph) Attaching package: 'classGraph' The following object is masked from 'package:graphics': plot The following object is masked from 'package:base': plot > > stopifnot(require("Matrix"), + require("graph")) Loading required package: Matrix Loading required package: graph Loading required package: BiocGenerics Attaching package: 'BiocGenerics' The following objects are masked from 'package:stats': IQR, mad, sd, var, xtabs The following objects are masked from 'package:base': Filter, Find, Map, Position, Reduce, anyDuplicated, aperm, append, as.data.frame, basename, cbind, colnames, dirname, do.call, duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted, lapply, mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank, rbind, rownames, sapply, setdiff, sort, table, tapply, union, unique, unsplit, which.max, which.min > > allCl <- getClasses("package:Matrix") > ## Those called "...Matrix" : > M.Cl <- grep("Matrix$",allCl, value = TRUE) > > str(M3cl <- grep("^...Matrix$",M.Cl, value = TRUE)) chr [1:48] "lgeMatrix" "dtrMatrix" "dgRMatrix" "lspMatrix" "lsTMatrix" ... > > M3cl <- M3cl[M3cl != "corMatrix"] # corMatrix not desired in following > > > > > > ################################################### > ### chunk number 2: tree-Matrix > ################################################### > trMatrix <- classTree("Matrix") ; trMatrix A graphNEL graph with directed edges Number of Nodes = 74 Number of Edges = 166 > ## 2005-08: 58 nodes with 109 edges > ## 2007-01: 74 nodes with 151 edges > par(lwd = 0.3)# no effect --- learn to use Rgraphviz!! > plotRag(mRagraph(trMatrix), subArgs=.optRagargs(adj = 0.5)) > > > ################################################### > ### chunk number 3: sTree-M1 > ################################################### > allN <- nodes(trMatrix) > "%w/o%" <- function(x,y) x[!x %in% y] #-- x without y > > hier1 <- paste(c("diagonal", "triangular", "symmetric", "general", "comp"), + "Matrix", sep = '') # composites can be factorized: ^^^^ > > ## dropping 1st ``dim'' hierarchy -- much less edges: > (trM1 <- subGraph(allN %w/o% hier1, trMatrix)) A graphNEL graph with directed edges Number of Nodes = 69 Number of Edges = 116 > plotRag(mRagraph(trM1), subArgs=.optRagargs(adj = 0.5)) > > > ################################################### > ### chunk number 4: sTree-top12 > ################################################### > defMatrix <- getClassDef("Matrix") > ## Distances of subclasses: > table(subDist <- sapply(defMatrix@subclasses, slot, "distance")) 1 2 3 4 5 9 18 44 3 2 > sub12 <- defMatrix@subclasses[subDist <= 2] # but not unique! > trM_top12 <- subGraph(c("Matrix", unique(names(sub12))), trMatrix) > plotRag(mRagraph(trM_top12)) ## first and second level virtual classes > > > ################################################### > ### chunk number 5: sTree-sparse > ################################################### > trSpMatrix <- classTree("sparseMatrix") > trSpMatrix A graphNEL graph with directed edges Number of Nodes = 39 Number of Edges = 65 > plotRag(mRagraph(trSpMatrix, "dot"), + subArgs= .optRagargs(side = 3, adj = 1, line = 0), + main = "'sparseMatrix' classes -- sub graph") > > > ################################################### > ### chunk number 6: sTree-sp-neato > ################################################### > ## now this *does* look kind of neat: > plotRag(mRagraph(trSpMatrix, "neato"), + subArgs= .optRagargs(side = 3, adj = 1, line = 0), + main = "'sparseMatrix' classes -- in \"neato\" layout") Warning messages: 1: In arrows(head_from[1], head_from[2], head_to[1], head_to[2], col = edgeColor, : zero-length arrow is of indeterminate angle and so skipped 2: In arrows(head_from[1], head_from[2], head_to[1], head_to[2], col = edgeColor, : zero-length arrow is of indeterminate angle and so skipped 3: In arrows(head_from[1], head_from[2], head_to[1], head_to[2], col = edgeColor, : zero-length arrow is of indeterminate angle and so skipped > ## all three others do not > > > > proc.time() user system elapsed 2.54 0.29 2.89