home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD2.mdf
/
c
/
interpre
/
proxy
/
topsort.prx
< prev
Wrap
Text File
|
1991-10-04
|
400b
|
12 lines
// transforms a partial order into a total order
// topsort: map(string,string) x set(string) -> seq(string)
topsort(g,nodes;x,n) { x={x:x<-nodes;x notin rng g};
if(x=={}) return [];
else n=oneof x;
return [n] conc topsort(g ds {n}, nodes diff {n});};
nodes = {"c1","c2","c3","c4","c5"};
g = {"c1" -> "c3", "c2" -> "c3", "c2" -> "c4", "c3" -> "c5",
"c4" -> "c5"};
end