A simple algorithm I devised to enumerate the disjoint paths between a pair of vertices in a given graph. This algorithm was devised as a part of my course-work for Masters [Tech.] at IIT-Banaras Hindu University.
1. Algorithm To Count Number of
Disjoint Paths Between A Source
and Target, In A Given Graph
Sujith Nair
2. Introduction
• This algorithm finds all the edge-disjoint paths
between a source S ∈ V and a target T ∈ V, in a
given graph G(E,V).
• The algorithm uses Dijkstra’s Single-Source-
Shortest-Path algorithm as a sub-routine.
5. path_find(G,X,Y){
for each vertex V in G:
dist[v]:=infinity;
previous[v]:= undefined;
dist[x]:=0;
Q:= set of all nodes in G;
while Q is not empty
u:=vertex in Q with smallest distance in
dist[];
6. If dist[u]=infinity:
break;
remove u from Q;
for each neighbour v of u:
alt:= dist[u]+1;
if alt<dist[v]:
dist[v]:=alt;
previous[v]=u;
7. path:=empty sequence;
k=Y;
while (previous[k]!=NULL)
insert k at the end of path;
k:=previous[k];
return path;
}
11. Example Continued
List Of Edge-
Disjoint Paths:
1.a-b-f
2.a-c-f
3.a-d-c-f
12. Endnotes
• This algorithm will also work in the case of
weighted graphs. In the case of weighted
graphs, the algorithm returns a list of paths
with the lowest weights.
• This algorithm, with minor modifications, will
also work for the case of vertex-disjoint paths.