Skip to content

Instantly share code, notes, and snippets.

@jmchilton
Created July 30, 2014 20:03
Show Gist options
  • Save jmchilton/8b71c5d0ea8ef0d7f88b to your computer and use it in GitHub Desktop.
Save jmchilton/8b71c5d0ea8ef0d7f88b to your computer and use it in GitHub Desktop.
diff --git a/lib/galaxy/util/topsort.py b/lib/galaxy/util/topsort.py
index 80c6bd3..84cedae 100644
--- a/lib/galaxy/util/topsort.py
+++ b/lib/galaxy/util/topsort.py
@@ -31,9 +31,10 @@ then CycleError is raised, and the exception object supports
many methods to help analyze and break the cycles. This requires
a good deal more code than topsort itself!
"""
-
+from collections import OrderedDict
from exceptions import Exception
+
class CycleError(Exception):
def __init__(self, sofar, numpreds, succs):
Exception.__init__(self, "cycle in constraints",
@@ -124,8 +125,8 @@ class CycleError(Exception):
return answer
def topsort(pairlist):
- numpreds = {} # elt -> # of predecessors
- successors = {} # elt -> list of successors
+ numpreds = OrderedDict() # elt -> # of predecessors
+ successors = OrderedDict() # elt -> list of successors
for first, second in pairlist:
# make sure every elt is a key in numpreds
if not numpreds.has_key(first):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment