I have a path through a complete directed acyclic graph stored as a List(of nodes). Part of an algorithm I am implementing for propagating evidence through the graph requires that I sum all the contributions from all combinations of the path where nodes in the path between the first and and last may or may not contribute.
As an example, consider the path {r1, r2, ¬r3, r4, r5}
where ¬
denotes that the node (r3)
is not in the path. Therefore the nodes between the first and last nodes that are in the path are r2
and r4
. The set of all combinations of r2
and r4
are:
{[r2,r4], [r2,¬r4], [¬r2,r4], [¬r2,¬r4]}
So, given an original List(of Nodes)
{r2, r4}
I would like to return a List(of List(of nodes))
{[r2,r4], [r2], [r4]}
I'm completely stumped as to how to implement this part of the algorithm, so any help would be gatefully received.
The algorithm can be found in this paper: http://arxiv.org/ftp/cs/papers/0305/0305014.pdf