Learn R Programming

wfg (version 0.1)

network.simu: Simulation of Networks with Community Structures

Description

Simulation of networks under the framework by Girvan and Newman. The vertices are connected with each other randomly and independents with probability p.in (within same community) and p.out (between communities).

Usage

network.simu(nv = c(32, 32, 32, 32), p.in = c(0.323, 0.323, 0.323, 0.323), p.out = 0.0625, p.del = 0)

Arguments

nv
a vector of community sizes. The number of communities equals the number of elements in this vector.
p.in
a vector of probability of a node to be randomly linked to other nodes in the same community.
p.out
the probability of a node to be randomly linked to nodes in other communities.
p.del
the proportion of links that are randomly deleted.

Value

net
The simulated network.
group
The membership of vertices.

References

Girvan, Michelle, and Mark EJ Newman. "Community structure in social and biological networks." Proceedings of the national academy of sciences 99.12 (2002): 7821-7826.

Examples

Run this code

## simulation of a network with four communities, each with size 32

library(wfg)
nv = c(32, 32, 32, 32)
p.in = c(0.452, 0.452, 0.452, 0.452)
p.out = 0.021
p.del = 0
net.simu <- network.simu(nv=nv, p.in=p.in, p.out=p.out, p.del=p.del)
net <- net.simu$net
group <- net.simu$group

## plot simulated network with vertices colored by membership

V(net)$size <- 7
V(net)$color <- group
plot(net, vertex.label='')

Run the code above in your browser using DataLab