topological-sort

deceptively simple implementation of topological sorting in python

deceptively simple implementation of topological sorting in python Question: Extracted from here we got a minimal iterative dfs routine, i call it minimal because you can hardly simplify the code further: def iterative_dfs(graph, start, path=[]): q = [start] while q: v = q.pop(0) if v not in path: path = path + [v] q = …

Total answers: 5

Python: sorting a dependency list

Python: sorting a dependency list Question: I’m trying to work out if my problem is solvable using the builtin sorted() function or if I need to do myself – old school using cmp would have been relatively easy. My data-set looks like: x = [ (‘business’, Set(‘fleet’,’address’)) (‘device’, Set(‘business’,’model’,’status’,’pack’)) (‘txn’, Set(‘device’,’business’,’operator’)) …. The sort rule …

Total answers: 6