incidence_matrix: Find the Incidence Matrix of a Hypergraph

View source: R/create_matrices.R

incidence_matrixR Documentation

Find the Incidence Matrix of a Hypergraph

Description

An incidence matrix has rows indexed by vertices and columns indexed by hyperedges. Each entry is non-zero if the associated vertex is a member of the associated hyperedge. For an oriented hypergraph, this returns a list of two matrices with the first representing incidence to one end of the hyperedges and the second representing incidence to the other end. For a directed hypergraph the first represents incidence to the tail of a hyperedge and the second represents incidence to the head.

Usage

incidence_matrix(hype, augment_oriented = TRUE, as_matrix = FALSE)

Arguments

hype

A hypergraph object

augment_oriented

Whether to augment an oriented hypergraph

as_matrix

Whether to coerce the result to a simple matrix

Details

It is hard to use the incidence matrices of oriented undirected hypergraphs in calculations. The augment_oriented option turns the hypergraph into a directed hypergraph, but each hyperedge is represented twice, once pointing in each direction. This is much easier to use for further calculations.

Value

An incidence matrix or a list of two incidence matrices.

Examples

h1 <- example_hype()
incidence_matrix(h1)

h2 <- example_hype(oriented = TRUE, directed = TRUE)
incidence_matrix(h2)

rhype documentation built on Aug. 6, 2022, 5:05 p.m.