-- Testfaelle Aufgabenblatt 5 testall = and [testinp, testkonv, testfkt] -- 1. tinp_all = [tinp_1, tinp_2, tinp_3, tinp_4] tinp_1 = (4,[(1,2,500), (0,3,100), (0,2,200)]) -- okay tinp_2 = (2,xs) -- zu viele Kanten where (_,xs) = tinp_1 tinp_3 = (maxno,(2,1,400):xs) -- zwei Kanten zwischen zwei Knoten where (maxno,xs) = tinp_1 tinp_4 = (maxno,(1,3,-400):xs) -- negative Kosten where (maxno,xs) = tinp_1 testinp = [True,False,True,False] == [isValid x | x <- tinp_all] -- 2.: Beachten Sie, dass das Resultat i.a. nicht eindeutig festgelegt ist! tkonv_all = [tkonv_a, tkonv_b, tkonv_c, tkonv_d, tkonv_e, tkonv_f, tkonv_g] tkonv_a = inp2el tinp_1 == (ELg 4 [(1,500,2),(0,100,3),(0,200,2)]) tkonv_b = al2am (el2al (inp2el tinp_1)) == (AMg [[0,0,200,100,0],[0,0,500,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]]) tkonv_c = al2el (el2al (inp2el tinp_1)) == (ELg 4 [(0,100,3),(0,200,2),(1,500,2)] ) tkonv_d = am2al (el2am (inp2el tinp_1)) == (ALg [(0,[(2,200),(3,100)]),(1,[(2,500)]),(2,[]),(3,[]),(4,[])]) tkonv_e = am2el (el2am (inp2el tinp_1)) == (ELg 4 [(0,200,2),(0,100,3),(1,500,2)]) tkonv_f = el2al (inp2el tinp_1) == (ALg [(0,[(3,100),(2,200)]),(1,[(2,500)]),(2,[]),(3,[]),(4,[])]) tkonv_g = el2am (inp2el tinp_1) == (AMg [[0,0,200,100,0],[0,0,500,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]]) testkonv = and tkonv_all -- 3. tfkt_all = [tfkt_a,tfkt_b,tfkt_c,tfkt_d,tfkt_e,tfkt_f] tfkt_a = isNeighbourOf (inp2el tinp_1) 0 2 == True tfkt_b = allNeighboursOf (inp2el tinp_1) 0 == [2,3] tfkt_c = numberOfEdges (el2am (inp2el tinp_1)) == 3 gcycle = ALg [(0,[]), (1,[(2,20)]), (2,[(3,30),(5,50)]), (3,[(0,500),(4,40)]), (4,[(1,10)])] tfkt_d = isOnCycle gcycle 1 200 == True tfkt_e = isOnCycle gcycle 2 50 == False tfkt_f = isOnCycle gcycle 5 1000 == False testfkt = and tfkt_all