Challenge: Removing a Given Edge
Given a graph and an edge, check whether removing that edge creates components in the graph.
We'll cover the following
Problem statement
Implement a function that takes a source vertex and a destination vertex as arguments and checks whether deleting the corresponding edge creates separate components in the directed graph.
Input
The inputs are a graph, a source (integer), and a destination (integer).
Output
The output is true
or false
(a boolean variable), confirming whether separate components will be created or not.
Sample input
graph { 0 -> 1
0 -> 2
2 -> 3
2 -> 4
4 -> 0}
source = 0 destination = 1
Sample output
true
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.