plot_diffnet(graph, cumadopt, slices = NULL, undirected = TRUE, vertex.col = c("white", "red", "blue"), vertex.shape = c("square", "circle", "circle"), vertex.cex = "degree", label = NA, edge.col = "gray", mode = "fruchtermanreingold", layout.par = NULL, mfrow.par = NULL, main = "Network in period %d", gmode = ifelse(undirected, "graph", "digraph"), lgd = list(x = "bottom", legend = c("Non-adopters", "New adopters", "Adopters"), pch = 21, bty = "n", cex = 1.2, horiz = TRUE), coords = NULL, vertex.frame.color = "gray", edge.arrow.size = 0.25, intra.space = c(0.15, 0.15), key.height = 0.1, rescale.fun = function(x) rescale_vertex_igraph(x, adjust = 100), ...)
netdiffuseR-graphs
).TRUE
only the lower triangle will be processed.par.
sprintf.
gplot.
legend
.plot.igraph
plot.igraph
plot.igraph
rescale_vertex_igraph
plot.igraph
.gplot
,
and its layout via gplot.layout
, both from
the (sna) package.In order to center the attention on the diffusion process itself, the positions of each vertex are computed only once by aggregating the networks through time, this is, instead of computing the layout for each time $t$, the function creates a new graph accumulating links through time.
The mfrow.par
sets how to arrange the plots on the device. If $T=5$
and mfrow.par=c(2,3)
, the first three networks will be in the top
of the device and the last two in the bottom.
The argument vertex.col
contains the colors of non-adopters, new-adopters,
and adopters respectively. The new adopters (default color "red"
) have a different
color that the adopters when the graph is at their time of adoption, hence,
when the graph been plotted is in $t=2$ and $toa=2$ the vertex will
be plotted in red.
vertex.cex
can either be a numeric scalar, a numeric vector or a character
scalar taking any of the following values "degree"
, "indegree"
, or
"outdegree"
. The later will be passed to dgr
to calculate
degree of the cumulated graph and will be normalized as
$$vertex.cex = [d - \min(d) + .1]/[\max(d) - \min(d) + .1]\times 2$$
where $d=sqrt(dgr(graph))$.
dgr
,
diffusionMap
, drawColorKey
,
grid_distribution
,
hazard_rate
, plot_adopters
,
plot_diffnet2
,
plot_infectsuscep
,
plot_threshold
,
rescale_vertex_igraph
# Generating a random graph
set.seed(1234)
n <- 6
nper <- 5
graph <- rgraph_er(n,nper, p=.3, undirected = FALSE)
toa <- sample(2000:(2000+nper-1), n, TRUE)
adopt <- toa_mat(toa)
plot_diffnet(graph, adopt$cumadopt)
Run the code above in your browser using DataLab