Weighted graphs [00NP]
- October 2, 2026
So far we have considered undirected and directed graphs, but each edge either exists or not. We will now consider weighted graphs, where each edge has some sort of cost.
Definition Weighted graph [00NN]
- October 2, 2026
A weighted (directed or undirected) graph is a graph where each edge is assigned a weight. That is, formally, there is a function w : E \to W which assigns to each edge e \in E a weight w(e) taken from a suitable set of weights W. The weight of an edge (u,v) is also denoted w(u,v) or w_{uv}.
The weight or length of a path is just the sum of the weights of its edges.
Remark ★ What kind of things can we use for weights? [00NO]
- October 2, 2026
For now, we will typically consider the set of weights W = \mathbb {R}^+, that is, nonnegative real numbers; later, we will consider W = \mathbb {R} and include the possibility of negative weights.
In general, one can use other sets besides real numbers for weights. For example, we could use integers, or natural numbers, or rational numbers. In fact, one can use any ordered semiring: there must be two operations corresponding to combining weights in series and in parallel (typically, for finding shortest paths, we combine weights in series by adding them, and in parallel by taking the minimum), these two operations must play nicely together, and there must also be some notion of "less than" which also plays nicely with the operations.
Remark Unweighted graphs as weighted graphs [00NQ]
- October 2, 2026
Note that we can usually think of an unweighted graph as a weighted graph where all edges have weight 1.