type kante = (int*int*int)
type ebene = kante list;
val graf1 = [(1,2,20),(1,3,23),(1,4,1),(2,4,4),(2,5,15),(3,4,36),
(3,6,28),(4,5,9),(4,7,16),(4,6,25),(5,7,3),(6,7,17)];
fun ALPHA(liste:ebene,element:kante)=
if tl(liste)=[]
then if hd(liste)=element
then []
else [hd(liste)]
else if hd(liste)=element
then tl(liste)
else hd(liste)::ALPHA(tl(liste),element);
fun min(liste:ebene)=
if length(liste) > 2
then if #1(nth(liste,1))< #1(nth(liste,0)) then min(tl(liste)) else if #1(nth(liste,1))=#1(nth(liste,0)) then if #2(nth(liste,1))< #2(nth(liste,0)) then min(tl(liste)) else min(hd(liste)::tl(tl(liste))) else min(hd(liste)::tl(tl(liste))) else if #1(nth(liste,1))< #1(nth(liste,0)) then hd(tl(liste)) else if #1(nth(liste,1))=#1(nth(liste,0)) then if #2(nth(liste,1))< #2(nth(liste,0)) then hd(tl(liste)) else hd(liste) else hd(liste); fun MINSORT(liste:ebene)=if length(liste)=1 then [nth(liste,0)] else min(liste)::MINSORT(ALPHA(liste,min(liste))); fun BETA(liste:ebene,knoten:int,zahl:int)=if knoten=#1(nth(liste,zahl)) then (#2(nth(liste,zahl)),true,nth(liste,zahl)) else if knoten=#2(nth(liste,zahl)) then (#1(nth(liste,zahl)),true,nth(liste,zahl)) else if zahl=(length(liste)-1) then (0,false,(0,0,0)) else BETA(liste,knoten,zahl+1); fun GAMMA(liste,knoten)=if length(liste)=0 then [] else if #2(BETA(liste,knoten,0)) then #1(BETA(liste,knoten,0)):: GAMMA(ALPHA(liste,#3(BETA(liste,knoten,0))) ,#1(BETA(liste,knoten,0))) else []; fun DELTA(liste)=#1(nth(liste,0))::GAMMA(liste,#1(nth(liste,0))); fun EPSILON(hliste,zahl1,zahl2)=if nth(hliste,zahl1)=nth(hliste,zahl2) then false else if zahl2=(length(hliste)-1) then if zahl1=(length(hliste)-2) then true else EPSILON(hliste,zahl1+1,zahl1+2) else EPSILON(hliste,zahl1,zahl2+1); fun OMIKRON(liste,hliste,zahl)=if #1(nth(liste,zahl))=nth(hliste,0) then if #2(nth(liste,zahl))=nth(hliste,1) then if length(hliste)=2 then ALPHA(liste,nth(liste,zahl)) else OMIKRON(ALPHA(liste,nth(liste,zahl)),tl(hliste),0) else OMIKRON(liste,hliste,zahl+1) else if #2(nth(liste,zahl))=nth(hliste,0) then if #1(nth(liste,zahl))=nth(hliste,1) then if length(hliste)=2 then ALPHA(liste,nth(liste,zahl)) else OMIKRON(ALPHA(liste,nth(liste,zahl)),tl(hliste),0) else OMIKRON(liste,hliste,zahl+1) else OMIKRON(liste,hliste,zahl+1); fun OMEGA(liste)=if length(OMIKRON(liste,DELTA(liste),0))=0 then EPSILON(DELTA(liste),0,1) else if EPSILON(DELTA(liste),0,1) then OMEGA(OMIKRON(liste,DELTA(liste),0)) else false; fun CONTROL(liste)=if length(liste)=0 then false else if length(liste)<3 then true else OMEGA(liste); (*------------------------------------------------------------*) fun kleinsteLaenge(Liste:(int*int*int) list)=if length(Liste)> 2
then if #3(nth(Liste,1)) >= #3(nth(Liste,0))
then kleinsteLaenge(tl(Liste))
else kleinsteLaenge(hd(Liste)::(tl(tl(Liste))))
else if #3(nth(Liste,1)) >= #3(nth(Liste,0))
then hd(tl(Liste))
else hd(Liste);
fun SORTLIST(liste:ebene)=
if length(liste)=1
then [nth(liste,0)]
else kleinsteLaenge(liste)::SORTLIST(ALPHA(liste,kleinsteLaenge(liste)));
fun GRAPH(liste:ebene)=
if length(liste)<3
then liste else if length(liste)=1 then [nth(liste,0)] else if CONTROL(MINSORT(hd(liste)::GRAPH(tl(liste)))) then hd(liste)::GRAPH(tl(liste)) else GRAPH(tl(liste)); fun XXX(liste)=GRAPH(SORTLIST(liste)); val x>