So far, all of the edges in this chapter have been unweighted, but the Graph class also supports weighted edges. Edge weights are handy when connections can have different strengths and when there is a way to quantify the strength of a connection; for example, how often two friends talk to each other, the volume of fluid a pipe can transport, or the number of direct flights between two cities.
The karate club network doesn't have any additional information about the strength of the edges, but there are relevant properties of those edges that can be calculated, such as the tie strength. Tie strength increases with the number of neighbors that two nodes have in common. It is motivated by the observation that closer friends tend to have more friends in common, and it can often reveal insight into the structure of a social network. The following code calculates...