Use Floyd Warshall Algorithm to claculate distance from all sources to all destinations with distance between each node as 1 . Consider only those pairs where difference is n.
n