Skip to content

Instantly share code, notes, and snippets.

@jmchilton
Created July 30, 2014 19:58
Show Gist options
  • Save jmchilton/a7c4020ddf6520ca3601 to your computer and use it in GitHub Desktop.
Save jmchilton/a7c4020ddf6520ca3601 to your computer and use it in GitHub Desktop.
from galaxy.util import topsort
def test_topsort_level_stability():
data = [
(0, 2),
(1, 2),
(2, 3),
(2, 4),
(3, 4),
(3, 5),
]
assert topsort.topsort( data ) == [ 0, 1, 2, 3, 4, 5 ]
# Swap first two edges - so 1 appears first
tmp = data[ 0 ]
data[ 0 ] = data[ 1 ]
data[ 1 ] = tmp
assert topsort.topsort( data ) == [ 1, 0, 2, 3, 4, 5 ]
# Above line fails...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment