The distance matrix and its variants for graphs and digraphs