View source: R/bipartite_groups.R
| bipartite_groups | R Documentation |
Constructs a net_hypergraph from long-format event
data in which each row records a player participating in a group
(a session, team, project, transaction, or any group context). Each
unique group becomes one hyperedge spanning the players that appeared in
it. Optional weight column produces a weighted incidence matrix.
bipartite_groups(data, player, group, weight = NULL)
data |
Data frame in long format. Must contain |
player |
Character. Name of the column whose values become the hypergraph's nodes (players, participants, actors). |
group |
Character. Name of the column whose values become the hypergraph's hyperedges (groups, sessions, teams). |
weight |
Character or |
The bipartite representation preserves the full group structure without projecting to a pairwise network. A group of three players A, B, C produces a single 3-hyperedge containing all three, not three pairwise edges AB, AC, BC. This avoids information loss when group interactions are the primary unit of analysis (Perc et al. 2013).
Unlike build_hypergraph() (which derives hyperedges from a network's
clique structure), bipartite_groups() takes group memberships
directly. The two functions are complementary:
bipartite_groups() - when group membership is observed
(sessions, transactions, co-authorships).
build_hypergraph() - when only pairwise interactions are
observed and triadic structure must be inferred from triangles.
Rows with NA in either the player or group column (or, when
supplied, the weight column) are dropped silently.
A net_hypergraph object with the same structure produced by
build_hypergraph() (hyperedges, incidence, nodes, n_nodes,
n_hyperedges, size_distribution, params). The params list
records source = "bipartite_groups" and the original column names.
(experimental) Validated against a hand-computed table() incidence
reference only; no independent R package exposes the
long-format-to-binary-incidence primitive, because the operation is
definitionally table(). The code path is a direct one-to-one
restatement of its definition.
Perc, M., Gomez-Gardenes, J., Szolnoki, A., Floria, L. M., & Moreno, Y. (2013). Evolutionary dynamics of group interactions on structured populations: a review. Journal of the Royal Society Interface 10(80), 20120997. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1098/rsif.2012.0997")}
build_hypergraph() for the clique-based constructor.
df <- data.frame(
player = c("Alice", "Bob", "Carol", "Alice", "Bob",
"Dave", "Carol", "Dave", "Eve"),
session = c("S1", "S1", "S1", "S2", "S2",
"S3", "S3", "S3", "S3")
)
hg <- bipartite_groups(df, player = "player", group = "session")
print(hg)
summary(hg)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.