Java: Count all possible Paths between two Vertices

Level : Advanced
Mentor: Shailendra Chauhan
Type : GuidedLab
Points : 10
Duration : 00:40:00

Lab Details

Problem Statement:

Count the total number of ways or paths that exist between two vertices in a directed graph.

These paths don’t contain a cycle, the simple enough reason is that a cycle contains an infinite

number of paths and hence they create a problem

For the following Graph:


Input:

Count paths between A and E

Output:

Total paths between A and E are 4
The 4 paths between A and E are:
A -> E
A -> B -> E
A -> C -> E
A -> B -> D -> C -> E
Self-paced Membership
  • 22+ Courses
  • 750+ Hands-On Labs
  • 200+ Quick Notes
  • 55+ Skill Tests
  • 45+ Interview Q&A
  • 10+ Real-world Projects
  • Career Coaching
  • Email Support
Upto 66% OFF
KNOW MORE..

To get full access to all courses

Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this