The denominator counts all possible pairs of nodes (in both directions).
So `G=nx.DiGraph([(1, 2)])` gives an average path length of 0.5.
The treatment for the case of weakly_connected_graphs (that are not
strongly connected) has never been satisfactory to my mind.
From one perspective, there is no path from 2 to 1 so one might expect the
answer to be infinity. But that's not useful. And the sum of the paths that are
not infinite is potentially useful I guess. In any case, the API chosen for this
function is that we take the sum of the finite length shortest paths and divide
by the number of pairs of nodes in the DiGraph.
This should probably be explained better in the documentation.
It's a question of how you want to handle pairs of nodes where you can't
get from one to the other.