I have a directed graph, which I know doesn't have any circular dependencies and have "termination" nodes i.e they have a custom vertex property, which is a bool that I can check. Each edge is weighted using the BGL built-in edge weight property.
What I want to do is walk from any vertex along all possible paths, until it hits all the termination nodes that can be reached and track the "weighted" edge weights of each termination node reached. By this I mean the following is best explained by the following simple example.
Say from node 4 there are following out edges with weights and if T (a termination)
4->1 : 0.25 : T
4->5 : 0.45
4->6 : 0.5
5->2 : 0.65 : T
6->3 : 0.18
6->7 : 0.44 : T
3->1 : 0.33 : T
I want to return a vector of pairs which is the termination nodes / "weighted" combination of edge weights that were walked on its way to each node, which in this case would be :
{1, 0.25 + (0.5*0.18*0.33) }
{2, (0.45*0.65)}
{7, (0.5*0.44)}
Final Result : [ {1, 0.2797}, {2, 0.2925}, {7, 0.22}]
By "weighted", i mean each new step is weighted by the product of all previous edge weights walked on a particular path.
So from 4 to termination node 1, there are two paths. An direct edge to 1, weighted by 0.25. There is also a path that goes 4->6->3->1, so that is 0.5*0.18*0.33. Therefore, for node 1, we have a total resultant weight of 0.25 + (0.5*0.18*0.33) = 0.2797.
Again from 4 to termination node 2, there is an path to 4->5->2 (0.45*0.65), so node 2 = 0.2925
And finally 4 to termination node 7, path 4->6->7, (0.5*0.44), so node 7 = 0.22
Is this possible in BGL, I presume I need some sort of custom visitor / predecessor?
Any help much appreciated.