HyperModularity.jl

Author nveldt
Popularity
10 Stars
Updated Last
10 Months Ago
Started In
February 2021

Build Status Build Status Build Status Coverage

HyperModularity

This package contains code for hypergraph modularity clustering algorithms, based on the generative model described in

Generative hypergraph clustering: from blockmodels to modularity
Philip S. Chodrow, Nate Veldt, Austin R. Benson
preprint

Package Installation

To install package
using Pkg
Pkg.add("HyperModularity")
using HyperModularity

Data available

For a full list of all datasets:
hypermodularity_datasets()
Loading data example:
dataset = "contact-high-school-classes"
maxsize = 5	# max hyperedge size
minsize = 2	# min hyperedge size
return_labels = true
H, L = read_hypergraph_data(dataset,maxsize,minsize,return_labels)

Some Examples

Run graph Louvain algorithm on clique expanded graph

gamma = 1.0 # default resolution parameter
Z_g = CliqueExpansionModularity(H,gamma) # see code for default parameters

# Compute MLE resolution parameter given clustering Z_g
(ωᵢ, ωₒ) = computeDyadicResolutionParameter(H, Z_g; mode = 0)
γ_mle = (ωᵢ - ωₒ)/(log(ωᵢ) - log(ωₒ))
loglike = dyadicLogLikelihood(H, Z, ωᵢ, ωₒ)

Run all-or-nothing Louvain algorithm

n = size(H,2)
Z_ = collect(1:n) # trivial clustering

# all or nothing aggregator: p -> [length(p) == 1, sum(p)]
# This gives a starter estimate for Ω, from a trivial clustering Z_
Ω = estimateΩEmpirically(H, Z_; aggregator = p -> [length(p) == 1, sum(p)])

Z = AON_Louvain(H,Ω)

# Alternatively, one can learn Ω from graph Louvain solution Z_g
Ω = estimateΩEmpirically(H, Z_g; aggregator = p -> [length(p) == 1, sum(p)])
Z = AON_Louvain(H,Ω)

Additional examples

See demo notebooks in demos folder for other examples of how to use the code.