Generate random graphs according to the random dot product graph model
Source:R/games.R
sample_dot_product.Rd
In this model, each vertex is represented by a latent position vector. Probability of an edge between two vertices are given by the dot product of their latent position vectors.
Arguments
- vecs
A numeric matrix in which each latent position vector is a column.
- directed
A logical scalar, TRUE if the generated graph should be directed.
- ...
Passed to
sample_dot_product()
.
Details
The dot product of the latent position vectors should be in the [0,1] interval, otherwise a warning is given. For negative dot products, no edges are added; dot products that are larger than one always add an edge.
References
Christine Leigh Myers Nickel: Random dot product graphs, a model for social networks. Dissertation, Johns Hopkins University, Maryland, USA, 2006.
See also
sample_dirichlet()
, sample_sphere_surface()
and sample_sphere_volume()
for sampling position vectors.
Random graph models (games)
erdos.renyi.game()
,
sample_bipartite()
,
sample_correlated_gnp_pair()
,
sample_correlated_gnp()
,
sample_degseq()
,
sample_fitness_pl()
,
sample_fitness()
,
sample_forestfire()
,
sample_gnm()
,
sample_gnp()
,
sample_grg()
,
sample_growing()
,
sample_hierarchical_sbm()
,
sample_islands()
,
sample_k_regular()
,
sample_last_cit()
,
sample_pa_age()
,
sample_pa()
,
sample_pref()
,
sample_sbm()
,
sample_smallworld()
,
sample_traits_callaway()
,
sample_tree()
,
sample_()
Random graph models (games)
erdos.renyi.game()
,
sample_bipartite()
,
sample_correlated_gnp_pair()
,
sample_correlated_gnp()
,
sample_degseq()
,
sample_fitness_pl()
,
sample_fitness()
,
sample_forestfire()
,
sample_gnm()
,
sample_gnp()
,
sample_grg()
,
sample_growing()
,
sample_hierarchical_sbm()
,
sample_islands()
,
sample_k_regular()
,
sample_last_cit()
,
sample_pa_age()
,
sample_pa()
,
sample_pref()
,
sample_sbm()
,
sample_smallworld()
,
sample_traits_callaway()
,
sample_tree()
,
sample_()
Author
Gabor Csardi csardi.gabor@gmail.com
Examples
## A randomly generated graph
lpvs <- matrix(rnorm(200), 20, 10)
lpvs <- apply(lpvs, 2, function(x) {
return(abs(x) / sqrt(sum(x^2)))
})
g <- sample_dot_product(lpvs)
g
#> IGRAPH f7c3843 U--- 10 31 --
#> + edges from f7c3843:
#> [1] 1-- 4 1-- 5 1-- 6 1-- 7 1-- 8 1-- 9 1--10 2-- 4 2-- 5 2-- 6 2-- 8 2--10
#> [13] 3-- 4 3-- 5 3-- 8 3-- 9 3--10 4-- 5 4-- 7 4-- 8 4--10 5-- 6 5-- 7 5-- 8
#> [25] 6-- 7 6-- 8 7-- 8 7-- 9 8-- 9 8--10 9--10
## Sample latent vectors from the surface of the unit sphere
lpvs2 <- sample_sphere_surface(dim = 5, n = 20)
g2 <- sample_dot_product(lpvs2)
g2
#> IGRAPH 2974242 U--- 20 128 --
#> + edges from 2974242:
#> [1] 1-- 3 1-- 5 1-- 7 1-- 8 1-- 9 1--10 1--11 1--12 1--15 1--19
#> [11] 2-- 3 2-- 4 2-- 5 2-- 6 2-- 9 2--10 2--11 2--12 2--13 2--17
#> [21] 2--18 2--19 2--20 3-- 6 3-- 7 3-- 8 3-- 9 3--10 3--11 3--12
#> [31] 3--13 3--14 3--15 3--16 3--17 3--18 3--20 4-- 6 4--10 4--11
#> [41] 4--12 4--13 4--14 4--17 4--18 4--19 4--20 5-- 6 5-- 7 5--13
#> [51] 5--14 6-- 7 6-- 8 6-- 9 6--10 6--11 6--12 6--13 6--14 6--15
#> [61] 6--16 6--17 6--18 6--19 7-- 8 7--10 7--11 7--12 7--14 7--15
#> [71] 7--18 7--19 8-- 9 8--10 8--11 8--12 8--14 8--15 8--16 8--17
#> [81] 9--10 9--11 9--13 9--14 9--15 9--16 9--17 9--18 10--11 10--12
#> + ... omitted several edges