Watts-Strogatz Small-World Network Simulation
Implementation of Watts-Strogatz small-world network model. The simulation starts with constructing a regular ring lattice with N nodes, where each node connects to K/2 neighbors on each side (K must be even). The algorithm then randomly rewires each edge with probability p, keeping one endpoint fixed while connecting the other to a randomly chosen node. The implementation ensures no self-connections or duplicate edges between nodes.