Skip to contents

Generate bipartite graphs using the Erdős-Rényi model

Usage

bipartite_gnm(n1, n2, m, ..., directed = FALSE, mode = c("out", "in", "all"))

bipartite_gnp(n1, n2, p, ..., directed = FALSE, mode = c("out", "in", "all"))

sample_bipartite_gnm(
  n1,
  n2,
  m,
  ...,
  directed = FALSE,
  mode = c("out", "in", "all")
)

sample_bipartite_gnp(
  n1,
  n2,
  p,
  ...,
  directed = FALSE,
  mode = c("out", "in", "all")
)

Arguments

n1

Integer scalar, the number of bottom vertices.

n2

Integer scalar, the number of top vertices.

m

Integer scalar, the number of edges for \(G(n,m)\) graphs.

...

These dots are for future extensions and must be empty.

directed

Logical scalar, whether to create a directed graph. See also the mode argument.

mode

Character scalar, specifies how to direct the edges in directed graphs. If it is ‘out’, then directed edges point from bottom vertices to top vertices. If it is ‘in’, edges point from top vertices to bottom vertices. ‘out’ and ‘in’ do not generate mutual edges. If this argument is ‘all’, then each edge direction is considered independently and mutual edges might be generated. This argument is ignored for undirected graphs.

p

Real scalar, connection probability for \(G(n,p)\) graphs.

Details

Similarly to unipartite (one-mode) networks, we can define the \(G(n,p)\), and \(G(n,m)\) graph classes for bipartite graphs, via their generating process. In \(G(n,p)\) every possible edge between top and bottom vertices is realized with probability \(p\), independently of the rest of the edges. In \(G(n,m)\), we uniformly choose \(m\) edges to realize.

bipartite_game_gnm(), vcount(), bipartite_game_gnp()

Examples


## empty graph
sample_bipartite_gnp(10, 5, p = 0)
#> ── <igraph> Bipartite Gnp random graph ────────────────────────────── 7640905 ──
#>  undirected · bipartite
#>  15 vertices · 0 edges
#> 
#> ── Attributes ──────────────────────────────────────────────────────────────────
#> → graph:  name <chr>, p <dbl>
#> → vertex: type <lgl>

## full graph
sample_bipartite_gnp(10, 5, p = 1)
#> ── <igraph> Bipartite Gnp random graph ────────────────────────────── 73ed106 ──
#>  undirected · bipartite
#>  15 vertices · 50 edges
#> 
#> ── Attributes ──────────────────────────────────────────────────────────────────
#> → graph:  name <chr>, p <dbl>
#> → vertex: type <lgl>
#> 
#> ── Edges ───────────────────────────────────────────────────────────────────────
#>  [1] 1 ─ 11   1 ─ 12   1 ─ 13   1 ─ 14   1 ─ 15   2 ─ 11   2 ─ 12   2 ─ 13  
#>  [9] 2 ─ 14   2 ─ 15   3 ─ 11   3 ─ 12   3 ─ 13   3 ─ 14   3 ─ 15   4 ─ 11  
#> [17] 4 ─ 12   4 ─ 13   4 ─ 14   4 ─ 15   5 ─ 11   5 ─ 12   5 ─ 13   5 ─ 14  
#> [25] 5 ─ 15   6 ─ 11   6 ─ 12   6 ─ 13   6 ─ 14   6 ─ 15   7 ─ 11   7 ─ 12  
#> [33] 7 ─ 13   7 ─ 14   7 ─ 15   8 ─ 11   8 ─ 12   8 ─ 13   8 ─ 14   8 ─ 15  
#> [41] 9 ─ 11   9 ─ 12   9 ─ 13   9 ─ 14   9 ─ 15   10 ─ 11  10 ─ 12  10 ─ 13 
#> [49] 10 ─ 14  10 ─ 15 

## random bipartite graph
sample_bipartite_gnp(10, 5, p = 0.1)
#> ── <igraph> Bipartite Gnp random graph ────────────────────────────── 877a207 ──
#>  undirected · bipartite
#>  15 vertices · 6 edges
#> 
#> ── Attributes ──────────────────────────────────────────────────────────────────
#> → graph:  name <chr>, p <dbl>
#> → vertex: type <lgl>
#> 
#> ── Edges ───────────────────────────────────────────────────────────────────────
#> [1] 7 ─ 11   6 ─ 14   9 ─ 14   3 ─ 15   6 ─ 15   10 ─ 15 

## directed bipartite graph, G(n,m)
sample_bipartite_gnm(10, 5, m = 20, directed = TRUE, mode = "all")
#> ── <igraph> Bipartite Gnm random graph ────────────────────────────── cee16e6 ──
#>  directed · bipartite
#>  15 vertices · 20 edges
#> 
#> ── Attributes ──────────────────────────────────────────────────────────────────
#> → graph:  name <chr>, m <dbl>
#> → vertex: type <lgl>
#> 
#> ── Edges ───────────────────────────────────────────────────────────────────────
#>  [1] 4 → 12   4 → 13   7 → 13   8 → 13   3 → 14   5 → 14   7 → 14   4 → 15  
#>  [9] 15 → 1   11 → 2   14 → 2   11 → 3   14 → 4   13 → 5   12 → 6   14 → 6  
#> [17] 11 → 7   12 → 7   15 → 9   12 → 10