Adding edge weights

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 ...

Get Network Science with Python and NetworkX Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.