Challenge: Transpose a Graph
Given a graph, find its transpose.
We'll cover the following
Problem statement
You have to implement a function which will take a graph as input and print its transpose.
Input
A graph
Output
Return a transpose of the given graph
Sample input
Graph:
Vertex | Edges |
---|---|
0 | 2, 1 |
1 | 4, 3 |
2 | None |
3 | None |
4 | None |
Sample output
Graph:
Vertex | Edges |
---|---|
0 | None |
1 | 0 |
2 | 0 |
3 | 1 |
4 | 1 |
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.