You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once you've made your knowledge graph instance, it's helpful to know how well connected it is. Then you can go about adding/pruning connections as needed.
#' Compute sparsity#'#' Compute sparsity (proportion of zero values) in a matrix or graph.#' @param x An igraph object or a (sparse) matrix.#' @param fun Function to convert graph to matrix.#' @param ... Arguments passed to \code{fun}.#' @returns A numeric value representing the proportion of zero#' values in the graph/matrix.#' @export#' @examples#' g <- make_ring(10)#' sparsity(g)sparsity<-function(x,
fun=igraph::as_adjacency_matrix,
...){
if(is(x,"igraph")){
x<- fun(x)
}
if(is(x,"Matrix")||is(x,"sparseMatrix")){
return(sum(x==0)/length(x))
}
else{
stop("x must be an igraph object or a (sparse) matrix.")
}
}
The text was updated successfully, but these errors were encountered:
Once you've made your knowledge graph instance, it's helpful to know how well connected it is. Then you can go about adding/pruning connections as needed.
The text was updated successfully, but these errors were encountered: