https://github.com/benmaier/smallworld
Generate and analyze small-world networks according to the revised Watts-Strogatz model where the randomization at β = 1 is truly equal to the Erdős-Rényi network model.
https://github.com/benmaier/smallworld
networks networkx networkx-drawing-utilities small-world-networks
Last synced: about 2 months ago
JSON representation
Generate and analyze small-world networks according to the revised Watts-Strogatz model where the randomization at β = 1 is truly equal to the Erdős-Rényi network model.
- Host: GitHub
- URL: https://github.com/benmaier/smallworld
- Owner: benmaier
- License: mit
- Created: 2018-11-20T16:38:30.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-12T15:09:28.000Z (almost 4 years ago)
- Last Synced: 2024-10-11T11:07:07.112Z (8 months ago)
- Topics: networks, networkx, networkx-drawing-utilities, small-world-networks
- Language: Python
- Size: 469 KB
- Stars: 18
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# smallworld
Generate and analyze small-world networks according to the revised Watts-Strogatz model where the randomization
at _β_ = 1 is truly equal to the Erdős-Rényi network model.In the Watts-Strogatz model each node rewires its _k_/2 rightmost edges with probality _β_. This means each node has halways minimum degree _k_/2. Also, at _β_ = 1, each edge has been rewired. Hence the probability of it existing is <_k_/(_N_-1), contrary to the ER model.
In the adjusted model, each pair of nodes is connected with a certain connection probability. If the lattice distance between the potentially connected nodes is d(i,j) <= _k_/2 then they are connected with short-range probability `p_S = k / (k + β (N-1-k))`, otherwise they're connected with long-range probability `p_L = β * p_S`.
## Install
pip install smallworld
Beware: `smallworld` only works with Python 3!
## Example
In the following example you can see how to generate and draw according to the model described above.
```python
from smallworld.draw import draw_network
from smallworld import get_smallworld_graphimport matplotlib.pyplot as pl
# define network parameters
N = 21
k_over_2 = 2
betas = [0, 0.025, 1.0]
labels = [ r'$\beta=0$', r'$\beta=0.025$', r'$\beta=1$']focal_node = 0
fig, ax = pl.subplots(1,3,figsize=(9,3))
# scan beta values
for ib, beta in enumerate(betas):# generate small-world graphs and draw
G = get_smallworld_graph(N, k_over_2, beta)
draw_network(G,k_over_2,focal_node=focal_node,ax=ax[ib])ax[ib].set_title(labels[ib],fontsize=11)
# show
pl.subplots_adjust(wspace=0.3)
pl.show()
```