Tables of a hypergraph community ensemble
Source:R/hypergraph_communities.R
hg_get.hg_communities.RdReads, prints and plots the result of hg_communities() on a hypergraph.
Arguments
- x
An
hg_communitiesobject.- n
Number of rows of the default table to print. Default
10.- ...
For
plot(), additional arguments passed tocograph::splot(); otherwise unused.- what
Table to return:
"medoid"(default: one row per node with its community in the AMI-medoid run),"partitions","runs","sizes","ami","ari","nmi", or (IRMM fits only)"weights". The three similarity tables have one row per distinct pair of runs (run_a,run_b, and the similarity), without the diagonal.- converged
For
what = "runs"of an IRMM fit:TRUEkeeps the runs whose weights settled,FALSEthe runs that reachedmax_iter.NULL(default) keeps every run.- sort_by
For
what = "runs": a numeric column of the runs table ("modularity","n_communities"or"iterations") to order the runs by, largest first, ties broken by run number.NULL(default) keeps run order.- top
NULL(default, every row) or the number of first rows of any table to return, applied afterconvergedandsort_by.
Value
hg_get(): a base data.frame. Raises hypergraphs_bad_input
for converged or sort_by with a table other than "runs", or
converged with an Infomap fit. print(): x, invisibly.
plot(): the cograph plot of the projection, coloured by the medoid
communities.
Examples
dat <- data.frame(
member = c("a", "b", "c", "a", "b", "c", "x", "y", "z", "x", "y", "z"),
edge = rep(paste0("e", 1:4), each = 3)
)
h <- group_hypergraph(dat, "member", "edge")
if (requireNamespace("igraph", quietly = TRUE)) {
fit <- hg_communities(h, n_runs = 2, trials = 2, seeds = 1:2)
hg_get(fit, what = "runs")
hg_get(fit, what = "runs", sort_by = "n_communities", top = 1)
}
#> run seed n_communities codelength
#> 1 1 1 2 2.052397