Weighted graph
A weighted graph is a graph whose vertices or edges have been assigned real weights. A vertex-weighted graph has weights on its vertices and an edge-weighted graph has weights on its edges. Looking for a formal definition? Here you go:
A graph \(G = (V, E)\) is weighted if there exists an underlying function \(w
: E \rightarrow \mathbb{R}.\)
Subgraphs of weighted graphs are defined to have a weight that is the sum of the weights of all the edges in them:
The weight of a subgraph \(G = (V, E)\) is the sum of the weights of all its edges:
$$w(G) = \sum_{e \in E} w(e)$$
Weights could be used to represent how difficult it is to travel along a certain edge, or how expensive it is. In those cases, it'd be wise to find a minimum spanning tree to traverse the whole graph optimally.