I am trying to find out what is the best (time efficient) algorithm to accomplish the task described below.
I have a set of records. For this set of records I have connection data which indicates how pairs of records from this set connect to one another (basically a graph, the records being the vertices and the connection data the edges).
All of the records in the set have connection information (i.e. no orphan records are present; each record in the set connects to one or more other records in the set).
I want to choose any two (arbitrary) records from the set and be able to show all ways possible the chosen records connect (either directly or through other connections).
For example:
If I have the following records: A, B, C, D, E and the following represents the connections: (A,B),(A,C),(B,A),(B,D),(B,E),(B,F),(C,A),(C,E), (C,F),(D,B),(E,C),(E,F),(F,B),(F,C),(F,E) [where (A,B) means record A connects to record B]
If I chose B as my starting record and E as my ending record, I would want to find all paths through the record connections that would connect record B to record E.
All paths connecting B to E: B->E B->F->E B->F->C->E B->A->C->E B->A->C->F->E
This is an example, in practice I may have sets containing hundreds of thousands of records.