Subject: | suggest total path length |
Date: | Tue, 14 Mar 2017 11:20:37 +1100 |
To: | bug-Graph [...] rt.cpan.org |
From: | Kevin Ryde <user42_kevin [...] yahoo.com.au> |
As an idea for a feature, it could be good to have some sort of total
path length method, like what average_path_length() does but giving
total distance and count of paths. (The average then the ratio.)
Not sure what a good name would be. total_path_length_and_count() would
be suggestive but a bit of a mouthful. Maybe total_path_length() which
in scalar context just the total length or in array context both total
length and count.
For an undirected graph, I think paths could be counted in one direction
only, so u to v and not back v to u. That would seem sensible as
they're the same, and the total length is then the Wiener index.
(In the code it could be easier to divide total/2 and count/2 at the end
instead of tracking which direction to count and not.)
In any case, total and count separately is nice to work with average as
an exact rational (one of the rationals classes or just own num,den).