Learn R Programming

dils (version 0.8.1)

RelationStrengthSimilarity: Calculate the RSS from one node to another.

Description

For a single pair of nodes, implement the RSS algorithm of Chen et al. (2012).

Usage

RelationStrengthSimilarity(xadj, v1, v2, radius = 3, directed = TRUE, method = c("Rcpp", "BetterR", "NaiveR"))

Arguments

xadj
numeric matrix, then description of arg1.
v1
numeric Object type, then description of arg2.
v2
numeric Object type, then description of arg2.
radius
numeric, length of longest path examined from v1 to v2.
directed
logical, if TRUE returns a symmetric RSS matrix.
method
character, choose the method of calculation.

Value

numeric, Relation Strength Similarity score(s).

Details

If v1 and v2 are specified, this returns the RSS from v1 to v2. If not, it calculates the RSS scores for all dyads in the network.

References

"Discovering Missing Links in Networks Using Similarity Measures", Hung-Hsuan Chen, Liang Gou, Xiaolong (Luke) Zhang, C. Lee Giles. 2012.

https://github.com/shaptonstahl/

See Also

ScalablePCA

Examples

Run this code
g1 <- graph.atlas(128)
## Not run: plot(g1)

M1 <- as.matrix(get.adjacency(g1))
M1
RelationStrengthSimilarity(xadj=M1, v1=5, v2=6, radius=1)
RelationStrengthSimilarity(xadj=M1, v1=5, v2=6, radius=2)
RelationStrengthSimilarity(xadj=M1, v1=5, v2=6, radius=3)
RelationStrengthSimilarity(xadj=M1, v1=5, v2=6, radius=4)

RelationStrengthSimilarity(xadj=M1, radius=2)

TestUndirectedNetwork <- function(n) {
  M <- matrix(runif(n*n), nrow=n)
  M <- (M + t(M)) / 2
  diag(M) <- 0
  return(M)
}
M2 <- TestUndirectedNetwork(75)
system.time(RelationStrengthSimilarity(xadj=M2, directed=FALSE, method="BetterR"))  # all R
system.time(RelationStrengthSimilarity(xadj=M2, directed=FALSE))                    # Rcpp

Run the code above in your browser using DataLab