Challenge: Remove Edge from a Directed Graph

In this challenge, we will learn how to delete an edge between two vertices of a directed graph.

Problem Statement

You must implement the removeEdge function which takes a source and a destination as arguments. If an edge exists between the two, it should be deleted.

Input

A directed graph, a source (integer), and a destination (integer).

Output

A directed graph with the edge between the source and the destination removed.

Sample Input

removeEdge(graph, 1, 2)

source: 1
destination: 2

graph:

Vertex Edges
0 1,2
1 2,3
2 None
3 4
4 None

Sample Output

graph:

Vertex Edges
0 1,2
1 3
2 None
3 4
4 None

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.