SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Algorithm To Count Number of
Disjoint 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 graph G(E,V).



• The algorithm uses Dijkstra’s Single-Source-
  Shortest-Path algorithm as a sub-routine.
Pseudo-Code
disjoint-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;
}
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 all nodes in G;

  while Q is not empty
      u:=vertex in Q with smallest distance in
  dist[];
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;
path:=empty sequence;
    k=Y;
    while (previous[k]!=NULL)
       insert k at the end of path;
       k:=previous[k];

    return path;
}
Example
Source Vertex: a
Target 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
                    2.a-c-f
                    3.a-d-c-f
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.
Thank You

Weitere ähnliche Inhalte

Was ist angesagt?

Unit26 shortest pathalgorithm
Unit26 shortest pathalgorithmUnit26 shortest pathalgorithm
Unit26 shortest pathalgorithm
meisamstar
 
Skiena algorithm 2007 lecture12 topological sort connectivity
Skiena algorithm 2007 lecture12 topological sort connectivitySkiena algorithm 2007 lecture12 topological sort connectivity
Skiena algorithm 2007 lecture12 topological sort connectivity
zukun
 
Data structures and algorithms lab7
Data structures and algorithms lab7Data structures and algorithms lab7
Data structures and algorithms lab7
Bianca Teşilă
 

Was ist angesagt? (20)

Graph Algorithms: Breadth-First Search (BFS)
Graph Algorithms: Breadth-First Search (BFS)Graph Algorithms: Breadth-First Search (BFS)
Graph Algorithms: Breadth-First Search (BFS)
 
Unit26 shortest pathalgorithm
Unit26 shortest pathalgorithmUnit26 shortest pathalgorithm
Unit26 shortest pathalgorithm
 
Maximum flow
Maximum flowMaximum flow
Maximum flow
 
Shortest path problem
Shortest path problemShortest path problem
Shortest path problem
 
Shortest path algorithm
Shortest path algorithmShortest path algorithm
Shortest path algorithm
 
(148064384) bfs
(148064384) bfs(148064384) bfs
(148064384) bfs
 
Max Flow Problem
Max Flow ProblemMax Flow Problem
Max Flow Problem
 
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
 
SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS
 
Skiena algorithm 2007 lecture12 topological sort connectivity
Skiena algorithm 2007 lecture12 topological sort connectivitySkiena algorithm 2007 lecture12 topological sort connectivity
Skiena algorithm 2007 lecture12 topological sort connectivity
 
Minimum cost maximum flow
Minimum cost maximum flowMinimum cost maximum flow
Minimum cost maximum flow
 
Ford Fulkerson Algorithm
Ford Fulkerson AlgorithmFord Fulkerson Algorithm
Ford Fulkerson Algorithm
 
chapter22.ppt
chapter22.pptchapter22.ppt
chapter22.ppt
 
Data structure
Data structureData structure
Data structure
 
Data structures and algorithms lab7
Data structures and algorithms lab7Data structures and algorithms lab7
Data structures and algorithms lab7
 
CSE633
CSE633CSE633
CSE633
 
Network flows
Network flowsNetwork flows
Network flows
 
Max flow min cut
Max flow min cutMax flow min cut
Max flow min cut
 
Network flows
Network flowsNetwork flows
Network flows
 
Algorithms of graph
Algorithms of graphAlgorithms of graph
Algorithms of graph
 

Andere mochten auch

Recreational Mathematics
Recreational MathematicsRecreational Mathematics
Recreational Mathematics
MRIDUL GUPTA
 
Healthy Living and Healthy Eating EDU 290 Powerpoint
Healthy Living and Healthy Eating EDU 290 PowerpointHealthy Living and Healthy Eating EDU 290 Powerpoint
Healthy Living and Healthy Eating EDU 290 Powerpoint
Kris Barron
 
Powerpoint on class rules
Powerpoint on class rulesPowerpoint on class rules
Powerpoint on class rules
Shodge2
 
lesson plan elements of short story
lesson plan elements of short storylesson plan elements of short story
lesson plan elements of short story
Mhelane Herebesi
 
Elements of Short Story
Elements of Short StoryElements of Short Story
Elements of Short Story
Virginia Vidar
 

Andere mochten auch (18)

Maths Games & Videos
Maths Games & VideosMaths Games & Videos
Maths Games & Videos
 
Print maths loop games (print)
Print maths loop games (print)Print maths loop games (print)
Print maths loop games (print)
 
Myself
MyselfMyself
Myself
 
Students Rule 11
Students Rule 11Students Rule 11
Students Rule 11
 
