hype_from_inc_mat: Create a Hypergraph From an Incidence Matrix

Description Usage Arguments Value Examples

View source: R/create_hypergraphs.R

Description

Create a Hypergraph From an Incidence Matrix

Usage

1
hype_from_inc_mat(inc_mat, directed = FALSE, real_coef = FALSE)

Arguments

inc_mat

An incidence matrix or, for an oriented hypergraph, a list of two incidence matrices.

directed

A logical value representing whether the hypergraph should be directed.

real_coef

A logical value representing whether the hypergraph should have real coefficients associating vertices to hyperedges.

Value

A hypergraph object with the given incidence structure.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
i1 <- matrix(
  c(1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0),
  nrow = 5,
  ncol = 3,
  dimnames = list(
    paste0("v", 1:5),
    paste0("h", 1:3)
  )
)
hype1 <- hype_from_inc_mat(i1)

i2 <- list(
  matrix(
    c(1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0),
    nrow = 4,
    ncol = 3,
    dimnames = list(
      paste0("v", 1:4),
      paste0("h", 1:3)
    )
  ),
  matrix(
    c(0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0),
    nrow = 4,
    ncol = 3,
    dimnames = list(
      paste0("v", 1:4),
      paste0("h", 1:3)
    )
  )
)
hype2 <- hype_from_inc_mat(i2)
hype3 <- hype_from_inc_mat(i2, directed = TRUE)

rhype documentation built on Nov. 9, 2021, 9:06 a.m.