some metric related algorithmic implementations.