Algorithm To Count Number ofDisjoint Paths Between A Source  and Target, In A Given Graph                      Sujith Nair
Introduction• This algorithm finds all the edge-disjoint paths  between a source S ∈ V and a target T ∈ V, in a  given gra...
Pseudo-Codedisjoint-path(G[n][n],X,Y){  path=path_find(X,Y);  while(path!=NULL){      count++;      delete_path(G,path);  ...
delete_path(G,path){  for each edge in path      G:=G-edge;}
path_find(G,X,Y){  for each vertex V in G:      dist[v]:=infinity;      previous[v]:= undefined;  dist[x]:=0;  Q:= set of ...
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]:=...
path:=empty sequence;    k=Y;    while (previous[k]!=NULL)       insert k at the end of path;       k:=previous[k];    ret...
ExampleSource Vertex: aTarget Vertex: f
Example Continued.                List Of Edge-                Disjoint Paths:                1. a-b-f
Example Continued             List Of Edge-Disjoint             Paths:             1.a-b-f             2.a-c-f
Example Continued                    List Of Edge-                    Disjoint Paths:                    1.a-b-f          ...
Endnotes• This algorithm will also work in the case of  weighted graphs. In the case of weighted  graphs, the algorithm re...
Thank You
Upcoming SlideShare
Loading in …5
×

Algorithm to count number of disjoint paths

1,622 views

Published on

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.

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,622
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Algorithm to count number of disjoint paths

  1. 1. Algorithm To Count Number ofDisjoint Paths Between A Source and Target, In A Given Graph Sujith Nair
  2. 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.
  3. 3. Pseudo-Codedisjoint-path(G[n][n],X,Y){ path=path_find(X,Y); while(path!=NULL){ count++; delete_path(G,path); path=path_find(X,Y); } return count;}
  4. 4. delete_path(G,path){ for each edge in path G:=G-edge;}
  5. 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. 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. 7. path:=empty sequence; k=Y; while (previous[k]!=NULL) insert k at the end of path; k:=previous[k]; return path;}
  8. 8. ExampleSource Vertex: aTarget Vertex: f
  9. 9. Example Continued. List Of Edge- Disjoint Paths: 1. a-b-f
  10. 10. Example Continued List Of Edge-Disjoint Paths: 1.a-b-f 2.a-c-f
  11. 11. Example Continued List Of Edge- Disjoint Paths: 1.a-b-f 2.a-c-f 3.a-d-c-f
  12. 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.
  13. 13. Thank You

×