Load and filter data
Search hypergraphx-data, load datasets into the library, and use filtering tools to prepare them for analysis.
Hypergraph analysis in Python
Hypergraphx is a research-friendly Python library for building, analyzing, and visualizing hypergraphs.
pip install hypergraphx
Higher-order networks
Standard networks record one-to-one relations. Hypergraphs keep the full group: a collaboration, a coauthored paper, a reaction, or a shared event can be represented as one object.
Pairwise links
Overlapping group interactions
Workflow
Create hypergraphs from node groups, files, or generators.
Run measures for degree, centrality, motifs, projections, and spectra.
Draw hypergraphs and derived views with reproducible layouts.
Features
Search hypergraphx-data, load datasets into the library, and use filtering tools to prepare them for analysis.
Compute degrees, centralities, motifs, and communities on the same hypergraph object.
Switch between hypergraphs, bipartite graphs, clique projections, line graphs, and simplicial complexes.
Sample random hypergraphs with specified numbers of nodes, hyperedges, and hyperedge sizes.
Explore contagion, synchronization, random walks, diffusion, and temporal activity on higher-order structures.
Visualize pairwise links and higher-order hyperedges from the same Hypergraphx object.
Tutorials
from hypergraphx.generation import random_hypergraph
h = random_hypergraph(
num_nodes=8,
num_edges_by_size={2: 4, 3: 4, 4: 4},
seed=9,
)
import matplotlib.pyplot as plt
from hypergraphx.measures.degree import degree_sequence
deg = degree_sequence(h)
plt.hist(deg.values())
from hypergraphx.measures.degree import degree_sequence
from hypergraphx.viz import draw_hypergraph
deg = degree_sequence(h)
top = set(sorted(deg, key=deg.get, reverse=True)[:2])
draw_hypergraph(h) # then recolor top nodes
Dataset loading
Search the remote catalog, choose a dataset, and load it as a Hypergraphx object for analysis.
from hypergraphx.readwrite import (
search_remote_datasets,
load_hypergraph_from_server,
)
from hypergraphx.measures.degree import degree_sequence
matches = search_remote_datasets(tags="Food")
dataset = matches[0]["name"]
h = load_hypergraph_from_server(dataset, fmt="json")
print(dataset, h.num_nodes(), h.num_edges())
print(degree_sequence(h))
Citation
If you use Hypergraphx in a publication, cite the paper below.
@article{lotito2023hypergraphx,
author = {Lotito, Quintino Francesco and Contisciani, Martina and De Bacco, Caterina and Di Gaetano, Leonardo and Gallo, Luca and Montresor, Alberto and Musciotto, Federico and Ruggeri, Nicolo and Battiston, Federico},
title = "{Hypergraphx: a library for higher-order network analysis}",
journal = {Journal of Complex Networks},
volume = {11},
number = {3},
year = {2023},
doi = {10.1093/comnet/cnad019},
pages = {cnad019},
publisher = {Oxford University Press}
}