Learn R Programming

XGR (version 1.1.4)

xRWkernel: Function to calculate random walk kernel on the input graph

Description

xRWkernel is supposed to calculate a weighted random walk kernel (at a predefined number of steps) for estimating pairwise affinity between nodes.

Usage

xRWkernel(g, steps = 4, chance = 2, verbose = TRUE)

Arguments

g

an object of class "igraph" or "graphNEL". It will be a weighted graph if having an edge attribute 'weight'. The edge directions are ignored for directed graphs

steps

an integer specifying the number of steps that random walk performs. By default, it is 4

chance

an integer specifying the chance of remaining at the same vertex. By default, it is 2, the higher the higher chance

verbose

logical to indicate whether the messages will be displayed in the screen. By default, it sets to true for display

Value

It returns a sparse matrix for pairwise affinity between nodes via short random walks

See Also

xRWkernel

Examples

Run this code
# NOT RUN {
# 1) generate a random graph according to the ER model
set.seed(825)
g <- erdos.renyi.game(10, 3/10)
V(g)$name <- paste0('n',1:vcount(g))

# }
# NOT RUN {
# 2) pre-computate affinity matrix between all nodes
Amatrix <- xRWkernel(g)
# visualise affinity matrix
visHeatmapAdv(as.matrix(Amatrix), colormap="wyr",
KeyValueName="Affinity")
# }

Run the code above in your browser using DataLab