September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,15 @@
fcn topoSort(data){ // data is L( L(root,L(leaves)),...)
allDs:=data.pump(List,fcn(rds){ T(Void.Write,Void.Write,rds[1]) }).copy();
roots:=Dictionary(data); // dictionary of root:leaves
L:=List();
S:=data.pump(List,'wrap([(r,_)]){ if(allDs.holds(r)) Void.Skip else r }).copy();
while(S){ //while S is non-empty do
(n:=S.pop()) : L.append(_); //remove a node n from S, add n to tail of L
foreach m in (ds:=roots.find(n,List)){ //node m with an edge e from n to m
allDs.del(allDs.index(m));
if (Void==allDs.find(m)) S.append(m); //m has no other incoming edges
} roots.del(n); // remove edge e from the graph
}
if(roots) throw(Exception.ValueError("Cycle: "+roots.keys));
L
}

View file

@ -0,0 +1,19 @@
data:=T(
"des_system_lib", "std synopsys std_cell_lib des_system_lib dw02 dw01 ramlib ieee",
"dw01", "ieee dw01 dware gtech",
"dw02", "ieee dw02 dware",
"dw03", "std synopsys dware dw03 dw02 dw01 ieee gtech",
"dw04", "dw04 ieee dw01 dware gtech",
"dw05", "dw05 ieee dware",
"dw06", "dw06 ieee dware",
"dw07", "ieee dware",
"dware", "ieee dware",
"gtech", "ieee gtech",
"ramlib", "std ieee",
"std_cell_lib", "ieee std_cell_lib",
"synopsys", "",
);
data=data.pump(List,Void.Read,fcn(r,ds){
T( r, ds.replace(r,"").strip().split().copy() ) // leaves writable 'cause they will be
});
topoSort(data).println();