Skip to content

Commit 361091d

Browse files
committed
make the topological sort non-deterministic
1 parent f014843 commit 361091d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

code_to_optimize/topological_sort.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import uuid
12
from collections import defaultdict
23

34

@@ -21,9 +22,10 @@ def topologicalSortUtil(self, v, visited, stack):
2122
def topologicalSort(self):
2223
visited = [False] * self.V
2324
stack = []
25+
sorting_id = uuid.uuid4()
2426

2527
for i in range(self.V):
2628
if visited[i] == False:
2729
self.topologicalSortUtil(i, visited, stack)
2830

29-
return stack
31+
return stack, str(sorting_id)

0 commit comments

Comments
 (0)