rgraph_ws: Watts-Strogatz model

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/random_graph.R

Description

Generates a small-world random graph.

Usage

1
2
rgraph_ws(n, k, p, both.ends = FALSE, self = FALSE, multiple = FALSE,
  undirected = FALSE)

Arguments

n

Integer scalar. Set the size of the graph.

k

Integer scalar. Set the initial degree of the ring (must be less than n).

p

Numeric scalar/vector of length T. Set the probability of changing an edge.

both.ends

Logical scalar. When TRUE rewires both ends.

self

Logical scalar. When TRUE, allows loops (self edges).

multiple

Logical scalar. When TRUE allows multiple edges.

undirected

Logical scalar. Passed to ring_lattice

Details

Implemented as in Watts and Strogatz (1998). Starts from an undirected ring with n vertices all with degree k (so it must be an even number), and then rewire each edge by setting the endpoint (so now you treat it as a digraph) randomly any vertex in N \ {i} avoiding multiple links (by default) using the rewiring algorithm described on the paper.

Value

A random graph of size n*n following the small-world model. The resulting graph will have attr(graph, "undirected")=FALSE.

Author(s)

George G. Vega Yon

References

Watts, D. J., & Strogatz, S. H. (1998). Collective dynamics of "small-world" networks. Nature, 393(6684), 440<e2><80><93>2. http://dx.doi.org/10.1038/30918

Newman, M. E. J. (2003). The Structure and Function of Complex Networks. SIAM Review, 45(2), 167<e2><80><93>256. http://doi.org/10.1137/S003614450342480

See Also

Other simulation functions: permute_graph, rdiffnet, rewire_graph, rgraph_ba, rgraph_er, ring_lattice

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(igraph)
set.seed(7123)
x0 <- graph_from_adjacency_matrix(rgraph_ws(10,2, 0))
x1 <- graph_from_adjacency_matrix(rgraph_ws(10,2, .3))
x2 <- graph_from_adjacency_matrix(rgraph_ws(10,2, 1))

oldpar <- par(no.readonly=TRUE)
par(mfrow=c(1,3))
plot(x0, layout=layout_in_circle, edge.curved=TRUE, main="Regular")
plot(x1, layout=layout_in_circle, edge.curved=TRUE, main="Small-world")
plot(x2, layout=layout_in_circle, edge.curved=TRUE, main="Random")
par(oldpar)

netdiffuseR documentation built on May 19, 2017, 6:39 p.m.

Search within the netdiffuseR package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.