def get_cycles(graph_dict, vertices=None):
 if (not graph_dict):
  return ()
 result = []
 if (vertices is None):
  vertices = graph_dict.keys()
 for vertice in vertices:
  _get_cycles(graph_dict, [], set(), result, vertice)
 return result

def get_cycles ( graph_dict , vertices = None ) : if ( not graph_dict ) : return ( ) result = [ ] if ( vertices is None ) : vertices = graph_dict . keys ( ) for vertice in vertices : _get_cycles ( graph_dict , [ ] , set ( ) , result , vertice ) return result
given a dictionary representing an ordered graph .