And so, while this model gets the two properties that we discussed,

the clustering coefficient and the shortest paths, it doesn't get the power

level degree distribution that we also observe in real networks.

And the preferential attachment model gets correctly.

There are certain variants of the small world network in NetworkX that

you can use.

So the first one addresses and issue that small world networks,

in general, can become disconnected.

So there's nothing that makes them so

that they necessarily are in a single component.

If you rewire too many of the edges,

you could end up with more than one connected component.

And this is sometimes something we don't want.

Sometimes we want to create a network that is connected,

where every node can reach every other node.

And so if that's what we need,

then we can use the function connected watts_strogatz_graph,

which has the same parameters except it has an additional parameter t.

And what it does is, it runs the standard watts_strogatz_graph model up to t times

until it returns a connected small world network.

So it kind of keeps trying different iterations of the model until

it gets one that's connected.

Unless it runs out of tries, which if it tries more than t times,

then it returns some type of error.

There's also the newman_watts_strogatz_graph,

which is very similar to its small world model.

But instead of rewiring the edges, when it's time to rewire an edge,

it actually adds a new edge and leaves the other one still in the network, and

still does this with probability p.

So instead of rewiring, it adds additional edges.

In summary, today we looked at real networks and

we found that they appear to have a small shortest path.

And that they tend to have high clustering coefficient.

And we found that this preferential attachment model that we talked about last

time produces that works that have small shortest paths, but

they also have a very small in clustering coefficient.

So then we talked about a new model, the small world a model,

that starts with a ring lattice with nodes connected to the k nearest neighbors, so

it starts out a very high clustering.

But then it rewires some of the edges with probability p.

And we found that for some values of p, namely for very small values of p,

this small world networks have a small average shortest path.

Because new long edges are added to that network and those create bridges for

nodes to reach each other.

And they still maintain these high clustering coefficient,

which matches what we observe in the real networks that we look at.

However, the degree distribution of a small world network is not a power law,

as we had also seen in real data.

And on NetworkX, you can use the function watts_strogatz_graph or

some of the other variants that we covered to produce small world networks.

And that's all for today, I hope to see you next time.