Unique Edges from A and B to D

Revision en1, by jankit366, 2024-09-11 12:59:08

A and B wants to reach some destination in an undirected graph using the least number of unique edges. Find the count of unique edges.

Let's say the two paths come out to be this.. A-x-y-D B-y-D

Output : 4

Explanation : A-x, x-y, y-D and B-y

Follow up: What if there are multiple sources?

Can someone help me to solve this optimally?

Tags bfs, multisource bfs, mssp

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English jankit366 2024-09-11 13:03:38 17 Tiny change: 'A and B wa' -> 'LeatA and B wa'
en1 English jankit366 2024-09-11 12:59:08 393 Initial revision (published)