File: sample_pref.Rd

package info (click to toggle)
r-cran-igraph 2.1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 27,044 kB
  • sloc: ansic: 204,981; cpp: 21,711; fortran: 4,090; yacc: 1,229; lex: 519; sh: 52; makefile: 8
file content (133 lines) | stat: -rw-r--r-- 4,208 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/games.R
\name{sample_pref}
\alias{sample_pref}
\alias{pref}
\alias{sample_asym_pref}
\alias{asym_pref}
\title{Trait-based random generation}
\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{
\item{nodes}{The number of vertices in the graphs.}

\item{types}{The number of different vertex types.}

\item{type.dist}{The distribution of the vertex types, a numeric vector of
length \sQuote{types} containing non-negative numbers. The vector will be
normed to obtain probabilities.}

\item{fixed.sizes}{Fix the number of vertices with a given vertex type
label. The \code{type.dist} argument gives the group sizes (i.e. number of
vertices with the different labels) in this case.}

\item{pref.matrix}{A square matrix giving the preferences of the vertex
types. The matrix has \sQuote{types} rows and columns. When generating
an undirected graph, it must be symmetric.}

\item{directed}{Logical constant, whether to create a directed graph.}

\item{loops}{Logical constant, whether self-loops are allowed in the graph.}

\item{...}{Passed to the constructor, \code{sample_pref()} or
\code{sample_asym_pref()}.}

\item{type.dist.matrix}{The joint distribution of the in- and out-vertex
types.}
}
\value{
An igraph graph.
}
\description{
Generation of random graphs based on different vertex types.
}
\details{
Both models generate random graphs with given vertex types. For
\code{sample_pref()} the probability that two vertices will be connected
depends on their type and is given by the \sQuote{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
\sQuote{type.dist} vector.

For \code{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 \sQuote{pref.matrix} argument, which can be
asymmetric. The joint distribution for the in- and out-types is given in the
\sQuote{type.dist.matrix} argument.

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

pf <- matrix(c(1, 0, 0, 1), nrow = 2)
g <- sample_pref(20, 2, pref.matrix = pf)
\dontshow{if (rlang::is_installed("tcltk") && rlang::is_interactive()) withAutoprint(\{ # examplesIf}
# example code

tkplot(g, layout = layout_with_fr)
\dontshow{\}) # examplesIf}

pf <- matrix(c(0, 1, 0, 0), nrow = 2)
g <- sample_asym_pref(20, 2, pref.matrix = pf)
\dontshow{if (rlang::is_installed("tcltk") && rlang::is_interactive()) withAutoprint(\{ # examplesIf}
tkplot(g, layout = layout_in_circle)
\dontshow{\}) # examplesIf}
}
\seealso{
Random graph models (games)
\code{\link{erdos.renyi.game}()},
\code{\link{sample_}()},
\code{\link{sample_bipartite}()},
\code{\link{sample_chung_lu}()},
\code{\link{sample_correlated_gnp}()},
\code{\link{sample_correlated_gnp_pair}()},
\code{\link{sample_degseq}()},
\code{\link{sample_dot_product}()},
\code{\link{sample_fitness}()},
\code{\link{sample_fitness_pl}()},
\code{\link{sample_forestfire}()},
\code{\link{sample_gnm}()},
\code{\link{sample_gnp}()},
\code{\link{sample_grg}()},
\code{\link{sample_growing}()},
\code{\link{sample_hierarchical_sbm}()},
\code{\link{sample_islands}()},
\code{\link{sample_k_regular}()},
\code{\link{sample_last_cit}()},
\code{\link{sample_pa}()},
\code{\link{sample_pa_age}()},
\code{\link{sample_sbm}()},
\code{\link{sample_smallworld}()},
\code{\link{sample_traits_callaway}()},
\code{\link{sample_tree}()}
}
\author{
Tamas Nepusz \email{ntamas@gmail.com} and Gabor Csardi
\email{csardi.gabor@gmail.com} for the R interface
}
\concept{games}
\keyword{graphs}