I was given the next assignment:
Let $G=(V,E)$ be an undirected graph and connected,such that every $e\in E$ has a color-blue or red.
Given the same $G$ and some $a,b\in V$ ,construct an efficient algorithm that finds, out of all of the paths with the minimal amount of red edges from $a$ to $b$,a path with the minimal amount of blue edges.
I tried answering but got stuck. Any help will be very appreciated!
- I'm only allowed to use BFS/DFS
I'm assuming you can only use plain vanilla DFS and BFS, and are not allowed to make any modifications to them. Thus, to achieve what you want, you need to modify the behavior of the algorithm by altering the input graph it is running on. Here is a hint on how to find the subgraph of all the paths that connect $a$ and $b$ and contain the smallest possible number of red edges:
Hint:
I hope this helps $\ddot\smile$
Edit: Added a missing piece of info about the fact that the red edges in (6) should be directed.