Commits

dirkbaechle  committed 15a465d Draft

- removed default values for _get_cycles() parameters 'path', 'visited' and 'result'

  • Participants
  • Parent commits 966524e

Comments (0)

Files changed (1)

     if vertices is None:
         vertices = graph_dict.keys()
     for vertice in vertices:
-        _get_cycles(graph_dict, vertice, [], set(), result)
+        _get_cycles(graph_dict, [], set(), result, vertice)
     return result
 
-def _get_cycles(graph_dict, vertice=None, path=None, visited=None, result=None):
+def _get_cycles(graph_dict, path, visited, result, vertice=None):
     """recursive function doing the real work for get_cycles"""
     if vertice in path:
         cycle = [vertice]
     path.append(vertice)
     try:
         for node in graph_dict[vertice]:
+            # don't check already visited nodes again
             if node not in visited:
-                if visited is None:
-                    visited = set()
-                _get_cycles(graph_dict, node, path, visited, result)
+                _get_cycles(graph_dict, path, visited, result, node)
                 visited.add(node)
     except KeyError:
         pass