Chapter 9
Higher-order structure and null models
A statistic computed on a single hypergraph means little until it is compared with what chance would produce. This chapter introduces the random hypergraph models of hatvis, from the uniform model of HAT to the degree- and size-preserving configuration model of Chodrow, and uses them to test three kinds of structure that have no counterpart in graphs: how three hyperedges overlap (the 26 h-motifs of Lee, Ko, and Shin), how a triple of vertices is covered by pairs and triples (higher-order node motifs), and how close a hypergraph is to a simplicial complex (the simpliciality measures of Landry, Young, and Eikmeier). Clustering coefficients and degree assortativity for hypergraphs complete the toolkit. The examples show that the wire-harness space is far more nested and clustered than its degree and size sequences explain.
9.1 Problem and idea
Suppose the two-node clustering coefficient of a manufacturing space is 0.18. Is that high? A hypergraph in which a few resources take part in most activities and the activities have four or five members will show substantial clustering even if the activities were assembled at random, simply because large hyperedges and hub vertices create many shared neighbors. The meaningful question is whether the observed value exceeds the value expected for hypergraphs with the same degrees and hyperedge sizes. The answer requires a null model that preserves exactly these sequences and randomizes everything else, and an ensemble of samples from it.
The same logic applies to every structural pattern of this chapter. An h-motif, a configuration of three overlapping hyperedges, is significant only if it occurs more often than in the randomized ensemble; a high fraction of hyperedges contained in other hyperedges is interesting only if chance does not produce it. The idea is therefore always the same: compute the statistic, compute it on many samples of a suitable null model, and report the z-score or the whole null distribution. The choice of the null model determines what “chance” means, and hatvis provides models that preserve progressively more of the observed structure.
9.2 Theory
9.2.1 Random hypergraph models
hatvis implements six generators, ordered here by how much of an observed hypergraph they preserve.
Uniform random hypergraph. Each of hyperedges is a uniformly random -subset of vertices. It is the hypergraph analogue of the Erdős–Rényi graph and the generator uniformErdosRenyi of HAT [18].
Random hypergraph with a size sequence. Each hyperedge is a uniformly random subset of the prescribed size. It preserves the size distribution but not the degrees, which become approximately binomial; in the comparisons below it is called the random model.
Chung–Lu hypergraph. Vertices enter each hyperedge with probability proportional to a target degree, so that the expected degrees match the targets when no vertex dominates [121, 122]. It generates hypergraphs with heterogeneous degrees from scratch, as used in section 6.4.
Configuration model. Chodrow [120] defined configuration models of hypergraphs that preserve the degree of every vertex and the size of every hyperedge, and sampled them by Markov chain Monte Carlo. The pairwise reshuffle of fig. 9.1 is a simple move of this kind: it picks two hyperedges , keeps their intersection in both, and redistributes the vertices of the symmetric difference at random while keeping both sizes. Every degree and every size is preserved, no vertex appears twice in a hyperedge, and after a number of steps proportional to the number of hyperedges (ten times by default) the sample has forgotten the correlations of the original beyond its degree and size sequences. This is the standard null model for testing higher-order structure.
Planted partition. The hypergraph stochastic block model of section 7.4 draws a hyperedge entirely from one random community with probability and from the whole vertex set otherwise; it provides ground truth for community detection. Chodrow, Veldt, and Benson [98] discuss degree-corrected versions and their relation to modularity.
Temporal random hypergraph. A sequence of snapshots in which a tunable fraction of the hyperedges is repeated from the previous step; it serves as a null model for the persistence and turnover measures of chapter 12.
9.2.2 Clustering and assortativity
The clustering coefficient of a graph measures how often two neighbors of a vertex are themselves neighbors. On the clique expansion it is inflated by every hyperedge of size three or more, which contributes complete triangles regardless of any further structure. Gallagher and Goldberg [123] proposed a two-node clustering coefficient that asks instead how much the hyperedge memberships of a vertex and its neighbors overlap. With the set of hyperedges containing and its neighbors in the clique expansion,
|
| (9.1) |
the mean Jaccard similarity of the memberships of and each of its neighbors. It is large when a vertex meets its neighbors repeatedly, in many of the same hyperedges, and small when every neighbor is met once.
The degree assortativity of a hypergraph [120] is the Pearson correlation of the degrees of pairs of vertices that share a hyperedge, where the pairs are either all pairs of members or one pair per hyperedge chosen by a rule (the members of largest and smallest degree, for example). Negative values mean that high-degree vertices tend to share hyperedges with low-degree ones, as in a hub-and-spoke organization.
9.2.3 Hypergraph motifs
Network motifs are small subgraphs that occur significantly more often than in randomized networks [124]. Lee, Ko, and Shin [125] defined their hypergraph counterpart for three connected hyperedges. Three hyperedges , , partition the vertices of into seven regions: the vertices only in , only in , only in , only in and , only in and , only in and , and in all three. The emptiness pattern of the seven regions, up to permutations of , is the h-motif of the triple. Excluding patterns with duplicate hyperedges and patterns in which the three hyperedges are not connected leaves 26 h-motifs; 20 of them are closed (all three pairs intersect) and 6 are open (one pair is disjoint) [125]. The definition is independent of the hyperedge sizes, so the motif profile of hypergraphs with very different sizes can be compared. hatvis numbers the motifs in the lexicographic order of their canonical patterns, which differs from the figure order of the original paper, and lists the patterns with h_motif_catalog().
Counting h-motifs requires the connected triples of distinct hyperedges, which hatvis enumerates from the line graph. The significance of motif is the z-score of its count against a null ensemble, usually the configuration model, and the vector of z-scores normalized to unit length is the significance profile of Milo et al. [126], which makes hypergraphs of different sizes comparable. Lee et al. showed that the h-motif profiles of real hypergraphs are similar within a domain (co-authorship, contact, e-mail, tags) and different across domains.
The complementary view of Lotito et al. [127] looks at small sets of vertices and records which of their subsets are hyperedges. For three vertices , the hyperedges contained in the triple are a subset of the three pairs and the triple itself. hatvis counts the six connected classes: the open wedge (two pairs), the triangle (three pairs), the lone 3-hyperedge, the 3-hyperedge with one or with two of its pairs, and the full simplex (the 3-hyperedge with all three pairs). The last class is the signature of a downward-closed, simplicial organization; the lone 3-hyperedge is the signature of a genuinely higher-order interaction that does not decompose into pairs.
9.2.4 Simpliciality and nestedness
A simplicial complex is a hypergraph closed under taking subsets: if is a hyperedge, so are , , , and the singletons. Many models of higher-order dynamics are formulated on simplicial complexes, and the choice between a hypergraph and a simplicial complex as the representation of data should be guided by how much downward closure the data actually show [13, 14]. Landry, Young, and Eikmeier [128] defined three measures, computed on the hyperedges of size at least two (singletons are ignored by default):
- the simplicial fraction: the fraction of hyperedges (of size at least three) all of whose subsets of size at least two are hyperedges;
- the edit simpliciality: , where is the smallest simplicial complex containing , i.e. the fraction of the simplicial closure that is present;
- the face edit simpliciality: the mean, over the maximal hyperedges, of the fraction of their subsets that are present.
All three are 1 for a simplicial complex and close to 0 for a hypergraph without inclusions. They found that many empirical hypergraphs are far from simplicial but much more simplicial than their randomized counterparts. A related, simpler statistic is the included fraction: the fraction of hyperedges that are proper subsets of another hyperedge. LaRock and Lambiotte [129] studied this encapsulation structure and its effect on dynamics.
In a nutshell: Higher-order structure and null models
- Null models: uniform (HAT), size-preserving random, Chung–Lu, configuration model by pairwise reshuffles (degrees and sizes preserved), planted partition, temporal with persistence. Report z-scores or null distributions.
- Two-node clustering (9.1): mean Jaccard overlap of the memberships of a vertex and its neighbors; degree assortativity of co-members.
- h-motifs: emptiness patterns of the seven regions of three connected hyperedges; 26 motifs (20 closed, 6 open); z-scores and significance profile against the configuration model.
- Node motifs of order three: open wedge, triangle, lone 3-hyperedge, partial and full simplex.
- Simpliciality (simplicial fraction, edit and face edit simpliciality) and the included fraction measure the distance from a simplicial complex.
9.3 Using it in hatvis
motifs.motif_zscores(H, counter, n_samples=30, null="configuration", random_state=None)
- counter
-
a function that maps a hypergraph to a Series of counts, e.g. motifs.h_motifs or motifs.node_motifs.
- Returns
-
observed counts, null mean and standard deviation, z-scores, and the significance profile.
- Related
-
motifs.h_motif_catalog(), motifs.h_motif_pattern(a, b, c); models.uniform_random, models.random_hypergraph, models.chung_lu, models.configuration_model(H, n_steps), models.planted_partition, models.temporal_random; metrics.two_node_clustering, metrics.clique_clustering, metrics.degree_assortativity, simpliciality(H), metrics.nestedness(H), metrics.degree_entropy, metrics.spectral_entropy; plot_motif_profile.
9.4 Examples
h-motifs of the manufacturing space. The h-motifs of the wire-harness space are counted and compared with thirty samples of the configuration model.
cat = hv.motifs.h_motif_catalog() z = hv.motifs.motif_zscores(H, hv.motifs.h_motifs, n_samples=30, random_state=0)
Four motifs are over-represented (fig. 9.2). The strongest is (96 instances against 21.3 expected, ): two of the three activities have no private resources, one of them is contained in the other, and all three share a common core, the typical relation between a short handling step, the station activity that contains it, and a neighboring activity that uses the same sensor or competence. The open motif (96 against 39.2, ) is the same nesting without the common core: a contained activity, its container, and a third activity that overlaps the container but not the contained one. The rare motifs and (4 instances each, against fewer than one expected) are configurations in which no activity has a private resource at all. The most under-represented motif is , the open chain of three activities that each have private resources (2524 instances against 12 706 expected, ), followed by and , closed triples in which all three pairs overlap but no resource is shared by all three, and in which at least two activities have private resources. Together the profile says that the activities of the manufacturing space overlap in a nested way, with shared cores and contained steps, while loose chains of activities with their own resources, the generic configuration of randomly assembled groups, are rare.
Hypergraph or simplicial complex? Four hypergraphs are compared: a simplicial complex (the downward closure of a random 4-uniform hypergraph), a random hypergraph with sizes 2 to 4, the hypergraph of frequent itemsets of the news data (downward closed by construction, since every subset of a frequent itemset is frequent), and the news articles themselves.
table = pd.DataFrame({name: pd.concat([hv.simpliciality(H, max_size=12), hv.metrics.nestedness(H)]) for name, H in cases.items()}).T
| random |
|
|
|||||||
| simplicial fraction | 1.000 | 0.000 | 1.000 | 0.054 | ||||||
| edit simpliciality | 1.000 | 0.219 | 1.000 | 0.052 | ||||||
| face edit simpliciality | 1.000 | 0.018 | 1.000 | 0.162 | ||||||
| included fraction | 0.906 | 0.111 | 0.875 | 0.829 | ||||||
| open wedge | 66 | 56 | 0 | 0 | ||||||
| triangle of pairs | 10 | 0 | 1 | 2 | ||||||
| lone 3-hyperedge | 0 | 30 | 0 | 3 | ||||||
| 3-hyperedge + 1 pair | 0 | 0 | 0 | 29 | ||||||
| 3-hyperedge + 2 pairs | 0 | 0 | 0 | 6 | ||||||
| full simplex | 31 | 0 | 23 | 13 |
Table 9.1 and fig. 9.3 confirm the extreme cases: the simplicial complex and the itemset hypergraph score 1 on all three measures, the random hypergraph close to 0. The news articles are instructive. Their simplicial fraction and edit simpliciality are only about 0.05, yet 83% of the articles are subsets of other articles. The articles are highly nested, because many short articles repeat part of the theme set of longer ones, but they are not downward closed, because most subsets of a long article never occur as articles of their own. The node motifs show the same: the dominant class is the 3-hyperedge with only one of its pairs present (29 triples), whereas the simplicial complex consists of open wedges, triangles, and full simplices. Representing the news data as a simplicial complex would add 95% of the faces that do not exist; representing them as a graph would destroy the 3-hyperedges. The hypergraph is the representation that matches the data.
Open in ColabExample plot_29_simpliciality.py in the gallery
What is structure and what is chance? The last script compares four statistics of the wire-harness space with thirty samples of the configuration model and of the size-preserving random model.
lab = hv.hypergraph_louvain(G, random_state=0) return {"two-node clustering": hv.metrics.two_node_clustering(G).mean(), "degree assortativity": hv.metrics.degree_assortativity(G), "modularity": hv.modularity(G, lab), "2-components": len(hv.s_connected_components(G, 2))}
| Statistic | observed | configuration | random |
| two-node clustering | 0.183 | ||
| degree assortativity | |||
| strict modularity (hypergraph Louvain) | 0.419 | ||
| number of 2-components | 4 |
The two-node clustering of the real space is almost twice the null value, more than twenty standard deviations above it: resources meet their neighbors again and again, in many of the same activities, which is what a cellular organization means. The modularity of the best partition is twice the null value; a partition of comparable quality cannot be found in randomized spaces with the same degrees and sizes, so the cells of section 7.4 are not an artifact of the degree sequence. The degree assortativity is negative in all three, but more so in the real space (), reflecting the hub-and-spoke structure in which the sensors and the AGV share activities with low-degree operators and tools; the difference is about 1.5 null standard deviations from the configuration model, so it is only weakly significant. The real space has fewer 2-components (4) than either null model, because its strong overlaps are concentrated in chains of nested activities rather than scattered. Figure 9.4 shows the null distributions.
9.5 Further reading
Chodrow [120] introduces configuration models of hypergraphs and shows how the choice between vertex-labeled and stub-labeled ensembles affects the conclusions. Lee, Ko, and Shin [125] define h-motifs and give exact and approximate counting algorithms; Lotito et al. [127] study higher-order motifs of vertices and their significance. Landry, Young, and Eikmeier [128] define the simpliciality measures and survey empirical data sets, and LaRock and Lambiotte [129] study encapsulation. Do et al. [85] describe structural patterns and generators of real hypergraphs, and Lee et al. [29] survey the field.