def test_topSort(self, its = 1000): for it in range(its): net = gen_simple_ConcreteNet(defaultGenLabel, defaultDeltaTime, sortable = True, pathMustExist = True) if randBool(): net = wnet.concretizeNetSimple(net, accessibleOnly = True) sortedNodes = wnet.topSort(net, defaultDeltaTime, forwards = randBool(), detectCycles = randBool(), debugCheckInvariants = randBool()) assert is_valid_topSort(net, sortedNodes, defaultDeltaTime)
def test_topSort_net_not_necessarily_sortable(self, its = 500): for it in range(its): net = gen_simple_ConcreteNet(defaultGenLabel, defaultDeltaTime, sortable = False, pathMustExist = True) if randBool(): net = wnet.concretizeNetSimple(net, accessibleOnly = True) sortedNodes = wnet.topSort(net, defaultDeltaTime, forwards = randBool(), detectCycles = False, debugCheckInvariants = randBool()) # perform basic sanity checks (don't check return value, since we # already know the net is probably not sortable) is_valid_topSort(net, sortedNodes, defaultDeltaTime)
def test_concretizeNetTopSort(self, its = 1000): for it in range(its): net = gen_simple_ConcreteNet(defaultGenLabel, defaultDeltaTime, sortable = True, pathMustExist = True) if randBool(): net = wnet.concretizeNetSimple(net, accessibleOnly = True) sortedNodes = wnet.topSort(net, defaultDeltaTime) sortedNet = wnet.concretizeNetTopSort(net, defaultDeltaTime) sortedNetNodeSet = wnet.nodeSetCompute(sortedNet, accessibleOnly = False) assert wnet.netIsTopSorted(sortedNet, sortedNetNodeSet, defaultDeltaTime) assert len(sortedNetNodeSet) == len(sortedNodes)