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?