First a lattice is created with the given dim, size and
nei arguments. Then the edges of the lattice are rewired uniformly
randomly with probability p.
Note that this function might create graphs with loops and/or multiple
edges. You can use simplify to get rid of these.
References
Duncan J Watts and Steven H Strogatz: Collective dynamics of
‘small world’ networks, Nature 393, 440-442, 1998.