Last active
June 10, 2021 06:05
-
-
Save Julisam/15930ba6520a7e2304ad1a3c06a9d42c to your computer and use it in GitHub Desktop.
AlgorithmFriday_Week9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx as nx | |
def isThereCycle(graph): | |
if graph==None or type(graph) != dict or len(graph)<0: return False | |
edges = [(a.upper(),b.upper()) for a in graph for b in graph[a]] | |
G = nx.DiGraph(edges) | |
if list(nx.simple_cycles(G)): | |
return True | |
else: | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @Julisam, thank you for participating in Week 9 of #AlgorithmFridays.
The goal of this week's challenge was to deepen your knowledge of solving graph traversal problems. You made an assumption that using an external package like
networkx
would be acceptable but I'm sorry that it's not acceptable as it defeats the purpose of the week's challenge.It is always best to cross-check your assumptions with your interviewer or whoever it is you are solving a problem for.
Let me know what you think.