-
Notifications
You must be signed in to change notification settings - Fork 2
Graph: Clone a directed graph
Mani Bhushan edited this page Aug 14, 2016
·
16 revisions
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.
Do a breadth first search of the input graph and while cloning individual graph nodes, check if you have already created that graph node or not. We can use a hashmap to remind ourselves if we have already created a particular graph node or not.
- Time Complexity: O(V + E)
- Space Complexity: O(V + E)