Quantcast
Channel: Graph Algorithm To Find All Connections Between Two Arbitrary Vertices - Stack Overflow
Viewing all articles
Browse latest Browse all 18

Graph Algorithm To Find All Connections Between Two Arbitrary Vertices

$
0
0

I am trying to determine 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. This basically represents an undirected graph, with 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 records from the set and be able to show all simple paths between the chosen records. By "simple paths" I mean the paths which do not have repeated records in the path (i.e. finite paths only).

Note: The two chosen records will always be different (i.e. start and end vertex will never be the same; no cycles).

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 simple 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.


Viewing all articles
Browse latest Browse all 18

Latest Images

Trending Articles





Latest Images