Skip to content

Instantly share code, notes, and snippets.

@Julisam
Last active June 10, 2021 06:05
Show Gist options
  • Save Julisam/15930ba6520a7e2304ad1a3c06a9d42c to your computer and use it in GitHub Desktop.
Save Julisam/15930ba6520a7e2304ad1a3c06a9d42c to your computer and use it in GitHub Desktop.
AlgorithmFriday_Week9
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
@meekg33k
Copy link

meekg33k commented Jun 10, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment