sample_pref {igraph} R Documentation

## Trait-based random generation

### Description

Generation of random graphs based on different vertex types.

### Usage

sample_pref(
nodes,
types,
type.dist = rep(1, types),
fixed.sizes = FALSE,
pref.matrix = matrix(1, types, types),
directed = FALSE,
loops = FALSE
)

pref(...)

sample_asym_pref(
nodes,
types,
type.dist.matrix = matrix(1, types, types),
pref.matrix = matrix(1, types, types),
loops = FALSE
)

asym_pref(...)


### Arguments

 nodes The number of vertices in the graphs. types The number of different vertex types. type.dist The distribution of the vertex types, a numeric vector of length ‘types’ containing non-negative numbers. The vector will be normed to obtain probabilities. fixed.sizes Fix the number of vertices with a given vertex type label. The type.dist argument gives the group sizes (i.e. number of vertices with the different labels) in this case. pref.matrix A square matrix giving the preferences of the vertex types. The matrix has ‘types’ rows and columns. directed Logical constant, whether to create a directed graph. loops Logical constant, whether self-loops are allowed in the graph. ... Passed to the constructor, sample_pref() or sample_asym_pref(). type.dist.matrix The joint distribution of the in- and out-vertex types.

### Details

Both models generate random graphs with given vertex types. For sample_pref() the probability that two vertices will be connected depends on their type and is given by the ‘pref.matrix’ argument. This matrix should be symmetric to make sense but this is not checked. The distribution of the different vertex types is given by the ‘type.dist’ vector.

For sample_asym_pref() each vertex has an in-type and an out-type and a directed graph is created. The probability that a directed edge is realized from a vertex with a given out-type to a vertex with a given in-type is given in the ‘pref.matrix’ argument, which can be asymmetric. The joint distribution for the in- and out-types is given in the ‘type.dist.matrix’ argument.

The types of the generated vertices can be retrieved from the type vertex attribute for sample_pref() and from the intype and outtype vertex attribute for sample_asym_pref().

An igraph graph.

### Author(s)

Tamas Nepusz ntamas@gmail.com and Gabor Csardi csardi.gabor@gmail.com for the R interface

### See Also

sample_traits(). sample_traits_callaway()

Random graph models (games) erdos.renyi.game(), sample_bipartite(), sample_correlated_gnp_pair(), sample_correlated_gnp(), sample_degseq(), sample_dot_product(), 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_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_dot_product(), 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_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_dot_product(), 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_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_dot_product(), 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_sbm(), sample_smallworld(), sample_traits_callaway(), sample_tree(), sample_()

### Examples


pf <- matrix(c(1, 0, 0, 1), nrow = 2)
g <- sample_pref(20, 2, pref.matrix = pf)
## Not run:
tkplot(g, layout = layout_with_fr)

## End(Not run)

pf <- matrix(c(0, 1, 0, 0), nrow = 2)
g <- sample_asym_pref(20, 2, pref.matrix = pf)
## Not run:
tkplot(g, layout = layout_in_circle)

## End(Not run)



[Package igraph version 1.5.1 Index]