Compute sparsity (proportion of zero values) in a matrix or graph.
graph_sparsity(x, fun = igraph::as_adjacency_matrix, ...)
A numeric value representing the proportion of zero values in the graph/matrix.
## Using example KGX file packaged with monarchr
data(eds_marfan_kg)
g <- eds_marfan_kg |>
fetch_nodes(query_ids = "MONDO:0007525") |>
expand(predicates = "biolink:has_phenotype",
categories = "biolink:PhenotypicFeature")
graph_sparsity(g)
#> [1] 0.9800083