I'm working on a gem called ActiveTouch. It's for creating complex touch or cache invalidation networks. Currently, I'm trying to determine a way of identifying loops within the network.
A simplified version of a dependency map is a hash where the key represents a Model, and the value represents models that are touched.
For example
{
A => [B, C],
B => [D, F],
D => [A]
}
In this example we can see there is a dependency loop between A and D, A->B->D->A or D->A->B->D
In order to determine a loop, I need to see all possible paths. How can I see all possible paths, like this:
[
[A, B, D, A],
[A, B, F],
[A, C],
...
[D, A, B, D]
]
A response in Ruby would be great, but any language will suffice.