Skip to contents

Sample a pair of graphs with specified edge probability and correlation between each pair of vertices.

Usage

sample_correlated_ieg_pair(
  n,
  p_mat,
  c_mat,
  ncore = n,
  directed = FALSE,
  loops = FALSE,
  permutation = 1:n
)

sample_correlated_rdpg_pair(X, corr, ncore = nrow(X), ...)

Arguments

n

An integer. Number of total vertices for the sampled graphs.

p_mat

An n-by-n matrix. Edge probability matrix, each entry should be in the open (0,1) interval.

c_mat

An n-by-n matrix. The target Pearson correlation matrix, each entry should be in the open (0,1) interval.

ncore

An integer. Number of core vertices.

directed

Logical scalar, whether to generate directed graphs.

loops

Logical scalar, whether self-loops are allowed in the graph.

permutation

A numeric vector,permute second graph.

X

A matrix. Dot products matrix, each entry must be in open (0,1) interval.

corr

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

...

Passed to sample_correlated_ieg_pair.

Value

sample_correlated_ieg_pair returns two igraph objects named

graph1 and graph2. If sample two graphs with junk vertices, the first ncore vertices are core vertices and the rest are junk vertices.

sample_correlated_rdpg_pair returns two igraph objects named graph1 and graph2 that are sampled from random dot product graphs model. If sample two graphs with junk vertices, the first ncore vertices are core vertices and the rest are junk vertices.

References

S. Young and E. Scheinerman (2007), Random Dot Product Graph Models for Social Networks. Proceedings of the 5th International Conference on Algorithms and Models for the Web-graph, pages 138-149.

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

Examples

n <- 50
p_mat <- matrix(runif(n^2),n)
c_mat <- matrix(runif(n^2),n)
sample_correlated_ieg_pair(n,p_mat,c_mat,ncore=40)
#> $graph1
#> IGRAPH 1d2cbfb U--- 50 594 -- 
#> + edges from 1d2cbfb:
#>   [1] 1-- 5 1-- 6 1-- 8 1-- 9 1--10 1--11 1--18 1--21 1--22 1--23 1--24 1--27
#>  [13] 1--29 1--30 1--32 1--35 1--36 1--37 1--38 1--39 1--40 1--41 1--47 1--48
#>  [25] 2-- 3 2-- 4 2-- 7 2-- 9 2--10 2--13 2--14 2--15 2--20 2--21 2--22 2--29
#>  [37] 2--30 2--33 2--34 2--36 2--37 2--39 2--40 2--43 2--45 2--46 3-- 5 3-- 8
#>  [49] 3--12 3--14 3--16 3--18 3--20 3--23 3--24 3--27 3--28 3--32 3--36 3--37
#>  [61] 3--45 3--46 3--49 4-- 5 4-- 7 4-- 8 4--10 4--12 4--13 4--15 4--18 4--20
#>  [73] 4--21 4--25 4--27 4--29 4--35 4--38 4--42 4--43 4--44 4--45 4--47 4--48
#>  [85] 4--49 4--50 5-- 6 5-- 7 5-- 8 5-- 9 5--10 5--11 5--14 5--15 5--16 5--17
#>  [97] 5--19 5--20 5--23 5--24 5--25 5--27 5--28 5--35 5--36 5--37 5--39 5--40
#> + ... omitted several edges
#> 
#> $graph2
#> IGRAPH 66fc2a0 U--- 50 607 -- 
#> + edges from 66fc2a0:
#>   [1] 1-- 5 1-- 8 1--10 1--11 1--18 1--21 1--22 1--23 1--24 1--27 1--28 1--29
#>  [13] 1--32 1--35 1--37 1--39 1--40 1--41 1--44 1--47 1--48 2-- 4 2-- 9 2--13
#>  [25] 2--14 2--15 2--18 2--20 2--21 2--22 2--29 2--33 2--34 2--36 2--37 2--38
#>  [37] 2--39 2--40 2--45 2--46 2--48 3-- 5 3-- 6 3-- 8 3--12 3--13 3--14 3--16
#>  [49] 3--18 3--19 3--23 3--24 3--26 3--27 3--28 3--30 3--32 3--36 3--37 3--44
#>  [61] 3--45 3--46 3--48 3--49 4-- 7 4-- 8 4--10 4--11 4--12 4--15 4--18 4--19
#>  [73] 4--20 4--21 4--25 4--27 4--29 4--35 4--38 4--40 4--42 4--43 4--44 4--45
#>  [85] 4--47 4--48 4--49 5-- 6 5-- 8 5-- 9 5--11 5--12 5--14 5--15 5--16 5--17
#>  [97] 5--18 5--20 5--24 5--25 5--27 5--28 5--29 5--34 5--35 5--36 5--37 5--39
#> + ... omitted several edges
#> 

## sample a pair of igraph objects from random dot
## product graphs model with dimension 3 and scale 8
n <- 50
xdim <- 3
scale <- 8
X <- matrix(rgamma(n*(xdim+1),scale,1),n,xdim+1)
X <- X/rowSums(X)
X <- X[,1:xdim]
sample_correlated_rdpg_pair(X,corr=0.5,ncore=40)
#> $graph1
#> IGRAPH dbac679 U--- 50 216 -- 
#> + edges from dbac679:
#>  [1]  1-- 8  2--14  2--24  2--35  2--38  2--41  2--47  2--48  2--49  3-- 7
#> [11]  3--10  3--13  3--14  3--15  3--17  3--23  3--26  3--27  3--36  3--38
#> [21]  3--43  3--44  3--46  3--50  4-- 5  4-- 8  4--11  4--25  4--30  4--37
#> [31]  5-- 8  5--13  5--23  5--26  5--34  6-- 9  6--10  6--42  6--44  7--13
#> [41]  7--18  7--21  7--23  7--26  7--31  7--33  7--36  7--43  8--10  8--13
#> [51]  8--19  8--21  8--22  8--32  8--36  8--49  9--13  9--17  9--20  9--22
#> [61]  9--40 10--16 10--18 10--19 10--20 10--22 10--25 10--34 10--35 11--22
#> [71] 11--40 11--43 12--14 12--15 12--20 12--26 12--30 12--37 12--43 13--17
#> [81] 13--27 13--28 13--34 13--35 13--37 13--39 13--40 13--41 13--42 13--43
#> + ... omitted several edges
#> 
#> $graph2
#> IGRAPH 4453f45 U--- 50 210 -- 
#> + edges from 4453f45:
#>  [1]  1-- 8  1--21  1--25  1--28  1--46  2--36  2--37  2--38  2--43  3-- 9
#> [11]  3--12  3--15  3--17  3--23  3--26  3--27  3--31  3--36  3--38  4-- 8
#> [21]  4--18  4--25  4--30  5-- 8  5--18  5--26  5--27  5--30  5--32  5--34
#> [31]  5--40  5--46  5--49  6-- 9  6--10  6--20  6--29  6--34  7--13  7--23
#> [41]  7--26  7--28  7--31  7--39  7--42  7--44  8-- 9  8--10  8--13  8--19
#> [51]  8--21  8--22  8--24  8--32  8--36  8--40  8--47  8--49  9--12  9--13
#> [61]  9--17  9--22  9--27  9--28  9--34  9--40 10--16 10--19 10--20 10--22
#> [71] 10--25 10--26 10--27 10--32 10--35 10--41 11--41 12--18 12--20 12--26
#> [81] 12--28 12--30 12--34 12--44 13--17 13--25 13--27 13--34 13--40 13--44
#> + ... omitted several edges
#>