Returns the dual hypergraph: every hyperedge becomes a vertex and every
vertex becomes a hyperedge, with the transposed weighted incidence. For a
bag-construction text_hypergraph(), the dual is identical to rebuilding
with the opposite nodes orientation (tested), so document-level and
word-level analyses can share one constructed object. Duals of windowed
and kNN hypergraphs are returned as plain net_hg objects (their
corpus bookkeeping does not transpose meaningfully).
Arguments
- hg
A
text_hypergraph(),knn_hypergraph(), or any hypergraphsnet_hg.
Value
A hypergraph whose incidence is exactly the transpose of hg's,
sparse when hg is sparse, with every row and column kept: an isolated
vertex of hg becomes an empty hyperedge of the dual and an empty
hyperedge an isolated vertex, so the dual of the dual is hg's
incidence again. A text_hypergraph with flipped nodes for bag
constructions (dense or sparse), otherwise a net_hg. Hyperedge
metadata (edge_data, window counts) describes hyperedges that become
vertices, so it is not carried over. Accepted by all hg_* verbs.
References
Berge, C. (1989). Hypergraphs: Combinatorics of Finite Sets. North-Holland Mathematical Library 45. North-Holland.
Examples
hg <- text_hypergraph(c(a = "salt and soup", b = "soup and stars"))
dual <- dual_hypergraph(hg)
dual
#> Text hypergraph: 2 documents, 4 words (words as nodes, weight = n)
#> Hyperedges: 2 (documents); sizes 3-3, median 3
#> doc word count weight
#> a and 1 1
#> a salt 1 1
#> a soup 1 1
#> b and 1 1
#> b soup 1 1
#> b stars 1 1
hg_measures(dual, what = "edges")
#> edge size
#> 1 a 3
#> 2 b 3