Question: I need help with this python code. Just need to fill in the part where it says #your code here. I cannot edit the test
I need help with this python code. Just need to fill in the part where it says #your code here. I cannot edit the test cells so please do not alter the variables! Thanks :) 1C on there twice is a typo, it is still separate problems.








![- This is automatically done for you when you get self.adj_list [i]](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66ef27458121a_18966ef2745271ff.jpg)


1B Complete the code for the dfs_visit function below. To do so, please read the rest of the code provided and the surrounding comments very carefully. Please ensure that the following rules are followed: - When visiting a node i, consider the set of adjacent nodes in increasing order. - This is automatically done for you when you get self.adj_list [i] which is implemented as a python set. - Use the DFSTimeCounter class provided to keep track of DFS time. - The timer should be incremented just before we return from dfs_visit and record the finish time for a node. - Recall that a back edge in a DFS is encountered whenever we visit a node i and encounter adjacent node j such that j has been discovered but not finished. - If this happens, add (i,j) to the set of back edges. The dfs_visit code does not return anything but updates the arguments discovery_times,finish_times, dfs_tree_parent and dfs_back_edges in place. In [6]: \# This is a useful data structure for implementing \# a counter that counts the time. class DFSTimeCounter: def _init__(self): self. count =0 def reset(self): self. count =0 def increment (self): self count = self count +1 def get (self): return self.count #i id of the vertex being visited. \# dfs_timer ..) An instance of DFSTimeCounter structure provided for you. \# discovery . - discovery time of each vertex .. a list of size self.n \# None if the vertex is yet to be visited. \# finish finish time of each vertex -. a list of size self.n \# None if the vertex is yet to be finished. \# dfs_tree_parent the parent for for each node \# if we visited node j from node i, then j 's parent is i. \# Do not forget to set tree_parent when you call dfs_visit \# on node j from node i. \# dfs_back_edges a list of back edges. \# a back edge is an edge from i to j wherein \# DFS has already discovered j when i is discovered \# but not finished j def dfs_visit(self, i, dfs_timer, discovery_times, finish_times, dfs_tree_parent, dfs_back_edges): assert
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
