Complex networks became famous after a curious experiment called six degrees of separation. In this experiment, researchers stated that you could get in touch with anyone in the world by just passing your message forward to six persons on average.

This experiment showed that, even with our world being so large, it’s highly connected. Therefore, it’s easy to access anyone we want. This gave origin to the term small-world.

Small-world network definition

A small-world network is a network where each node can be accessed with only a small number of steps, even if we have a lot of nodes with a low degree, which means that nodes don’t have a lot of neighbors. Because of that, we can say that a small-world network has a low diameter.

The diameter of a network is the maximum distance between the two farther-apart nodes in the network. In other words, it measures the maximum amount of steps we need to take to walk from one side of the network to the other.

To calculate the diameter of a network with NetworkX, we can use the nx.diameter() method.

Get hands-on with 1400+ tech skills courses.