definition example

Given a Metric Space and subsets , the (asymmetric, “Lawvere”) Hausdorff distance is

— “put me in the worst part of ; how far must I go to get anywhere in ?“. The usual symmetric Hausdorff metric is ; 7 Sketches finds the unsymmetrized notion “more interesting”. It makes the regions US, Spain, Boston a Lawvere Metric Space: , , and .

Sources: 7 Sketches §2.3.3 (footnote 3), Exercise 2.52, Remark 2.97.

Generalization (Remark 2.97). For any Quantale and -category with subsets of objects,

For this asks “can I get into from every ?”, i.e. ; for (modes of transportation) it gives the modes that get you into from every point of . (In , and because of the reversed order.)

Docs: plain Julia — Catlab has no dedicated API for this; related: Catlab v0.16 docs · GATlab standard library

# Lawvere-Hausdorff distance between index sets U, V of a finite metric matrix D
hausdorff(D, U, V) = maximum(minimum(D[u, v] for v in V) for u in U)
D = [0.0 4 3; 3 0 6; 7 4 0]
hausdorff(D, [1, 2], [3]), hausdorff(D, [3], [1, 2])   # (6.0, 4.0): asymmetric
#check EMetric.hausdorffEdist     -- the symmetric extended Hausdorff distance in Mathlib
#check EMetric.infEdist           -- inf_{v ∈ V} edist u v, the inner part of d_L
hausdorffL :: (a -> a -> Double) -> [a] -> [a] -> Double
hausdorffL d us vs = maximum [ minimum [ d u v | v <- vs ] | u <- us ]