add d(): distance of an edge