rdiffnet(n, t, seed.nodes = "random", seed.p.adopt = 0.05,
seed.graph = "scale-free", rgraph.args = list(), rewire = TRUE,
rewire.args = list(p = 0.1, undirected = TRUE),
threshold.dist = function(x) runif(1), exposure.args = list(outgoing =
TRUE, valued = getOption("diffnet.valued", FALSE), normalized = TRUE))
rewire_graph
).rewire_graph
.sapply
, sets the
adoption threshold for each node.link{exposure}
.diffnet
class object.seed.graph
, a baseline graph is created.seed.nodes
.rewire=TRUE
$t-1$slices of the network are created
by iteratively rewiring the baseline graph.threshold.dist
function is applied to each node in the graph.seed.nodes
can be "marginal"
, "central"
or "random"
,
So each of these values sets the initial adopters using the vertices with lowest
degree, with highest degree or completely randomly. The number of early adoptes
is set as seed.p.adopt * n
. Please note that when marginal nodes are
set as seed it may be the case that no diffusion process is attained as the
chosen set of first adopters can be isolated.
The argument seed.graph
allows the user to set the algorithm used to
generate the first network (network in t=1). This can be either "scale-free"
(Barabasi-Albert model using the rgraph_ba
function, the default),
"bernoulli"
(Erdos-Renyi model using the rgraph_er
function),
or "small-world"
(Watts-Strogatz model using the rgraph_ws
function). The list rgraph.args
passes arguments to the chosen algorithm.
When rewire=TRUE
, the networks that follow t=1 will be generated using the
rewire_graph
function as $G(t) = G(t-1)$.
Finally, threshold.dist
sets the threshold for each vertex in the graph.
It is applied using sapply
as follows
sapply(1:n, threshold.dist)
By default sets the threshold to be random for each node in the graph.
rewire_graph
,
rgraph_ba
, rgraph_er
,
rgraph_ws
# Asimple example -----------------------------------------------------------
z <- rdiffnet(50,10)
z
summary(z)
# A more complex example: Adopt if at least one neighbor has adopted --------
y <- rdiffnet(50, 10, threshold.dist=function(x) 1,
exposure.args=list(valued=FALSE, normalized=FALSE))
Run the code above in your browser using DataLab