Question: ( 1 0 points ) Finding cycles Press shift enter to test your code. Ensure that your code has been saved first by pressing shift
points Finding cycles Press shift enter to test your code. Ensure that your code has been saved first by pressing shiftenter on the previous cell.
from IPython.core.display import display, HTML
def partofacycletest:testcases False False Falsefor testgraph, startingnode, solution in testcases: if solution output: s strsolution Your code output: stroutput failed True displayHTML displayHTML
partofacycletesttmpipykernelpy:: DeprecationWarning: Importing display from IPython.core.display is deprecated since IPython please import from IPython display
from IPython.core.display import display, HTML
Failed test case: Inputs: graph node
Expected Output: True Your code output: False
One or more tests failed.
Write a function that returns whether a node is part of a cycle.
HINT: Modify you DFS to return early when it finds a cycledef partofacyclea u: coloru 'GRAY' if colorv 'WHITE': return True coloru 'BLACK'n lenareturn dfsa u color,
def detectcyclea:color WHITE n if coloru 'WHITE': return True
Testing below
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
