Weighted graphs
So far, we have seen graphs that have a sort of binary representation, where 1 represents the existence of an edge between two nodes and 0 signifies that there is no connection between two edges. We have also seen graphs that have self-edges and multiple edges. However, sometimes we may want to represent the strength between the two nodes instead, which we represent as a weight. The greater the weight, the greater the strength.
These sorts of graphs can be used in a variety of settings, such as in social networks where the weight represents how frequently two people communicate with each other, which we can use to determine their closeness. In the adjacency matrix for a weighted graph, each Ai,j instance represents the weight ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access