You are given a directed graph G = (V, E) and two vertices s and t. Moreover, each edge of this graph is colored either blue or red. Your goal is to find whether there is at least one path from s to t such that all red edges in this path appear after all blue edges (the path may not contain any blue edges or any red edges, but if it has both types of edges, all red edges should appear after all blue edges). Design and analyze an algorithm for solving this problem in O(n + m) time.
You are given a directed graph G = (V, E) and two vertices s and t. Moreover, each edge of this graph is colored either blue or red. Your goal is to find whether there is at least one path from s to t such that all red edges in this path appear after all blue edges (the path may not contain any blue edges or any red edges, but if it has both types of edges, all red edges should appear after all blue edges). Design and analyze an algorithm for solving this problem in O(n + m) time.
Related questions
Question
I need the algorithm, proof of correctness and runtime analysis for the problem. No code necessary ONLY algorithm. And runtime should be O(n + m) as stated in the question.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps