I'm trying to solve a puzzle where I need to calculate the average weight between every node in the graph.
For example, for the following graph:
The results is calculated like this:
1 -> 2 = 3;
1 -> 3 = 7;
1 -> 4 = 5;
2 -> 3 = 4;
2 -> 4 = 2;
3 -> 4 = 7;
Average = 3+7+5+4+2+7 / 6;
NOTE: I'm visualizing the problem as a Graph, I might be wrong. The following constraints apply to this problem:
There is exactly one path between any two nodes, but all nodes are connected to every other node.
So we can assume that in the example, there will not be a path from 1 -> 4 directly
I'm looking for a recommendation of an algorithm that I can study in order to solve this type of problems. Not the actual solution.