Skip to contents

Sample a pair of random graphs from stochastic block model with correlation between two graphs being corr and edge probability being p.

Usage

sample_correlated_sbm_pair(
  n,
  pref.matrix,
  block.sizes,
  corr,
  core.block.sizes = NULL,
  permutation = 1:n,
  ...
)

Arguments

n

An integer. Number of vertices in the graph.

pref.matrix

The matrix giving the Bernoulli rates. This is a K-by-K matrix, where k is the number of groups. The probability of creating an edge between vertices from groups i and j is given by element i,j. For undirected graphs, this matrix must be symmetric.

block.sizes

A numeric vector. Give the number of vertices in each group. The sum of the vector must match the number of vertices.

corr

A number. The target Pearson correlation between the adjacency matrices of the generated graphs. It must be in open (0,1) interval.

core.block.sizes

A numeric vector. Give the number of core vertices in each group. Entries should be smaller than block.sizes and the vector length should be the same as block.sizes.

permutation

A numeric vector, permute second graph.

...

Passed to sample_sbm.

Value

Returns a list of two igraph object, named graph1 and

graph2. If sample two graphs with junk vertices, in each corresponding block the first core.block.sizes vertices are core vertices and the rest are junk vertices.

References

P. Holland and K. Laskey and S. Leinhardt (1983), Stochastic Blockmodels: First Steps. Social Networks, pages 109-137.

F. Fang and D. Sussman and V. Lyzinski (2018), Tractable Graph Matching via Soft Seeding. https://arxiv.org/abs/1807.09299.

Examples

pm <- cbind( c(.1, .001), c(.001, .05) )
sample_correlated_sbm_pair(n=1000, pref.matrix=pm, block.sizes=c(300,700), corr=0.5)
#> $graph1
#> IGRAPH a14a0fb U--- 1000 17089 -- Stochastic block model
#> + attr: name (g/c), loops (g/l)
#> + edges from a14a0fb:
#>  [1]  4-- 6  2-- 7  9--10 10--11  5--12  6--12  7--12  7--13 11--13  3--14
#> [11]  6--16 12--16 10--17 12--17 15--18  6--19  7--19 10--19  2--21 10--21
#> [21] 14--21 19--21 20--21  9--22 15--22  7--23  9--23 12--23 16--24 18--24
#> [31] 15--25 20--25  9--26 15--27 18--27 21--27 24--27 26--27  6--28  8--28
#> [41] 14--28  1--29  6--29 11--29 26--29 27--29 28--29  1--30 11--30 12--30
#> [51] 29--30 10--31  1--32  9--32 25--33 23--34 31--34 12--35  1--36 11--36
#> [61] 24--36  1--37  3--37  6--37 13--37 23--37 24--37 29--37 13--38 16--38
#> [71] 32--38  8--39 12--39 23--39 24--39 36--39  2--40  6--40 35--40 10--41
#> + ... omitted several edges
#> 
#> $graph2
#> IGRAPH c5f59de U--- 1000 16833 -- Stochastic block model
#> + attr: name_1 (g/c), name_2 (g/c), loops_1 (g/l), loops_2 (g/l), name
#> | (g/c), loops (g/l)
#> + edges from c5f59de:
#>  [1] 984-- 989 984-- 987 983-- 984 979-- 999 979-- 996 979-- 991 979-- 986
#>  [8] 978--1000 978-- 998 978-- 980 975-- 991 974-- 981 973-- 997 972-- 985
#> [15] 971-- 994 971-- 990 971-- 981 971-- 978 970-- 992 970-- 978 970-- 972
#> [22] 969-- 971 967-- 992 966-- 992 966-- 989 965-- 999 965-- 988 965-- 987
#> [29] 964-- 993 964-- 976 963-- 987 962-- 987 962-- 966 961-- 999 961-- 998
#> [36] 961-- 977 961-- 974 961-- 971 959-- 975 959-- 962 958-- 990 958-- 985
#> [43] 957--1000 957-- 989 957-- 987 957-- 986 957-- 978 957-- 973 956-- 993
#> + ... omitted several edges
#> 
sample_correlated_sbm_pair(n=1000, pref.matrix=pm, block.sizes=c(300,700), corr=0.5,
core.block.sizes=c(200,500))
#> $graph1
#> IGRAPH 26a5ebf U--- 1000 16836 -- Stochastic block model
#> + attr: name (g/c), loops (g/l)
#> + edges from 26a5ebf:
#>  [1]  1-- 2  1-- 6  4-- 8  2-- 9  3-- 9  8--10  9--12  2--13 12--14 12--15
#> [11]  2--16  3--16  5--16 13--16  7--17  8--17 11--17 12--17 14--17  1--18
#> [21] 16--19 18--19 10--20 11--20 17--20  3--21  2--23 11--23 15--23 21--23
#> [31] 11--24 15--24 17--24 20--24 15--25 19--25 23--25  6--26 14--26 26--27
#> [41]  3--28  5--28 15--28 20--28 25--28  9--30 13--30 21--30 10--31 26--31
#> [51] 29--31  9--32 27--32  5--33 18--33 20--33 21--33 21--34 30--34 12--35
#> [61] 20--35 30--35  4--36  5--36 11--36 14--36 24--36 28--36 30--36  8--37
#> [71] 13--37 18--37 24--37 25--37 28--37 12--38 16--38 18--38 25--38 30--38
#> + ... omitted several edges
#> 
#> $graph2
#> IGRAPH 51f40f7 U--- 1000 17004 -- Stochastic block model
#> + attr: name_1 (g/c), name_2 (g/c), loops_1 (g/l), loops_2 (g/l), name
#> | (g/c), loops (g/l)
#> + edges from 51f40f7:
#>  [1] 999--1000 988-- 994 985-- 996 985-- 990 985-- 989 984-- 996 983-- 998
#>  [8] 981-- 986 980-- 993 978-- 989 977-- 985 976-- 996 976-- 992 976-- 988
#> [15] 976-- 977 975-- 995 975-- 979 974-- 995 974-- 984 974-- 981 974-- 978
#> [22] 973-- 986 973-- 977 973-- 974 972-- 997 972-- 996 971-- 999 971-- 975
#> [29] 971-- 973 970-- 995 970-- 986 970-- 985 970-- 972 969-- 998 969-- 983
#> [36] 969-- 973 967-- 997 967-- 994 967-- 993 967-- 986 967-- 982 967-- 972
#> [43] 963-- 995 963-- 992 963-- 990 963-- 972 962-- 984 961-- 996 961-- 994
#> + ... omitted several edges
#>