library(PathwaySpace)
# Load a demo igraph
data('gtoy1', package = 'RGraphSpace')
ps <- buildPathwaySpace(gtoy1, nrc = 100)
# Check vertex names
names(ps)
##--------------------------------------
## 'vertexSignal' accessor
# Access signal values from all vertices
vertexSignal(ps)
# Modify signal value of a specific vertex
vertexSignal(ps)[1] <- 1
# Modify signal value of specific vertices
vertexSignal(ps)[c("n2","n3")] <- 1
# Set '1s' to all vertices
vertexSignal(ps) <- 1
##--------------------------------------
## 'activeFeature' accessor
# Assign a signal feature matrix
signal_mtx <- matrix(
rep(rnorm(gs_vcount(ps)), 2),
ncol = 2,
dimnames = list(names(ps), c("feature1", "feature2"))
)
gs_fdata(ps) <- signal_mtx
# Set the active feature — automatically updates vertexSignal()
activeFeature(ps) <- "feature1"
##--------------------------------------
## 'vertexDecay' accessor
# Access decay function of a specific vertex
vertexDecay(ps)[["n3"]]
# Modify decay function of a specific vertex
vertexDecay(ps)[["n3"]] <- linearDecay()
# Modify decay functions of two vertices
vertexDecay(ps)[c("n1","n3")] <- list( weibullDecay() )
# Modify decay functions of all vertices
vertexDecay(ps) <- weibullDecay(shape = 2)
Run the code above in your browser using DataLab