Edge length (source code)

= Edge length
{title2=$\ell(e)\geq0$}

An edge length is a nonnegative numerical label assigned to an edge of a <graph> to measure the length or cost of traversing it. A path's length is the sum of its edge lengths, and the shortest-path distance is the infimum of these sums. This metric use is more restrictive than a general <edge weight>, which can be negative in other models.

For a triangle with edge lengths $\ell(AB)=2$, $\ell(BC)=3$, and $\ell(AC)=10$, the shortest distance from $A$ to $C$ is five via $B$, although the direct edge has length ten. Thus edge length and vertex-to-vertex distance need not coincide.

Strictly positive lengths on a finite connected graph give a metric on its vertices. Zero-length edges can identify distinct vertices at distance zero, producing a pseudometric; negative edges can destroy the metric interpretation. The labels need not equal the apparent lengths of edges in a drawing.