Maths
MathsMaths
Maths
 
slidespdf
slidespdfslidespdf
slidespdf
 
2015 Maths Information Evening
2015 Maths Information Evening2015 Maths Information Evening
2015 Maths Information Evening
 
Maths &Fun
Maths &FunMaths &Fun
Maths &Fun
 
Adding Fractions Mathematics GCSE Maths
Adding Fractions Mathematics GCSE MathsAdding Fractions Mathematics GCSE Maths
Adding Fractions Mathematics GCSE Maths
 
Recreational Mathematics
Recreational MathematicsRecreational Mathematics
Recreational Mathematics
 
Healthy Living and Healthy Eating EDU 290 Powerpoint
Healthy Living and Healthy Eating EDU 290 PowerpointHealthy Living and Healthy Eating EDU 290 Powerpoint
Healthy Living and Healthy Eating EDU 290 Powerpoint
 
How The Love of Music has changed our Business World
How The Love of Music has changed our Business WorldHow The Love of Music has changed our Business World
How The Love of Music has changed our Business World
 
EdTech Europe 2015 [Track 3]: [Mangahigh], ([Mohit Midha], [COO])
EdTech Europe 2015 [Track 3]: [Mangahigh], ([Mohit Midha], [COO])EdTech Europe 2015 [Track 3]: [Mangahigh], ([Mohit Midha], [COO])
EdTech Europe 2015 [Track 3]: [Mangahigh], ([Mohit Midha], [COO])
 
Blazing Performance with Flame Graphs
Blazing Performance with Flame GraphsBlazing Performance with Flame Graphs
Blazing Performance with Flame Graphs
 
Powerpoint on class rules
Powerpoint on class rulesPowerpoint on class rules
Powerpoint on class rules
 
Applications of mathematics in our daily life
Applications of mathematics in our daily lifeApplications of mathematics in our daily life
Applications of mathematics in our daily life
 
lesson plan elements of short story
lesson plan elements of short storylesson plan elements of short story
lesson plan elements of short story
 
Elements of Short Story
Elements of Short StoryElements of Short Story
Elements of Short Story
 

Ähnlich wie Algorithm to count number of disjoint paths

Inroduction_To_Algorithms_Lect14
Inroduction_To_Algorithms_Lect14Inroduction_To_Algorithms_Lect14
Inroduction_To_Algorithms_Lect14
Naor Ami
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slides
HJ DS
 
Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10
Traian Rebedea
 

Ähnlich wie Algorithm to count number of disjoint paths (20)

Inroduction_To_Algorithms_Lect14
Inroduction_To_Algorithms_Lect14Inroduction_To_Algorithms_Lect14
Inroduction_To_Algorithms_Lect14
 
Unit ix graph
Unit   ix    graph Unit   ix    graph
Unit ix graph
 
Unit 9 graph
Unit   9 graphUnit   9 graph
Unit 9 graph
 
Single source shortes path in dag
Single source shortes path in dagSingle source shortes path in dag
Single source shortes path in dag
 
Shortest Path Problem.docx
Shortest Path Problem.docxShortest Path Problem.docx
Shortest Path Problem.docx
 
Ppt 1
Ppt 1Ppt 1
Ppt 1
 
Temporal graph
Temporal graphTemporal graph
Temporal graph
 
Dijkstra.ppt
Dijkstra.pptDijkstra.ppt
Dijkstra.ppt
 
14 chapter9 graph_algorithmstopologicalsort_shortestpath
14 chapter9 graph_algorithmstopologicalsort_shortestpath14 chapter9 graph_algorithmstopologicalsort_shortestpath
14 chapter9 graph_algorithmstopologicalsort_shortestpath
 
Lecture_10_Parallel_Algorithms_Part_II.ppt
Lecture_10_Parallel_Algorithms_Part_II.pptLecture_10_Parallel_Algorithms_Part_II.ppt
Lecture_10_Parallel_Algorithms_Part_II.ppt
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slides
 
Daa chpater14
Daa chpater14Daa chpater14
Daa chpater14
 
Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10
 
Graphs
GraphsGraphs
Graphs
 
Graph 3
Graph 3Graph 3
Graph 3
 
Graph 1
Graph 1Graph 1
Graph 1
 
Graphs
GraphsGraphs
Graphs
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slides
 
1535 graph algorithms
1535 graph algorithms1535 graph algorithms
1535 graph algorithms
 
path
pathpath
path
 

Kürzlich hochgeladen

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Kürzlich hochgeladen (20)

Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

Algorithm to count number of disjoint paths